/[emacs]/emacs/lisp/international/encoded-kb.el
ViewVC logotype

Diff of /emacs/lisp/international/encoded-kb.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.28 by lektu, Tue Feb 4 13:09:38 2003 UTC revision 1.28.6.1 by handa, Mon Sep 8 12:53:40 2003 UTC
# Line 1  Line 1 
1  ;;; encoded-kb.el --- handler to input multibyte characters encoded somehow  ;;; encoded-kb.el --- handler to input multibyte characters encoded somehow
2    
3  ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.  ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
4  ;; Licensed to the Free Software Foundation.  ;;   Licensed to the Free Software Foundation.
5    ;; Copyright (C) 2002 Free Software Foundation, Inc.
6    ;; Copyright (C) 2003
7    ;;   National Institute of Advanced Industrial Science and Technology (AIST)
8    ;;   Registration Number H13PRO009
9    
10  ;; This file is part of GNU Emacs.  ;; This file is part of GNU Emacs.
11    
# Line 165  The following key sequence may cause mul Line 169  The following key sequence may cause mul
169                  (aset encoded-kbd-iso2022-invocations 2 3))                  (aset encoded-kbd-iso2022-invocations 2 3))
170    
171                 ((>= last-command-char ?\240)                 ((>= last-command-char ?\240)
172                  (encoded-kbd-self-insert-iso2022-8bit))                  (encoded-kbd-self-insert-iso2022-8bit 1))
173    
174                 (t                 (t
175                  (error "Can't handle the character code %d"                  (error "Can't handle the character code %d"
# Line 188  The following key sequence may cause mul Line 192  The following key sequence may cause mul
192      (aset encoded-kbd-iso2022-invocations 2 nil)      (aset encoded-kbd-iso2022-invocations 2 nil)
193      (setq unread-command-events (cons char unread-command-events))))      (setq unread-command-events (cons char unread-command-events))))
194    
195  (defun encoded-kbd-self-insert-iso2022-8bit ()  (defun encoded-kbd-self-insert-iso2022-8bit (arg)
196    (interactive)    (interactive "p")
197    (cond    (cond
198     ((= last-command-char ?\216)         ; SS2 (Single Shift 2)     ((= last-command-char ?\216)         ; SS2 (Single Shift 2)
199      (aset encoded-kbd-iso2022-invocations 2 2))      (aset encoded-kbd-iso2022-invocations 2 2))
# Line 204  The following key sequence may cause mul Line 208  The following key sequence may cause mul
208                     (make-char charset last-command-char                     (make-char charset last-command-char
209                                (read-char-exclusive)))))                                (read-char-exclusive)))))
210        (aset encoded-kbd-iso2022-invocations 2 nil)        (aset encoded-kbd-iso2022-invocations 2 nil)
211        (setq unread-command-events (cons char unread-command-events))))))        ;; As simply setting unread-command-events may result in
212          ;; infinite-loop for characters 160..255, this is a temporary
213          ;; workaround until we found a better solution.
214          (let ((last-command-char char))
215            (self-insert-command arg))))))
216    
217  (defun encoded-kbd-self-insert-sjis ()  (defun encoded-kbd-self-insert-sjis ()
218    (interactive)    (interactive)
# Line 223  The following key sequence may cause mul Line 231  The following key sequence may cause mul
231  (defun encoded-kbd-self-insert-ccl ()  (defun encoded-kbd-self-insert-ccl ()
232    (interactive)    (interactive)
233    (let ((str (char-to-string last-command-char))    (let ((str (char-to-string last-command-char))
234          (ccl (car (aref (coding-system-spec (keyboard-coding-system)) 4)))          (ccl (coding-system-get (keyboard-coding-system) :ccl-decoder))
235          (vec [nil nil nil nil nil nil nil nil nil])          (vec [nil nil nil nil nil nil nil nil nil])
236          result)          result)
237      (while (= (length (setq result (ccl-execute-on-string ccl vec str t))) 0)      (while (= (length (setq result (ccl-execute-on-string ccl vec str t))) 0)
# Line 232  The following key sequence may cause mul Line 240  The following key sequence may cause mul
240      (setq unread-command-events      (setq unread-command-events
241            (append result unread-command-events))))            (append result unread-command-events))))
242    
243    (defun encoded-kbd-self-insert-charset (arg)
244      (interactive "p")
245      (let* ((charset-list
246              (coding-system-get (keyboard-coding-system) :charset-list))
247             (charset (car charset-list))
248             ;; For the moment, we can assume that the length of CHARSET-LIST
249             ;; is 1, and the dimension of CHARSET is 1.
250             (c (decode-char charset last-command-char)))
251        (unless c
252          (error "Can't decode the code point %d by %s"
253                 last-command-char charset))
254        ;; As simply setting unread-command-events may result in
255        ;; infinite-loop for characters 160..255, this is a temporary
256        ;; workaround until we found a better solution.
257        (let ((last-command-char c))
258          (self-insert-command arg))))
259    
260  (defun encoded-kbd-setup-keymap (coding)  (defun encoded-kbd-setup-keymap (coding)
261    ;; At first, reset the keymap.    ;; At first, reset the keymap.
262    (setcdr encoded-kbd-mode-map nil)    (setcdr encoded-kbd-mode-map nil)
263    ;; Then setup the keymap according to the keyboard coding system.    ;; Then setup the keymap according to the keyboard coding system.
264    (cond    (cond
265       ((eq encoded-kbd-coding 'charset)
266        (let* ((charset (car (coding-system-get coding :charset-list)))
267               (code-space (get-charset-property charset :code-space))
268               (from (max (aref code-space 0) 128))
269               (to (aref code-space 1)))
270          (while (<= from to)
271            (define-key encoded-kbd-mode-map
272              (vector from) 'encoded-kbd-self-insert-charset)
273            (setq from (1+ from)))))
274    
275     ((eq encoded-kbd-coding 'sjis)     ((eq encoded-kbd-coding 'sjis)
276      (let ((i 128))      (let ((i 128))
277        (while (< i 256)        (while (< i 256)
# Line 266  The following key sequence may cause mul Line 301  The following key sequence may cause mul
301          (setq i (1+ i)))))          (setq i (1+ i)))))
302    
303     ((eq encoded-kbd-coding 'ccl)     ((eq encoded-kbd-coding 'ccl)
304      (let ((valid-codes (or (coding-system-get coding 'valid-codes)      (let ((valid-codes (or (coding-system-get coding :valid)
305                             '((128 . 255))))                             '((128 . 255))))
306            elt from to)            elt from to)
307        (while valid-codes        (while valid-codes
# Line 310  as a multilingual text encoded in a codi Line 345  as a multilingual text encoded in a codi
345                 (setq encoded-kbd-mode nil)                 (setq encoded-kbd-mode nil)
346                 (error "No coding system for keyboard input is set"))                 (error "No coding system for keyboard input is set"))
347    
348                ((= (coding-system-type coding) 1) ; SJIS                ((eq (coding-system-type coding) 'shift-jis)
349                 (set-input-mode                 (set-input-mode
350                  (nth 0 saved-input-mode) (nth 1 saved-input-mode)                  (nth 0 saved-input-mode) (nth 1 saved-input-mode)
351                  'use-8th-bit (nth 3 saved-input-mode))                  'use-8th-bit (nth 3 saved-input-mode))
352                 (setq encoded-kbd-coding 'sjis))                 (setq encoded-kbd-coding 'sjis))
353    
354                ((= (coding-system-type coding) 2) ; ISO2022                ((eq (coding-system-type coding) 'iso-2022)
355                 (if (aref (coding-system-flags coding) 7) ; 7-bit only                 (if (memq '7-bit (coding-system-get coding :flags))
356                     (setq encoded-kbd-coding 'iso2022-7)                     (setq encoded-kbd-coding 'iso2022-7)
357                   (set-input-mode                   (set-input-mode
358                    (nth 0 saved-input-mode) (nth 1 saved-input-mode)                    (nth 0 saved-input-mode) (nth 1 saved-input-mode)
359                    'use-8th-bit (nth 3 saved-input-mode))                    'use-8th-bit (nth 3 saved-input-mode))
360                   (setq encoded-kbd-coding 'iso2022-8))                   (setq encoded-kbd-coding 'iso2022-8))
361                 (setq encoded-kbd-iso2022-designations (make-vector 4 nil))                 (setq encoded-kbd-iso2022-designations
362                 (let ((flags (coding-system-flags coding))                       (coding-system-get coding :designation))
                      (i 0))  
                  (while (< i 4)  
                    (if (charsetp (aref flags i))  
                        (aset encoded-kbd-iso2022-designations i  
                              (aref flags i))  
                      (if (charsetp (car-safe (aref flags i)))  
                        (aset encoded-kbd-iso2022-designations i  
                              (car (aref flags i)))))  
                    (setq i (1+ i))))  
363                 (setq encoded-kbd-iso2022-invocations (make-vector 3 nil))                 (setq encoded-kbd-iso2022-invocations (make-vector 3 nil))
364                 (aset encoded-kbd-iso2022-invocations 0 0)                 (aset encoded-kbd-iso2022-invocations 0 0)
365                 (aset encoded-kbd-iso2022-invocations 1 1))                 (aset encoded-kbd-iso2022-invocations 1 1))
366    
367                ((= (coding-system-type coding) 3) ; BIG5                ((eq (coding-system-type coding) 'big5)
368                 (set-input-mode                 (set-input-mode
369                  (nth 0 saved-input-mode) (nth 1 saved-input-mode)                  (nth 0 saved-input-mode) (nth 1 saved-input-mode)
370                  'use-8th-bit (nth 3 saved-input-mode))                  'use-8th-bit (nth 3 saved-input-mode))
371                 (setq encoded-kbd-coding 'big5))                 (setq encoded-kbd-coding 'big5))
372    
373                ((= (coding-system-type coding) 4) ; CCL based coding                ((eq (coding-system-type coding) 'ccl)
374                 (set-input-mode                 (set-input-mode
375                  (nth 0 saved-input-mode) (nth 1 saved-input-mode)                  (nth 0 saved-input-mode) (nth 1 saved-input-mode)
376                  'use-8th-bit (nth 3 saved-input-mode))                  'use-8th-bit (nth 3 saved-input-mode))
377                 (setq encoded-kbd-coding 'ccl))                 (setq encoded-kbd-coding 'ccl))
378    
379                  ((and (eq (coding-system-type coding) 'charset)
380                        (let* ((charset-list (coding-system-get coding
381                                                                :charset-list))
382                               (charset (car charset-list)))
383                          (and (= (length charset-list) 1)
384                               (= (charset-dimension charset) 1))))
385                   (set-input-mode
386                    (nth 0 saved-input-mode) (nth 1 saved-input-mode)
387                    'use-8th-bit (nth 3 saved-input-mode))
388                   (setq encoded-kbd-coding 'charset))
389    
390                (t                (t
391                 (setq encoded-kbd-mode nil)                 (setq encoded-kbd-mode nil)
392                 (error "Coding-system `%s' is not supported in Encoded-kbd mode"                 (error "Coding-system `%s' is not supported in Encoded-kbd mode"

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.28.6.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26