From e645a1ddd6a4552bf6d14dac038ecd9587c010ac Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Fri, 20 Dec 1991 08:24:06 +0000 Subject: [PATCH] Initial revision --- lisp/term/sun.el | 273 +++++++++++++++++++++++++++++++++++++++++++++ lisp/term/vt100.el | 62 ++++++++++ 2 files changed, 335 insertions(+) create mode 100644 lisp/term/sun.el create mode 100644 lisp/term/vt100.el diff --git a/lisp/term/sun.el b/lisp/term/sun.el new file mode 100644 index 00000000000..df4ddf80526 --- /dev/null +++ b/lisp/term/sun.el @@ -0,0 +1,273 @@ +;; keybinding for standard default sunterm keys +;; Copyright (C) 1987 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY. No author or distributor +;; accepts responsibility to anyone for the consequences of using it +;; or for whether it serves any particular purpose or works at all, +;; unless he says so in writing. Refer to the GNU Emacs General Public +;; License for full details. + +;; Everyone is granted permission to copy, modify and redistribute +;; GNU Emacs, but only under the conditions described in the +;; GNU Emacs General Public License. A copy of this license is +;; supposed to have been given to you along with GNU Emacs so you +;; can know your rights and responsibilities. It should be in a +;; file named COPYING. Among other things, the copyright notice +;; and this notice must be preserved on all copies. + +;; Jeff Peck, Sun Microsystems Inc + +;; The function key sequences for the console have been converted for +;; use with function-key-map, but the *tool stuff hasn't been touched. + + +(defun ignore-key () + "interactive version of ignore" + (interactive) + (ignore)) + +(defun scroll-down-in-place (n) + (interactive "p") + (previous-line n) + (scroll-down n)) + +(defun scroll-up-in-place (n) + (interactive "p") + (next-line n) + (scroll-up n)) + +(defun kill-region-and-unmark (beg end) + "Like kill-region, but pops the mark [which equals point, anyway.]" + (interactive "r") + (kill-region beg end) + (setq this-command 'kill-region-and-unmark) + (set-mark-command t)) + +(defun select-previous-complex-command () + "Select Previous-complex-command" + (interactive) + (if (zerop (minibuffer-depth)) + (repeat-complex-command 1) + (previous-complex-command 1))) + +(defun rerun-prev-command () + "Repeat Previous-complex-command." + (interactive) + (eval (nth 0 command-history))) + +(defvar grep-arg nil "Default arg for RE-search") +(defun grep-arg () + (if (memq last-command '(research-forward research-backward)) grep-arg + (let* ((command (car command-history)) + (command-name (symbol-name (car command))) + (search-arg (car (cdr command))) + (search-command + (and command-name (string-match "search" command-name))) + ) + (if (and search-command (stringp search-arg)) (setq grep-arg search-arg) + (setq search-command this-command + grep-arg (read-string "REsearch: " grep-arg) + this-command search-command) + grep-arg)))) + +(defun research-forward () + "Repeat RE search forward." + (interactive) + (re-search-forward (grep-arg))) + +(defun research-backward () + "Repeat RE search backward." + (interactive) + (re-search-backward (grep-arg))) + +;;; +;;; handle sun's extra function keys +;;; this version for those who run with standard .ttyswrc and no emacstool +;;; +;;; sunview picks up expose and open on the way UP, +;;; so we ignore them on the way down +;;; + +(defvar sun-esc-bracket nil + "*If non-nil, rebind ESC [ as prefix for Sun function keys.") + +(define-prefix-command 'sun-raw-prefix 'sun-raw-map) +(define-key function-key-map "\e[" 'sun-raw-prefix) + +(define-key sun-raw-map "210z" [r3]) +(define-key sun-raw-map "213z" [r6]) +(define-key sun-raw-map "214z" [r7]) +(define-key sun-raw-map "216z" [r9]) +(define-key sun-raw-map "218z" [r11]) +(define-key sun-raw-map "220z" [r13]) +(define-key sun-raw-map "222z" [r15]) +(define-key sun-raw-map "193z" [again]) +(define-key sun-raw-map "194z" [props]) +(define-key sun-raw-map "195z" [undo]) +; (define-key sun-raw-map "196z" 'ignore-key) ; Expose-down +; (define-key sun-raw-map "197z" [put]) +; (define-key sun-raw-map "198z" 'ignore-key) ; Open-down +; (define-key sun-raw-map "199z" [get]) +(define-key sun-raw-map "200z" [find]) +; (define-key sun-raw-map "201z" 'kill-region-and-unmark) ; Delete +(define-key sun-raw-map "226z" [t3]) +(define-key sun-raw-map "227z" [t4]) +(define-key sun-raw-map "229z" [t6]) +(define-key sun-raw-map "230z" [t7]) +(define-key sun-raw-map "A" [up]) ; R8 +(define-key sun-raw-map "B" [down]) ; R14 +(define-key sun-raw-map "C" [right]) ; R12 +(define-key sun-raw-map "D" [left]) ; R10 + +(global-set-key [r3] 'backward-page) +(global-set-key [r6] 'forward-page) +(global-set-key [r7] 'beginning-of-buffer) +(global-set-key [r9] 'scroll-down) +(global-set-key [r11] 'recenter) +(global-set-key [r13] 'end-of-buffer) +(global-set-key [r15] 'scroll-up) +(global-set-key [again] 'redraw-display) +(global-set-key [props] 'list-buffers) +(global-set-key [undo] 'undo) +(global-set-key [put] 'sun-select-region) +(global-set-key [get] 'sun-yank-selection) +(global-set-key [find] 'exchange-point-and-mark) +(global-set-key [t3] 'scroll-down-in-place) +(global-set-key [t4] 'scroll-up-in-place) +(global-set-key [t6] 'shrink-window) +(global-set-key [t7] 'enlarge-window) + + +(if sun-esc-bracket (global-unset-key "\e[")) + +;;; Since .emacs gets loaded before this file, a hook is supplied +;;; for you to put your own bindings in. + +(defvar sun-raw-map-hooks nil + "List of forms to evaluate after setting sun-raw-map.") + +(let ((hooks sun-raw-map-hooks)) + (while hooks + (eval (car hooks)) + (setq hooks (cdr hooks)) + )) + + +;;; This section adds defintions for the emacstool users +;;; emacstool event filter converts function keys to C-x*{c}{lrt} +;;; +;;; for example the Open key (L7) would be encoded as "\C-x*gl" +;;; the control, meta, and shift keys modify the character {lrt} +;;; note that (unshifted) C-l is ",", C-r is "2", and C-t is "4" +;;; +;;; {c} is [a-j] for LEFT, [a-i] for TOP, [a-o] for RIGHT. +;;; A higher level insists on encoding {h,j,l,n}{r} (the arrow keys) +;;; as ANSI escape sequences. Use the shell command +;;; % setkeys noarrows +;;; if you want these to come through for emacstool. +;;; +;;; If you are not using EmacsTool, +;;; you can also use this by creating a .ttyswrc file to do the conversion. +;;; but it won't include the CONTROL, META, or SHIFT keys! +;;; +;;; Important to define SHIFTed sequence before matching unshifted sequence. +;;; (talk about bletcherous old uppercase terminal conventions!*$#@&%*&#$%) +;;; this is worse than C-S/C-Q flow control anyday! +;;; Do *YOU* run in capslock mode? +;;; + +;;; Note: al, el and gl are trapped by EmacsTool, so they never make it here. + +(defvar meta-flag t) + +(defvar suntool-map (make-sparse-keymap) + "*Keymap for Emacstool bindings.") + +(define-key suntool-map "gr" 'beginning-of-buffer) ; r7 +(define-key suntool-map "iR" 'backward-page) ; R9 +(define-key suntool-map "ir" 'scroll-down) ; r9 +(define-key suntool-map "kr" 'recenter) ; r11 +(define-key suntool-map "mr" 'end-of-buffer) ; r13 +(define-key suntool-map "oR" 'forward-page) ; R15 +(define-key suntool-map "or" 'scroll-up) ; r15 +(define-key suntool-map "b\M-L" 'rerun-prev-command) ; M-AGAIN +(define-key suntool-map "b\M-l" 'prev-complex-command) ; M-Again +(define-key suntool-map "bl" 'redraw-display) ; Again +(define-key suntool-map "cl" 'list-buffers) ; Props +(define-key suntool-map "dl" 'undo) ; Undo +(define-key suntool-map "el" 'ignore-key) ; Expose-Open +(define-key suntool-map "fl" 'sun-select-region) ; Put +(define-key suntool-map "f," 'copy-region-as-kill) ; C-Put +(define-key suntool-map "gl" 'ignore-key) ; Open-Open +(define-key suntool-map "hl" 'sun-yank-selection) ; Get +(define-key suntool-map "h," 'yank) ; C-Get +(define-key suntool-map "il" 'research-forward) ; Find +(define-key suntool-map "i," 're-search-forward) ; C-Find +(define-key suntool-map "i\M-l" 'research-backward) ; M-Find +(define-key suntool-map "i\M-," 're-search-backward) ; C-M-Find + +(define-key suntool-map "jL" 'yank) ; DELETE +(define-key suntool-map "jl" 'kill-region-and-unmark) ; Delete +(define-key suntool-map "j\M-l" 'exchange-point-and-mark); M-Delete +(define-key suntool-map "j," + '(lambda () (interactive) (pop-mark 1))) ; C-Delete + +(define-key suntool-map "fT" 'shrink-window-horizontally) ; T6 +(define-key suntool-map "gT" 'enlarge-window-horizontally) ; T7 +(define-key suntool-map "ft" 'shrink-window) ; t6 +(define-key suntool-map "gt" 'enlarge-window) ; t7 +(define-key suntool-map "cT" '(lambda(n) (interactive "p") (scroll-down n))) +(define-key suntool-map "dT" '(lambda(n) (interactive "p") (scroll-up n))) +(define-key suntool-map "ct" 'scroll-down-in-place) ; t3 +(define-key suntool-map "dt" 'scroll-up-in-place) ; t4 +(define-key ctl-x-map "*" suntool-map) + +;;; Since .emacs gets loaded before this file, a hook is supplied +;;; for you to put your own bindings in. + +(defvar suntool-map-hooks nil + "List of forms to evaluate after setting suntool-map.") + +(let ((hooks suntool-map-hooks)) + (while hooks + (eval (car hooks)) + (setq hooks (cdr hooks)) + )) + +;;; +;;; If running under emacstool, arrange to call suspend-emacstool +;;; instead of suspend-emacs. +;;; +;;; First mouse blip is a clue that we are in emacstool. +;;; +;;; C-x C-@ is the mouse command prefix. + +(autoload 'sun-mouse-handler "sun-mouse" + "Sun Emacstool handler for mouse blips (not loaded)." t) + +(defun emacstool-init () + "Set up Emacstool window, if you know you are in an emacstool." + ;; Make sure sun-mouse and sun-fns are loaded. + (require 'sun-fns) + (define-key ctl-x-map "\C-@" 'sun-mouse-handler) + + (if (< (sun-window-init) 0) + (message "Not a Sun Window") + (progn + (substitute-key-definition 'suspend-emacs 'suspend-emacstool global-map) + (substitute-key-definition 'suspend-emacs 'suspend-emacstool esc-map) + (substitute-key-definition 'suspend-emacs 'suspend-emacstool ctl-x-map)) + (send-string-to-terminal + (concat "\033]lEmacstool - GNU Emacs " emacs-version "\033\\")) + )) + +(defun sun-mouse-once () + "Converts to emacstool and sun-mouse-handler on first mouse hit." + (interactive) + (emacstool-init) + (sun-mouse-handler) ; Now, execute this mouse blip. + ) +(define-key ctl-x-map "\C-@" 'sun-mouse-once) diff --git a/lisp/term/vt100.el b/lisp/term/vt100.el new file mode 100644 index 00000000000..c9d4e5db104 --- /dev/null +++ b/lisp/term/vt100.el @@ -0,0 +1,62 @@ +;;;; Define VT100 function key escape sequences in function-key-map. + + +;;; CSI sequences - those that start with "\e[". +(define-prefix-command 'vt100-CSI-prefix 'vt100-CSI-map) +(define-key function-key-map "\e[" 'vt100-CSI-prefix) + +(define-key vt100-CSI-map "A" [up]) +(define-key vt100-CSI-map "B" [down]) +(define-key vt100-CSI-map "C" [right]) +(define-key vt100-CSI-map "D" [left]) + +(defun enable-arrow-keys () + "Enable the use of the VT100 arrow keys for cursor motion. +Because of the nature of the VT100, this unavoidably breaks +the standard Emacs command ESC [; therefore, it is not done by default, +but only if you give this command." + (interactive) + (global-unset-key "\e[")) + + + +;;; SS3 sequences - those that start with "\eO". +(define-prefix-command 'vt100-SS3-prefix 'vt100-SS3-map) +(define-key function-key-map "\eO" 'vt100-SS3-prefix) + +(define-key vt100-SS3-map "A" [up]) +(define-key vt100-SS3-map "B" [down]) ; down-arrow +(define-key vt100-SS3-map "C" [right]) ; right-arrow +(define-key vt100-SS3-map "D" [left]) ; left-arrow +(define-key vt100-SS3-map "M" [kp-enter]) ; Enter +(define-key vt100-SS3-map "P" [kp-f1]) ; PF1 +(define-key vt100-SS3-map "Q" [kp-f2]) ; PF2 +(define-key vt100-SS3-map "R" [kp-f3]) ; PF3 +(define-key vt100-SS3-map "S" [kp-f4]) ; PF4 +(define-key vt100-SS3-map "l" [kp-separator]) ; , +(define-key vt100-SS3-map "m" [kp-subtract]) ; - +(define-key vt100-SS3-map "n" [kp-period]) ; . +(define-key vt100-SS3-map "p" [kp-0]) ; 0 +(define-key vt100-SS3-map "q" [kp-1]) ; 1 +(define-key vt100-SS3-map "r" [kp-2]) ; 2 +(define-key vt100-SS3-map "s" [kp-3]) ; 3 +(define-key vt100-SS3-map "t" [kp-4]) ; 4 +(define-key vt100-SS3-map "u" [kp-5]) ; 5 +(define-key vt100-SS3-map "v" [kp-6]) ; 6 +(define-key vt100-SS3-map "w" [kp-7]) ; 7 +(define-key vt100-SS3-map "x" [kp-8]) ; 8 +(define-key vt100-SS3-map "y" [kp-9]) ; 9 + + +;;; Controlling the screen width. +(defconst vt100-wide-mode (= (screen-width) 132) + "t if vt100 is in 132-column mode.") + +(defun vt100-wide-mode (&optional arg) + "Toggle 132/80 column mode for vt100s." + (interactive "P") + (setq vt100-wide-mode + (if (null arg) (not vt100-wide-mode) + (> (prefix-numeric-value arg) 0))) + (send-string-to-terminal (if vt100-wide-mode "\e[?3h" "\e[?3l")) + (set-screen-width (if vt100-wide-mode 132 80)))