Mercurial > emacs
comparison lisp/international/encoded-kb.el @ 91041:bdb3fe0ba9fa
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 866-879)
- Merge multi-tty branch
- Update from CVS
- Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-257
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 11 Oct 2007 16:22:07 +0000 |
parents | f55f9811f5d7 7960438eca87 |
children | 35069180a991 |
comparison
equal
deleted
inserted
replaced
91040:14c4a6aac623 | 91041:bdb3fe0ba9fa |
---|---|
32 ;;; Code: | 32 ;;; Code: |
33 | 33 |
34 ;; Usually this map is empty (even if Encoded-kbd mode is on), but if | 34 ;; Usually this map is empty (even if Encoded-kbd mode is on), but if |
35 ;; the keyboard coding system is iso-2022-based, it defines dummy key | 35 ;; the keyboard coding system is iso-2022-based, it defines dummy key |
36 ;; bindings for ESC $ ..., etc. so that those bindings in | 36 ;; bindings for ESC $ ..., etc. so that those bindings in |
37 ;; key-translation-map take effect. | 37 ;; input-decode-map take effect. |
38 (defconst encoded-kbd-mode-map (make-sparse-keymap) | 38 (defconst encoded-kbd-mode-map (make-sparse-keymap) |
39 "Keymap for Encoded-kbd minor mode.") | 39 "Keymap for Encoded-kbd minor mode.") |
40 | 40 |
41 ;; Subsidiary keymaps for handling ISO2022 escape sequences. | 41 ;; Subsidiary keymaps for handling ISO2022 escape sequences. |
42 | 42 |
234 (while (> len 0) | 234 (while (> len 0) |
235 (setq char (logior (lsh char 6) (logand (read-char-exclusive) #x3F)) | 235 (setq char (logior (lsh char 6) (logand (read-char-exclusive) #x3F)) |
236 len (1- len))) | 236 len (1- len))) |
237 (vector char))) | 237 (vector char))) |
238 | 238 |
239 (defun encoded-kbd-setup-keymap (coding) | 239 (defun encoded-kbd-setup-keymap (keymap coding) |
240 ;; At first, reset the keymap. | 240 ;; At first, reset the keymap. |
241 (define-key encoded-kbd-mode-map "\e" nil) | 241 (define-key encoded-kbd-mode-map "\e" nil) |
242 ;; Then setup the keymap according to the keyboard coding system. | 242 ;; Then setup the keymap according to the keyboard coding system. |
243 (cond | 243 (cond |
244 ((eq (coding-system-type coding) 'shift-jis) | 244 ((eq (coding-system-type coding) 'shift-jis) |
245 (let ((i 128)) | 245 (let ((i 128)) |
246 (while (< i 256) | 246 (while (< i 256) |
247 (define-key key-translation-map | 247 (define-key keymap |
248 (vector i) 'encoded-kbd-self-insert-sjis) | 248 (vector i) 'encoded-kbd-self-insert-sjis) |
249 (setq i (1+ i)))) | 249 (setq i (1+ i)))) |
250 8) | 250 8) |
251 | 251 |
252 ((eq (coding-system-type coding) 'charset) | 252 ((eq (coding-system-type coding) 'charset) |
258 (aref code-space (1+ (* (1- dim) 2)))))) | 258 (aref code-space (1+ (* (1- dim) 2)))))) |
259 (coding-system-get coding :charset-list))) | 259 (coding-system-get coding :charset-list))) |
260 (let ((from (max (car elt) 128)) | 260 (let ((from (max (car elt) 128)) |
261 (to (cdr elt))) | 261 (to (cdr elt))) |
262 (while (<= from to) | 262 (while (<= from to) |
263 (define-key key-translation-map | 263 (define-key keymap |
264 (vector from) 'encoded-kbd-self-insert-charset) | 264 (vector from) 'encoded-kbd-self-insert-charset) |
265 (setq from (1+ from))))) | 265 (setq from (1+ from))))) |
266 8) | 266 8) |
267 | 267 |
268 ((eq (coding-system-type coding) 'iso-2022) | 268 ((eq (coding-system-type coding) 'iso-2022) |
283 (aset encoded-kbd-iso2022-invocations 0 0) | 283 (aset encoded-kbd-iso2022-invocations 0 0) |
284 (if (aref encoded-kbd-iso2022-designations 1) | 284 (if (aref encoded-kbd-iso2022-designations 1) |
285 (aset encoded-kbd-iso2022-invocations 1 1)) | 285 (aset encoded-kbd-iso2022-invocations 1 1)) |
286 (when (memq 'designation flags) | 286 (when (memq 'designation flags) |
287 (define-key encoded-kbd-mode-map "\e" 'encoded-kbd-iso2022-esc-prefix) | 287 (define-key encoded-kbd-mode-map "\e" 'encoded-kbd-iso2022-esc-prefix) |
288 (define-key key-translation-map "\e" 'encoded-kbd-iso2022-esc-prefix)) | 288 (define-key keymap "\e" 'encoded-kbd-iso2022-esc-prefix)) |
289 (when (or (aref designation 2) (aref designation 3)) | 289 (when (or (aref designation 2) (aref designation 3)) |
290 (define-key key-translation-map | 290 (define-key keymap |
291 [?\216] 'encoded-kbd-iso2022-single-shift) | 291 [?\216] 'encoded-kbd-iso2022-single-shift) |
292 (define-key key-translation-map | 292 (define-key keymap |
293 [?\217] 'encoded-kbd-iso2022-single-shift)) | 293 [?\217] 'encoded-kbd-iso2022-single-shift)) |
294 (or (eq (aref designation 0) 'ascii) | 294 (or (eq (aref designation 0) 'ascii) |
295 (dotimes (i 96) | 295 (dotimes (i 96) |
296 (define-key key-translation-map | 296 (define-key keymap |
297 (vector (+ 32 i)) 'encoded-kbd-self-insert-iso2022-7bit))) | 297 (vector (+ 32 i)) 'encoded-kbd-self-insert-iso2022-7bit))) |
298 (if (memq '7-bit flags) | 298 (if (memq '7-bit flags) |
299 t | 299 t |
300 (dotimes (i 96) | 300 (dotimes (i 96) |
301 (define-key key-translation-map | 301 (define-key keymap |
302 (vector (+ 160 i)) 'encoded-kbd-self-insert-iso2022-8bit)) | 302 (vector (+ 160 i)) 'encoded-kbd-self-insert-iso2022-8bit)) |
303 8)))) | 303 8)))) |
304 | 304 |
305 ((eq (coding-system-type coding) 4) ; CCL-base | 305 ((eq (coding-system-type coding) 4) ; CCL-base |
306 (let ((valid-codes (or (coding-system-get coding :valid) | 306 (let ((valid-codes (or (coding-system-get coding :valid) |
311 (if (consp elt) | 311 (if (consp elt) |
312 (setq from (car elt) to (cdr elt)) | 312 (setq from (car elt) to (cdr elt)) |
313 (setq from (setq to elt))) | 313 (setq from (setq to elt))) |
314 (while (<= from to) | 314 (while (<= from to) |
315 (if (>= from 128) | 315 (if (>= from 128) |
316 (define-key key-translation-map | 316 (define-key keymap |
317 (vector from) 'encoded-kbd-self-insert-ccl)) | 317 (vector from) 'encoded-kbd-self-insert-ccl)) |
318 (setq from (1+ from)))) | 318 (setq from (1+ from)))) |
319 8)) | 319 8)) |
320 | 320 |
321 ((eq (coding-system-type coding) 'utf-8) | 321 ((eq (coding-system-type coding) 'utf-8) |
322 (let ((i #xC0)) | 322 (let ((i #xC0)) |
323 (while (< i 256) | 323 (while (< i 256) |
324 (define-key key-translation-map | 324 (define-key keymap |
325 (vector i) 'encoded-kbd-self-insert-utf-8) | 325 (vector i) 'encoded-kbd-self-insert-utf-8) |
326 (setq i (1+ i)))) | 326 (setq i (1+ i)))) |
327 8) | 327 8) |
328 | 328 |
329 (t | 329 (t |
330 nil))) | 330 nil))) |
331 | 331 |
332 ;; key-translation-map at the time Encoded-kbd mode is turned on is | 332 ;;;###autoload |
333 ;; saved here. | 333 (defun encoded-kbd-setup-display (display) |
334 (defvar saved-key-translation-map nil) | 334 "Set up a `input-decode-map' for `keyboard-coding-system' on DISPLAY. |
335 | |
336 ;; Input mode at the time Encoded-kbd mode is turned on is saved here. | |
337 (defvar saved-input-mode nil) | |
338 | 335 |
339 (put 'encoded-kbd-mode 'permanent-local t) | 336 (put 'encoded-kbd-mode 'permanent-local t) |
340 ;;;###autoload | 337 ;;;###autoload |
341 (define-minor-mode encoded-kbd-mode | 338 (define-minor-mode encoded-kbd-mode |
342 "Toggle Encoded-kbd minor mode. | 339 "Toggle Encoded-kbd minor mode. |
384 (apply 'set-input-mode saved-input-mode) | 381 (apply 'set-input-mode saved-input-mode) |
385 (setq saved-input-mode nil)))) | 382 (setq saved-input-mode nil)))) |
386 | 383 |
387 (provide 'encoded-kb) | 384 (provide 'encoded-kb) |
388 | 385 |
389 ;;; arch-tag: 76f0f9b3-65e7-45c3-b692-59509a87ad44 | 386 ;; arch-tag: 76f0f9b3-65e7-45c3-b692-59509a87ad44 |
390 ;;; encoded-kb.el ends here | 387 ;;; encoded-kb.el ends here |