Revision: 6816
Author: deton.kih
Date: Sat Nov 13 16:01:52 2010
Log: * Change of kanji combination guide to check Yomi in prediction mode.
* scm/tutcode.scm
  - (tutcode-lib-set-prediction-src-string):
    Change to return all yomi returned from predict search.
  - (tutcode-guide-set-candidates):
    Add argument all-yomi.
    Add check of all-yomi for guide in prediction mode.
  - (tutcode-check-completion):
    Follow the change of tutcode-guide-set-candidates.
  - (tutcode-check-prediction):
    Change to pass all-yomi returned from
    tutcode-lib-set-prediction-src-string to tutcode-guide-set-candidates.

http://code.google.com/p/uim/source/detail?r=6816

Modified:
 /trunk/scm/tutcode.scm

=======================================
--- /trunk/scm/tutcode.scm      Fri Nov 12 23:29:29 2010
+++ /trunk/scm/tutcode.scm      Sat Nov 13 16:01:52 2010
@@ -189,6 +189,8 @@
 (define tutcode-stroke-help-top-page-alist ())
 ;;; stroke-help¤Ç¡¢²¿¤â¥­¡¼ÆþÎϤ¬Ìµ¤¤¾ì¹ç¤Ëɽ¼¨¤¹¤ëÆâÍÆ¤Îalist¡£
 ;;; ¥«¥¿¥«¥Ê¥â¡¼¥ÉÍÑ¡£
+;;; (XXX:¥­¡¼ÆþÎÏÍ­¤Î¾ì¹ç¤â¥­¥ã¥Ã¥·¥å¤ò»È¤¦¤è¤¦¤Ë¤¹¤ë?
+;;;  ¤â¤·¤½¤¦¤¹¤ì¤Ð¡¢~/.uim¤Ç²¾ÁÛ¸°È×ɽ¼¨ÆâÍÆ¤Î¥«¥¹¥¿¥Þ¥¤¥º¤âÍÆ°×¤Ë¤Ê¤ë)
 (define tutcode-stroke-help-top-page-katakana-alist ())

 ;;; ¥³¡¼¥Éɽ¤ò¾å½ñ¤­Êѹ¹/Äɲ乤뤿¤á¤Î¥³¡¼¥Éɽ¡£
@@ -543,6 +545,7 @@
 ;;; Êä´°/ͽ¬ÆþÎϸõÊä¤ò¸¡º÷
 ;;; @param str ¸¡º÷ʸ»úÎó
 ;;; @param completion? Êä´°¤Î¾ì¹ç¤Ï#t
+;;; @return ½ÅÊ£½üµîÁ°¤ÎÁ´¤Æ¤ÎÆÉ¤ß¤Î¥ê¥¹¥È(½Ï¸ì¥¬¥¤¥ÉÍÑ)
 (define (tutcode-lib-set-prediction-src-string pc str completion?)
   (let* ((ret      (tutcode-predict pc str))
          (word     (predict-meta-word? ret))
@@ -587,8 +590,8 @@
           filtered-cands)
         filtered-cands))
     (tutcode-context-set-prediction-appendix! pc filtered-appendix)
-    (tutcode-context-set-prediction-nr! pc (length filtered-cands)))
-  #f)
+    (tutcode-context-set-prediction-nr! pc (length filtered-cands))
+    word))
 (define (tutcode-lib-get-nr-predictions pc)
   (tutcode-context-prediction-nr pc))
 (define (tutcode-lib-get-nth-word pc nth)
@@ -619,8 +622,10 @@
 ;;; ½Ï¸ì¥¬¥¤¥Éɽ¼¨ÍѸõÊä¥ê¥¹¥È¤òÊä´°/ͽ¬ÆþÎϸõÊ䤫¤éºîÀ®¤¹¤ë
 ;;; @param str Êä´°/ͽ¬ÆþÎϸõÊä¤Î¸¡º÷»þ¤Ë»ÈÍѤ·¤¿Ê¸»úÎó=ÆþÎϺÑʸ»úÎó
 ;;; @param completion? Êä´°»þ¤Ï#t
-(define (tutcode-guide-set-candidates pc str completion?)
+;;; @param all-yomi ͽ¬ÆþÎϸõÊ両º÷·ë²Ì¤Ë´Þ¤Þ¤ì¤ëÁ´¤Æ¤ÎÆÉ¤ß
+(define (tutcode-guide-set-candidates pc str completion? all-yomi)
   (let* ((cands (tutcode-context-prediction-candidates pc))
+         (word all-yomi)
          (strlen (string-length str))
          (filtered-cands
           (if (not completion?)
@@ -632,20 +637,36 @@
                   (string=? str (substring cand 0 strlen))))
               cands)
             cands))
-         (trim-cands
-          (if (not completion?)
-            (map
+         ;; ÆÉ¤ßÆþÎÏÃæ¤Ï¡¢ÆÉ¤ß(word)¤â¸«¤Æ¼¡¤ËÍè¤ë²ÄǽÀ­¤Î¤¢¤ë´Á»ú¤ò¥¬¥¤¥É
+ ;; Îã:"¤¢¤ª"¤òÆþÎϤ·¤¿»þÅÀ¤Ç¡¢look·ë²ÌÆâ¤Î"¤¢¤ªÃî"¤È¤¤¤¦ÆÉ¤ß¤ò¤â¤È¤Ë¡¢
+         ;;    "Ãî"¤ò¥¬¥¤¥É
+         (filtered-words
+          (if completion?
+            ()
+            (filter
               (lambda (cand)
-                ;; ͽ¬ÆþÎÏ»þ¤ÏÆþÎϺѤÎstr¤â´Þ¤Þ¤ì¤Æ¤¤¤ë¤Î¤Ç¡¢
-                ;; ¤½¤ì¤è¤ê¸å¤Îʸ»ú¤ò¥¬¥¤¥Éɽ¼¨
-                (if (string=? str (substring cand 0 strlen))
-                  (substring cand strlen (string-length cand))
-                  cand))
-              filtered-cands)
-            filtered-cands))
+                (let ((candlen (string-length cand)))
+                  (and
+                    (> candlen strlen)
+ ;; str¤Î¸å¤Ë¡¢³èÍѤ¹¤ë¸ì¤ò¼¨¤¹"¡½"¤·¤«»Ä¤é¤Ê¤¤¸õÊä¤Ï½ü¤¯ + (not (string=? "¡½" (substring cand strlen candlen))))))
+              word)))
+         (trim-str
+          (lambda (lst)
+            (if (not completion?)
+              (map
+                (lambda (cand)
+                  ;; ͽ¬ÆþÎÏ»þ¤ÏÆþÎϺѤÎstr¤â´Þ¤Þ¤ì¤Æ¤¤¤ë¤Î¤Ç¡¢
+                  ;; ¤½¤ì¤è¤ê¸å¤Îʸ»ú¤ò¥¬¥¤¥Éɽ¼¨
+                  (substring cand strlen (string-length cand)))
+                lst)
+              lst)))
+         (trim-cands (trim-str filtered-cands))
+         (trim-words (trim-str filtered-words))
          (candchars ; ͽ¬¤·¤¿½Ï¸ì¤Î1ʸ»úÌܤδÁ»ú¤Î¥ê¥¹¥È
           (delete-duplicates
-            (map (lambda (cand) (last (string-to-list cand))) trim-cands)))
+            (map (lambda (cand) (last (string-to-list cand)))
+              (append trim-cands trim-words))))
          (cand-stroke
           (map
             (lambda (elem)
@@ -1609,7 +1630,7 @@
                 ((nr-guide
                   (if tutcode-use-kanji-combination-guide?
                     (begin
-                      (tutcode-guide-set-candidates pc str #t)
+                      (tutcode-guide-set-candidates pc str #t ())
                       (length (tutcode-context-guide pc)))
                     0))
                  (res (tutcode-prediction-calc-window-param nr nr-guide))
@@ -1647,32 +1668,32 @@
       (if
         (or (>= preedit-len tutcode-prediction-start-char-count)
             force-check?)
-        (begin
-          (tutcode-lib-set-prediction-src-string pc preconv-str #f)
-          (let ((nr (tutcode-lib-get-nr-predictions pc)))
-            (if (and nr (> nr 0))
-              (let*
-                ((nr-guide
-                  (if tutcode-use-kanji-combination-guide?
-                    (begin
-                      (tutcode-guide-set-candidates pc preconv-str #f)
-                      (length (tutcode-context-guide pc)))
-                    0))
-                 (res (tutcode-prediction-calc-window-param nr nr-guide))
-                 (nr-all (list-ref res 0)) ; Á´¸õÊä¿ô(ͽ¬¸õÊä+½Ï¸ì¥¬¥¤¥É)
-                 (page-limit (list-ref res 1)) ; ¥Ú¡¼¥¸Æâ¸õÊä¿ô(ͽ¬+½Ï¸ì)
- (nr-in-page (list-ref res 2))) ; ¥Ú¡¼¥¸Æâ¸õÊä¿ô(ͽ¬¸õÊä¤Î¤ß)
-                (if (> page-limit 0)
+        (let*
+ ((all-yomi (tutcode-lib-set-prediction-src-string pc preconv-str #f))
+           (nr (tutcode-lib-get-nr-predictions pc)))
+          (if (and nr (> nr 0))
+            (let*
+              ((nr-guide
+                (if tutcode-use-kanji-combination-guide?
                   (begin
- (tutcode-context-set-prediction-nr-in-page! pc nr-in-page) - (tutcode-context-set-prediction-page-limit! pc page-limit)
-                    (tutcode-context-set-prediction-nr-all! pc nr-all)
-                    (tutcode-context-set-prediction-index! pc 0)
-                    (tutcode-context-set-candidate-window! pc
-                      'tutcode-candidate-window-predicting)
-                    (tutcode-context-set-predicting! pc
-                      'tutcode-predicting-prediction)
- (im-activate-candidate-selector pc nr-all page-limit))))))) + (tutcode-guide-set-candidates pc preconv-str #f all-yomi)
+                    (length (tutcode-context-guide pc)))
+                  0))
+               (res (tutcode-prediction-calc-window-param nr nr-guide))
+               (nr-all (list-ref res 0)) ; Á´¸õÊä¿ô(ͽ¬¸õÊä+½Ï¸ì¥¬¥¤¥É)
+               (page-limit (list-ref res 1)) ; ¥Ú¡¼¥¸Æâ¸õÊä¿ô(ͽ¬+½Ï¸ì)
+ (nr-in-page (list-ref res 2))) ; ¥Ú¡¼¥¸Æâ¸õÊä¿ô(ͽ¬¸õÊä¤Î¤ß)
+              (if (> page-limit 0)
+                (begin
+ (tutcode-context-set-prediction-nr-in-page! pc nr-in-page) + (tutcode-context-set-prediction-page-limit! pc page-limit)
+                  (tutcode-context-set-prediction-nr-all! pc nr-all)
+                  (tutcode-context-set-prediction-index! pc 0)
+                  (tutcode-context-set-candidate-window! pc
+                    'tutcode-candidate-window-predicting)
+                  (tutcode-context-set-predicting! pc
+                    'tutcode-predicting-prediction)
+ (im-activate-candidate-selector pc nr-all page-limit))))))
         (tutcode-reset-candidate-window pc)))))

 ;;; Êä´°¸õÊä¤È½Ï¸ì¥¬¥¤¥Éɽ¼¨¤Î¤¿¤á¤ÎcandwinÍѥѥé¥á¡¼¥¿¤ò·×»»¤¹¤ë

Reply via email to