diff options
| author | Richard M. Stallman | 1993-05-12 18:41:29 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-05-12 18:41:29 +0000 |
| commit | d3f7c8c6e4985a7d2cf3c9fa0a0cc48b5328c796 (patch) | |
| tree | 1728be7ff1441c14c1c4515a938b387a620e33af | |
| parent | 819012f0555783d74d7f7fcf381a993ceac457e8 (diff) | |
| download | emacs-d3f7c8c6e4985a7d2cf3c9fa0a0cc48b5328c796.tar.gz emacs-d3f7c8c6e4985a7d2cf3c9fa0a0cc48b5328c796.zip | |
(te-pass-through): Handle meta chars and non-char events.
(terminal-map, etc.): Use default bindings, not fillarray.
Make the maps sparse.
(terminal-meta-map): New map; lets us make ESC a prefix key.
(terminal-map): Bind ESC to terminal-meta-map.
(te-more-break-unread): Handle non-char as last-input-char.
(te-filter): Delete code that worked with meta-flag.
(terminal-emulator): Don't look at meta-flag.
(terminal-mode): Don't make meta-flag local.
(te-stty-string): Quote the args that have ^. Add pass8.
Changes that esr made in the previous version but didn't describe in detail:
Some defvars moved.
Defvars added for many variables.
(te-stty-string): Specify the characters explicitly--not `stty dec'.
| -rw-r--r-- | lisp/terminal.el | 76 |
1 files changed, 43 insertions, 33 deletions
diff --git a/lisp/terminal.el b/lisp/terminal.el index 6b4739f881a..8abcf9d4302 100644 --- a/lisp/terminal.el +++ b/lisp/terminal.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; terminal.el --- terminal emulator for GNU Emacs. | 1 | ;;; terminal.el --- terminal emulator for GNU Emacs. |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1986, 1987, 1988, 1989 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1986, 1987, 1988, 1989, 1993 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Richard Mlynarik <mly@eddie.mit.edu> | 5 | ;; Author: Richard Mlynarik <mly@eddie.mit.edu> |
| 6 | ;; Maintainer: FSF | 6 | ;; Maintainer: FSF |
| @@ -65,11 +65,19 @@ performance.") | |||
| 65 | (defvar terminal-more-break-insertion | 65 | (defvar terminal-more-break-insertion |
| 66 | "*** More break -- Press space to continue ***") | 66 | "*** More break -- Press space to continue ***") |
| 67 | 67 | ||
| 68 | (defvar terminal-meta-map nil) | ||
| 69 | (if terminal-meta-map | ||
| 70 | nil | ||
| 71 | (let ((map (make-sparse-keymap))) | ||
| 72 | (define-key map [t] 'te-pass-through) | ||
| 73 | (setq terminal-meta-map map))) | ||
| 74 | |||
| 68 | (defvar terminal-map nil) | 75 | (defvar terminal-map nil) |
| 69 | (if terminal-map | 76 | (if terminal-map |
| 70 | nil | 77 | nil |
| 71 | (let ((map (make-keymap))) | 78 | (let ((map (make-sparse-keymap))) |
| 72 | (fillarray (car (cdr map)) 'te-pass-through) | 79 | (define-key map [t] 'te-pass-through) |
| 80 | (define-key map "\e" terminal-meta-map) | ||
| 73 | ;(define-key map "\C-l" | 81 | ;(define-key map "\C-l" |
| 74 | ; '(lambda () (interactive) (te-pass-through) (redraw-display))) | 82 | ; '(lambda () (interactive) (te-pass-through) (redraw-display))) |
| 75 | (setq terminal-map map))) | 83 | (setq terminal-map map))) |
| @@ -77,9 +85,8 @@ performance.") | |||
| 77 | (defvar terminal-escape-map nil) | 85 | (defvar terminal-escape-map nil) |
| 78 | (if terminal-escape-map | 86 | (if terminal-escape-map |
| 79 | nil | 87 | nil |
| 80 | (let ((map (make-keymap))) | 88 | (let ((map (make-sparse-keymap))) |
| 81 | ;(fillarray map 'te-escape-extended-command-unread) | 89 | (define-key map [t] 'undefined) |
| 82 | (fillarray (car (cdr map)) 'undefined) | ||
| 83 | (let ((s "0")) | 90 | (let ((s "0")) |
| 84 | (while (<= (aref s 0) ?9) | 91 | (while (<= (aref s 0) ?9) |
| 85 | (define-key map s 'digit-argument) | 92 | (define-key map s 'digit-argument) |
| @@ -124,8 +131,8 @@ performance.") | |||
| 124 | (defvar terminal-more-break-map nil) | 131 | (defvar terminal-more-break-map nil) |
| 125 | (if terminal-more-break-map | 132 | (if terminal-more-break-map |
| 126 | nil | 133 | nil |
| 127 | (let ((map (make-keymap))) | 134 | (let ((map (make-sparse-keymap))) |
| 128 | (fillarray (car (cdr map)) 'te-more-break-unread) | 135 | (define-key map [t] 'te-more-break-unread) |
| 129 | (define-key map (char-to-string help-char) 'te-more-break-help) | 136 | (define-key map (char-to-string help-char) 'te-more-break-help) |
| 130 | (define-key map " " 'te-more-break-resume) | 137 | (define-key map " " 'te-more-break-resume) |
| 131 | (define-key map "\C-l" 'redraw-display) | 138 | (define-key map "\C-l" 'redraw-display) |
| @@ -343,7 +350,7 @@ set it smaller for more frequent updates (but overall slower performance." | |||
| 343 | (put 'te-more-break-unread 'suppress-keymap t) | 350 | (put 'te-more-break-unread 'suppress-keymap t) |
| 344 | (defun te-more-break-unread () | 351 | (defun te-more-break-unread () |
| 345 | (interactive) | 352 | (interactive) |
| 346 | (if (= last-input-char terminal-escape-char) | 353 | (if (eq last-input-char terminal-escape-char) |
| 347 | (call-interactively 'te-escape) | 354 | (call-interactively 'te-escape) |
| 348 | (message "Continuing from more break (\"%s\" typed, %d chars output pending...)" | 355 | (message "Continuing from more break (\"%s\" typed, %d chars output pending...)" |
| 349 | (single-key-description last-input-char) | 356 | (single-key-description last-input-char) |
| @@ -416,13 +423,31 @@ One characters is treated specially: | |||
| 416 | the terminal escape character (normally C-^) | 423 | the terminal escape character (normally C-^) |
| 417 | lets you type a terminal emulator command." | 424 | lets you type a terminal emulator command." |
| 418 | (interactive) | 425 | (interactive) |
| 419 | (cond ((= last-input-char terminal-escape-char) | 426 | (setq list (cons last-input-char list)) |
| 427 | (cond ((eq last-input-char terminal-escape-char) | ||
| 420 | (call-interactively 'te-escape)) | 428 | (call-interactively 'te-escape)) |
| 421 | (t | 429 | (t |
| 422 | (and terminal-more-processing (null (cdr te-pending-output)) | 430 | ;; Convert `return' to C-m, etc. |
| 423 | (te-set-more-count nil)) | 431 | (if (and (symbolp last-input-char) |
| 424 | (send-string te-process (make-string 1 last-input-char)) | 432 | (get last-input-char 'ascii-character)) |
| 425 | (te-process-output t)))) | 433 | (setq last-input-char (get last-input-char 'ascii-character))) |
| 434 | ;; Convert meta characters to 8-bit form for transmission. | ||
| 435 | (if (and (integerp last-input-char) | ||
| 436 | (not (zerop (logand last-input-char (lsh 1 23))))) | ||
| 437 | (setq last-input-char (+ 128 (logand last-input-char 127)))) | ||
| 438 | (setq list (cons (list 'really last-input-char) list)) | ||
| 439 | ;; Now ignore all but actual characters. | ||
| 440 | ;; (It ought to be possible to send through function | ||
| 441 | ;; keys as character sequences if we add a description | ||
| 442 | ;; to our termcap entry of what they should look like.) | ||
| 443 | (if (integerp last-input-char) | ||
| 444 | (progn | ||
| 445 | (and terminal-more-processing (null (cdr te-pending-output)) | ||
| 446 | (te-set-more-count nil)) | ||
| 447 | (send-string te-process (make-string 1 last-input-char)) | ||
| 448 | (te-process-output t)) | ||
| 449 | (message "Function key `%s' ignored" | ||
| 450 | (single-key-description last-input-char)))))) | ||
| 426 | 451 | ||
| 427 | 452 | ||
| 428 | (defun te-set-window-start () | 453 | (defun te-set-window-start () |
| @@ -803,8 +828,7 @@ move to start of new line, clear to end of line." | |||
| 803 | 828 | ||
| 804 | 829 | ||
| 805 | (defun te-filter (process string) | 830 | (defun te-filter (process string) |
| 806 | (let* ((obuf (current-buffer)) | 831 | (let* ((obuf (current-buffer))) |
| 807 | (m meta-flag)) | ||
| 808 | ;; can't use save-excursion, as that preserves point, which we don't want | 832 | ;; can't use save-excursion, as that preserves point, which we don't want |
| 809 | (unwind-protect | 833 | (unwind-protect |
| 810 | (progn | 834 | (progn |
| @@ -820,13 +844,8 @@ move to start of new line, clear to end of line." | |||
| 820 | (set-buffer (process-buffer process)))) | 844 | (set-buffer (process-buffer process)))) |
| 821 | (setq te-pending-output (nconc te-pending-output (list string))) | 845 | (setq te-pending-output (nconc te-pending-output (list string))) |
| 822 | (te-update-pending-output-display) | 846 | (te-update-pending-output-display) |
| 823 | ;; this binding is needed because emacs looks at meta-flag when | 847 | (te-process-output (eq (current-buffer) |
| 824 | ;; the keystroke is read from the keyboard, not when it is about | 848 | (window-buffer (selected-window)))) |
| 825 | ;; to be fed into a keymap (or returned by read-char) | ||
| 826 | ;; There still could be some screws, though. | ||
| 827 | (let ((meta-flag m)) | ||
| 828 | (te-process-output (eq (current-buffer) | ||
| 829 | (window-buffer (selected-window))))) | ||
| 830 | (set-buffer (process-buffer process)) | 849 | (set-buffer (process-buffer process)) |
| 831 | (setq te-saved-point (point))) | 850 | (setq te-saved-point (point))) |
| 832 | (set-buffer obuf)))) | 851 | (set-buffer obuf)))) |
| @@ -993,7 +1012,7 @@ move to start of new line, clear to end of line." | |||
| 993 | (progn (goto-char (point-max)) | 1012 | (progn (goto-char (point-max)) |
| 994 | (recenter -1))))))) | 1013 | (recenter -1))))))) |
| 995 | 1014 | ||
| 996 | (defvar te-stty-string "stty -nl erase ^? kill ^u intr ^c echo" | 1015 | (defvar te-stty-string "stty -nl erase '^?' kill '^u' intr '^c' echo pass8" |
| 997 | "Shell command to set terminal modes for terminal emulator.") | 1016 | "Shell command to set terminal modes for terminal emulator.") |
| 998 | ;; This used to have `new' in it, but that loses outside BSD | 1017 | ;; This used to have `new' in it, but that loses outside BSD |
| 999 | ;; and it's apparently not needed in BSD. | 1018 | ;; and it's apparently not needed in BSD. |
| @@ -1117,11 +1136,6 @@ work with `terminfo' we will try to use it." | |||
| 1117 | (set-process-sentinel te-process 'te-sentinel)) | 1136 | (set-process-sentinel te-process 'te-sentinel)) |
| 1118 | (error (fundamental-mode) | 1137 | (error (fundamental-mode) |
| 1119 | (signal (car err) (cdr err)))) | 1138 | (signal (car err) (cdr err)))) |
| 1120 | ;; sigh | ||
| 1121 | (if (default-value 'meta-flag) | ||
| 1122 | (progn (message | ||
| 1123 | "Note: Meta key disabled due to maybe-eventually-reparable braindamage") | ||
| 1124 | (sit-for 1))) | ||
| 1125 | (setq inhibit-quit t) ;sport death | 1139 | (setq inhibit-quit t) ;sport death |
| 1126 | (use-local-map terminal-map) | 1140 | (use-local-map terminal-map) |
| 1127 | (run-hooks 'terminal-mode-hook) | 1141 | (run-hooks 'terminal-mode-hook) |
| @@ -1194,10 +1208,6 @@ of the terminal-emulator" | |||
| 1194 | (setq te-more-count -1) | 1208 | (setq te-more-count -1) |
| 1195 | (make-local-variable 'te-redisplay-count) | 1209 | (make-local-variable 'te-redisplay-count) |
| 1196 | (setq te-redisplay-count terminal-redisplay-interval) | 1210 | (setq te-redisplay-count terminal-redisplay-interval) |
| 1197 | ;;>> Nothing can be done about this without decruftifying | ||
| 1198 | ;;>> emacs keymaps. | ||
| 1199 | (make-local-variable 'meta-flag) ;sigh | ||
| 1200 | (setq meta-flag nil) | ||
| 1201 | ;(use-local-map terminal-mode-map) | 1211 | ;(use-local-map terminal-mode-map) |
| 1202 | ;; terminal-mode-hook is called above in function terminal-emulator | 1212 | ;; terminal-mode-hook is called above in function terminal-emulator |
| 1203 | ) | 1213 | ) |