Revision: 7370
Author: deton.kih
Date: Mon Nov 21 14:06:45 2011
Log: * Fix division by zero error on delay showing bushu prediction
with
no candidates for "YA"(hiragana) after bushu prediction candidates
for "A"(hiragana) are shown and "A" is deleted by backspace.
* scm/tutcode.scm
- (tutcode-check-bushu-prediction-make):
Move common codes from tutcode-check-bushu-prediction-{tc21,tc23}.
- (tutcode-check-bushu-prediction-tc21):
Rename to tutcode-bushu-predict-tc21.
- (tutcode-bushu-predict-tc21):
Rename from tutcode-check-bushu-prediction-tc21.
Change not to depend on tutcode context.
- (tutcode-check-bushu-prediction-tc23):
Rename to tutcode-bushu-predict-tc23.
- (tutcode-bushu-predict-tc23):
Rename from tutcode-check-bushu-prediction-tc23.
Change not to depend on tutcode context.
- (tutcode-bushu-prediction-make-page):
Change to return #f for no candidates.
- (tutcode-delay-activating-handler):
Change to check return value of tutcode-bushu-prediction-make-page.
http://code.google.com/p/uim/source/detail?r=7370
Modified:
/trunk/scm/tutcode.scm
=======================================
--- /trunk/scm/tutcode.scm Fri Nov 18 15:47:55 2011
+++ /trunk/scm/tutcode.scm Mon Nov 21 14:06:45 2011
@@ -2631,50 +2631,47 @@
;;; Éô¼ó¹çÀ®ÊÑ´¹Ãæ¤Ëͽ¬ÆþÎϸõÊä¤ò¸¡º÷¤·¤Æ¸õÊä¥ê¥¹¥È¤òºîÀ®¤¹¤ë
;;; @param char ÆþÎϤµ¤ì¤¿Éô¼ó1
;;; @param show-candwin?
¸õÊä¥ê¥¹¥È¤ÎºîÀ®¸å¸õÊ䥦¥£¥ó¥É¥¦¤Îɽ¼¨¤ò¹Ô¤¦¤«¤É¤¦¤«
+;;; @return #t:ɽ¼¨¤¹¤ë¸õÊ䤢¤ê, #f:ɽ¼¨¤¹¤ë¸õÊä¤Ê¤·
(define (tutcode-check-bushu-prediction-make pc char show-candwin?)
- (case tutcode-bushu-conversion-algorithm
- ((tc-2.3.1-22.6)
- (tutcode-check-bushu-prediction-tc23 pc char show-candwin?))
- (else ; 'tc-2.1+ml1925
- (tutcode-check-bushu-prediction-tc21 pc char show-candwin?))))
+ (let ((res
+ (case tutcode-bushu-conversion-algorithm
+ ((tc-2.3.1-22.6)
+ (tutcode-bushu-predict-tc23 char))
+ (else ; 'tc-2.1+ml1925
+ (tutcode-bushu-predict-tc21 char)))))
+ (tutcode-context-set-prediction-bushu! pc res)
+ (tutcode-context-set-prediction-bushu-page-start! pc 0)
+ (tutcode-bushu-prediction-make-page pc 0 show-candwin?)))
;;; Éô¼ó¹çÀ®ÊÑ´¹Ãæ¤Ëͽ¬ÆþÎϸõÊä¤ò¸¡º÷¤·¤Æ¸õÊä¥ê¥¹¥È¤òºîÀ®¤¹¤ë
;;; @param char ÆþÎϤµ¤ì¤¿Éô¼ó1
-;;; @param show-candwin?
¸õÊä¥ê¥¹¥È¤ÎºîÀ®¸å¸õÊ䥦¥£¥ó¥É¥¦¤Îɽ¼¨¤ò¹Ô¤¦¤«¤É¤¦¤«
-(define (tutcode-check-bushu-prediction-tc21 pc char show-candwin?)
- (if (eq? (tutcode-context-predicting pc) 'tutcode-predicting-off)
- (let* ((res (tutcode-bushu-predict char tutcode-bushudic))
- (alt (assoc char tutcode-bushudic-altchar))
- (altres
- (if alt
- (tutcode-bushu-predict (cadr alt) tutcode-bushudic)
- ()))
- (resall (append res altres)))
- (tutcode-context-set-prediction-bushu! pc resall)
- (tutcode-context-set-prediction-bushu-page-start! pc 0)
- (tutcode-bushu-prediction-make-page pc 0 show-candwin?))))
+;;; @return (<Éô¼ó2> <¹çÀ®Ê¸»ú>)¤Î¥ê¥¹¥È
+(define (tutcode-bushu-predict-tc21 char)
+ (let* ((res (tutcode-bushu-predict char tutcode-bushudic))
+ (alt (assoc char tutcode-bushudic-altchar))
+ (altres
+ (if alt
+ (tutcode-bushu-predict (cadr alt) tutcode-bushudic)
+ ()))
+ (resall (append res altres)))
+ resall))
;;; Éô¼ó¹çÀ®ÊÑ´¹Ãæ¤Ëͽ¬ÆþÎϸõÊä¤ò¸¡º÷¤·¤Æ¸õÊä¥ê¥¹¥È¤òºîÀ®¤¹¤ë
;;; @param char ÆþÎϤµ¤ì¤¿Éô¼ó1
-;;; @param show-candwin?
¸õÊä¥ê¥¹¥È¤ÎºîÀ®¸å¸õÊ䥦¥£¥ó¥É¥¦¤Îɽ¼¨¤ò¹Ô¤¦¤«¤É¤¦¤«
-(define (tutcode-check-bushu-prediction-tc23 pc char show-candwin?)
- (if (eq? (tutcode-context-predicting pc) 'tutcode-predicting-off)
- (let*
- ((gosei (tutcode-bushu-compose-tc23 (list char) #f))
- (res
- (map
- (lambda (elem)
- (list #f elem))
- gosei)))
- (tutcode-context-set-prediction-bushu! pc res)
- (tutcode-context-set-prediction-bushu-page-start! pc 0)
- (tutcode-bushu-prediction-make-page pc 0 show-candwin?))))
+;;; @return (<Éô¼ó2> <¹çÀ®Ê¸»ú>)¤Î¥ê¥¹¥È
+(define (tutcode-bushu-predict-tc23 char)
+ (let ((gosei (tutcode-bushu-compose-tc23 (list char) #f)))
+ (map
+ (lambda (elem)
+ (list #f elem))
+ gosei)))
;;; Éô¼ó¹çÀ®ÊÑ´¹¤Îͽ¬ÆþÎϸõÊä¤Î¤¦¤Á¡¢
;;; »ØÄꤵ¤ì¤¿Èֹ椫¤é»Ï¤Þ¤ë1¥Ú¡¼¥¸¤Ö¤ó¤Î¸õÊä¥ê¥¹¥È¤òºîÀ®¤¹¤ë¡£
;;; @param start-index ³«»ÏÈÖ¹æ
;;; @param show-candwin?
¸õÊä¥ê¥¹¥È¤ÎºîÀ®¸å¸õÊ䥦¥£¥ó¥É¥¦¤Îɽ¼¨¤ò¹Ô¤¦¤«¤É¤¦¤«¡£
;;; #f¤Î¾ì¹ç¤Ï¡¢¸õÊä¥ê¥¹¥È¤ÎºîÀ®¤Î¤ß¹Ô¤¦(delay-activating-handler»þ)
+;;; @return #t:ɽ¼¨¤¹¤ë¸õÊ䤢¤ê, #f:ɽ¼¨¤¹¤ë¸õÊä¤Ê¤·
(define (tutcode-bushu-prediction-make-page pc start-index show-candwin?)
(tutcode-lib-set-bushu-prediction pc start-index)
(let ((nr (tutcode-lib-get-nr-predictions pc)))
@@ -2700,7 +2697,10 @@
(if show-candwin?
(tutcode-activate-candidate-window pc
'tutcode-candidate-window-predicting
- 0 nr-all page-limit))))))))
+ 0 nr-all page-limit))
+ #t)
+ #f))
+ #f)))
;;; Êä´°¸õÊä¤È½Ï¸ì¥¬¥¤¥Éɽ¼¨¤Î¤¿¤á¤ÎcandwinÍѥѥé¥á¡¼¥¿¤ò·×»»¤¹¤ë
;;; @param nr Êä´°¸õÊä¿ô
@@ -5377,10 +5377,11 @@
'tutcode-candidate-window-predicting)
(case (tutcode-context-state tc)
((tutcode-state-bushu)
- (tutcode-check-bushu-prediction-make tc
- (tutcode-context-prediction-bushu tc) #f) ;
¸õÊä¥ê¥¹¥ÈºîÀ®
- (list (tutcode-context-prediction-page-limit tc)
- (tutcode-context-prediction-nr-all tc)))
+ (if (tutcode-check-bushu-prediction-make tc
+ (tutcode-context-prediction-bushu tc)
#f) ;¸õÊä¥ê¥¹¥ÈºîÀ®
+ (list (tutcode-context-prediction-page-limit tc)
+ (tutcode-context-prediction-nr-all tc))
+ (list (tutcode-context-prediction-page-limit tc) 0)))
((tutcode-state-on)
(if (tutcode-check-completion-make tc #f 0)
(list (tutcode-context-prediction-page-limit tc)