home *** CD-ROM | disk | FTP | other *** search
- # $Header: P:/source/ppee/macros/repeat.pev 1.16 09 Aug 1990 17:05:38 skipr $
-
- ##############################################################################
- #
- # Sage Software - POLYTRON Division
- # 1700 NW 167th Place
- # Beaverton, OR 97006
- #
- # Copyright 1990, Sage Software, Inc.
- #
- # Permission is hereby granted for licensed users of Sage Professional
- # Editor and PolyAwk to copy and modify this source code for their own
- # personal use. These derivative works may be distributed only to other
- # licensed Sage Professional Editor and PolyAwk users. All other usage
- # is prohibited without express written permission from Sage Software.
- #
- ##############################################################################
-
- #### $Workfile: repeat.pel $: repeat count support
-
-
- global function repeat_key_action() {
-
- local repeatCount = 0
- local msg = "Enter repeat count followed by the key to repeat. ["
- local digit = "zip"
- local keyToExecute
- local keyUsedToGetHere = current_key
- local binding
- local c
- local functionId
-
- ###
- ### build the repeat count
- ###
-
- begin_dialog()
- notify( msg 1 "]" )
-
- while (1) {
- while ( chr(c = getchar()) ~ /[0-9]/ ) {
- digit = c - ord("0")
- repeatCount = repeatCount * 10 + digit
- notify( msg repeatCount "]" )
- }
-
- # Esc key to exit
- if ( current_key == KEYCODE_ESC ) {
- notify( "Command canceled" )
- digit = ""
- repeatCount = 0
- break
- }
-
- # repeat key multiplies by four ala Emacs
- if ( current_key == keyUsedToGetHere ) {
- digit = ""
- repeatCount = (repeatCount ? repeatCount : 1) * 4
- notify( msg repeatCount "]" )
- } else {
- break
- }
- }
-
- message( "" )
- end_dialog()
-
- if ( digit == "zip" ) {
- repeatCount = 1
- } else if ( repeatCount < 1 ) {
- return
- }
-
- ###
- ### build the string representation of the key then repeat its action
- ###
-
- keyToExecute = "#" current_key
-
- # eat the character remaining after a DOS two-character sequence
- # (must be done after accessing "current_key")
- if (c == 0) {
- getchar()
- }
-
- binding = keymap_binding( keyToExecute )
- if ( binding !~ /repeat_key_action/ ) {
- if ((functionId = function_id( binding ))) {
- while (repeatCount--) {
- execute_function( functionId )
- }
- }
- }
- }
-
-
- ##
- ## execute the function bound to a given key
- ##
-
- global function execute_key_action( keystring ){ #PUBLIC
- local binding = keymap_binding( keystring )
-
- if ( binding && ( binding !~ /execute_key_action/ )){
- return execute_function( binding )
- }
- }
-