comparison lisp/international/encoded-kb.el @ 19268:ecb55608fa91

(saved-input-mode): New variable. (encoded-kbd-mode): Doc-string fixed. Save current-input-mode when turning on Encoded-kbd mode, and recover it when turning off Encoded-kbd mode. Set encoded-kbd-iso2022-designations correctly. (encoded-kbd-self-insert-iso2022-7bit): Call charset-dimension instead fo charset-bytes. (encoded-kbd-self-insert-iso2022-8bit): Likewise.
author Kenichi Handa <handa@m17n.org>
date Sun, 10 Aug 1997 04:07:03 +0000
parents 2185491b8d24
children 5c790f1ce4b4
comparison
equal deleted inserted replaced
19267:6e152439176f 19268:ecb55608fa91
186 (interactive) 186 (interactive)
187 (let* ((charset (aref encoded-kbd-iso2022-designations 187 (let* ((charset (aref encoded-kbd-iso2022-designations
188 (or (aref encoded-kbd-iso2022-invocations 2) 188 (or (aref encoded-kbd-iso2022-invocations 2)
189 (aref encoded-kbd-iso2022-invocations 0)))) 189 (aref encoded-kbd-iso2022-invocations 0))))
190 (last-command-char 190 (last-command-char
191 (if (= (charset-bytes charset) 1) 191 (if (= (charset-dimension charset) 1)
192 (make-char charset last-command-char) 192 (make-char charset last-command-char)
193 (make-char charset last-command-char (read-char-exclusive))))) 193 (make-char charset last-command-char (read-char-exclusive)))))
194 (self-insert-command 1) 194 (self-insert-command 1)
195 (aset encoded-kbd-iso2022-invocations 2 nil) 195 (aset encoded-kbd-iso2022-invocations 2 nil)
196 )) 196 ))
199 (interactive) 199 (interactive)
200 (let* ((charset (aref encoded-kbd-iso2022-designations 200 (let* ((charset (aref encoded-kbd-iso2022-designations
201 (or (aref encoded-kbd-iso2022-invocations 2) 201 (or (aref encoded-kbd-iso2022-invocations 2)
202 (aref encoded-kbd-iso2022-invocations 1)))) 202 (aref encoded-kbd-iso2022-invocations 1))))
203 (last-command-char 203 (last-command-char
204 (if (= (charset-bytes charset) 1) 204 (if (= (charset-dimension charset) 1)
205 (make-char charset last-command-char) 205 (make-char charset last-command-char)
206 (make-char charset last-command-char (read-char-exclusive))))) 206 (make-char charset last-command-char (read-char-exclusive)))))
207 (self-insert-command 1) 207 (self-insert-command 1)
208 (aset encoded-kbd-iso2022-invocations 2 nil) 208 (aset encoded-kbd-iso2022-invocations 2 nil)
209 )) 209 ))
222 (let ((last-command-char 222 (let ((last-command-char
223 (decode-big5-char (+ (ash last-command-char 8) 223 (decode-big5-char (+ (ash last-command-char 8)
224 (read-char-exclusive))))) 224 (read-char-exclusive)))))
225 (self-insert-command 1))) 225 (self-insert-command 1)))
226 226
227 ;; Input mode at the time Encoded-kbd mode is turned on is saved here.
228 (defvar saved-input-mode nil)
229
227 ;;;###autoload 230 ;;;###autoload
228 (defun encoded-kbd-mode (&optional arg) 231 (defun encoded-kbd-mode (&optional arg)
229 "Toggle Encoded-kbd minor mode. 232 "Toggle Encoded-kbd minor mode.
230 With arg, turn Keyboard-kbd mode on if and only if arg is positive. 233 With arg, turn Encoded-kbd mode on if and only if arg is positive.
231 234
232 When in Encoded-kbd mode, a text sent from a terminal keyboard 235 When in Encoded-kbd mode, a text sent from keyboard
233 is accepted as a multilingual text encoded in a coding system 236 is accepted as a multilingual text encoded in a coding system
234 set by the command `encoded-kbd-set-coding-system'" 237 set by the command `set-keyboard-coding-system'."
235 (interactive "P") 238 (interactive "P")
239 (if encoded-kbd-mode
240 ;; We must at first reset input-mode to the original.
241 (apply 'set-input-mode saved-input-mode))
236 (setq encoded-kbd-mode 242 (setq encoded-kbd-mode
237 (if (null arg) (null encoded-kbd-mode) 243 (if (null arg) (null encoded-kbd-mode)
238 (> (prefix-numeric-value arg) 0))) 244 (> (prefix-numeric-value arg) 0)))
239 (if encoded-kbd-mode 245 (if encoded-kbd-mode
240 (let ((coding (keyboard-coding-system)) 246 (let ((coding (keyboard-coding-system)))
241 (input-mode (current-input-mode))) 247 (setq saved-input-mode (current-input-mode))
242 (cond ((null coding) 248 (cond ((null coding)
243 (setq encoded-kbd-mode nil) 249 (setq encoded-kbd-mode nil)
244 (error "No coding-system for terminal keyboard is set")) 250 (error "No coding system for keyboard input is set"))
245 251
246 ((= (coding-system-type coding) 1) ; SJIS 252 ((= (coding-system-type coding) 1) ; SJIS
247 (set-input-mode (nth 0 input-mode) (nth 1 input-mode) 253 (set-input-mode
248 'use-8th-bit (nth 3 input-mode)) 254 (nth 0 saved-input-mode) (nth 1 saved-input-mode)
255 'use-8th-bit (nth 3 saved-input-mode))
249 (setq encoded-kbd-coding 'sjis)) 256 (setq encoded-kbd-coding 'sjis))
250 257
251 ((= (coding-system-type coding) 2) ; ISO2022 258 ((= (coding-system-type coding) 2) ; ISO2022
252 (if (aref (coding-system-flags coding) 7) ; 7-bit only 259 (if (aref (coding-system-flags coding) 7) ; 7-bit only
253 (setq encoded-kbd-coding 'iso2022-7) 260 (setq encoded-kbd-coding 'iso2022-7)
254 (set-input-mode (nth 0 input-mode) (nth 1 input-mode) 261 (set-input-mode
255 'use-8th-bit (nth 3 input-mode)) 262 (nth 0 saved-input-mode) (nth 1 saved-input-mode)
263 'use-8th-bit (nth 3 saved-input-mode))
256 (setq encoded-kbd-coding 'iso2022-8)) 264 (setq encoded-kbd-coding 'iso2022-8))
257 (make-variable-buffer-local 'encoded-kbd-iso2022-designations) 265 (make-variable-buffer-local 'encoded-kbd-iso2022-designations)
258 (setq encoded-kbd-iso2022-designations (make-vector 4 nil)) 266 (setq encoded-kbd-iso2022-designations (make-vector 4 nil))
259 (let ((flags (coding-system-flags coding)) 267 (let ((flags (coding-system-flags coding))
260 (i 0)) 268 (i 0))
261 (while (< i 4) 269 (while (< i 4)
262 (if (charsetp (aref flags i)) 270 (if (charsetp (aref flags i))
263 (aset encoded-kbd-iso2022-designations i 271 (aset encoded-kbd-iso2022-designations i
264 (aref flags i))) 272 (aref flags i))
273 (if (charsetp (car-safe (aref flags i)))
274 (aset encoded-kbd-iso2022-designations i
275 (car (aref flags i)))))
265 (setq i (1+ i)))) 276 (setq i (1+ i))))
266 (make-variable-buffer-local 'encoded-kbd-iso2022-invocations) 277 (make-variable-buffer-local 'encoded-kbd-iso2022-invocations)
267 (setq encoded-kbd-iso2022-invocations (make-vector 3 nil)) 278 (setq encoded-kbd-iso2022-invocations (make-vector 3 nil))
268 (aset encoded-kbd-iso2022-invocations 0 0) 279 (aset encoded-kbd-iso2022-invocations 0 0)
269 (aset encoded-kbd-iso2022-invocations 1 1)) 280 (aset encoded-kbd-iso2022-invocations 1 1))
270 281
271 ((= (coding-system-type coding) 3) ; BIG5 282 ((= (coding-system-type coding) 3) ; BIG5
272 (set-input-mode (nth 0 input-mode) (nth 1 input-mode) 283 (set-input-mode
273 'use-8th-bit (nth 3 input-mode)) 284 (nth 0 saved-input-mode) (nth 1 saved-input-mode)
285 'use-8th-bit (nth 3 saved-input-mode))
274 (setq encoded-kbd-coding 'big5)) 286 (setq encoded-kbd-coding 'big5))
275 287
276 (t 288 (t
277 (setq encoded-kbd-mode nil) 289 (setq encoded-kbd-mode nil)
278 (error "Coding-system `%s' is not supported in Encoded-kbd mode" 290 (error "Coding-system `%s' is not supported in Encoded-kbd mode"
279 (keyboard-coding-system)))) 291 (keyboard-coding-system))))
280 (setq inactivate-current-input-method-function 'encoded-kbd-mode) 292 (run-hooks 'encoded-kbd-mode-hook))))
281 (setq describe-current-input-method-function 'encoded-kbd-mode-help)
282 (run-hooks 'encoded-kbd-mode-hook))
283 (setq describe-current-input-method-function nil)
284 (setq current-input-method nil))
285 (force-mode-line-update))
286 293
287 ;;; encoded-kb.el ends here 294 ;;; encoded-kb.el ends here