Author: ek.kato
Date: Sun Mar 1 01:50:42 2009
New Revision: 5871
Modified:
trunk/scm/anthy-custom.scm
trunk/scm/anthy-utf8-custom.scm
trunk/scm/anthy-utf8.scm
trunk/scm/anthy.scm
Log:
* Add custom setting to check pre-converting string length to
begin input prediction with anthy.
* scm/anthy-custom.scm
* scm/anthy-utf8-custom.scm
- (anthy-prediction-start-char-count) : New. Default is 1.
* scm/anthy.scm
- (anthy-proc-input-state-with-preedit) : Examine
anthy-next-prediction-key? to force to get prediction.
- (anthy-check-prediction)
- Add force-check? argument.
- Check the preedit string length to begin input prediction.
- (anthy-proc-input-state) : Don't check prediction when the
state is already changed.
Modified: trunk/scm/anthy-custom.scm
==============================================================================
--- trunk/scm/anthy-custom.scm (original)
+++ trunk/scm/anthy-custom.scm Sun Mar 1 01:50:42 2009
@@ -313,6 +313,12 @@
(N_ "Show selected prediction candidate in preedit area")
(N_ "long description will be here."))
+(define-custom 'anthy-prediction-start-char-count 1
+ '(anthy-advanced prediction)
+ '(integer 1 65535)
+ (N_ "Character count to start input prediction")
+ (N_ "long description will be here."))
+
(custom-add-hook 'anthy-use-candidate-window?
'custom-get-hooks
(lambda ()
@@ -330,6 +336,11 @@
anthy-use-prediction?))
(custom-add-hook 'anthy-use-implicit-commit-prediction?
+ 'custom-activity-hooks
+ (lambda ()
+ anthy-use-prediction?))
+
+(custom-add-hook 'anthy-prediction-start-char-count
'custom-activity-hooks
(lambda ()
anthy-use-prediction?))
Modified: trunk/scm/anthy-utf8-custom.scm
==============================================================================
--- trunk/scm/anthy-utf8-custom.scm (original)
+++ trunk/scm/anthy-utf8-custom.scm Sun Mar 1 01:50:42 2009
@@ -320,6 +320,12 @@
(N_ "Show selected prediction candidate in preedit area")
(N_ "long description will be here."))
+(define-custom 'anthy-prediction-start-char-count 1
+ '(anthy-advanced prediction)
+ '(integer 1 65535)
+ (N_ "Character count to start input prediction")
+ (N_ "long description will be here."))
+
(custom-add-hook 'anthy-use-candidate-window?
'custom-get-hooks
(lambda ()
@@ -337,6 +343,11 @@
anthy-use-prediction?))
(custom-add-hook 'anthy-use-implicit-commit-prediction?
+ 'custom-activity-hooks
+ (lambda ()
+ anthy-use-prediction?))
+
+(custom-add-hook 'anthy-prediction-start-char-count
'custom-activity-hooks
(lambda ()
anthy-use-prediction?))
Modified: trunk/scm/anthy-utf8.scm
==============================================================================
--- trunk/scm/anthy-utf8.scm (original)
+++ trunk/scm/anthy-utf8.scm Sun Mar 1 01:50:42 2009
@@ -1023,7 +1023,7 @@
(not (shift-key-mask key-state))))
;; go back to unselected prediction
(anthy-utf8-reset-prediction-window ac)
- (anthy-utf8-check-prediction ac))
+ (anthy-utf8-check-prediction ac #f))
((and
(ichar-numeric? key)
anthy-select-prediction-by-numeral-key?
@@ -1053,7 +1053,11 @@
((anthy-begin-conv-key? key key-state)
(anthy-utf8-reset-prediction-window ac)
(anthy-utf8-begin-conv ac))
-
+
+ ;; prediction
+ ((anthy-next-prediction-key? key key-state)
+ (anthy-utf8-check-prediction ac #t))
+
;; backspace
((anthy-backspace-key? key key-state)
(if (not (rk-backspace rkc))
@@ -1319,17 +1323,31 @@
(anthy-utf8-context-set-prediction-index! ac #f)))
(define anthy-utf8-check-prediction
- (lambda (ac)
+ (lambda (ac force-check?)
(if (and
(not (anthy-utf8-context-converting ac))
(not (anthy-utf8-context-transposing ac))
(not (anthy-utf8-context-predicting ac)))
- (let ((preconv-str
- (anthy-utf8-make-whole-string ac #t (anthy-utf8-context-kana-mode
ac)))
- (ac-id (anthy-utf8-context-ac-id ac)))
- (if (not (string=? preconv-str ""))
+ (let* ((use-pending-rk-for-prediction? #f)
+ (preconv-str
+ (anthy-utf8-make-whole-string
+ ac
+ (not use-pending-rk-for-prediction?)
+ (anthy-utf8-context-kana-mode ac)))
+ (ac-id (anthy-utf8-context-ac-id ac))
+ (preedit-len
+ (+
+ (ustr-length (anthy-utf8-context-preconv-ustr ac))
+ (if (not use-pending-rk-for-prediction?)
+ 0
+ (string-length
+ (rk-pending (anthy-utf8-context-rkc ac)))))))
+ (if (or
+ (>= preedit-len anthy-prediction-start-char-count)
+ force-check?)
(begin
- (anthy-utf8-lib-set-prediction-src-string ac-id
(anthy-utf8-lib-eucjp-to-utf8 preconv-str))
+ (anthy-utf8-lib-set-prediction-src-string
+ ac-id (anthy-utf8-lib-eucjp-to-utf8 preconv-str))
(let ((nr (anthy-utf8-lib-get-nr-predictions ac-id)))
(if (and
nr
@@ -1348,8 +1366,9 @@
(anthy-utf8-proc-input-state-with-preedit ac key key-state)
(anthy-utf8-proc-input-state-no-preedit ac key key-state))
(if (and
- anthy-use-prediction?)
- (anthy-utf8-check-prediction ac))))
+ anthy-use-prediction?
+ (not (anthy-utf8-context-predicting ac)))
+ (anthy-utf8-check-prediction ac #f))))
(define anthy-separator
(lambda (ac)
Modified: trunk/scm/anthy.scm
==============================================================================
--- trunk/scm/anthy.scm (original)
+++ trunk/scm/anthy.scm Sun Mar 1 01:50:42 2009
@@ -1018,7 +1018,7 @@
(not (shift-key-mask key-state))))
;; go back to unselected prediction
(anthy-reset-prediction-window ac)
- (anthy-check-prediction ac))
+ (anthy-check-prediction ac #f))
((and
(ichar-numeric? key)
anthy-select-prediction-by-numeral-key?
@@ -1048,7 +1048,11 @@
((anthy-begin-conv-key? key key-state)
(anthy-reset-prediction-window ac)
(anthy-begin-conv ac))
-
+
+ ;; prediction
+ ((anthy-next-prediction-key? key key-state)
+ (anthy-check-prediction ac #t))
+
;; backspace
((anthy-backspace-key? key key-state)
(if (not (rk-backspace rkc))
@@ -1314,15 +1318,25 @@
(anthy-context-set-prediction-index! ac #f)))
(define anthy-check-prediction
- (lambda (ac)
+ (lambda (ac force-check?)
(if (and
(not (anthy-context-converting ac))
(not (anthy-context-transposing ac))
(not (anthy-context-predicting ac)))
- (let ((preconv-str
- (anthy-make-whole-string ac #t (anthy-context-kana-mode ac)))
- (ac-id (anthy-context-ac-id ac)))
- (if (not (string=? preconv-str ""))
+ (let* ((use-pending-rk-for-prediction? #f)
+ (preconv-str
+ (anthy-make-whole-string ac #t (anthy-context-kana-mode ac)))
+ (ac-id (anthy-context-ac-id ac))
+ (preedit-len
+ (+
+ (ustr-length (anthy-context-preconv-ustr ac))
+ (if (not use-pending-rk-for-prediction?)
+ 0
+ (string-length
+ (rk-pending (anthy-context-rkc ac)))))))
+ (if (or
+ (>= preedit-len anthy-prediction-start-char-count)
+ force-check?)
(begin
(anthy-lib-set-prediction-src-string ac-id preconv-str)
(let ((nr (anthy-lib-get-nr-predictions ac-id)))
@@ -1343,8 +1357,9 @@
(anthy-proc-input-state-with-preedit ac key key-state)
(anthy-proc-input-state-no-preedit ac key key-state))
(if (and
- anthy-use-prediction?)
- (anthy-check-prediction ac))))
+ anthy-use-prediction?
+ (not (anthy-context-predicting ac)))
+ (anthy-check-prediction ac #f))))
(define anthy-separator
(lambda (ac)