177 |
(setq str (format "%s%c" str (read-char-exclusive)))) |
(setq str (format "%s%c" str (read-char-exclusive)))) |
178 |
(vector (aref result 0)))) |
(vector (aref result 0)))) |
179 |
|
|
180 |
|
|
181 |
|
;; Decode list of codes in CODE-LIST by CHARSET and return the decoded |
182 |
|
;; characters. If CODE-LIST is too short for the dimension of |
183 |
|
;; CHARSET, read new codes and append them to the tail of CODE-LIST. |
184 |
|
;; Return nil if CODE-LIST can't be decoded. |
185 |
|
|
186 |
|
(defun encoded-kbd-decode-code-list (charset code-list) |
187 |
|
(let ((dimension (charset-dimension charset)) |
188 |
|
code) |
189 |
|
(while (> dimension (length code-list)) |
190 |
|
(nconc code-list (list (read-char-exclusive)))) |
191 |
|
(setq code (car code-list)) |
192 |
|
(if (= dimension 1) |
193 |
|
(decode-char charset code) |
194 |
|
(setq code-list (cdr code-list) |
195 |
|
code (logior (lsh code 8) (car code-list))) |
196 |
|
(if (= dimension 2) |
197 |
|
(decode-char charset code) |
198 |
|
(setq code-list (cdr code-list) |
199 |
|
code (logior (lsh code 8) (car code-list))) |
200 |
|
(if (= dimension 3) |
201 |
|
(decode-char charset code) |
202 |
|
;; As Emacs can't handle full 32-bit integer, we must give a |
203 |
|
;; cons of higher and lower 16-bit codes to decode-char. |
204 |
|
(setq code (cons (lsh code -8) |
205 |
|
(logior (lsh (car code-list) 8) (cadr code-list)))) |
206 |
|
(decode-char charset code)))))) |
207 |
|
|
208 |
(defun encoded-kbd-self-insert-charset (ignore) |
(defun encoded-kbd-self-insert-charset (ignore) |
209 |
(let* ((charset-list |
(let ((charset-list |
210 |
(coding-system-get (keyboard-coding-system) :charset-list)) |
(coding-system-get (keyboard-coding-system) :charset-list)) |
211 |
(charset (car charset-list)) |
(code-list (list (encoded-kbd-last-key))) |
212 |
;; For the moment, we can assume that the length of CHARSET-LIST |
tail char) |
213 |
;; is 1, and the dimension of CHARSET is 1. |
(while (and charset-list (not char)) |
214 |
(char (encoded-kbd-last-key))) |
(setq char (encoded-kbd-decode-code-list (car charset-list) code-list) |
215 |
(vector (or (decode-char charset char) char)))) |
charset-list (cdr charset-list))) |
216 |
|
(if char |
217 |
|
(vector char) |
218 |
|
(setq unread-command-events (cdr code-list)) |
219 |
|
(vector (car code-list))))) |
220 |
|
|
221 |
(defun encoded-kbd-self-insert-utf-8 (arg) |
(defun encoded-kbd-self-insert-utf-8 (arg) |
222 |
(interactive "p") |
(interactive "p") |
249 |
8) |
8) |
250 |
|
|
251 |
((eq (coding-system-type coding) 'charset) |
((eq (coding-system-type coding) 'charset) |
252 |
(let* ((charset (car (coding-system-get coding :charset-list))) |
(dolist (elt (mapcar |
253 |
(code-space (get-charset-property charset :code-space)) |
#'(lambda (x) |
254 |
(from (max (aref code-space 0) 128)) |
(let ((dim (charset-dimension x)) |
255 |
(to (aref code-space 1))) |
(code-space (get-charset-property x :code-space))) |
256 |
(while (<= from to) |
(cons (aref code-space (* (1- dim) 2)) |
257 |
(define-key key-translation-map |
(aref code-space (1+ (* (1- dim) 2)))))) |
258 |
(vector from) 'encoded-kbd-self-insert-charset) |
(coding-system-get coding :charset-list))) |
259 |
(setq from (1+ from)))) |
(let ((from (max (car elt) 128)) |
260 |
|
(to (cdr elt))) |
261 |
|
(while (<= from to) |
262 |
|
(define-key key-translation-map |
263 |
|
(vector from) 'encoded-kbd-self-insert-charset) |
264 |
|
(setq from (1+ from))))) |
265 |
8) |
8) |
266 |
|
|
267 |
((eq (coding-system-type coding) 'iso-2022) |
((eq (coding-system-type coding) 'iso-2022) |