Commit 75a304b7 authored by Kenichi Handa's avatar Kenichi Handa
Browse files

(quail-indian-update-translation): Adjusted the

behaviour according to the change of quail-translate-key.
parent b909e366
...@@ -48,34 +48,41 @@ ...@@ -48,34 +48,41 @@
(defvar quail-indian-update-preceding-char nil) (defvar quail-indian-update-preceding-char nil)
(make-variable-frame-local 'quail-indian-update-preceding-char) (make-variable-frame-local 'quail-indian-update-preceding-char)
;;; update function ;; Input value ::
;; CONTROL-FLAG is integer `n'
;; CONTROL-FLAG is integer (n)
;; quail-current-key :: keyboard input. ;; quail-current-key :: keyboard input.
;; Only first n can be translated. ;; Only first `n' can be translated.
;; quail-current-string :: corresonding string. Translated when last ;; quail-current-str :: corresonding string.
;; time CONTROL-FLAG is nil. ;; jobs :: (1) put last (len-n) char to unrread-command-event.
;; todo :: (1) put last (len-n) char to unrread-command-event. ;; (2) put translated string to quail-current-str.
;; (2) put translated string to quail-current-string.
;; ;;
;; CONTROL-FLAG is t (terminate) or nil (proceed the translation) ;; CONTROL-FLAG is t (terminate) or nil (proceed the translation)
;; quail-current-key :: keyboard input. ;; quail-current-key :: keyboard input.
;; quail-current-string :: corresponding string. Created by database. ;; quail-current-str :: corresponding string.
;; todo :: (1) put modified translated string to quail-current-string. ;; jobs :: (1) put modified translated string to quail-current-str.
;;
;; When non-nil value is returned from quail-translation-update-function,
;; the quail-current-str is split to characters and put into event queue,
;; with `compose-last-char' event with composition info at the end.
(defun quail-indian-update-translation (control-flag) (defun quail-indian-update-translation (control-flag)
;;(message "input control-flag=%s, string=%s, key=%s"
;; control-flag quail-current-str quail-current-key)
;; make quail-current-str string when possible. ;; make quail-current-str string when possible.
(if (char-valid-p quail-current-str) (if (char-valid-p quail-current-str)
(setq quail-current-str (char-to-string quail-current-str))) (setq quail-current-str (char-to-string quail-current-str)))
;(message "\n input control-flag=%s, str=%s, key=%s q-ind-upd-prec-char=%s"
; control-flag quail-current-str quail-current-key
; quail-indian-update-preceding-char)
;; reset quail-indian-update-preceding-char if it's initial. ;; reset quail-indian-update-preceding-char if it's initial.
(if (= (overlay-start quail-overlay) (overlay-end quail-overlay)) (if (= (overlay-start quail-overlay) (overlay-end quail-overlay))
(setq quail-indian-update-preceding-char nil)) (setq quail-indian-update-preceding-char nil))
;; set quial-indian-update-preceding-char if appropriate. ;; Check the preceding character of the quail region. If the
;; preceding character can be composed with quail-current-str, then
;; grab that preceding character into the quail-current-str and
;; remove that char from the region.
(let* (prec-char-position composition-regexp (let* (prec-char-position composition-regexp
prec-char-str candidate-str match-pos match-end) prec-char-str candidate-str match-pos match-end)
(when (and quail-current-str (when (and quail-current-str
(null quail-indian-update-preceding-char)
(null input-method-use-echo-area) (null input-method-use-echo-area)
(null input-method-exit-on-first-char) (null input-method-exit-on-first-char)
(setq prec-char-position (setq prec-char-position
...@@ -85,7 +92,6 @@ ...@@ -85,7 +92,6 @@
(if prec-char-position (if prec-char-position
(caar (elt composition-function-table (caar (elt composition-function-table
(char-after prec-char-position))))) (char-after prec-char-position)))))
;; (null quail-indian-update-preceding-char)
(setq prec-char-str (setq prec-char-str
(buffer-substring prec-char-position (buffer-substring prec-char-position
(overlay-start quail-overlay)) (overlay-start quail-overlay))
...@@ -96,31 +102,19 @@ ...@@ -96,31 +102,19 @@
(setq quail-indian-update-preceding-char prec-char-str) (setq quail-indian-update-preceding-char prec-char-str)
(delete-region prec-char-position (delete-region prec-char-position
(overlay-start quail-overlay)))) (overlay-start quail-overlay))))
;; make quail-current-str string when possible. (setq quail-current-str
(if (null quail-current-str) (indian-compose-string
(setq quail-current-str "")) (concat quail-indian-update-preceding-char
;; set quail-current-str unless control-flag is number. quail-current-str)))
(if (numberp control-flag) (if (numberp control-flag)
(setq quail-indian-update-preceding-char nil (setq unread-command-events
quail-current-str
(if (equal quail-current-str "")
(substring quail-current-key 0 control-flag)
(indian-compose-string quail-current-str))
unread-command-events
(string-to-list (string-to-list
(substring quail-current-key control-flag))) (substring quail-current-key control-flag))))
(if quail-indian-update-preceding-char (when control-flag
(setq quail-current-str
(concat quail-indian-update-preceding-char
quail-current-str)))
(setq quail-current-str
(indian-compose-string quail-current-str)))
(when (eq t control-flag)
;; reset preceding-char if translation is terminated.
(setq quail-indian-update-preceding-char nil)) (setq quail-indian-update-preceding-char nil))
;; compose to previous char if it looks possible. ;(message "output control-flag=%s, str=%s, key=%s q-ind-upd-prec-char=%s"
;;(message " out control-flag=%s, string=%s, key=%s" ; control-flag quail-current-str quail-current-key
;; control-flag quail-current-str quail-current-key) ; quail-indian-update-preceding-char)
control-flag) control-flag)
;;; ;;;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment