wyse50.el 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. ;;; wyse50.el --- terminal support code for Wyse 50 -*- no-byte-compile: t -*-
  2. ;; Copyright (C) 1989, 1993-1994, 2001-2012 Free Software Foundation, Inc.
  3. ;; Author: Daniel Pfeiffer <occitan@esperanto.org>,
  4. ;; Jim Blandy <jimb@occs.cs.oberlin.edu>
  5. ;; Keywords: terminals
  6. ;; This file is part of GNU Emacs.
  7. ;; GNU Emacs is free software: you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation, either version 3 of the License, or
  10. ;; (at your option) any later version.
  11. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;; GNU General Public License for more details.
  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  17. ;;; Commentary:
  18. ;; Uses the Emacs 19 terminal initialization features --- won't work with 18.
  19. ;; Rewritten for Emacs 19 by jimb, January 1992
  20. ;; Cleaned up for new terminal package conventions by esr, March 1993
  21. ;; Should work well for Televideo TVI 925 although it's overkill.
  22. ;;
  23. ;; The Wyse50 is ergonomically wonderful, but its escape-sequence design sucks
  24. ;; rocks. The left-arrow key emits a backspace (!) and the down-arrow a line
  25. ;; feed (!!). Thus, you have to unbind some commonly-used Emacs keys to
  26. ;; enable the arrows.
  27. ;;; Code:
  28. (defvar wyse50-terminal-map
  29. (let ((map (make-sparse-keymap)))
  30. (dolist (key-definition
  31. '( ;; These might be set up by termcap and terminfo
  32. ("\C-k" [up])
  33. ("\C-j" [down])
  34. ("\C-l" [right])
  35. ("\C-h" [left])
  36. ("\^a@\^m" [f1])
  37. ("\^aA\^m" [f2])
  38. ("\^aB\^m" [f3])
  39. ("\^aC\^m" [f4])
  40. ("\^aD\^m" [f5])
  41. ("\^aE\^m" [f6])
  42. ("\^aF\^m" [f7])
  43. ("\^aG\^m" [f8])
  44. ("\^aH\^m" [f9])
  45. ;; These might be set up by terminfo
  46. ("\eK" [next])
  47. ("\eT" [clearline])
  48. ("\^^" [home])
  49. ("\e\^^" [end])
  50. ("\eQ" [insert])
  51. ("\eE" [insertline])
  52. ("\eR" [deleteline])
  53. ("\eP" [print])
  54. ("\er" [replace])
  55. ("\^aI\^m" [f10])
  56. ("\^aJ\^m" [f11])
  57. ("\^aK\^m" [f12])
  58. ("\^aL\^m" [f13])
  59. ("\^aM\^m" [f14])
  60. ("\^aN\^m" [f15])
  61. ("\^aO\^m" [f16])
  62. ("\^a`\^m" [f17])
  63. ("\^aa\^m" [f18])
  64. ("\^ab\^m" [f19])
  65. ("\^ac\^m" [f20])
  66. ("\^ad\^m" [f21])
  67. ("\^ae\^m" [f22])
  68. ("\^af\^m" [f23])
  69. ("\^ag\^m" [f24])
  70. ("\^ah\^m" [f25])
  71. ("\^ai\^m" [f26])
  72. ("\^aj\^m" [f27])
  73. ("\^ak\^m" [f28])
  74. ("\^al\^m" [f29])
  75. ("\^am\^m" [f30])
  76. ("\^an\^m" [f31])
  77. ("\^ao\^m" [f32])
  78. ;; Terminfo may know about these, but X won't
  79. ("\eI" [key-stab]) ;; Not an X keysym
  80. ("\eJ" [key-snext]) ;; Not an X keysym
  81. ("\eY" [key-clear]) ;; Not an X keysym
  82. ;; These are totally strange :-)
  83. ("\eW" [?\C-?]) ;; Not an X keysym
  84. ("\^a\^k\^m" [funct-up]) ;; Not an X keysym
  85. ("\^a\^j\^m" [funct-down]) ;; Not an X keysym
  86. ("\^a\^l\^m" [funct-right]) ;; Not an X keysym
  87. ("\^a\^h\^m" [funct-left]) ;; Not an X keysym
  88. ("\^a\^m\^m" [funct-return]) ;; Not an X keysym
  89. ("\^a\^i\^m" [funct-tab]) ;; Not an X keysym
  90. ))
  91. (define-key map
  92. (car key-definition) (nth 1 key-definition)))
  93. map))
  94. (defun terminal-init-wyse50 ()
  95. "Terminal initialization function for wyse50."
  96. ;; Use inheritance to let the main keymap override these defaults.
  97. ;; This way we don't override terminfo-derived settings or settings
  98. ;; made in the .emacs file.
  99. (let ((m (copy-keymap wyse50-terminal-map)))
  100. (set-keymap-parent m (keymap-parent input-decode-map))
  101. (set-keymap-parent input-decode-map m))
  102. ;; Miscellaneous hacks
  103. ;; This is an ugly hack for a nasty problem:
  104. ;; Wyse 50 takes one character cell to store video attributes (which seems to
  105. ;; explain width 79 rather than 80, column 1 is not used!!!).
  106. ;; On killing (C-x C-c) the end inverse code (on column 1 of line 24)
  107. ;; of the mode line is overwritten AFTER all the y-or-n questions.
  108. ;; This causes the attribute to remain in effect until the mode line has
  109. ;; scrolled of the screen. Suspending (C-z) does not cause this problem.
  110. ;; On such terminals, Emacs should sacrifice the first and last character of
  111. ;; each mode line, rather than a whole screen column!
  112. (add-hook 'kill-emacs-hook
  113. (function (lambda () (interactive)
  114. (send-string-to-terminal
  115. (concat "\ea23R" (1+ (frame-width)) "C\eG0"))))))
  116. (defun enable-arrow-keys ()
  117. "To be called by `term-setup-hook'. Overrides 6 Emacs standard keys
  118. whose functions are then typed as follows:
  119. C-a Funct Left-arrow
  120. C-h M-?
  121. LFD Funct Return, some modes override down-arrow via LFD
  122. C-k CLR Line
  123. C-l Scrn CLR
  124. M-r M-x move-to-window-line, Funct up-arrow or down-arrow are similar"
  125. (interactive)
  126. ;; Not needed any more now that we use input-decode-map.
  127. ;; (dolist (key-definition
  128. ;; ;; By unsetting C-a and then binding it to a prefix, we
  129. ;; ;; allow the rest of the function keys which start with C-a
  130. ;; ;; to be recognized.
  131. ;; '(("\C-a" nil)
  132. ;; ("\C-k" nil)
  133. ;; ("\C-j" nil)
  134. ;; ("\C-l" nil)
  135. ;; ("\C-h" nil)
  136. ;; ("\er" nil)))
  137. ;; (global-set-key (car key-definition)
  138. ;; (nth 1 key-definition)))
  139. (fset 'enable-arrow-keys nil))
  140. ;;; wyse50.el ends here