|
|
1.1 ! root 1: ;; Terminal-independent keypad and function key bindings. ! 2: ;; Copyright (C) 1986 Free Software Foundation, Inc. ! 3: ! 4: ;; This file is part of GNU Emacs. ! 5: ! 6: ;; GNU Emacs is distributed in the hope that it will be useful, ! 7: ;; but WITHOUT ANY WARRANTY. No author or distributor ! 8: ;; accepts responsibility to anyone for the consequences of using it ! 9: ;; or for whether it serves any particular purpose or works at all, ! 10: ;; unless he says so in writing. Refer to the GNU Emacs General Public ! 11: ;; License for full details. ! 12: ! 13: ;; Everyone is granted permission to copy, modify and redistribute ! 14: ;; GNU Emacs, but only under the conditions described in the ! 15: ;; GNU Emacs General Public License. A copy of this license is ! 16: ;; supposed to have been given to you along with GNU Emacs so you ! 17: ;; can know your rights and responsibilities. It should be in a ! 18: ;; file named COPYING. Among other things, the copyright notice ! 19: ;; and this notice must be preserved on all copies. ! 20: ! 21: ! 22: ;; These keys are handled by a two-level process. ! 23: ;; The first level, terminal-dependent, maps input sequences ! 24: ;; into the function keys that they represent. ! 25: ;; The second level, terminal-independent but customized by users, ! 26: ;; map function keys into meanings. ! 27: ! 28: ;; This file takes care of the second level of mapping. ! 29: ;; The first, terminal-dependent, level is handled by the ! 30: ;; terminal-specific files term/*.el. ! 31: ! 32: ;; The second-level mapping is done by a keymap, function-keymap. ! 33: ;; Here we document the meanings of the "characters" defined by ! 34: ;; function-keymap. ! 35: ! 36: ;; What do these letters mean? ! 37: ;; When we say that ``a stands for the clear-all-tabs key'', ! 38: ;; we mean that you should attach to the letter `a' in function-keymap ! 39: ;; whatever command you want to be executed when you type the ! 40: ;; clear-all-tabs key on any terminal. The terminal-dependent ! 41: ;; files will attempt to make this work. If a terminal has no ! 42: ;; clear-all-tabs key that can be recognized, it makes no difference ! 43: ;; what binding you give to `a' in function-keymap. ! 44: ! 45: ;; a -- clear all tabs key ! 46: ;; c -- erase key ! 47: ;; d -- down-arrow ! 48: ;; e -- enter key ! 49: ;; f -- find key or search key ! 50: ;; h -- home-position key ! 51: ;; k -- delete key or remove key. ! 52: ;; l -- left-arrow ! 53: ;; p -- portrait mode ! 54: ;; q -- landscape mode ! 55: ;; r -- right-arrow ! 56: ;; s -- select key ! 57: ;; t -- clear tab this column key ! 58: ;; u -- up-arrow ! 59: ;; x -- do key ! 60: ;; ? -- help ! 61: ! 62: ;; - -- keypad key labelled `-'. ! 63: ;; . -- keypad key labelled `.'. ! 64: ;; , -- keypad key labelled `,'. ! 65: ;; 0 ... 9 -- keypad key labelled with that digit, ! 66: ;; but only if that key is not also an arrow key. ! 67: ! 68: ;; C-@, C-a, ... C-x -- numbered function keys 0 through 24. ! 69: ;; These are used for function keys with no labels but numbers, ! 70: ;; and may also be used for function keys with labels ! 71: ;; that we have not defined letters for. ! 72: ! 73: ;; A -- insert line key ! 74: ;; C -- clear screen key ! 75: ;; D -- delete character key. ! 76: ;; E -- clear to end of line key ! 77: ;; F -- scroll forward key ! 78: ;; H -- home-down ! 79: ;; I -- insert character key ! 80: ;; If there is just an "insert" key, it should be this. ! 81: ;; L -- delete line key ! 82: ;; M -- exit insert mode key ! 83: ;; N -- next page key ! 84: ;; P -- previous page key ! 85: ;; R -- scroll reverse key ! 86: ;; S -- clear to end of screen key ! 87: ;; T -- set tab this column key ! 88: ! 89: (defun keypad-default (char definition) ! 90: (or (lookup-key function-keymap char) ! 91: (define-key function-keymap char definition))) ! 92: ! 93: ;; Here are the standard command meanings we give to the various ! 94: ;; function key names. Because this file is loaded after the user's ! 95: ;; init file, we are careful to avoid overriding any definitions ! 96: ;; already stored in function-keymap by the init file or (less often) ! 97: ;; by the terminal-specific term/*.el file. ! 98: ! 99: (keypad-default "l" 'backward-char) ! 100: (keypad-default "r" 'forward-char) ! 101: (keypad-default "D" 'delete-char) ! 102: (keypad-default "u" 'previous-line) ! 103: (keypad-default "d" 'next-line) ! 104: (keypad-default "N" 'scroll-up) ! 105: (keypad-default "P" 'scroll-down) ! 106: (keypad-default "C" 'recenter) ! 107: (keypad-default "?" 'help-for-help) ! 108: (keypad-default "s" 'set-mark-command) ! 109: (keypad-default "k" 'kill-region) ! 110: (keypad-default "f" 're-search-forward) ! 111: ! 112: (keypad-default "\C-a" 'beginning-of-line) ! 113: (keypad-default "\C-b" 'end-of-line) ! 114: (keypad-default "\C-c" 'isearch-forward) ! 115: (keypad-default "\C-d" 'kill-line) ! 116: ! 117: (keypad-default "." 'delete-char) ! 118: (keypad-default "0" 'yank) ! 119: (keypad-default "e" 'open-line) ! 120: (keypad-default "1" 'backward-word) ! 121: (keypad-default "3" 'forward-word) ! 122: (keypad-default "7" 'backward-paragraph) ! 123: (keypad-default "9" 'forward-paragraph) ! 124: (keypad-default "h" 'move-to-window-line) ! 125: ! 126: (defun setup-terminal-keymap (map translations) ! 127: "Set up keymap MAP to forward to function-keymap according to TRANSLATIONS. ! 128: TRANSLATIONS is an alist; each element of it looks like (FROMSTRING . TOCHAR). ! 129: For each such pair, we define the key sequence FROMSTRING in MAP ! 130: to forward to the definition of character TOCHAR in function-keymap. ! 131: \"Forwarding\" means that subsequent redefinition of TOCHAR in ! 132: function-keymap will be seen automatically in MAP as well. ! 133: ! 134: This function is used by files term/*.el to set up the mapping from the ! 135: escape sequences sent by function keys on particular terminals (FROMSTRINGs) ! 136: into Emacs standard function key slots (TOCHARs). ! 137: An actual definition (such as a symbol) may be given in place of TOCHAR. ! 138: Generally, MAP is a prefix keymap which will be attached to a key ! 139: that is the common prefix sent by all function keys (often ESC O or ESC [)." ! 140: (while translations ! 141: (define-key map (car (car translations)) ! 142: (if (numberp (cdr (car translations))) ! 143: (cons function-keymap (cdr (car translations))) ! 144: (cdr (car translations)))) ! 145: (setq translations (cdr translations)))) ! 146: ! 147: (defun function-key-sequence (char) ! 148: "Return key sequence for function key that on this terminal ! 149: translates into slot CHAR in function-keymap. ! 150: Or return nil if there is none." ! 151: (car (where-is-internal (cons function-keymap char) (current-local-map)))) ! 152: ! 153: (provide 'keypad)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.