Mercurial > emacs
comparison leim/quail/uni-input.el @ 89483:2f877ed80fa6
*** empty log message ***
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 08 Sep 2003 12:53:41 +0000 |
parents | 375f2633d815 02430d914fc1 |
children | 68c22ea6027c |
comparison
equal
deleted
inserted
replaced
88123:375f2633d815 | 89483:2f877ed80fa6 |
---|---|
1 ;;; uni-input.el --- Hex Unicode input method | 1 ;;; uni-input.el --- Hex Unicode input method |
2 | 2 |
3 ;; Copyright (C) 2001 Free Software Foundation, Inc. | 3 ;; Copyright (C) 2001, 2002 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Dave Love <fx@gnu.org> | 5 ;; Author: Dave Love <fx@gnu.org> |
6 ;; Keywords: i18n | 6 ;; Keywords: i18n |
7 | 7 |
8 ;; This file is part of GNU Emacs. | 8 ;; This file is part of GNU Emacs. |
28 ;; the form `uxxxx', similarly to the Yudit editor. | 28 ;; the form `uxxxx', similarly to the Yudit editor. |
29 | 29 |
30 ;; This is not really a Quail method, but uses some Quail functions. | 30 ;; This is not really a Quail method, but uses some Quail functions. |
31 ;; There is probably A Better Way. | 31 ;; There is probably A Better Way. |
32 | 32 |
33 ;; Compare `ucs-insert', which explicitly inserts a unicoded character | 33 ;; You can get a similar effect by using C-q with |
34 ;; rather than supplying an input method. | 34 ;; `read-quoted-char-radix' set to 16. |
35 | |
36 ;; Note that this only allows you to enter BMP values unless someone | |
37 ;; extends it to use variable numbers of digits. | |
35 | 38 |
36 ;;; Code: | 39 ;;; Code: |
37 | 40 |
38 (require 'quail) | 41 (require 'quail) |
39 | |
40 ;; Maybe stolen from Mule-UCS -- I don't remember. | |
41 (define-ccl-program utf-8-ccl-encode | |
42 `(4 (if (r0 < ?\x80) | |
43 ((write r0)) | |
44 (if (r0 < #x800) | |
45 ((write ((r0 >> 6) | ?\xC0)) | |
46 (write ((r0 & ?\x3F) | ?\x80))) | |
47 (if (r0 < #x10000) | |
48 ((write ((r0 >> 12) | ?\xE0)) | |
49 (write (((r0 >> 6) & ?\x3F) | ?\x80)) | |
50 (write ((r0 & ?\x3F) | ?\x80))) | |
51 (if (r0 < #x200000) | |
52 ((write ((r0 >> 18) | ?\xF0)) | |
53 (write (((r0 >> 12) & ?\x3F) | ?\x80)) | |
54 (write (((r0 >> 6) & ?\x3F) | ?\x80)) | |
55 (write ((r0 & ?\x3F) | ?\x80))) | |
56 (if (r0 < #x4000000) | |
57 ((write ((r0 >> 24) | ?\xF8)) | |
58 (write (((r0 >> 18) & ?\x3F) | ?\x80)) | |
59 (write (((r0 >> 12) & ?\x3F) | ?\x80)) | |
60 (write (((r0 >> 6) & ?\x3F) | ?\x80)) | |
61 (write ((r0 & ?\x3F) | ?\x80))) | |
62 ((write ((r0 >> 30) | ?\xFC)) | |
63 (write (((r0 >> 24) & ?\x3F) | ?\x80)) | |
64 (write (((r0 >> 18) & ?\x3F) | ?\x80)) | |
65 (write (((r0 >> 12) & ?\x3F) | ?\x80)) | |
66 (write (((r0 >> 6) & ?\x3F) | ?\x80)) | |
67 (write ((r0 & ?\x3F) | ?\x80)))))))))) | |
68 | 42 |
69 (defun ucs-input-method (key) | 43 (defun ucs-input-method (key) |
70 (if (or buffer-read-only | 44 (if (or buffer-read-only |
71 (and (/= key ?U) (/= key ?u))) | 45 (and (/= key ?U) (/= key ?u))) |
72 (list key) | 46 (list key) |
89 key) | 63 key) |
90 (if (and (stringp seq) | 64 (if (and (stringp seq) |
91 (= 1 (length seq)) | 65 (= 1 (length seq)) |
92 (setq key (aref seq 0)) | 66 (setq key (aref seq 0)) |
93 (memq key '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 ?a | 67 (memq key '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 ?a |
94 ?b ?c ?d ?e ?f ?A ?B ?C ?D ?E ?F))) | 68 ?b ?c ?d ?e ?f ?A ?B ?C ?D ?E ?F))) |
95 (progn | 69 (progn |
96 (push key events) | 70 (push key events) |
97 (let ((last-command-char key) | 71 (let ((last-command-char key) |
98 (current-prefix-arg)) | 72 (current-prefix-arg)) |
99 (call-interactively 'self-insert-command))) | 73 (call-interactively 'self-insert-command))) |
103 (call-interactively (key-binding seq)))) | 77 (call-interactively (key-binding seq)))) |
104 (quail-delete-region) | 78 (quail-delete-region) |
105 (throw 'non-digit (append (reverse events) | 79 (throw 'non-digit (append (reverse events) |
106 (listify-key-sequence seq)))))) | 80 (listify-key-sequence seq)))))) |
107 (quail-delete-region) | 81 (quail-delete-region) |
108 (let* ((n (string-to-number (apply 'string | 82 (let ((n (string-to-number (apply 'string |
109 (cdr (nreverse events))) | 83 (cdr (nreverse events))) |
110 16)) | 84 16))) |
111 (c (decode-char 'ucs n)) | 85 (if (characterp n) |
112 (status (make-vector 9 nil))) | 86 (list n))))) |
113 (if c | |
114 (list c) | |
115 (aset status 0 n) | |
116 (string-to-list (ccl-execute-on-string | |
117 'utf-8-ccl-encode status "")))))) | |
118 (quail-delete-overlays) | 87 (quail-delete-overlays) |
119 (set-buffer-modified-p modified-p) | 88 (set-buffer-modified-p modified-p) |
120 (run-hooks 'input-method-after-insert-chunk-hook))))) | 89 (run-hooks 'input-method-after-insert-chunk-hook))))) |
121 | 90 |
122 (defun ucs-input-activate (&optional arg) | 91 (defun ucs-input-activate (&optional arg) |