tvi970.el 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. ;;; tvi970.el --- terminal support for the Televideo 970
  2. ;; Copyright (C) 1992, 2001-2012 Free Software Foundation, Inc.
  3. ;; Author: Jim Blandy <jimb@occs.cs.oberlin.edu>
  4. ;; Keywords: terminals
  5. ;; Created: January 1992
  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. ;;; Code:
  20. (eval-when-compile (require 'cl))
  21. (defvar tvi970-terminal-map
  22. (let ((map (make-sparse-keymap)))
  23. ;; Miscellaneous keys
  24. (dolist (key-binding
  25. '(;; These are set up by termcap or terminfo
  26. ;; ("\eOP" [kp-f1])
  27. ;; ("\eOQ" [kp-f2])
  28. ;; ("\eOR" [kp-f3])
  29. ;; ("\eOS" [kp-f4])
  30. ;; These might bre set by terminfo.
  31. ("\e[H" [home])
  32. ("\e[Z" [backtab])
  33. ("\e[i" [print])
  34. ("\e[@" [insert])
  35. ("\e[L" [insertline])
  36. ("\e[M" [deleteline])
  37. ("\e[U" [next]) ;; actually the `page' key
  38. ;; These won't be set up by either
  39. ("\eOm" [kp-subtract])
  40. ("\eOl" [kp-separator])
  41. ("\eOn" [kp-decimal])
  42. ("\eOM" [kp-enter])
  43. ;; These won't be set up by either either
  44. ("\e[K" [key_eol]) ;; Not an X keysym
  45. ("\e[J" [key_eos]) ;; Not an X keysym
  46. ("\e[2J" [key_clear]) ;; Not an X keysym
  47. ("\e[P" [key_dc]) ;; Not an X keysym
  48. ("\e[g" [S-tab]) ;; Not an X keysym
  49. ("\e[2N" [clearentry]) ;; Not an X keysym
  50. ("\e[2K" [S-clearentry]) ;; Not an X keysym
  51. ("\e[E" [?\C-j]) ;; Not an X keysym
  52. ("\e[g" [S-backtab]) ;; Not an X keysym
  53. ("\e[?1i" [key_sprint]) ;; Not an X keysym
  54. ("\e[4h" [key_sic]) ;; Not an X keysym
  55. ("\e[4l" [S-delete]) ;; Not an X keysym
  56. ("\e[Q" [S-insertline]) ;; Not an X keysym
  57. ("\e[1Q" [key_sdl]) ;; Not an X keysym
  58. ("\e[19l" [key_seol]) ;; Not an X keysym
  59. ("\e[19h" [S-erasepage]) ;; Not an X keysym
  60. ("\e[V" [S-page]) ;; Not an X keysym
  61. ("\eS" [send]) ;; Not an X keysym
  62. ("\e5" [S-send]) ;; Not an X keysym
  63. ))
  64. (define-key map (car key-binding) (nth 1 key-binding)))
  65. ;; The numeric keypad keys.
  66. (dotimes (i 10)
  67. (define-key map (format "\eO%c" (+ i ?p))
  68. (vector (intern (format "kp-%d" i)))))
  69. ;; The numbered function keys.
  70. (dotimes (i 16)
  71. (define-key map (format "\e?%c" (+ i ?a))
  72. (vector (intern (format "f%d" (1+ i)))))
  73. (define-key map (format "\e?%c" (+ i ?A))
  74. (vector (intern (format "S-f%d" (1+ i))))))
  75. map))
  76. (defun terminal-init-tvi970 ()
  77. "Terminal initialization function for tvi970."
  78. ;; Use inheritance to let the main keymap override these defaults.
  79. ;; This way we don't override terminfo-derived settings or settings
  80. ;; made in the .emacs file.
  81. (let ((m (copy-keymap tvi970-terminal-map)))
  82. (set-keymap-parent m (keymap-parent input-decode-map))
  83. (set-keymap-parent input-decode-map m))
  84. (tvi970-set-keypad-mode 1))
  85. ;; Should keypad numbers send ordinary digits or distinct escape sequences?
  86. (define-minor-mode tvi970-set-keypad-mode
  87. "Toggle alternate keypad mode on TVI 970 keypad.
  88. With a prefix argument ARG, enable the mode if ARG is positive,
  89. and disable it otherwise. If called from Lisp, enable the mode
  90. if ARG is omitted or nil.
  91. In ``alternate keypad mode'', the keys send distinct escape
  92. sequences, meaning that they can have their own bindings,
  93. independent of the normal number keys.
  94. When disabled, the terminal enters ``numeric keypad mode'', in
  95. which the keypad's keys act as ordinary digits."
  96. :variable (terminal-parameter nil 'tvi970-keypad-numeric)
  97. (send-string-to-terminal
  98. (if (terminal-parameter nil 'tvi970-keypad-numeric) "\e=" "\e>")))
  99. ;;; tvi970.el ends here