comparison leim/quail/uni-input.el @ 88785:3387266b74c1

(utf-8-ccl-encode): Deleted. (ucs-input-method): Modified.
author Dave Love <fx@gnu.org>
date Mon, 24 Jun 2002 19:26:00 +0000
parents 44b4a14ae7fc
children 02430d914fc1
comparison
equal deleted inserted replaced
88784:7bb2a408955b 88785:3387266b74c1
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 35
36 ;;; Code: 36 ;;; Code:
37 37
38 (require 'quail) 38 (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) & ?\3F) | ?\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 39
69 (defun ucs-input-method (key) 40 (defun ucs-input-method (key)
70 (if (or buffer-read-only 41 (if (or buffer-read-only
71 (and (/= key ?U) (/= key ?u))) 42 (and (/= key ?U) (/= key ?u)))
72 (list key) 43 (list key)
89 key) 60 key)
90 (if (and (stringp seq) 61 (if (and (stringp seq)
91 (= 1 (length seq)) 62 (= 1 (length seq))
92 (setq key (aref seq 0)) 63 (setq key (aref seq 0))
93 (memq key '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 ?a 64 (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))) 65 ?b ?c ?d ?e ?f ?A ?B ?C ?D ?E ?F)))
95 (progn 66 (progn
96 (push key events) 67 (push key events)
97 (let ((last-command-char key) 68 (let ((last-command-char key)
98 (current-prefix-arg)) 69 (current-prefix-arg))
99 (call-interactively 'self-insert-command))) 70 (call-interactively 'self-insert-command)))
103 (call-interactively (key-binding seq)))) 74 (call-interactively (key-binding seq))))
104 (quail-delete-region) 75 (quail-delete-region)
105 (throw 'non-digit (append (reverse events) 76 (throw 'non-digit (append (reverse events)
106 (listify-key-sequence seq)))))) 77 (listify-key-sequence seq))))))
107 (quail-delete-region) 78 (quail-delete-region)
108 (let* ((n (string-to-number (apply 'string 79 (let ((n (string-to-number (apply 'string
109 (cdr (nreverse events))) 80 (cdr (nreverse events)))
110 16)) 81 16)))
111 (c (decode-char 'ucs n)) 82 (if (characterp n)
112 (status (make-vector 9 nil))) 83 (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) 84 (quail-delete-overlays)
119 (set-buffer-modified-p modified-p) 85 (set-buffer-modified-p modified-p)
120 (run-hooks 'input-method-after-insert-chunk-hook))))) 86 (run-hooks 'input-method-after-insert-chunk-hook)))))
121 87
122 (defun ucs-input-activate (&optional arg) 88 (defun ucs-input-activate (&optional arg)