Author: ek.kato
Date: Sun Mar 1 02:15:20 2009
New Revision: 5872
Modified:
trunk/scm/social-ime-custom.scm
trunk/scm/social-ime.scm
Log:
* scm/social-ime.scm
- (social-ime-proc-prediction-state)
- (social-ime-proc-input-state-with-preedit)
- (social-ime-check-prediction)
- (social-ime-proc-input-state)
- Ported from anthy.scm.
- Use pending rk to check prediction string.
* scm/social-ime-custom.scm
- (social-ime-prediction-start-char-count)
- Ditto. Default is set 2.
- (social-ime-select-prediction-by-numeral-key?)
- (social-ime-use-implicit-commit-prediction?)
- (social-ime-prediction-cache-words)
- (social-ime-prediction-start-char-count)
- Add custom hook.
Modified: trunk/scm/social-ime-custom.scm
==============================================================================
--- trunk/scm/social-ime-custom.scm (original)
+++ trunk/scm/social-ime-custom.scm Sun Mar 1 02:15:20 2009
@@ -359,6 +359,18 @@
(N_ "Show selected prediction candidate in preedit area")
(N_ "long description will be here."))
+(define-custom 'social-ime-prediction-cache-words 256
+ '(social-ime-advanced social-ime-prediction)
+ '(integer 1 65535)
+ (N_ "Number of cache of prediction candidates")
+ (N_ "long description will be here."))
+
+(define-custom 'social-ime-prediction-start-char-count 2
+ '(social-ime-advanced social-ime-prediction)
+ '(integer 1 65535)
+ (N_ "Character count to start input prediction")
+ (N_ "long description will be here."))
+
(custom-add-hook 'social-ime-use-candidate-window?
'custom-get-hooks
(lambda ()
@@ -370,8 +382,22 @@
(lambda ()
social-ime-use-candidate-window?))
-(define-custom 'social-ime-prediction-cache-words 256
- '(social-ime-advanced social-ime-prediction)
- '(integer 1 65535)
- (N_ "Number of cache of prediction candidates")
- (N_ "long description will be here."))
+(custom-add-hook 'social-ime-select-prediction-by-numeral-key?
+ 'custom-activity-hooks
+ (lambda ()
+ social-ime-use-prediction?))
+
+(custom-add-hook 'social-ime-use-implicit-commit-prediction?
+ 'custom-activity-hooks
+ (lambda ()
+ social-ime-use-prediction?))
+
+(custom-add-hook 'social-ime-prediction-cache-words
+ 'custom-activity-hooks
+ (lambda ()
+ social-ime-use-prediction?))
+
+(custom-add-hook 'social-ime-prediction-start-char-count
+ 'custom-activity-hooks
+ (lambda ()
+ social-ime-use-prediction?))
Modified: trunk/scm/social-ime.scm
==============================================================================
--- trunk/scm/social-ime.scm (original)
+++ trunk/scm/social-ime.scm Sun Mar 1 02:15:20 2009
@@ -1069,7 +1069,7 @@
(not (shift-key-mask key-state))))
;; go back to unselected prediction
(social-ime-reset-prediction-window sc)
- (social-ime-check-prediction sc))
+ (social-ime-check-prediction sc #f))
((and
(ichar-numeric? key)
social-ime-select-prediction-by-numeral-key?
@@ -1098,6 +1098,10 @@
(social-ime-reset-prediction-window sc)
(social-ime-begin-conv sc))
+ ;; prediction
+ ((social-ime-next-prediction-key? key key-state)
+ (social-ime-check-prediction sc #t))
+
;; backspace
((social-ime-backspace-key? key key-state)
(if (not (rk-backspace rkc))
@@ -1323,14 +1327,27 @@
(social-ime-context-set-prediction-window! sc #f)
(social-ime-context-set-prediction-index! sc #f))
-(define (social-ime-check-prediction sc)
+(define (social-ime-check-prediction sc force-check?)
(if (and
(not (social-ime-context-state sc))
(not (social-ime-context-transposing sc))
(not (social-ime-context-predicting sc)))
- (let ((preconv-str
- (social-ime-make-whole-string sc #t (social-ime-context-kana-mode
sc))))
- (if (not (string=? preconv-str ""))
+ (let* ((use-pending-rk-for-prediction? #t)
+ (preconv-str
+ (social-ime-make-whole-string
+ sc
+ (not use-pending-rk-for-prediction?)
+ (social-ime-context-kana-mode sc)))
+ (preedit-len (+
+ (ustr-length (social-ime-context-preconv-ustr sc))
+ (if (not use-pending-rk-for-prediction?)
+ 0
+ (string-length (rk-pending
+ (social-ime-context-rkc
+ sc)))))))
+ (if (or
+ (>= preedit-len social-ime-prediction-start-char-count)
+ force-check?)
(begin
(social-ime-lib-set-prediction-src-string sc preconv-str)
(let ((nr (social-ime-lib-get-nr-predictions sc)))
@@ -1350,7 +1367,7 @@
(social-ime-proc-input-state-with-preedit sc key key-state)
(social-ime-proc-input-state-no-preedit sc key key-state))
(if social-ime-use-prediction?
- (social-ime-check-prediction sc)))
+ (social-ime-check-prediction sc #f)))
(define social-ime-separator
(lambda (sc)