Mercurial > emacs
comparison lisp/international/encoded-kb.el @ 17080:d80a8a46437e
Many changes to cope with the above change.
(encoded-kbd-select-terminal): New function.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 26 Feb 1997 12:08:58 +0000 |
parents | 70194012fb3a |
children | a3ca5e15c82a |
comparison
equal
deleted
inserted
replaced
17079:7f8981eca2f7 | 17080:d80a8a46437e |
---|---|
29 (cons '(encoded-kbd-mode " Encoded-kbd") minor-mode-alist))) | 29 (cons '(encoded-kbd-mode " Encoded-kbd") minor-mode-alist))) |
30 | 30 |
31 (defvar encoded-kbd-mode-map | 31 (defvar encoded-kbd-mode-map |
32 (let ((map (make-sparse-keymap)) | 32 (let ((map (make-sparse-keymap)) |
33 (i 128)) | 33 (i 128)) |
34 (define-key map "\e" 'encoded-kbd-handle-iso2022-esc) | 34 (define-key map "\e" 'encoded-kbd-iso2022-esc-prefix) |
35 (while (< i 256) | 35 (while (< i 256) |
36 (define-key map (vector i) 'encoded-kbd-handle-8bit) | 36 (define-key map (vector i) 'encoded-kbd-handle-8bit) |
37 (setq i (1+ i))) | 37 (setq i (1+ i))) |
38 map) | 38 map) |
39 "Keymap for Encoded-kbd minor mode.") | 39 "Keymap for Encoded-kbd minor mode.") |
50 (define-key map "$" 'encoded-kbd-iso2022-esc-dollar-prefix) | 50 (define-key map "$" 'encoded-kbd-iso2022-esc-dollar-prefix) |
51 (define-key map "(" 'encoded-kbd-iso2022-designation-prefix) | 51 (define-key map "(" 'encoded-kbd-iso2022-designation-prefix) |
52 (define-key map ")" 'encoded-kbd-iso2022-designation-prefix) | 52 (define-key map ")" 'encoded-kbd-iso2022-designation-prefix) |
53 (define-key map "," 'encoded-kbd-iso2022-designation-prefix) | 53 (define-key map "," 'encoded-kbd-iso2022-designation-prefix) |
54 (define-key map "-" 'encoded-kbd-iso2022-designation-prefix) | 54 (define-key map "-" 'encoded-kbd-iso2022-designation-prefix) |
55 (append map '((t . encoded-kbd-outernal-command))) | |
56 map) | 55 map) |
57 "Keymap for handling ESC code in Encoded-kbd mode.") | 56 "Keymap for handling ESC code in Encoded-kbd mode.") |
57 (fset 'encoded-kbd-iso2022-esc-prefix encoded-kbd-iso2022-esc-map) | |
58 | 58 |
59 (defvar encoded-kbd-iso2022-esc-dollar-map | 59 (defvar encoded-kbd-iso2022-esc-dollar-map |
60 (let ((map (make-sparse-keymap))) | 60 (let ((map (make-sparse-keymap))) |
61 (define-key map "(" 'encoded-kbd-iso2022-designation-prefix) | 61 (define-key map "(" 'encoded-kbd-iso2022-designation-prefix) |
62 (define-key map ")" 'encoded-kbd-iso2022-designation-prefix) | 62 (define-key map ")" 'encoded-kbd-iso2022-designation-prefix) |
63 (define-key map "," 'encoded-kbd-iso2022-designation-prefix) | 63 (define-key map "," 'encoded-kbd-iso2022-designation-prefix) |
64 (define-key map "-" 'encoded-kbd-iso2022-designation-prefix) | 64 (define-key map "-" 'encoded-kbd-iso2022-designation-prefix) |
65 (define-key map "@" 'encoded-kbd-iso2022-designation) | 65 (define-key map "@" 'encoded-kbd-iso2022-designation) |
66 (define-key map "A" 'encoded-kbd-iso2022-designation) | 66 (define-key map "A" 'encoded-kbd-iso2022-designation) |
67 (define-key map "B" 'encoded-kbd-iso2022-designation) | 67 (define-key map "B" 'encoded-kbd-iso2022-designation) |
68 (append map '((t . encoded-kbd-outernal-command))) | 68 map) |
69 map) | 69 "Keymap for handling ESC $ sequence in Encoded-kbd mode.") |
70 "Keymap for handling ESC $ sequence handling in Encoded-kbd mode.") | |
71 (fset 'encoded-kbd-iso2022-esc-dollar-prefix | 70 (fset 'encoded-kbd-iso2022-esc-dollar-prefix |
72 encoded-kbd-iso2022-esc-dollar-map) | 71 encoded-kbd-iso2022-esc-dollar-map) |
73 | 72 |
74 (defvar encoded-kbd-iso2022-designation-map | 73 (defvar encoded-kbd-iso2022-designation-map |
75 (let ((map (make-sparse-keymap)) | 74 (let ((map (make-sparse-keymap)) |
76 (i 48)) | 75 (l charset-list)) |
77 (while (< i 128) | 76 (while l |
78 (define-key map (char-to-string i) 'encoded-kbd-iso2022-designation) | 77 (define-key map |
79 (setq i (1+ i))) | 78 (char-to-string (charset-iso-final-char (car l))) |
80 (append map '((t . encoded-kbd-outernal-command))) | 79 'encoded-kbd-iso2022-designation) |
80 (setq l (cdr l))) | |
81 map) | 81 map) |
82 "Keymap for handling ISO2022 designation sequence in Encoded-kbd mode.") | 82 "Keymap for handling ISO2022 designation sequence in Encoded-kbd mode.") |
83 (fset 'encoded-kbd-iso2022-designation-prefix | 83 (fset 'encoded-kbd-iso2022-designation-prefix |
84 encoded-kbd-iso2022-designation-map) | 84 encoded-kbd-iso2022-designation-map) |
85 | 85 |
87 (let ((map (make-keymap)) | 87 (let ((map (make-keymap)) |
88 (i 32)) | 88 (i 32)) |
89 (while (< i 128) | 89 (while (< i 128) |
90 (define-key map (char-to-string i) 'encoded-kbd-self-insert-iso2022-7bit) | 90 (define-key map (char-to-string i) 'encoded-kbd-self-insert-iso2022-7bit) |
91 (setq i (1+ i))) | 91 (setq i (1+ i))) |
92 (define-key map "\e" 'encoded-kbd-iso2022-esc-prefix) | |
92 map) | 93 map) |
93 "Keymap for handling non-ASCII character set in Encoded-kbd mode.") | 94 "Keymap for handling non-ASCII character set in Encoded-kbd mode.") |
94 | 95 |
95 ;; One of the symbols `sjis', `iso2022-7', `iso2022-8', or `big5' to | 96 ;; One of the symbols `sjis', `iso2022-7', `iso2022-8', or `big5' to |
96 ;; denote what kind of coding-system we are now handling in | 97 ;; denote what kind of coding-system we are now handling in |
119 The following key sequence may cause multilingual text insertion." | 120 The following key sequence may cause multilingual text insertion." |
120 (interactive) | 121 (interactive) |
121 (let ((key-seq (this-command-keys)) | 122 (let ((key-seq (this-command-keys)) |
122 intermediate-char final-char | 123 intermediate-char final-char |
123 reg dimension chars charset) | 124 reg dimension chars charset) |
124 (if (= (length key-seq) 3) | 125 (if (= (length key-seq) 4) |
125 ;; (ESC) $ <intermediate-char> <final-char> | 126 ;; ESC $ <intermediate-char> <final-char> |
126 (setq intermediate-char (aref key-seq 1) | 127 (setq intermediate-char (aref key-seq 2) |
127 dimension 2 | 128 dimension 2 |
128 chars (if (< intermediate-char ?,) 94 96) | 129 chars (if (< intermediate-char ?,) 94 96) |
129 final-char (aref key-seq 2) | 130 final-char (aref key-seq 3) |
130 reg (mod intermediate-char 4)) | 131 reg (mod intermediate-char 4)) |
131 (if (= (aref key-seq 1) ?$) | 132 (if (= (aref key-seq 1) ?$) |
132 ;; (ESC) $ <final-char> | 133 ;; ESC $ <final-char> |
133 (setq dimension 2 | 134 (setq dimension 2 |
134 chars 94 | 135 chars 94 |
135 final-char (aref key-seq 1) | 136 final-char (aref key-seq 2) |
136 reg 0) | 137 reg 0) |
137 ;; (ESC) <intermediate-char> <final-char> | 138 ;; ESC <intermediate-char> <final-char> |
138 (setq intermediate-char (aref key-seq 0) | 139 (setq intermediate-char (aref key-seq 1) |
139 dimension 1 | 140 dimension 1 |
140 chars (if (< intermediate-char ?,) 94 96) | 141 chars (if (< intermediate-char ?,) 94 96) |
141 final-char (aref key-seq 1) | 142 final-char (aref key-seq 2) |
142 reg (mod intermediate-char 4)))) | 143 reg (mod intermediate-char 4)))) |
143 (if (setq charset (iso-charset dimension chars final-char)) | 144 (if (setq charset (iso-charset dimension chars final-char)) |
144 (aset encoded-kbd-iso2022-designations reg charset) | 145 (aset encoded-kbd-iso2022-designations reg charset) |
145 (error "Character set of DIMENSION %s, CHARS %s, FINAL-CHAR `%c' is not supported" | 146 (error "Character set of DIMENSION %s, CHARS %s, FINAL-CHAR `%c' is not supported" |
146 dimension chars final-char)) | 147 dimension chars final-char)) |
147 | 148 |
148 (if (eq (aref encoded-kbd-iso2022-designations | 149 (if (memq (aref encoded-kbd-iso2022-designations |
149 (aref encoded-kbd-iso2022-invocations 0)) | 150 (aref encoded-kbd-iso2022-invocations 0)) |
150 'ascii) | 151 '(ascii latin-jisx0201)) |
151 ;; Graphic plane 0 (0x20..0x7f) is for ASCII. We don't have | 152 ;; Graphic plane 0 (0x20..0x7f) is for ASCII. We don't have |
152 ;; to handle characters in this range specially. | 153 ;; to handle characters in this range specially. |
153 (throw 'exit nil) | 154 (throw 'exit nil) |
154 ;; Graphic plane 0 is for non-ASCII. | 155 ;; Graphic plane 0 is for non-ASCII. |
155 (setq overriding-local-map encoded-kbd-iso2022-non-ascii-map)))) | 156 (let ((overriding-local-map encoded-kbd-iso2022-non-ascii-map)) |
156 | 157 (recursive-edit))))) |
157 (defun encoded-kbd-handle-iso2022-esc () | |
158 (interactive) | |
159 (let ((overriding-local-map encoded-kbd-iso2022-esc-map)) | |
160 (recursive-edit))) | |
161 | 158 |
162 (defun encoded-kbd-handle-8bit () | 159 (defun encoded-kbd-handle-8bit () |
163 "Handle an 8-bit character enterned in Encoded-kbd mode." | 160 "Handle an 8-bit character enterned in Encoded-kbd mode." |
164 (interactive) | 161 (interactive) |
165 (cond ((eq encoded-kbd-coding 'iso2022-7) | 162 (cond ((eq encoded-kbd-coding 'iso2022-7) |
225 (let ((last-command-char | 222 (let ((last-command-char |
226 (decode-big5-char (+ (ash last-command-char 8) | 223 (decode-big5-char (+ (ash last-command-char 8) |
227 (read-char-exclusive))))) | 224 (read-char-exclusive))))) |
228 (self-insert-command 1))) | 225 (self-insert-command 1))) |
229 | 226 |
227 ;;;###autoload | |
230 (defun encoded-kbd-mode (&optional arg) | 228 (defun encoded-kbd-mode (&optional arg) |
231 "Toggle Encoded-kbd minor mode. | 229 "Toggle Encoded-kbd minor mode. |
232 With arg, turn Keyboard-kbd mode on in and only if arg is positive. | 230 With arg, turn Keyboard-kbd mode on in and only if arg is positive. |
233 | 231 |
234 When in Encoded-kbd mode, a text sent from a terminal keyboard | 232 When in Encoded-kbd mode, a text sent from a terminal keyboard |
235 is accepted as a multilingual text encoded in a coding-system | 233 is accepted as a multilingual text encoded in a coding system |
236 set by the command `set-keyboard-coding-system'" | 234 set by the command `set-keyboard-coding-system'" |
237 (interactive "P") | 235 (interactive "P") |
238 (setq encoded-kbd-mode | 236 (setq encoded-kbd-mode |
239 (if (null arg) (null encoded-kbd-mode) | 237 (if (null arg) (null encoded-kbd-mode) |
240 (> (prefix-numeric-value arg) 0))) | 238 (> (prefix-numeric-value arg) 0))) |
259 (make-variable-buffer-local 'encoded-kbd-iso2022-designations) | 257 (make-variable-buffer-local 'encoded-kbd-iso2022-designations) |
260 (setq encoded-kbd-iso2022-designations (make-vector 4 nil)) | 258 (setq encoded-kbd-iso2022-designations (make-vector 4 nil)) |
261 (let ((flags (coding-vector-flags coding)) | 259 (let ((flags (coding-vector-flags coding)) |
262 (i 0)) | 260 (i 0)) |
263 (while (< i 4) | 261 (while (< i 4) |
264 (if (and (aref flags i) | 262 (if (charsetp (aref flags i)) |
265 (> (aref flags i) 0)) | |
266 (aset encoded-kbd-iso2022-designations i | 263 (aset encoded-kbd-iso2022-designations i |
267 (aref flags i))) | 264 (aref flags i))) |
268 (setq i (1+ i)))) | 265 (setq i (1+ i)))) |
269 (make-variable-buffer-local 'encoded-kbd-iso2022-invocations) | 266 (make-variable-buffer-local 'encoded-kbd-iso2022-invocations) |
270 (setq encoded-kbd-iso2022-invocations (make-vector 3 0)) | 267 (setq encoded-kbd-iso2022-invocations (make-vector 3 nil)) |
268 (aset encoded-kbd-iso2022-invocations 0 0) | |
271 (aset encoded-kbd-iso2022-invocations 1 1)) | 269 (aset encoded-kbd-iso2022-invocations 1 1)) |
272 | 270 |
273 ((= (coding-vector-type coding) 3) ; BIG5 | 271 ((= (coding-vector-type coding) 3) ; BIG5 |
274 (set-input-mode (nth 0 input-mode) (nth 1 input-mode) | 272 (set-input-mode (nth 0 input-mode) (nth 1 input-mode) |
275 'use-8th-bit (nth 3 input-mode)) | 273 'use-8th-bit (nth 3 input-mode)) |
277 | 275 |
278 (t | 276 (t |
279 (setq encoded-kbd-mode nil) | 277 (setq encoded-kbd-mode nil) |
280 (error "Coding-system `%s' is not supported in Encoded-kbd mode" | 278 (error "Coding-system `%s' is not supported in Encoded-kbd mode" |
281 (keyboard-coding-system)))) | 279 (keyboard-coding-system)))) |
282 | 280 (setq inactivate-current-input-method-function 'encoded-kbd-mode) |
283 (run-hooks 'encoded-kbd-mode-hook))) | 281 (setq describe-current-input-method-function 'encoded-kbd-mode-help) |
282 (run-hooks 'encoded-kbd-mode-hook)) | |
283 (setq describe-current-input-method-function nil) | |
284 (setq current-input-method nil)) | |
284 (force-mode-line-update)) | 285 (force-mode-line-update)) |
285 | 286 |
287 ;;;###autoload | |
288 (defun encoded-kbd-select-terminal (terminal coding-system) | |
289 "Activate Encoded-Kbd mode appropriately for TERMINAL using CODING-SYSTEM." | |
290 (interactive "STerminal name: \nzcoding-system: ") | |
291 (if window-system | |
292 (error "Should run emacs on an ordinary terminal")) | |
293 (set-terminal-coding-system coding-system) | |
294 (set-keyboard-coding-system coding-system) | |
295 (setq current-input-method-title terminal) | |
296 (encoded-kbd-mode t)) | |
297 | |
286 ;;; encoded-kb.el ends here | 298 ;;; encoded-kb.el ends here |