-; Like all the other files in this dir, this one needs to be redone
-; for the new way of handling function keys.
-
-; Terminal mode for Wyse 50
-; should work well for Televideo Tvi 925 though it's an overkill
-; Author Daniel Pfeiffer <pfeiffer@cix.cict.fr> january 1991
-
-(require 'keypad)
-
-; at least some of these should be transferred to keypad.el
-(keypad-default "A" '(lambda () (interactive)
- ; actually insert an empty line
- (beginning-of-line)
- (open-line 1)))
-(keypad-default "E" 'kill-line)
-; (keypad-default "h" 'execute-extended-command)
-(define-key function-keymap "h" 'execute-extended-command) ; bad, bad !!
-(keypad-default "H" 'shell-command)
-(keypad-default "I" '(lambda () (interactive)
- (insert ? ))) ; works even in overwrite-mode
-(keypad-default "L" '(lambda () (interactive)
- ; delete the whole line
- (beginning-of-line)
- (kill-line 1)))
-(keypad-default "M" 'overwrite-mode)
-(keypad-default "\^e" 'shell) ; F5
-(keypad-default "\^f" 'dired) ; F6
-(keypad-default "\^g" 'rnews) ; F7
-(keypad-default "\^h" 'rmail) ; F8
-
-(keypad-default "\^i" 'delete-other-windows) ; F9
-(keypad-default "\^j" 'other-window) ; F10
-(keypad-default "\^k" 'split-window-vertically) ; F11
-
-(keypad-default "\^m" 'help-for-help) ; F13
-(keypad-default "\^n" 'toggle-screen-width) ; F14
-(keypad-default "\^o" 'set-function-key) ; F15
-
-
-; Keys that don't conflict with Emacs defaults
-; I write \M-x and \C-x for what the user types, \ex and \^x for key sequences
-(setup-terminal-keymap global-map
- '(("\M-?" . ?\?) ; Esc ?
- ("\eI" . ?T) ; Shift Tab
- ("\eJ" . ?P) ; Shift Prev PAGE
- ("\eK" . ?N) ; PAGE Next
- ("\eY" . ?C) ; Shift Scrn CLR
- ("\eT" . ?E) ; CLR Line
- ("\^^" . ?h) ; Home
- ("\M-\^^" . ?H) ; Esc Home
- ("\eQ" . ?I) ; INS Char
- ("\eE" . ?A) ; Shift Line INS
- ("\eW" . ?D) ; DEL Char
- ("\eR" . ?L))) ; Shift Line DEL
-
-; Print -- put in some extra security
-(global-set-key "\eP" '(lambda () (interactive)
- (if (y-or-n-p
- (concat "Print buffer "
- (buffer-name) "? "))
- (print-buffer))))
-
-
-; this is an ugly hack for a nasty problem:
-; Wyse 50 takes one character cell to store video attributes (which seems to
-; explain width 79 rather than 80, column 1 is not used!!!).
-; On killing (C-x C-c) the end inverse code (on column 1 of line 24)
-; of the mode line is overwritten AFTER all the y-or-n questions.
-; This causes the attribute to remain in effect until the mode line has
-; scrolled of the screen. Suspending (C-z) does not cause this problem.
-; On such terminals, Emacs should sacrifice the first and last character of
-; each mode line, rather than a whole screen column!
-(setq kill-emacs-hook '(lambda () (interactive)
- (send-string-to-terminal
- (concat "\ea23R" (1+ (screen-width)) "C\eG0"))))
-
-
-; This function does more than its name which was copied from term/vt100.el
-; Some more neutral name should be used thru-out term/*.el to simplify
-; programming term-setup-hook
-(defun enable-arrow-keys ()
- "To be called by term-setup-hook. Overrides 6 Emacs standard keys
-whose functions are then typed as follows:
-C-a Funct Left-arrow
-C-h M-?
-LFD Funct Return, some modes override down-arrow via LFD
-C-k CLR Line
-C-l Scrn CLR
-M-r M-x move-to-window-line, Funct up-arrow or down-arrow are similar
-All special keys except Send, Shift Ins, Shift Home and shifted functions keys
-are assigned some hopefully useful meaning."
- (interactive)
-
- ; Function keys
- (define-prefix-command 'Funct-prefix)
- (define-key global-map "\^a" 'Funct-prefix)
-
- ; Arrow keys
- (setup-terminal-keymap global-map
- '(("\C-a\C-a" . beginning-of-line) ; for auld lang syne
- ("\^a\^m\^m" . newline-and-indent)
-
- ("\^k" . ?u) ; up-arrow
- ("\^j" . ?d) ; down-arrow
- ("\^l" . ?r) ; right-arrow
- ("\^h" . ?l) ; left-arrow
-
- ; Terminal needs both Ins and Repl but Emacs knows how to toggle
- ; with just one key. No need to override Ins which is "\eq".
- ("\er" . ?M) ; Repl
-
- ("\^a\^i\^m" . ?t) ; Funct Tab
-
- ; Function keys F1 thru F16 (we don't define shifted function keys,
- ; they send the same code with the middle character in lowercase.
- ; eg. "Shift F2" is the same as "Funct a" which is more mnemonic but
- ; keypad.el doesn't provide enough codes to accomodate all these)
- ("\^a@\^m" . 1) ("\^aH\^m" . 9)
- ("\^aA\^m" . 2) ("\^aI\^m" . 10)
- ("\^aB\^m" . 3) ("\^aJ\^m" . 11)
- ("\^aC\^m" . 4) ("\^aK\^m" . 12)
- ("\^aD\^m" . 5) ("\^aL\^m" . 13)
- ("\^aE\^m" . 6) ("\^aM\^m" . 14)
- ("\^aF\^m" . 7) ("\^aN\^m" . 15)
- ("\^aG\^m" . 8) ("\^aO\^m" . 16)
-
- ; Funct Arrow keys
- ("\^a\^k\^m" . (lambda (n) (interactive "p")
- (move-to-window-line (1- n))))
- ("\^a\^j\^m" . (lambda (n) (interactive "p")
- (move-to-window-line (- n))))
- ("\^a\^h\^m" . beginning-of-line)
- ("\^a\^l\^m" . end-of-line)))
-
- ; forget self to put memory to some serious use
- (fset 'enable-arrow-keys nil))
-
-
-(defun toggle-screen-width ()
- "Alternate between 80 and 132 columns."
- (interactive)
- (if (<= (screen-width) 80)
- (progn
- (send-string-to-terminal "\e`;")
- (set-screen-width 131))
- (send-string-to-terminal "\e`:")
- (set-screen-width 79)))
-
-;-----------------------------------------------------------------------------
-; this function is completely independent of wyse, it should be auto-loadable
-; (presumably from keypad.el) for use in ~/emacs. It should be the only thing
-; users need to know about all this unintelligible "forwarding" gibberish.
-; This paves the way for a save-function-keys (some day or sleepless night)
-; that will edit calls like (set-function-key ?x 'do-whatever) in ~/.emacs.
-(defun set-function-key (key &optional def)
- "Prompt for a function or other special key and assign it a meaning.
-The key must have been \"forwarded\" to a character in term/*.el.
-
-As a function takes two args CHAR and DEF, with DEF as in define-key.
-If your terminals term/*.el forwards a physical key to CHAR (before or after
-calling this function), then that key will mean DEF, else it is ignored.
-CHAR is one of the following:
-For numbered function keys
- 0, 1, ..., 24 (or ?\\^@, ?\\^a, ..., ?\\^x which is the same)
-For keypad keys in application mode
- ?0, ?1, ..., ?9 -- keypad key labelled with that digit,
- but only if that key is not an arrow key (see ?u, ?d, ?r, ?l).
- ?- -- keypad key labelled `-'.
- ?. -- keypad key labelled `.'.
- ?, -- keypad key labelled `,'.
- ?e -- key labelled enter.
-For keys labelled with some words or a symbol
- ?a -- clear all tabs key.
- ?A -- insert line key.
- ?C -- clear screen key.
- ?c -- erase key.
- ?D -- delete character key.
- ?d -- down-arrow.
- ?E -- clear to end of line key.
- ?e -- key labelled enter.
- ?f -- find key or search key.
- ?F -- scroll forward key.
- ?H -- home-down.
- ?h -- home-position key.
- ?I -- insert character key
- If there is just an \"insert\" key, it should be this.
- ?k -- delete key or remove key.
- ?L -- delete line key.
- ?l -- left-arrow.
- ?M -- exit insert mode key.
- ?N -- next page key.
- ?p -- portrait mode.
- ?P -- previous page key.
- ?q -- landscape mode.
- ?r -- right-arrow.
- ?R -- scroll reverse key.
- ?S -- clear to end of screen key.
- ?s -- select key.
- ?t -- clear tab this column key.
- ?T -- set tab this column key.
- ?u -- up-arrow.
- ?x -- do key.
- ?\\? -- help."
- (interactive "kKey to redefine: ")
- (let ((map function-keymap))
- (if (integerp key)
- ()
- ; reinvent lookup-key to get (map . char) instead of def of char in map
- (setq map (or (lookup-key global-map
- (substring key 0 (1- (length key))))
- global-map)
- key (string-to-char (substring key (1- (length key)))))
- (while (symbolp map)
- (setq map (symbol-function map)))
- (setq map (if (listp map)
- (cdr (assq key (cdr map)))
- (aref map key)))
- (if (and (consp map)
- (integerp (cdr map)))
- (setq key (cdr map)
- map (car map))
- (error "Key is not a \"forwarded\" definition.")))
- (if def
- ()
- (setq def (read-command "command (default last keyboard macro): "))
- (if (string-equal (symbol-name def) "")
- (setq def last-kbd-macro))
- (setq command-history ; nonsense really, since you don't see
- (cons ; key as in a function call (?char)
- (list 'set-function-key key
- (if (stringp def) def (list 'quote def)))
- command-history)))
- ; all we do when called as a function
- (define-key map (char-to-string key) def)))
-
-
+;;; wyse50.el --- terminal support code for Wyse 50
+
+;; Copyright (C) 1989, 1993, 1994 Free Software Foundation, Inc.
+
+;; Author: Daniel Pfieffer <pfieffer@cix.cict.fr> January 1991
+;; Jim Blandy <jimb@occs.cs.oberlin.edu>
+;; Keywords: terminals
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; Uses the Emacs 19 terminal initialization features --- won't work with 18.
+;; Rewritten for Emacs 19 by jimb, January 1992
+;; Cleaned up for new terminal package conventions by esr, March 1993
+;; Should work well for Televideo TVI 925 although it's overkill.
+;;
+;; The Wyse50 is ergonomically wonderful, but its escape-sequence design sucks
+;; rocks. The left-arrow key emits a backspace (!) and the down-arrow a line
+;; feed (!!). Thus, you have to unbind some commonly-used Emacs keys to
+;; enable the arrows.
+
+;;; Code:
+
+(define-key function-key-map "\C-a" (make-keymap))
+(mapcar (function (lambda (key-definition)
+ (define-key function-key-map
+ (car key-definition) (nth 1 key-definition))))
+ '(
+ ;; These might be set up by termcap and terminfo
+ ("\C-k" [up])
+ ("\C-j" [down])
+ ("\C-l" [right])
+ ("\C-h" [left])
+ ("\^a@\^m" [f1])
+ ("\^aA\^m" [f2])
+ ("\^aB\^m" [f3])
+ ("\^aC\^m" [f4])
+ ("\^aD\^m" [f5])
+ ("\^aE\^m" [f6])
+ ("\^aF\^m" [f7])
+ ("\^aG\^m" [f8])
+ ("\^aH\^m" [f9])
+
+ ;; These might be set up by terminfo
+ ("\eK" [next])
+ ("\eT" [clearline])
+ ("\^^" [home])
+ ("\e\^^" [end])
+ ("\eQ" [insert])
+ ("\eE" [insertline])
+ ("\eR" [deleteline])
+ ("\eP" [print])
+ ("\er" [replace])
+ ("\^aI\^m" [f10])
+ ("\^aJ\^m" [f11])
+ ("\^aK\^m" [f12])
+ ("\^aL\^m" [f13])
+ ("\^aM\^m" [f14])
+ ("\^aN\^m" [f15])
+ ("\^aO\^m" [f16])
+ ("\^a`\^m" [f17])
+ ("\^aa\^m" [f18])
+ ("\^ab\^m" [f19])
+ ("\^ac\^m" [f20])
+ ("\^ad\^m" [f21])
+ ("\^ae\^m" [f22])
+ ("\^af\^m" [f23])
+ ("\^ag\^m" [f24])
+ ("\^ah\^m" [f25])
+ ("\^ai\^m" [f26])
+ ("\^aj\^m" [f27])
+ ("\^ak\^m" [f28])
+ ("\^al\^m" [f29])
+ ("\^am\^m" [f30])
+ ("\^an\^m" [f31])
+ ("\^ao\^m" [f32])
+
+ ;; Terminfo may know about these, but X won't
+ ("\eI" [key-stab]) ;; Not an X keysym
+ ("\eJ" [key-snext]) ;; Not an X keysym
+ ("\eY" [key-clear]) ;; Not an X keysym
+
+ ;; These are totally strange :-)
+ ("\eW" [?\C-?]) ;; Not an X keysym
+ ("\^a\^k\^m" [funct-up]) ;; Not an X keysym
+ ("\^a\^j\^m" [funct-down]) ;; Not an X keysym
+ ("\^a\^l\^m" [funct-right]) ;; Not an X keysym
+ ("\^a\^h\^m" [funct-left]) ;; Not an X keysym
+ ("\^a\^m\^m" [funct-return]) ;; Not an X keysym
+ ("\^a\^i\^m" [funct-tab]) ;; Not an X keysym
+))
+
+(defun enable-arrow-keys ()
+ "To be called by term-setup-hook. Overrides 6 Emacs standard keys
+whose functions are then typed as follows:
+C-a Funct Left-arrow
+C-h M-?
+LFD Funct Return, some modes override down-arrow via LFD
+C-k CLR Line
+C-l Scrn CLR
+M-r M-x move-to-window-line, Funct up-arrow or down-arrow are similar
+"
+ (interactive)
+ (mapcar (function (lambda (key-definition)
+ (global-set-key (car key-definition)
+ (nth 1 key-definition))))
+ ;; By unsetting C-a and then binding it to a prefix, we
+ ;; allow the rest of the function keys which start with C-a
+ ;; to be recognized.
+ '(("\C-a" nil)
+ ("\C-k" nil)
+ ("\C-j" nil)
+ ("\C-l" nil)
+ ("\C-h" nil)
+ ("\er" nil)))
+ (fset 'enable-arrow-keys nil))
+
+\f
+;;; Miscellaneous hacks
+
+;;; This is an ugly hack for a nasty problem:
+;;; Wyse 50 takes one character cell to store video attributes (which seems to
+;;; explain width 79 rather than 80, column 1 is not used!!!).
+;;; On killing (C-x C-c) the end inverse code (on column 1 of line 24)
+;;; of the mode line is overwritten AFTER all the y-or-n questions.
+;;; This causes the attribute to remain in effect until the mode line has
+;;; scrolled of the screen. Suspending (C-z) does not cause this problem.
+;;; On such terminals, Emacs should sacrifice the first and last character of
+;;; each mode line, rather than a whole screen column!
+(add-hook 'kill-emacs-hook
+ (function (lambda () (interactive)
+ (send-string-to-terminal
+ (concat "\ea23R" (1+ (frame-width)) "C\eG0")))))
+
+;;; wyse50.el ends here