166 |
(aset encoded-kbd-iso2022-invocations 2 3)) |
(aset encoded-kbd-iso2022-invocations 2 3)) |
167 |
|
|
168 |
((>= last-command-char ?\240) |
((>= last-command-char ?\240) |
169 |
(encoded-kbd-self-insert-iso2022-8bit)) |
(encoded-kbd-self-insert-iso2022-8bit 1)) |
170 |
|
|
171 |
(t |
(t |
172 |
(error "Can't handle the character code %d" |
(error "Can't handle the character code %d" |
237 |
(setq unread-command-events |
(setq unread-command-events |
238 |
(append result unread-command-events)))) |
(append result unread-command-events)))) |
239 |
|
|
240 |
|
(defun encoded-kbd-self-insert-charset (arg) |
241 |
|
(interactive "p") |
242 |
|
(let* ((charset-list |
243 |
|
(coding-system-get (keyboard-coding-system) :charset-list)) |
244 |
|
(charset (car charset-list)) |
245 |
|
;; For the moment, we can assume that the length of CHARSET-LIST |
246 |
|
;; is 1, and the dimension of CHARSET is 1. |
247 |
|
(c (decode-char charset last-command-char))) |
248 |
|
(unless c |
249 |
|
(error "Can't decode the code point %d by %s" |
250 |
|
last-command-char charset)) |
251 |
|
;; As simply setting unread-command-events may result in |
252 |
|
;; infinite-loop for characters 160..255, this is a temporary |
253 |
|
;; workaround until we found a better solution. |
254 |
|
(let ((last-command-char c)) |
255 |
|
(self-insert-command arg)))) |
256 |
|
|
257 |
(defun encoded-kbd-setup-keymap (coding) |
(defun encoded-kbd-setup-keymap (coding) |
258 |
;; At first, reset the keymap. |
;; At first, reset the keymap. |
259 |
(setcdr encoded-kbd-mode-map nil) |
(setcdr encoded-kbd-mode-map nil) |
260 |
;; Then setup the keymap according to the keyboard coding system. |
;; Then setup the keymap according to the keyboard coding system. |
261 |
(cond |
(cond |
262 |
|
((eq encoded-kbd-coding 'charset) |
263 |
|
(let* ((charset (car (coding-system-get coding :charset-list))) |
264 |
|
(code-space (get-charset-property charset :code-space)) |
265 |
|
(from (max (aref code-space 0) 128)) |
266 |
|
(to (aref code-space 1))) |
267 |
|
(while (<= from to) |
268 |
|
(define-key encoded-kbd-mode-map |
269 |
|
(vector from) 'encoded-kbd-self-insert-charset) |
270 |
|
(setq from (1+ from))))) |
271 |
|
|
272 |
((eq encoded-kbd-coding 'sjis) |
((eq encoded-kbd-coding 'sjis) |
273 |
(let ((i 128)) |
(let ((i 128)) |
274 |
(while (< i 256) |
(while (< i 256) |
373 |
'use-8th-bit (nth 3 saved-input-mode)) |
'use-8th-bit (nth 3 saved-input-mode)) |
374 |
(setq encoded-kbd-coding 'ccl)) |
(setq encoded-kbd-coding 'ccl)) |
375 |
|
|
376 |
|
((and (eq (coding-system-type coding) 'charset) |
377 |
|
(let* ((charset-list (coding-system-get coding |
378 |
|
:charset-list)) |
379 |
|
(charset (car charset-list))) |
380 |
|
(and (= (length charset-list) 1) |
381 |
|
(= (charset-dimension charset) 1)))) |
382 |
|
(set-input-mode |
383 |
|
(nth 0 saved-input-mode) (nth 1 saved-input-mode) |
384 |
|
'use-8th-bit (nth 3 saved-input-mode)) |
385 |
|
(setq encoded-kbd-coding 'charset)) |
386 |
|
|
387 |
(t |
(t |
388 |
(setq encoded-kbd-mode nil) |
(setq encoded-kbd-mode nil) |
389 |
(error "Coding-system `%s' is not supported in Encoded-kbd mode" |
(error "Coding-system `%s' is not supported in Encoded-kbd mode" |