From a66d0684da34cdd6d5a78f36f09954f092cb4a88 Mon Sep 17 00:00:00 2001 From: Arthur Gleckler Date: Tue, 6 Aug 1991 15:40:55 +0000 Subject: [PATCH] Add support for special keys, including function keys and arrow keys, with bucky bits. A key is either a CHAR or a SPECIAL-KEY. SPECIAL-KEYs can be compared using EQ?. Support all the keys named in /usr/include/X11/keysym.h, using the names X gives them (with few exceptions). Rename most procedures for dealing with keys from "-char" to "-key" to prevent confusion. Requires microcode 11.91 or later because of changes to the X keyboard event structure. --- v7/src/edwin/argred.scm | 29 +++--- v7/src/edwin/basic.scm | 63 ++++++------ v7/src/edwin/c-mode.scm | 4 +- v7/src/edwin/calias.scm | 215 ++++++++++++++++++++++++---------------- v7/src/edwin/comred.scm | 83 ++++++++-------- v7/src/edwin/comtab.scm | 84 ++++++++-------- v7/src/edwin/decls.scm | 3 +- v7/src/edwin/dired.scm | 4 +- v7/src/edwin/ed-ffi.scm | 6 ++ v7/src/edwin/edwin.ldr | 5 +- v7/src/edwin/edwin.pkg | 60 +++++++++-- v7/src/edwin/hlpcom.scm | 32 +++--- v7/src/edwin/info.scm | 9 +- v7/src/edwin/input.scm | 42 ++++---- v7/src/edwin/iserch.scm | 8 +- v7/src/edwin/keymap.scm | 6 +- v7/src/edwin/kmacro.scm | 18 ++-- v7/src/edwin/lspcom.scm | 15 +-- v7/src/edwin/modefs.scm | 13 ++- v7/src/edwin/motcom.scm | 10 +- v7/src/edwin/prompt.scm | 36 ++++--- v7/src/edwin/regcom.scm | 8 +- v7/src/edwin/replaz.scm | 6 +- v7/src/edwin/sercom.scm | 4 +- v7/src/edwin/wincom.scm | 4 +- v7/src/edwin/xterm.scm | 51 +++++++--- 26 files changed, 484 insertions(+), 334 deletions(-) diff --git a/v7/src/edwin/argred.scm b/v7/src/edwin/argred.scm index 92530db76..63ac39fa4 100644 --- a/v7/src/edwin/argred.scm +++ b/v7/src/edwin/argred.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/argred.scm,v 1.30 1991/05/02 01:11:56 cph Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/argred.scm,v 1.31 1991/08/06 15:39:54 arthur Exp $ ;;; ;;; Copyright (c) 1986, 1989-91 Massachusetts Institute of Technology ;;; @@ -54,21 +54,24 @@ Used more than once, this command multiplies the argument by 4 each time." "P" (lambda (argument) (set-command-argument! (list (* (if (pair? argument) (car argument) 1) 4))) - (set-command-message! 'AUTO-ARGUMENT (char-name (last-command-char))))) + (set-command-message! 'AUTO-ARGUMENT (key-name (last-command-key))))) (define-command digit-argument "Part of the numeric argument for the next command." "P" (lambda (argument) - (let ((digit (char->digit (char-base (last-command-char))))) - (if digit - (begin - (set-command-argument! - (cond ((eq? '- argument) (- digit)) - ((not (number? argument)) digit) - ((negative? argument) (- (* 10 argument) digit)) - (else (+ (* 10 argument) digit)))) - (set-command-message! 'AUTO-ARGUMENT (auto-argument-mode?))))))) + (let ((key (last-command-key))) + (if (char? key) + (let ((digit (char->digit (char-base key)))) + (if digit + (begin + (set-command-argument! + (cond ((eq? '- argument) (- digit)) + ((not (number? argument)) digit) + ((negative? argument) (- (* 10 argument) digit)) + (else (+ (* 10 argument) digit)))) + (set-command-message! 'AUTO-ARGUMENT + (auto-argument-mode?))))))))) (define-command negative-argument "Begin a negative numeric argument for the next command." @@ -104,7 +107,9 @@ Otherwise, the character inserts itself." Digits following this command become part of the argument." "P" (lambda (argument) - (if (char=? #\- (char-base (last-command-char))) + (if (let ((key (last-command-key))) + (and (char? key) + (char=? #\- (char-base key)))) (if (not (number? argument)) ((ref-command negative-argument) argument)) ((ref-command digit-argument) argument)) diff --git a/v7/src/edwin/basic.scm b/v7/src/edwin/basic.scm index d6e7a1eaa..89776a13f 100644 --- a/v7/src/edwin/basic.scm +++ b/v7/src/edwin/basic.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/basic.scm,v 1.113 1991/05/17 00:27:32 cph Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/basic.scm,v 1.114 1991/08/06 15:38:20 arthur Exp $ ;;; ;;; Copyright (c) 1986, 1989-91 Massachusetts Institute of Technology ;;; @@ -51,25 +51,28 @@ With an argument, insert the character that many times." "P" (lambda (argument) - (insert-chars (last-command-char) + (insert-chars (last-command-key) (command-argument-numeric-value argument)))) (define-command quoted-insert "Reads a character and inserts it." "p" (lambda (argument) - (let ((read-char + (let ((read-ascii-char (lambda () - (let ((char (with-editor-interrupts-disabled keyboard-read-char))) + (let ((key (with-editor-interrupts-disabled keyboard-read))) + (or (and (char? key) + (char-ascii? key)) + (editor-error "Not an ASCII character" (key-name key))) (set-command-prompt! - (string-append (command-prompt) (char-name char))) - char)))) + (string-append (command-prompt) (key-name key))) + key)))) (let ((read-digit (lambda () - (or (char->digit (read-char) 8) + (or (char->digit (read-ascii-char) 8) (editor-error "Not an octal digit"))))) (set-command-prompt! "Quote Character: ") - (insert-chars (let ((char (read-char))) + (insert-chars (let ((char (read-ascii-char))) (let ((digit (char->digit char 4))) (if digit (ascii->char @@ -125,7 +128,7 @@ The key is bound in fundamental mode." This command followed by an = is equivalent to a Control-=." () (lambda () - (read-extension-char char-controlify))) + (read-extension-key char-controlify))) (define-command meta-prefix "Sets Meta-bit of following character. @@ -134,8 +137,8 @@ If the Metizer character is Altmode, it turns ^A into Control-Meta-A. Otherwise, it turns ^A into plain Meta-A." () (lambda () - (read-extension-char - (if (let ((char (current-command-char))) + (read-extension-key + (if (let ((char (current-command-key))) (and (char? char) (char=? #\altmode char))) char-metafy @@ -147,9 +150,9 @@ into Control-Meta-A. Otherwise, it turns ^A into plain Meta-A." Turns a following A (or C-A) into a Control-Meta-A." () (lambda () - (read-extension-char char-control-metafy))) + (read-extension-key char-control-metafy))) -(define execute-extended-chars? +(define execute-extended-keys? true) (define extension-commands @@ -157,32 +160,32 @@ Turns a following A (or C-A) into a Control-Meta-A." (name->command 'meta-prefix) (name->command 'control-meta-prefix))) -(define (read-extension-char modifier) - (if execute-extended-chars? +(define (read-extension-key modifier) + (if execute-extended-keys? (set-command-prompt-prefix!)) - (let ((char (modifier (with-editor-interrupts-disabled keyboard-read-char)))) - (if execute-extended-chars? - (dispatch-on-char (current-comtabs) char) - char))) + (let ((key (modifier (with-editor-interrupts-disabled keyboard-read)))) + (if execute-extended-keys? + (dispatch-on-key (current-comtabs) key) + key))) -(define-command prefix-char +(define-command prefix-key "This is a prefix for more commands. It reads another character (a subcommand) and dispatches on it." () (lambda () (set-command-prompt-prefix!) - (let ((prefix-char (current-command-char))) - (dispatch-on-char + (let ((prefix-key (current-command-key))) + (dispatch-on-key (current-comtabs) - ((if (pair? prefix-char) append cons) - prefix-char - (list (with-editor-interrupts-disabled keyboard-read-char))))))) + ((if (pair? prefix-key) append cons) + prefix-key + (list (with-editor-interrupts-disabled keyboard-read))))))) (define (set-command-prompt-prefix!) (set-command-prompt! (string-append-separated (command-argument-prompt) - (string-append (xchar->name (current-command-char)) " -")))) + (string-append (xkey->name (current-command-key)) " -")))) (define-command execute-extended-command "Read an extended command from the terminal with completion. @@ -194,7 +197,7 @@ For more information type the HELP key while entering the name." (dispatch-on-command (prompt-for-command ;; Prompt with the name of the command char. - (list (string-append (xchar->name (current-command-char)) " "))) + (list (string-append (xkey->name (current-command-key)) " "))) true))) ;;;; Errors @@ -211,7 +214,7 @@ For more information type the HELP key while entering the name." "This command is used to capture undefined keys." () (lambda () - (editor-error "Undefined command: " (xchar->name (current-command-char))))) + (editor-error "Undefined command: " (xkey->name (current-command-key))))) (define (barf-if-read-only) (editor-error "Trying to modify read only text.")) @@ -222,9 +225,9 @@ For more information type the HELP key while entering the name." (buffer-truename buffer) (buffer-modification-time buffer) (not (verify-visited-file-modification-time? buffer))) - (ask-user-about-supercession-threat buffer)))) + (ask-user-about-supersession-threat buffer)))) -(define (ask-user-about-supercession-threat buffer) +(define (ask-user-about-supersession-threat buffer) (if (not (with-selected-buffer buffer (lambda () diff --git a/v7/src/edwin/c-mode.scm b/v7/src/edwin/c-mode.scm index 941a8c86a..4214585bc 100644 --- a/v7/src/edwin/c-mode.scm +++ b/v7/src/edwin/c-mode.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/c-mode.scm,v 1.46 1991/04/12 23:17:56 cph Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/c-mode.scm,v 1.47 1991/08/06 15:39:50 arthur Exp $ ;;; ;;; Copyright (c) 1986, 1989-91 Massachusetts Institute of Technology ;;; @@ -157,7 +157,7 @@ and after colons and semicolons, inserted in C code." (insert-newline) ((ref-command c-indent-line) false)))) ((ref-command self-insert-command) false)) - (if (eqv? #\} (current-command-char)) + (if (eqv? #\} (current-command-key)) (mark-flash (backward-one-sexp (current-point)) 'RIGHT))))) (define-command electric-c-semi diff --git a/v7/src/edwin/calias.scm b/v7/src/edwin/calias.scm index c1d639ef3..c59f390ae 100644 --- a/v7/src/edwin/calias.scm +++ b/v7/src/edwin/calias.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/calias.scm,v 1.9 1991/05/17 00:26:01 cph Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/calias.scm,v 1.10 1991/08/06 15:38:59 arthur Exp $ ;;; ;;; Copyright (c) 1986, 1989-91 Massachusetts Institute of Technology ;;; @@ -42,58 +42,60 @@ ;;; of that license should have been included along with this file. ;;; -;;;; Alias Characters +;;;; Alias Keys (declare (usual-integrations)) -(define alias-characters '()) +(define alias-keys '()) -(define (define-alias-char char alias) - (let ((entry (assq char alias-characters))) +(define (define-alias-key key alias) + (let ((entry (assq key alias-keys))) (if entry (set-cdr! entry alias) - (set! alias-characters (cons (cons char alias) alias-characters)))) + (set! alias-keys (cons (cons key alias) alias-keys)))) unspecific) -(define (undefine-alias-char char) - (set! alias-characters (del-assq! char alias-characters)) +(define (undefine-alias-key key) + (set! alias-keys (del-assq! key alias-keys)) unspecific) -(define (remap-alias-char char) - (let ((entry (assq char alias-characters))) +(define (remap-alias-key key) + (let ((entry (assq key alias-keys))) (cond (entry - (remap-alias-char (cdr entry))) - ((odd? (quotient (char-bits char) 2)) ;Control bit is set - (let ((code (char-code char)) + (remap-alias-key (cdr entry))) + ((and (char? key) + (odd? (quotient (char-bits key) 2))) ;Control bit is set + (let ((code (char-code key)) (remap (lambda (code) - (make-char code (- (char-bits char) 2))))) + (make-char code (- (char-bits key) 2))))) (cond ((<= #x40 code #x5F) (remap (- code #x40))) ((<= #x61 code #x7A) (remap (- code #x60))) - (else char)))) - (else char)))) + (else key)))) + (else key)))) -(define (unmap-alias-char char) - (if (and (ascii-controlified? char) - (let ((code (char-code char))) +(define (unmap-alias-key key) + (if (and (char? key) + (ascii-controlified? key) + (let ((code (char-code key))) (not (or (= code #x09) ;tab (= code #x0A) ;linefeed (= code #x0C) ;page (= code #x0D) ;return (= code #x1B) ;altmode ))) - (even? (quotient (char-bits char) 2))) - (unmap-alias-char - (make-char (let ((code (char-code char))) + (even? (quotient (char-bits key) 2))) + (unmap-alias-key + (make-char (let ((code (char-code key))) (+ code (if (<= #x01 code #x1A) #x60 #x40))) - (+ (char-bits char) 2))) + (+ (char-bits key) 2))) (let ((entry - (list-search-positive alias-characters + (list-search-positive alias-keys (lambda (entry) - (eqv? (cdr entry) char))))) + (eqv? (cdr entry) key))))) (if entry - (unmap-alias-char (car entry)) - char)))) + (unmap-alias-key (car entry)) + key)))) (define-integrable (ascii-controlified? char) (< (char-code char) #x20)) @@ -103,75 +105,114 @@ true boolean?) -(define (char-name char) - (if (ref-variable enable-emacs-key-names) - (emacs-char-name char true) - (char->name (unmap-alias-char char)))) +(define (key-name key) + (cond ((ref-variable enable-emacs-key-names) + (emacs-key-name key true)) + ((special-key? key) + (special-key/name key)) + (else + (char->name (unmap-alias-key key))))) -(define (xchar->name xchar) - (let ((chars (xchar->list xchar))) +(define (xkey->name xkey) + (let ((keys (xkey->list xkey))) (string-append-separated - (char-name (car chars)) - (let ((char-name + (key-name (car keys)) + (let ((key-name (if (ref-variable enable-emacs-key-names) - (lambda (char) - (emacs-char-name char false)) - (lambda (char) - (char->name (unmap-alias-char char)))))) - (let loop ((chars (cdr chars))) - (if (null? chars) + (lambda (key) + (emacs-key-name key false)) + (lambda (key) + (key->name (unmap-alias-key key)))))) + (let loop ((keys (cdr keys))) + (if (null? keys) "" (string-append-separated - (char-name (car chars)) - (loop (cdr chars))))))))) + (key-name (car keys)) + (loop (cdr keys))))))))) + +(define (emacs-key-name key handle-prefixes?) + (if (special-key? key) + (special-key/name key) + (let ((code (char-code key)) + (bits (char-bits key))) + (let ((prefix + (lambda (bits suffix) + (if (zero? bits) + suffix + (string-append "M-" suffix))))) + (let ((process-code + (lambda (bits) + (cond ((< #x20 code #x7F) + (prefix bits (string (ascii->char code)))) + ((= code #x09) (prefix bits "TAB")) + ((= code #x0A) (prefix bits "LFD")) + ((= code #x0D) (prefix bits "RET")) + ((= code #x1B) (prefix bits "ESC")) + ((= code #x20) (prefix bits "SPC")) + ((= code #x7F) (prefix bits "DEL")) + (else + (string-append + (if (zero? bits) "C-" "C-M-") + (string + (ascii->char + (+ code (if (<= #x01 code #x1A) #x60 #x40)))))))))) + (cond ((< bits 2) + (process-code bits)) + ((and handle-prefixes? (< bits 4)) + (string-append (if (= 2 bits) "C-^ " "C-z ") (process-code 0))) + (else + (char->name (unmap-alias-key key))))))))) + +(define (key? object) + (or (char? object) + (special-key? object))) + +(define (key? key2 + (if (char? key1) + key1 + (string-ref (special-key/name key1) 0)))) + ((char? key1) + (not (or (key=? key1 key2) + (keychar code)))) - ((= code #x09) (prefix bits "TAB")) - ((= code #x0A) (prefix bits "LFD")) - ((= code #x0D) (prefix bits "RET")) - ((= code #x1B) (prefix bits "ESC")) - ((= code #x20) (prefix bits "SPC")) - ((= code #x7F) (prefix bits "DEL")) - (else - (string-append - (if (zero? bits) "C-" "C-M-") - (string - (ascii->char - (+ code (if (<= #x01 code #x1A) #x60 #x40)))))))))) - (cond ((< bits 2) - (process-code bits)) - ((and handle-prefixes? (< bits 4)) - (string-append (if (= 2 bits) "C-^ " "C-z ") (process-code 0))) - (else - (char->name (unmap-alias-char char)))))))) +(define (key=? key1 key2) + (if (and (char? key1) + (char? key2)) + (char=? key1 key2) + (and (special-key? key1) + (special-key? key2) + (string=? (special-key/name key1) + (special-key/name key2)) + (= (special-key/bucky-bits key1) + (special-key/bucky-bits key2))))) -(define (xcharlist x)) (y (xchar->list y))) - (or (charlist x)) (y (xkey->list y))) + (or (keylist xchar) - (cond ((char? xchar) - (list xchar)) - ((and (not (null? xchar)) - (list-of-type? xchar char?)) - xchar) - ((and (string? xchar) - (not (string-null? xchar))) - (string->list xchar)) +(define (xkey->list xkey) + (cond ((key? xkey) + (list xkey)) + ((and (not (null? xkey)) + (list-of-type? xkey + (lambda (element) + (or (char? element) + (special-key? element))))) + xkey) + ((and (string? xkey) + (not (string-null? xkey))) + (string->list xkey)) (else - (error "Not a character or list of characters" xchar)))) \ No newline at end of file + (error "Not a key or list of keys" xkey)))) \ No newline at end of file diff --git a/v7/src/edwin/comred.scm b/v7/src/edwin/comred.scm index 219f5bd28..4fe864eb9 100644 --- a/v7/src/edwin/comred.scm +++ b/v7/src/edwin/comred.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/comred.scm,v 1.86 1991/05/02 01:12:45 cph Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/comred.scm,v 1.87 1991/08/06 15:40:25 arthur Exp $ ;;; ;;; Copyright (c) 1986, 1989-91 Massachusetts Institute of Technology ;;; @@ -47,21 +47,21 @@ (declare (usual-integrations)) (define *command-continuation*) ;Continuation of current command -(define *command-char*) ;Character read to find current command +(define *command-key*) ;Key read to find current command (define *command*) ;The current command (define *command-argument*) ;Argument from last command (define *next-argument*) ;Argument to next command (define *command-message*) ;Message from last command (define *next-message*) ;Message to next command (define *non-undo-count*) ;# of self-inserts since last undo boundary -(define keyboard-chars-read) ;# of chars read from keyboard +(define keyboard-keys-read) ;# of keys read from keyboard (define command-history) (define command-history-limit 30) (define command-reader-reset-thunk) (define command-reader-reset-continuation) (define (initialize-command-reader!) - (set! keyboard-chars-read 0) + (set! keyboard-keys-read 0) (set! command-history (make-circular-list command-history-limit false)) (set! command-reader-reset-thunk false) unspecific) @@ -102,7 +102,7 @@ (call-with-current-continuation (lambda (continuation) (fluid-let ((*command-continuation* continuation) - (*command-char* false) + (*command-key* false) (*command*) (*next-argument* false) (*next-message* false)) @@ -112,19 +112,19 @@ (define (start-next-command) (reset-command-state!) - (let ((char (with-editor-interrupts-disabled keyboard-read-char))) - (set! *command-char* char) + (let ((key (with-editor-interrupts-disabled keyboard-read))) + (set! *command-key* key) (clear-message) (set-command-prompt! (if (not *command-argument*) - (char-name char) + (key-name key) (string-append-separated (command-argument-prompt) - (char-name char)))) + (key-name key)))) (let ((window (current-window))) (%dispatch-on-command window (comtab-entry (buffer-comtabs (window-buffer window)) - char) + key) false))) (start-next-command)) @@ -146,7 +146,7 @@ (if *command-argument* (set-command-prompt! (command-argument-prompt)) (reset-command-prompt!)) - (if *defining-keyboard-macro?* (keyboard-macro-finalize-chars))) + (if *defining-keyboard-macro?* (keyboard-macro-finalize-keys))) ;;; The procedures for executing commands come in two flavors. The ;;; difference is that the EXECUTE-foo procedures reset the command @@ -154,23 +154,23 @@ ;;; latter should only be used by "prefix" commands such as C-X or ;;; C-4, since they want arguments, messages, etc. to be passed on. -(define-integrable (execute-char comtab char) +(define-integrable (execute-key comtab key) (reset-command-state!) - (dispatch-on-char comtab char)) + (dispatch-on-key comtab key)) (define-integrable (execute-command command) (reset-command-state!) (%dispatch-on-command (current-window) command false)) -(define (read-and-dispatch-on-char) - (dispatch-on-char (current-comtabs) - (with-editor-interrupts-disabled keyboard-read-char))) +(define (read-and-dispatch-on-key) + (dispatch-on-key (current-comtabs) + (with-editor-interrupts-disabled keyboard-read))) -(define (dispatch-on-char comtab char) - (set! *command-char* char) +(define (dispatch-on-key comtab key) + (set! *command-key* key) (set-command-prompt! - (string-append-separated (command-argument-prompt) (xchar->name char))) - (%dispatch-on-command (current-window) (comtab-entry comtab char) false)) + (string-append-separated (command-argument-prompt) (xkey->name key))) + (%dispatch-on-command (current-window) (comtab-entry comtab key) false)) (define (dispatch-on-command command #!optional record?) (%dispatch-on-command (current-window) @@ -181,13 +181,13 @@ (keyboard-macro-disable) (*command-continuation* (if (default-object? value) 'ABORT value))) -(define-integrable (current-command-char) - *command-char*) +(define-integrable (current-command-key) + *command-key*) -(define (last-command-char) - (if (char? *command-char*) - *command-char* - (car (last-pair *command-char*)))) +(define (last-command-key) + (if (key? *command-key*) + *command-key* + (car (last-pair *command-key*)))) (define-integrable (current-command) *command*) @@ -250,16 +250,17 @@ (< point-x (-1+ (window-x-size window)))) (window-direct-output-backward-char! window) (normal))) - ((or (eq? command (ref-command-object self-insert-command)) - (and (eq? command (ref-command-object auto-fill-space)) - (not (auto-fill-break? point))) - (command-argument-self-insert? command)) - (let ((char *command-char*)) + ((and (not (special-key? *command-key*)) + (or (eq? command (ref-command-object self-insert-command)) + (and (eq? command (ref-command-object auto-fill-space)) + (not (auto-fill-break? point))) + (command-argument-self-insert? command))) + (let ((key *command-key*)) (if (let ((buffer (window-buffer window))) (and (buffer-auto-save-modified? buffer) (null? (cdr (buffer-windows buffer))) (line-end? point) - (char-graphic? char) + (char-graphic? key) (< point-x (-1+ (window-x-size window))))) (begin (if (or (zero? *non-undo-count*) @@ -268,8 +269,8 @@ (set! *non-undo-count* 0) (undo-boundary! point))) (set! *non-undo-count* (1+ *non-undo-count*)) - (window-direct-output-insert-char! window char)) - (region-insert-char! point char)))) + (window-direct-output-insert-char! window key)) + (region-insert-char! point key)))) (else (normal)))))) @@ -320,17 +321,17 @@ (lambda (arguments expressions any-from-tty?) (if (or record? (and any-from-tty? - (not (prefix-char-list? (current-comtabs) - (current-command-char))))) + (not (prefix-key-list? (current-comtabs) + (current-command-key))))) (record-command-arguments expressions)) arguments))) ((null? specification) (if record? (record-command-arguments '())) '()) (else - (let ((old-chars-read keyboard-chars-read)) + (let ((old-keys-read keyboard-keys-read)) (let ((arguments (specification))) - (if (or record? (not (= keyboard-chars-read old-chars-read))) + (if (or record? (not (= keyboard-keys-read old-keys-read))) (record-command-arguments (map quotify-sexp arguments))) arguments)))))) @@ -350,7 +351,7 @@ (eval-with-history expression environment))) (cdr entry)))) -(define (interactive-argument char prompt) +(define (interactive-argument key prompt) (let ((prompting (lambda (value) (values value (quotify-sexp value) true))) @@ -360,7 +361,7 @@ (varies (lambda (value expression) (values value expression false)))) - (case char + (case key ((#\b) (prompting (buffer-name (prompt-for-existing-buffer prompt (current-buffer))))) @@ -403,7 +404,7 @@ (prompting (prompt-for-expression-value prompt))) (else (editor-error "Invalid control letter " - char + key " in interactive calling string"))))) (define (quotify-sexp sexp) diff --git a/v7/src/edwin/comtab.scm b/v7/src/edwin/comtab.scm index 726cb9f71..e6a993b36 100644 --- a/v7/src/edwin/comtab.scm +++ b/v7/src/edwin/comtab.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/comtab.scm,v 1.59 1991/05/06 01:02:48 cph Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/comtab.scm,v 1.60 1991/08/06 15:39:30 arthur Exp $ ;;; ;;; Copyright (c) 1986, 1989-91 Massachusetts Institute of Technology ;;; @@ -50,42 +50,42 @@ (dispatch-alists (cons '() '()) read-only true) (button-alist '())) -(define (set-comtab-entry! alists char command) - (let ((entry (assq char (cdr alists)))) +(define (set-comtab-entry! alists key command) + (let ((entry (assq key (cdr alists)))) (if entry (set-cdr! entry command) - (set-cdr! alists (cons (cons char command) (cdr alists)))))) + (set-cdr! alists (cons (cons key command) (cdr alists)))))) -(define (make-prefix-char! alists char alists*) - (let ((entry (assq char (car alists)))) +(define (make-prefix-key! alists key alists*) + (let ((entry (assq key (car alists)))) (if entry (set-cdr! entry alists*) (set-car! alists - (cons (cons char alists*) + (cons (cons key alists*) (car alists)))))) (define (comtab-lookup-prefix comtabs key if-undefined if-defined) (let ((alists (comtab-dispatch-alists (car comtabs)))) - (cond ((char? key) - (if-defined alists (remap-alias-char key))) + (cond ((key? key) + (if-defined alists (remap-alias-key key))) ((pair? key) - (let ((chars (map remap-alias-char key))) - (let loop ((alists alists) (chars chars)) - (let ((char (car chars)) - (chars (cdr chars))) - (cond ((null? chars) - (if-defined alists char)) - ((assq char (car alists)) - => (lambda (entry) (loop (cdr entry) chars))) - ((assq char (cdr alists)) + (let ((keys (map remap-alias-key key))) + (let loop ((alists alists) (keys keys)) + (let ((key (car keys)) + (keys (cdr keys))) + (cond ((null? keys) + (if-defined alists key)) + ((assq key (car alists)) + => (lambda (entry) (loop (cdr entry) keys))) + ((assq key (cdr alists)) (error "Illegal prefix key:" key)) ((not if-undefined) (set-comtab-entry! alists - char - (ref-command-object prefix-char)) + key + (ref-command-object prefix-key)) (let ((alists* (cons '() '()))) - (make-prefix-char! alists char alists*) - (loop alists* chars))) + (make-prefix-key! alists key alists*) + (loop alists* keys))) (else (if-undefined))))))) (else @@ -111,26 +111,26 @@ (if entry (cdr entry) (continue)))))) - (cond ((or (char? key) (pair? key)) + (cond ((or (key? key) (pair? key)) (comtab-lookup-prefix comtabs key continue - (lambda (alists char) - (try char (cdr alists))))) + (lambda (alists key) + (try key (cdr alists))))) ((button? key) (try key (comtab-button-alist (car comtabs)))) (else (error "Illegal comtab key" key)))))) -(define (prefix-char-list? comtabs chars) +(define (prefix-key-list? comtabs keys) (let loop - ((char->alist (car (comtab-dispatch-alists (car comtabs)))) - (chars (if (list? chars) chars (list chars)))) - (or (null? chars) - (let ((entry (assq (remap-alias-char (car chars)) char->alist))) + ((key->alist (car (comtab-dispatch-alists (car comtabs)))) + (keys (if (list? keys) keys (list keys)))) + (or (null? keys) + (let ((entry (assq (remap-alias-key (car keys)) key->alist))) (if entry - (loop (cadr entry) (cdr chars)) + (loop (cadr entry) (cdr keys)) (and (not (null? (cdr comtabs))) (comtab? (cadr comtabs)) - (prefix-char-list? (cdr comtabs) chars))))))) + (prefix-key-list? (cdr comtabs) keys))))))) (define (define-key mode key command) (let ((comtabs (mode-comtabs (->mode mode))) @@ -145,9 +145,9 @@ (let ((normal-key (lambda (key) (comtab-lookup-prefix comtabs key false - (lambda (alists char) - (set-comtab-entry! alists char command)))))) - (cond ((or (char? key) (pair? key)) + (lambda (alists key) + (set-comtab-entry! alists key command)))))) + (cond ((or (key? key) (pair? key)) (normal-key key)) ((char-set? key) (for-each normal-key (char-set-members key))) @@ -158,12 +158,12 @@ (define (define-prefix-key mode key command) (let ((comtabs (mode-comtabs (->mode mode))) (command (->command command))) - (if (not (or (char? key) (pair? key))) + (if (not (or (key? key) (pair? key))) (error "Illegal comtab key" key)) (comtab-lookup-prefix comtabs key false - (lambda (alists char) - (set-comtab-entry! alists char command) - (make-prefix-char! alists char (cons '() '()))))) + (lambda (alists key) + (set-comtab-entry! alists key command) + (make-prefix-key! alists key (cons '() '()))))) key) (define (define-default-key mode command) @@ -186,7 +186,7 @@ (define (search-comtab prefix dispatch-alists) (define (search-prefix-map alist) (if (null? alist) - (map (lambda (char) (append prefix (list char))) + (map (lambda (key) (append prefix (list key))) (search-command-map (cdr dispatch-alists))) (append! (search-comtab (append prefix (list (caar alist))) (cdar alist)) @@ -204,8 +204,8 @@ ;; Filter out shadowed bindings. (list-transform-positive (search-comtabs comtabs) - (lambda (xchar) - (eq? command (comtab-entry comtabs xchar))))) + (lambda (xkey) + (eq? command (comtab-entry comtabs xkey))))) (define (comtab->alist comtab) (let loop ((prefix '()) (da (comtab-dispatch-alists comtab))) diff --git a/v7/src/edwin/decls.scm b/v7/src/edwin/decls.scm index 7961f6686..13181117d 100644 --- a/v7/src/edwin/decls.scm +++ b/v7/src/edwin/decls.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/decls.scm,v 1.21 1991/05/08 22:50:26 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/decls.scm,v 1.22 1991/08/06 15:38:12 arthur Exp $ Copyright (c) 1989-91 Massachusetts Institute of Technology @@ -99,6 +99,7 @@ MIT in each case. |# "winout" "winren" "xform" + "key" "xterm")) (for-each sf-edwin '("argred" diff --git a/v7/src/edwin/dired.scm b/v7/src/edwin/dired.scm index 6aaf3a12c..2eb7357f6 100644 --- a/v7/src/edwin/dired.scm +++ b/v7/src/edwin/dired.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/dired.scm,v 1.111 1991/05/18 03:01:49 cph Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/dired.scm,v 1.112 1991/08/06 15:38:01 arthur Exp $ ;;; ;;; Copyright (c) 1986, 1989-91 Massachusetts Institute of Technology ;;; @@ -95,7 +95,9 @@ Also: (define-key 'dired #\h 'describe-mode) (define-key 'dired #\space 'dired-next-line) (define-key 'dired #\c-n 'dired-next-line) +(define-key 'dired down 'dired-next-line) (define-key 'dired #\c-p 'dired-previous-line) +(define-key 'dired up 'dired-previous-line) (define-key 'dired #\n 'dired-next-line) (define-key 'dired #\p 'dired-previous-line) (define-key 'dired #\g 'dired-revert) diff --git a/v7/src/edwin/ed-ffi.scm b/v7/src/edwin/ed-ffi.scm index b369dc7a6..aa395f78a 100644 --- a/v7/src/edwin/ed-ffi.scm +++ b/v7/src/edwin/ed-ffi.scm @@ -1,3 +1,7 @@ +;;; -*- Scheme -*- + +(declare (usual-integrations)) + (standard-scheme-find-file-initialization '#(("argred" (edwin command-argument) edwin-syntax-table) @@ -91,6 +95,8 @@ edwin-syntax-table) ("iserch" (edwin incremental-search) edwin-syntax-table) + ("key" (edwin keys) + edwin-syntax-table) ("keymap" (edwin command-summary) edwin-syntax-table) ("kilcom" (edwin) diff --git a/v7/src/edwin/edwin.ldr b/v7/src/edwin/edwin.ldr index a58f1e5f1..1c56ece00 100644 --- a/v7/src/edwin/edwin.ldr +++ b/v7/src/edwin/edwin.ldr @@ -1,5 +1,5 @@ ;;; -*-Scheme-*- -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/edwin.ldr,v 1.16 1991/05/08 22:50:55 cph Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/edwin.ldr,v 1.17 1991/08/06 15:40:55 arthur Exp $ ;;; program to load package contents ;;; **** This program (unlike most .ldr files) is not generated by a program. @@ -49,6 +49,9 @@ (let ((env (->environment '(EDWIN X-SCREEN)))) (load "xterm" env) ((access initialize-package! env))) + (let ((env (->environment '(EDWIN KEYS)))) + (load "key" env) + ((access initialize-package! env))) (let ((env (->environment '(EDWIN CONSOLE-SCREEN)))) (load "termcap" env) (load "tterm" env) diff --git a/v7/src/edwin/edwin.pkg b/v7/src/edwin/edwin.pkg index cbf61ba52..d10983e78 100644 --- a/v7/src/edwin/edwin.pkg +++ b/v7/src/edwin/edwin.pkg @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/edwin.pkg,v 1.46 1991/08/01 17:51:07 bal Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/edwin.pkg,v 1.47 1991/08/06 15:40:49 arthur Exp $ Copyright (c) 1989-91 Massachusetts Institute of Technology @@ -181,7 +181,7 @@ MIT in each case. |# define-key define-prefix-key make-comtab - prefix-char-list?)) + prefix-key-list?)) (define-package (edwin undo) (files "undo") @@ -285,6 +285,47 @@ MIT in each case. |# (export (edwin x-screen) update-xterm-screen-names!)) +(define-package (edwin keys) + (files "key") + (parent (edwin)) + (export (edwin x-screen) + x-make-special-key) + (export (edwin) + make-special-key + special-key? + special-key/name + special-key/bucky-bits + stop + f1 + f2 + f3 + f4 + menu + system + user + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12 + insertline + deleteline + insertchar + deletechar + home + prior + next + up + down + left + right + select + print) + (initialization (initialize-package!))) + (define-package (edwin console-screen) (files "termcap" "tterm") (parent (edwin)) @@ -411,16 +452,16 @@ MIT in each case. |# command-reader command-reader/reset-and-execute current-command - current-command-char - dispatch-on-char + current-command-key + dispatch-on-key dispatch-on-command - execute-char + execute-key execute-command execute-command-history-entry initialize-command-reader! - keyboard-chars-read - last-command-char - read-and-dispatch-on-char + keyboard-keys-read + last-command-key + read-and-dispatch-on-key set-command-argument! set-command-message! top-level-command-reader)) @@ -438,7 +479,8 @@ MIT in each case. |# clear-message command-prompt initialize-typeout! - keyboard-peek-char + keyboard-read + keyboard-peek keyboard-read-char message message-args->string diff --git a/v7/src/edwin/hlpcom.scm b/v7/src/edwin/hlpcom.scm index e4741aab3..90e07c7c7 100644 --- a/v7/src/edwin/hlpcom.scm +++ b/v7/src/edwin/hlpcom.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/hlpcom.scm,v 1.99 1991/05/10 05:08:13 cph Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/hlpcom.scm,v 1.100 1991/08/06 15:39:10 arthur Exp $ ;;; ;;; Copyright (c) 1986, 1989-91 Massachusetts Institute of Technology ;;; @@ -51,7 +51,7 @@ It reads another character (a subcommand) and dispatches on it." "cA B C F I K L M T V W or C-h for more help" (lambda (char) - (dispatch-on-char + (dispatch-on-key (current-comtabs) (list #\Backspace (if (or (char=? char #\Backspace) @@ -88,7 +88,7 @@ W where-is. Type a command name and get its key binding." "A B C F I K L M T V W or space to scroll"))) (let ((test-for (lambda (char*) - (char=? char (remap-alias-char char*))))) + (char=? char (remap-alias-key char*))))) (cond ((or (test-for #\C-h) (test-for #\?)) (loop)) @@ -149,7 +149,7 @@ Prints the full documentation for the given command." (if (null? bindings) (message (command-name-string command) " is not on any keys") (message (command-name-string command) " is on " - (xchar->name (car bindings)))))))) + (xkey->name (car bindings)))))))) (define-command describe-key-briefly "Prompts for a key, and describes the command it is bound to. @@ -159,7 +159,7 @@ Prints the brief documentation for that command." (let ((command (comtab-entry (current-comtabs) key))) (if (eq? command (ref-command-object undefined)) (help-describe-unbound-key key) - (message (xchar->name key) + (message (xkey->name key) " runs the command " (command-name-string command)))))) @@ -174,7 +174,7 @@ Prints the full documentation for that command." (help-describe-command command))))) (define (help-describe-unbound-key key) - (message (xchar->name key) " is undefined")) + (message (xkey->name key) " is undefined")) ;;;; Variables @@ -249,8 +249,8 @@ If you want VALUE to be a string, you must surround it with doublequotes." (lambda () (with-output-to-help-display (lambda () - (for-each (lambda (char) - (write-string (string-append (char-name char) " "))) + (for-each (lambda (key) + (write-string (string-append (key-name key) " "))) (reverse (ring-list (current-char-history)))))))) (define-command describe-mode @@ -303,16 +303,16 @@ If you want VALUE to be a string, you must surround it with doublequotes." (let ((bindings (comtab-key-bindings (current-comtabs) command))) (if (not (null? bindings)) (begin (write-string " which is bound to: ") - (write-string (char-list-string bindings)) + (write-string (key-list-string bindings)) (newline))))) -(define (char-list-string xchars) - (let loop ((xchars (sort xchars xcharname (car xchars)) - (string-append (xchar->name (car xchars)) +(define (key-list-string xkeys) + (let loop ((xkeys (sort xkeys xkeyname (car xkeys)) + (string-append (xkey->name (car xkeys)) ", " - (loop (cdr xchars)))))) + (loop (cdr xkeys)))))) (define (print-variable-binding variable) (write-string " which is bound to: ") @@ -382,4 +382,4 @@ If you want VALUE to be a string, you must surround it with doublequotes." (let ((bindings (comtab-key-bindings (current-comtabs) command))) (if (null? bindings) (string-append "M-x " (command-name-string command)) - (xchar->name (car bindings))))) \ No newline at end of file + (xkey->name (car bindings))))) \ No newline at end of file diff --git a/v7/src/edwin/info.scm b/v7/src/edwin/info.scm index 5ccb237d8..a2af67dad 100644 --- a/v7/src/edwin/info.scm +++ b/v7/src/edwin/info.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/info.scm,v 1.104 1991/05/16 23:14:02 cph Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/info.scm,v 1.105 1991/08/06 15:38:47 arthur Exp $ ;;; ;;; Copyright (c) 1986, 1989-91 Massachusetts Institute of Technology ;;; @@ -268,10 +268,11 @@ s Search through this Info file for specified regexp, (message (if end-visible? "Type Space to return to Info" "Type Space to see more")) - (let ((char (keyboard-peek-char))) - (if (char=? char #\Space) + (let ((key (keyboard-peek))) + (if (and (char? key) + (char=? key #\Space)) (begin - (keyboard-read-char) + (keyboard-read) (if (not end-visible?) (begin ((ref-command scroll-up) false) diff --git a/v7/src/edwin/input.scm b/v7/src/edwin/input.scm index 7e7c32103..1abe117e2 100644 --- a/v7/src/edwin/input.scm +++ b/v7/src/edwin/input.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/input.scm,v 1.89 1991/05/02 20:38:36 cph Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/input.scm,v 1.90 1991/08/06 15:38:30 arthur Exp $ ;;; ;;; Copyright (c) 1986, 1989-91 Massachusetts Institute of Technology ;;; @@ -175,26 +175,32 @@ B 3BAB8C (if (not command-prompt-displayed?) (clear-current-message!))))) -(define (keyboard-peek-char) +(define (keyboard-peek) (if *executing-keyboard-macro?* - (keyboard-macro-peek-char) - (keyboard-read-char-1 (editor-peek-char current-editor)))) + (keyboard-macro-peek-key) + (keyboard-read-1 (editor-peek-char current-editor)))) -(define (keyboard-read-char) - (set! keyboard-chars-read (1+ keyboard-chars-read)) +(define (keyboard-read) + (set! keyboard-keys-read (1+ keyboard-keys-read)) (if *executing-keyboard-macro?* - (keyboard-macro-read-char) - (let ((char (keyboard-read-char-1 (editor-read-char current-editor)))) + (keyboard-macro-read-key) + (let ((key (keyboard-read-1 (editor-read-char current-editor)))) (set! auto-save-keystroke-count (1+ auto-save-keystroke-count)) - (ring-push! (current-char-history) char) - (if *defining-keyboard-macro?* (keyboard-macro-write-char char)) - char))) + (ring-push! (current-char-history) key) + (if *defining-keyboard-macro?* (keyboard-macro-write-key key)) + key))) + +(define (keyboard-read-char) + (let loop ((key (keyboard-read))) + (if (char? key) + key + (loop (keyboard-read))))) -(define read-char-timeout/fast 500) -(define read-char-timeout/slow 2000) +(define read-key-timeout/fast 500) +(define read-key-timeout/slow 2000) -(define (keyboard-read-char-1 read-char) - (remap-alias-char +(define (keyboard-read-1 read-key) + (remap-alias-key (let ((char-ready? (editor-char-ready? current-editor))) (if (not (char-ready?)) (begin @@ -220,14 +226,14 @@ B 3BAB8C (cond ((within-typein-edit?) (if message-string (begin - (wait read-char-timeout/slow) + (wait read-key-timeout/slow) (set! message-string false) (set! message-should-be-erased? false) (clear-current-message!)))) ((and (or message-should-be-erased? (and command-prompt-string (not command-prompt-displayed?))) - (wait read-char-timeout/fast)) + (wait read-key-timeout/fast)) (set! message-string false) (set! message-should-be-erased? false) (if command-prompt-string @@ -236,7 +242,7 @@ B 3BAB8C (set-current-message! command-prompt-string)) (clear-current-message!))))) (let loop () - (or (read-char) + (or (read-key) (begin (accept-process-output) (notify-process-status-changes) diff --git a/v7/src/edwin/iserch.scm b/v7/src/edwin/iserch.scm index 1bb99689e..6ece45c7f 100644 --- a/v7/src/edwin/iserch.scm +++ b/v7/src/edwin/iserch.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/iserch.scm,v 1.13 1991/05/17 04:52:42 cph Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/iserch.scm,v 1.14 1991/08/06 15:39:15 arthur Exp $ ;;; ;;; Copyright (c) 1986, 1989-91 Massachusetts Institute of Technology ;;; @@ -67,7 +67,7 @@ (dispatch-on-command result)) (else (push-current-mark! point) - (if result (execute-char (current-comtabs) result)))))))) + (if result (execute-key (current-comtabs) result)))))))) (define (isearch-loop state) (if (not ((editor-char-ready? current-editor))) @@ -77,7 +77,7 @@ (let ((char (keyboard-read-char))) (let ((test-for (lambda (char*) - (char=? char (remap-alias-char char*))))) + (char=? char (remap-alias-key char*))))) (cond ((test-for (ref-variable search-quote-char)) (isearch-append-char state @@ -120,7 +120,7 @@ (isearch-append-char state char)))))) (define (nonincremental-search forward? regexp?) - (cond ((char=? (remap-alias-char (ref-variable search-yank-word-char)) + (cond ((char=? (remap-alias-key (ref-variable search-yank-word-char)) (prompt-for-typein (if regexp? (prompt-for-string/prompt diff --git a/v7/src/edwin/keymap.scm b/v7/src/edwin/keymap.scm index 2fb0fd531..a422ff8d3 100644 --- a/v7/src/edwin/keymap.scm +++ b/v7/src/edwin/keymap.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/keymap.scm,v 1.9 1991/05/06 22:27:45 cph Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/keymap.scm,v 1.10 1991/08/06 15:39:26 arthur Exp $ ;;; ;;; Copyright (c) 1986, 1989-91 Massachusetts Institute of Technology ;;; @@ -166,9 +166,9 @@ Previous contents of that buffer are killed first." (define (sort-and-simplify elements) (map (lambda (element) - (cons (xchar->name (car element)) + (cons (xkey->name (car element)) (command-name-string (cdr element)))) - (sort elements (lambda (a b) (xcharname chars) true) - (if (prefix-char-list? comtab chars) + (set-typein-string! (xkey->name chars) true) + (if (prefix-key-list? comtab chars) (outer-loop chars) (let ((command (comtab-entry comtab chars))) (if (memq command extension-commands) @@ -649,13 +653,15 @@ a repetition of this command will exit." (prompt-for-typein (string-append prompt " (y or n)? ") false (lambda () (let loop ((lost? false)) - (let ((char (keyboard-read-char))) - (cond ((or (char-ci=? char #\y) - (char-ci=? char #\space)) + (let ((char (keyboard-read))) + (cond ((and (char? char) + (or (char-ci=? char #\y) + (char-ci=? char #\space))) (set-typein-string! "y" true) true) - ((or (char-ci=? char #\n) - (char-ci=? char #\rubout)) + ((and (char? char) + (or (char-ci=? char #\n) + (char-ci=? char #\rubout))) (set-typein-string! "n" true) false) (else diff --git a/v7/src/edwin/regcom.scm b/v7/src/edwin/regcom.scm index 1d11f068e..8c85f3c8b 100644 --- a/v7/src/edwin/regcom.scm +++ b/v7/src/edwin/regcom.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/regcom.scm,v 1.19 1991/05/10 04:58:23 cph Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/regcom.scm,v 1.20 1991/08/06 15:39:38 arthur Exp $ ;;; ;;; Copyright (c) 1987, 1989 Massachusetts Institute of Technology ;;; @@ -148,11 +148,11 @@ With prefix arg, delete as well." (lambda (register) (let ((value (get-register register))) (if (not value) - (message "Register " (char-name register) " is empty") + (message "Register " (key-name register) " is empty") (with-output-to-temporary-buffer "*Output*" (lambda () (write-string "Register ") - (write-string (char-name register)) + (write-string (key-name register)) (write-string " contains ") (cond ((integer? value) (write value)) @@ -174,7 +174,7 @@ With prefix arg, delete as well." (write value))))))))) (define (register-error register . strings) - (apply editor-error "Register " (char-name register) " " strings)) + (apply editor-error "Register " (key-name register) " " strings)) (define (get-register char) (let ((entry (assv char register-alist))) diff --git a/v7/src/edwin/replaz.scm b/v7/src/edwin/replaz.scm index cfd8deff2..5884cf313 100644 --- a/v7/src/edwin/replaz.scm +++ b/v7/src/edwin/replaz.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/replaz.scm,v 1.70 1991/05/04 20:14:19 cph Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/replaz.scm,v 1.71 1991/08/06 15:40:39 arthur Exp $ ;;; ;;; Copyright (c) 1986, 1989-91 Massachusetts Institute of Technology ;;; @@ -176,9 +176,9 @@ and \\ means insert what matched th \\(...\\) in REGEXP." (let ((char (with-editor-interrupts-disabled keyboard-peek-char))) (let ((test-for (lambda (char*) - (and (char=? char (remap-alias-char char*)) + (and (char=? char (remap-alias-key char*)) (begin - (keyboard-read-char) + (keyboard-read) true))))) (cond ((test-for #\C-h) (with-output-to-help-display diff --git a/v7/src/edwin/sercom.scm b/v7/src/edwin/sercom.scm index 02b1d6e61..ea96aea34 100644 --- a/v7/src/edwin/sercom.scm +++ b/v7/src/edwin/sercom.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/sercom.scm,v 1.59 1991/05/17 18:39:00 cph Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/sercom.scm,v 1.60 1991/08/06 15:39:42 arthur Exp $ ;;; ;;; Copyright (c) 1986, 1989-91 Massachusetts Institute of Technology ;;; @@ -298,7 +298,7 @@ Special characters: (let ((char (prompt-for-char "Character search"))) (let ((test-for (lambda (char*) - (char=? char (remap-alias-char char*))))) + (char=? char (remap-alias-key char*))))) (if (test-for #\C-a) (dispatch-on-command (if forward? diff --git a/v7/src/edwin/wincom.scm b/v7/src/edwin/wincom.scm index 3841c9ed0..ccacb56a0 100644 --- a/v7/src/edwin/wincom.scm +++ b/v7/src/edwin/wincom.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/wincom.scm,v 1.104 1991/05/18 03:23:44 cph Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/wincom.scm,v 1.105 1991/08/06 15:39:34 arthur Exp $ ;;; ;;; Copyright (c) 1987, 1989-91 Massachusetts Institute of Technology ;;; @@ -237,7 +237,7 @@ means scroll one screenful down." "" (let ((char (mark-right-char point))) (let ((n (char->ascii char))) - (string-append "Char: " (char-name char) + (string-append "Char: " (key-name char) " (" (if (zero? n) "" "0") (number->string n 8) diff --git a/v7/src/edwin/xterm.scm b/v7/src/edwin/xterm.scm index ebe622f3a..866bcb48b 100644 --- a/v7/src/edwin/xterm.scm +++ b/v7/src/edwin/xterm.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/xterm.scm,v 1.20 1991/07/26 21:56:09 arthur Exp $ +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/xterm.scm,v 1.21 1991/08/06 15:39:21 arthur Exp $ ;;; ;;; Copyright (c) 1989-91 Massachusetts Institute of Technology ;;; @@ -43,6 +43,7 @@ ;;; ;;;; X Terminal +;;; Package: (edwin x-screen) (declare (usual-integrations)) @@ -228,10 +229,14 @@ ;;;; Event Handling +(define-integrable control-bucky-bit 2) + (define (get-xterm-input-operations) (let ((display x-display-data) (queue x-display-events) (bucky-bits 0) + (keysym false) + (special-key? false) (string false) (start 0) (end 0) @@ -240,9 +245,12 @@ (lambda (event) (set! string (vector-ref event 2)) (set! bucky-bits (vector-ref event 3)) + (set! keysym (vector-ref event 4)) (set! start 0) (set! end (string-length string)) - (if signal-interrupts? + (set! special-key? (zero? end)) + (if (and signal-interrupts? + (not special-key?)) (let ((i (string-find-previous-char string #\BEL))) (if i (begin @@ -263,9 +271,12 @@ (error "#F returned from blocking read")) ((eq? true event) false) - ((fix:= event-type:key-press (vector-ref event 0)) + ((fix:= event-type:key-press + (vector-ref event 0)) (process-key-press-event event) - (if (fix:< start end) true (loop))) + (if (or special-key? (fix:< start end)) + true + (loop))) (else (process-special-event event) (loop))))))) @@ -274,11 +285,12 @@ (if (and (zero? start) (= end 1)) (make-char (char-code character) - bucky-bits) + (fix:andc bucky-bits + control-bucky-bit)) character)))) (values (lambda () ;halt-update? - (if (or (fix:< start end) pending-event) + (if (or special-key? (fix:< start end) pending-event) true (let ((event (get-next-event 0))) (and event @@ -286,7 +298,7 @@ (set! pending-event event) true))))) (lambda () ;char-ready? - (if (fix:< start end) + (if (or special-key? (fix:< start end)) true (let loop () (let ((event (get-next-event 0))) @@ -294,20 +306,27 @@ false) ((fix:= event-type:key-press (vector-ref event 0)) (process-key-press-event event) - (if (fix:< start end) true (loop))) + (if (or special-key? (fix:< start end)) + true + (loop))) (else (process-special-event event) (loop))))))) (lambda () ;peek-char - (and (or (fix:< start end) (guarantee-input)) - (apply-bucky-bits (string-ref string start)))) + (and (or special-key? (fix:< start end) (guarantee-input)) + (if special-key? + (x-make-special-key keysym bucky-bits) + (apply-bucky-bits (string-ref string start))))) (lambda () ;read-char - (and (or (fix:< start end) (guarantee-input)) - (let ((char - (apply-bucky-bits - (string-ref string start)))) - (set! start (fix:+ start 1)) - char))))))))) + (and (or special-key? (fix:< start end) (guarantee-input)) + (if special-key? + (begin (set! special-key? false) + (x-make-special-key keysym bucky-bits)) + (let ((char + (apply-bucky-bits + (string-ref string start)))) + (set! start (fix:+ start 1)) + char)))))))))) (define (read-event queue display time-limit) ;; If no time-limit, we're reading from the keyboard. In that case, -- 2.25.1