comparison lisp/international/kkc.el @ 30251:9a4962f4ea62

(kkc-show-conversion-list-count): Customize it. (kkc-region): Update kkc-next-count and kkc-prev-count here. Show the conversion list at first if appropriate. (kkc-next): Don't update kkc-next-count here. (kkc-prev): Don't update kkc-prev-count here. (kkc-show-conversion-list-update): Fix setting up of conversion list message.
author Kenichi Handa <handa@m17n.org>
date Mon, 17 Jul 2000 01:22:09 +0000
parents ded7fa3de6db
children e4b4bca5087a
comparison
equal deleted inserted replaced
30250:bf443dabe303 30251:9a4962f4ea62
129 ;; The remaining elements are widths (including columns for index 129 ;; The remaining elements are widths (including columns for index
130 ;; numbers) of conversions stored in the same order as in 130 ;; numbers) of conversions stored in the same order as in
131 ;; `kkc-current-conversion'. 131 ;; `kkc-current-conversion'.
132 (defvar kkc-current-conversions-width nil) 132 (defvar kkc-current-conversions-width nil)
133 133
134 (defvar kkc-show-conversion-list-count 4 134 (defcustom kkc-show-conversion-list-count 4
135 "Count of successive `kkc-next' or `kkc-prev' to show conversion list.") 135 "*Count of successive `kkc-next' or `kkc-prev' to show conversion list.
136 When you type SPC or C-p successively this count while using the input
137 method `japanese', the conversion candidates are shown in the echo
138 area while indicating the current selection by `<N>'."
139 :group 'mule
140 :type 'integer)
141
142 ;; Count of successive invocations of `kkc-next'.
143 (defvar kkc-next-count nil)
144
145 ;; Count of successive invocations of `kkc-prev'.
146 (defvar kkc-prev-count nil)
136 147
137 ;; Provided that `kkc-current-key' is [A B C D E F G H I], the current 148 ;; Provided that `kkc-current-key' is [A B C D E F G H I], the current
138 ;; conversion target is [A B C D E F], and the sequence of which 149 ;; conversion target is [A B C D E F], and the sequence of which
139 ;; conversion is found is [A B C D]: 150 ;; conversion is found is [A B C D]:
140 ;; 151 ;;
235 (while (not (kkc-lookup-key kkc-length-head nil first)) 246 (while (not (kkc-lookup-key kkc-length-head nil first))
236 (setq kkc-length-head (1- kkc-length-head) 247 (setq kkc-length-head (1- kkc-length-head)
237 first nil)) 248 first nil))
238 (goto-char to) 249 (goto-char to)
239 (kkc-update-conversion 'all) 250 (kkc-update-conversion 'all)
251 (setq kkc-next-count 1 kkc-prev-count 0)
252 (if (and (>= kkc-next-count kkc-show-conversion-list-count)
253 (>= (length kkc-current-conversions) 3))
254 (kkc-show-conversion-list-or-next-group))
240 255
241 ;; Then, ask users to select a desirable conversion. 256 ;; Then, ask users to select a desirable conversion.
242 (force-mode-line-update) 257 (force-mode-line-update)
243 (setq kkc-converting t) 258 (setq kkc-converting t)
244 (while kkc-converting 259 (while kkc-converting
247 (help-char nil) 262 (help-char nil)
248 (keyseq (read-key-sequence nil)) 263 (keyseq (read-key-sequence nil))
249 (cmd (lookup-key kkc-keymap keyseq))) 264 (cmd (lookup-key kkc-keymap keyseq)))
250 (if (commandp cmd) 265 (if (commandp cmd)
251 (condition-case err 266 (condition-case err
252 (call-interactively cmd) 267 (progn
268 (cond ((eq cmd 'kkc-next)
269 (setq kkc-next-count (1+ kkc-next-count)
270 kkc-prev-count 0))
271 ((eq cmd 'kkc-prev)
272 (setq kkc-prev-count (1+ kkc-prev-count)
273 kkc-next-count 0))
274 (t
275 (setq kkc-next-count 0 kkc-prev-count 0)))
276 (call-interactively cmd))
253 (kkc-error (message "%s" (cdr err)) (beep))) 277 (kkc-error (message "%s" (cdr err)) (beep)))
254 ;; KEYSEQ is not defined in KKC keymap. 278 ;; KEYSEQ is not defined in KKC keymap.
255 ;; Let's put the event back. 279 ;; Let's put the event back.
256 (setq unread-input-method-events 280 (setq unread-input-method-events
257 (append (string-to-list keyseq) 281 (append (string-to-list keyseq)
286 (goto-char (overlay-start kkc-overlay-head)) 310 (goto-char (overlay-start kkc-overlay-head))
287 (forward-char 1) 311 (forward-char 1)
288 (delete-region (point) (overlay-end kkc-overlay-tail)) 312 (delete-region (point) (overlay-end kkc-overlay-tail))
289 (kkc-terminate)) 313 (kkc-terminate))
290 314
291 ;; Count of successive invocations of `kkc-next'.
292 (defvar kkc-next-count nil)
293
294 (defun kkc-next () 315 (defun kkc-next ()
295 "Select the next candidate of conversion." 316 "Select the next candidate of conversion."
296 (interactive) 317 (interactive)
297 (if (eq this-command last-command)
298 (setq kkc-next-count (1+ kkc-next-count))
299 (setq kkc-next-count 1))
300 (let ((idx (1+ (car kkc-current-conversions)))) 318 (let ((idx (1+ (car kkc-current-conversions))))
301 (if (< idx 0) 319 (if (< idx 0)
302 (setq idx 1)) 320 (setq idx 1))
303 (if (>= idx (length kkc-current-conversions)) 321 (if (>= idx (length kkc-current-conversions))
304 (setq idx 0)) 322 (setq idx 0))
311 (if (or kkc-current-conversions-width 329 (if (or kkc-current-conversions-width
312 (>= kkc-next-count kkc-show-conversion-list-count)) 330 (>= kkc-next-count kkc-show-conversion-list-count))
313 (kkc-show-conversion-list-update)) 331 (kkc-show-conversion-list-update))
314 (kkc-update-conversion))) 332 (kkc-update-conversion)))
315 333
316 ;; Count of successive invocations of `kkc-next'.
317 (defvar kkc-prev-count nil)
318
319 (defun kkc-prev () 334 (defun kkc-prev ()
320 "Select the previous candidate of conversion." 335 "Select the previous candidate of conversion."
321 (interactive) 336 (interactive)
322 (if (eq this-command last-command)
323 (setq kkc-prev-count (1+ kkc-prev-count))
324 (setq kkc-prev-count 1))
325 (let ((idx (1- (car kkc-current-conversions)))) 337 (let ((idx (1- (car kkc-current-conversions))))
326 (if (< idx 0) 338 (if (< idx 0)
327 (setq idx (1- (length kkc-current-conversions)))) 339 (setq idx (1- (length kkc-current-conversions))))
328 (setcar kkc-current-conversions idx) 340 (setcar kkc-current-conversions idx)
329 (if (> idx 1) 341 (if (> idx 1)
539 (width-table kkc-current-conversions-width) 551 (width-table kkc-current-conversions-width)
540 (width 0) 552 (width 0)
541 (idx this-idx) 553 (idx this-idx)
542 (max-items (length kkc-show-conversion-list-index-chars)) 554 (max-items (length kkc-show-conversion-list-index-chars))
543 l) 555 l)
544 (while (< idx current-idx) 556 ;; Set THIS-IDX to the first index of conversion to be shown
557 ;; in MSG, and reflect it in kkc-current-conversions-width.
558 (while (<= idx current-idx)
545 (if (and (<= (+ width (aref width-table idx)) max-width) 559 (if (and (<= (+ width (aref width-table idx)) max-width)
546 (< (- idx this-idx) max-items)) 560 (< (- idx this-idx) max-items))
547 (setq width (+ width (aref width-table idx))) 561 (setq width (+ width (aref width-table idx)))
548 (setq this-idx idx width (aref width-table idx))) 562 (setq this-idx idx width (aref width-table idx)))
549 (setq idx (1+ idx) 563 (setq idx (1+ idx)
550 l (cdr l))) 564 l (cdr l)))
551 (aset first-slot 0 this-idx) 565 (aset first-slot 0 this-idx)
566 ;; Set NEXT-IDX to the next index of the last conversion
567 ;; shown in MSG, and reflect it in
568 ;; kkc-current-conversions-width.
552 (while (and (< idx len) 569 (while (and (< idx len)
553 (<= (+ width (aref width-table idx)) max-width) 570 (<= (+ width (aref width-table idx)) max-width)
554 (< (- idx this-idx) max-items)) 571 (< (- idx this-idx) max-items))
555 (setq width (+ width (aref width-table idx)) 572 (setq width (+ width (aref width-table idx))
556 idx (1+ idx) 573 idx (1+ idx)
557 l (cdr l))) 574 l (cdr l)))
558 (aset first-slot 1 (setq next-idx idx)) 575 (aset first-slot 1 (setq next-idx idx))
559 (setq l (nthcdr this-idx kkc-current-conversions)) 576 (setq l (nthcdr this-idx kkc-current-conversions))
560 (setq msg "") 577 (setq msg (format " %c %s"
561 (setq idx this-idx) 578 (aref kkc-show-conversion-list-index-chars 0)
579 (car l))
580 idx (1+ this-idx)
581 l (cdr l))
562 (while (< idx next-idx) 582 (while (< idx next-idx)
563 (setq msg (format "%s %c %s " 583 (setq msg (format "%s %c %s"
564 msg 584 msg
565 (aref kkc-show-conversion-list-index-chars 585 (aref kkc-show-conversion-list-index-chars
566 (- idx this-idx)) 586 (- idx this-idx))
567 (car l))) 587 (car l)))
568 (setq idx (1+ idx) 588 (setq idx (1+ idx)