Revision: 7374
Author:   deton.kih
Date:     Thu Nov 24 02:51:02 2011
Log:      * Change to use label key as next key sequence when the key has
  no candidate or candidate window is not shown.
* scm/tutcode-custom.scm
  - (tutcode-commit-candidate-by-label-key?): Remove.
  - (tutcode-commit-candidate-by-label-key): New custom.
* scm/tutcode.scm
  - Add conversion from tutcode-commit-candidate-by-label-key?
    to tutcode-commit-candidate-by-label-key for upgrade.
  - (tutcode-commit-by-label-key,
     tutcode-commit-by-label-key-for-kigou-mode,
     tutcode-commit-by-label-key-for-history,
     tutcode-commit-by-label-key-for-prediction):
    Change to return #t on commit.
  - (tutcode-proc-state-on):
    Change to treat prediction label key as normal key input
    when label key does not match any candidates.
  - (tutcode-proc-state-kigou): Ditto.
    Remove needless key check.
  - (tutcode-proc-state-history): Ditto.
  - (tutcode-proc-state-yomi): Ditto.
  - (tutcode-proc-state-bushu): Ditto.
  - (tutcode-proc-state-interactive-bushu): Ditto.
  - (tutcode-proc-state-converting):
    Change to treat label key as normal key input when the key
    does not match any candidates or candidate window is not shown.

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

Modified:
 /trunk/scm/tutcode-custom.scm
 /trunk/scm/tutcode.scm

=======================================
--- /trunk/scm/tutcode-custom.scm       Fri Nov 11 15:35:20 2011
+++ /trunk/scm/tutcode-custom.scm       Thu Nov 24 02:51:02 2011
@@ -214,9 +214,15 @@
   (N_ "Key layout of table style candidate window")
   (N_ "long description will be here."))

-(define-custom 'tutcode-commit-candidate-by-label-key? #t
+(define-custom 'tutcode-commit-candidate-by-label-key 'always
   '(tutcode candwin)
-  '(boolean)
+  (list 'choice
+       (list 'always (N_ "always") (N_ "All keys as label key"))
+       (list 'havecand (N_ "which have candidate")
+          (N_ "Enable keys which have candidate"))
+       (list 'candwin (N_ "while candidate window is shown")
+          (N_ "Enable while candidate window is shown"))
+       (list 'never (N_ "never") (N_ "Never")))
   (N_ "Commit candidate by heading label keys")
   (N_ "long description will be here."))

=======================================
--- /trunk/scm/tutcode.scm      Tue Nov 22 02:42:43 2011
+++ /trunk/scm/tutcode.scm      Thu Nov 24 02:51:02 2011
@@ -419,6 +419,9 @@
 (if (and (symbol-bound? 'tutcode-use-table-style-candidate-window?)
          tutcode-use-table-style-candidate-window?)
   (set! candidate-window-style 'table))
+(if (and (symbol-bound? 'tutcode-commit-candidate-by-label-key?)
+         tutcode-commit-candidate-by-label-key?)
+  (set! tutcode-commit-candidate-by-label-key 'always))

 ;;; ɽ·Á¼°¤Î¸õÊ䥦¥£¥ó¥É¥¦¾å¤Î³Æ¥Ü¥¿¥ó¤È¥­¡¼¤ÎÂбþɽ(13Îó8¹Ô)¡£
 ;;; ɽ·Á¼°¸õÊ䥦¥£¥ó¥É¥¦¤¬»²¾È¤·¤Æ»ÈÍѤ¹¤ë¡£
@@ -1416,6 +1419,7 @@

;;; ¸ò¤¼½ñ¤­ÊÑ´¹¤Î¸õÊäÁªÂò»þ¤Ë¡¢»ØÄꤵ¤ì¤¿¥é¥Ù¥ëʸ»ú¤ËÂбþ¤¹¤ë¸õÊä¤ò³ÎÄꤹ¤ë
 ;;; @param ch ÆþÎϤµ¤ì¤¿¥é¥Ù¥ëʸ»ú
+;;; @return ³ÎÄꤷ¤¿¾ì¹ç#t
 (define (tutcode-commit-by-label-key pc ch)
   ;; ¸½ºß¸õÊ䥦¥£¥ó¥É¥¦¤Ëɽ¼¨¤µ¤ì¤Æ¤¤¤Ê¤¤¥é¥Ù¥ëʸ»ú¤òÆþÎϤ·¤¿¾ì¹ç¡¢
   ;; ¸½ºß°Ê¹ß¤Î¸õÊäÆâ¤Ë¤ª¤¤¤ÆÆþÎÏ¥é¥Ù¥ëʸ»ú¤ËÂбþ¤¹¤ë¸õÊä¤ò³ÎÄꤹ¤ë¡£
@@ -1431,7 +1435,9 @@
              (< idx nr))
       (begin
         (tutcode-context-set-nth! pc idx)
-        (tutcode-commit-with-auto-help pc)))))
+        (tutcode-commit-with-auto-help pc)
+        #t)
+      (eq? tutcode-commit-candidate-by-label-key 'always))))

 ;;; ¸õÊäÁªÂò»þ¤Ë¡¢»ØÄꤵ¤ì¤¿¥é¥Ù¥ëʸ»ú¤ËÂбþ¤¹¤ë¸õÊäÈÖ¹æ¤ò·×»»¤¹¤ë
 ;;; @param ch ÆþÎϤµ¤ì¤¿¥é¥Ù¥ëʸ»ú
@@ -1464,6 +1470,7 @@
     idx))

 ;;; µ­¹æÆþÎϥ⡼¥É»þ¤Ë¡¢»ØÄꤵ¤ì¤¿¥é¥Ù¥ëʸ»ú¤ËÂбþ¤¹¤ë¸õÊä¤ò³ÎÄꤹ¤ë
+;;; @return ³ÎÄꤷ¤¿¾ì¹ç#t
 (define (tutcode-commit-by-label-key-for-kigou-mode pc ch)
   ;; ¸ò¤¼½ñ¤­ÊÑ´¹»þ¤È°Û¤Ê¤ê¡¢¸½ºß¤è¤êÁ°¤Î¸õÊä¤ò³ÎÄꤹ¤ë¾ì¹ç¤¢¤ê
   ;; (Á´³Ñ±Ñ¿ôÆþÎϥ⡼¥É¤È¤·¤Æ»È¤¨¤ë¤è¤¦¤Ë¤¹¤ë¤¿¤á)¡£
@@ -1487,10 +1494,13 @@
       (begin
         (tutcode-context-set-nth! pc idx)
         (tutcode-commit pc
-          (tutcode-prepare-commit-string-for-kigou-mode pc))))))
+          (tutcode-prepare-commit-string-for-kigou-mode pc))
+        #t)
+      (eq? tutcode-commit-candidate-by-label-key 'always))))

;;; ¥Ò¥¹¥È¥êÆþÎϤθõÊäÁªÂò»þ¤Ë¡¢»ØÄꤵ¤ì¤¿¥é¥Ù¥ëʸ»ú¤ËÂбþ¤¹¤ë¸õÊä¤ò³ÎÄꤹ¤ë
 ;;; @param ch ÆþÎϤµ¤ì¤¿¥é¥Ù¥ëʸ»ú
+;;; @return ³ÎÄꤷ¤¿¾ì¹ç#t
 (define (tutcode-commit-by-label-key-for-history pc ch)
   (let* ((nr (tutcode-context-nr-candidates pc))
          (nth (tutcode-context-nth pc))
@@ -1506,11 +1516,14 @@
         (let ((str (tutcode-prepare-commit-string-for-history pc)))
           (tutcode-commit pc str)
           (tutcode-flush pc)
- (tutcode-check-auto-help-window-begin pc (string-to-list str) ())))))) + (tutcode-check-auto-help-window-begin pc (string-to-list str) ()))
+        #t)
+      (eq? tutcode-commit-candidate-by-label-key 'always))))

 ;;; Êä´°/ͽ¬ÆþÎϸõÊäɽ¼¨»þ¤Ë¡¢»ØÄꤵ¤ì¤¿¥é¥Ù¥ëʸ»ú¤ËÂбþ¤¹¤ë¸õÊä¤ò³ÎÄꤹ¤ë
 ;;; @param ch ÆþÎϤµ¤ì¤¿¥é¥Ù¥ëʸ»ú
 ;;; @param mode tutcode-context-predicting¤ÎÃÍ
+;;; @return ³ÎÄꤷ¤¿¾ì¹ç#t
 (define (tutcode-commit-by-label-key-for-prediction pc ch mode)
   (let*
     ((nth (tutcode-context-prediction-index pc))
@@ -1520,17 +1533,22 @@
       (tutcode-get-idx-by-label-key ch nth page-limit nr-in-page
         tutcode-heading-label-char-list-for-prediction))
      (nr (tutcode-lib-get-nr-predictions pc))
+     ;; XXX:½Ï¸ì¥¬¥¤¥É¤Î¥Ú¡¼¥¸¿ô¤ÎÊý¤¬Â¿¤¤¾ì¹ç¡¢
+ ;; Êä´°¸õÊä¤Ï¥ë¡¼¥×¤·¤Æ2½çÌܰʹߤβÄǽÀ­¤¢¤ê(ɽ·Á¼°candwin¤Ç¤Ê¤¤¾ì¹ç)
      (i (remainder idx nr)))
     (if (>= i 0)
-      (case mode
-        ((tutcode-predicting-bushu)
-          (tutcode-do-commit-prediction-for-bushu pc i))
-        ((tutcode-predicting-interactive-bushu)
-          (tutcode-do-commit-prediction-for-interactive-bushu pc i))
-        ((tutcode-predicting-completion)
-          (tutcode-do-commit-prediction pc i #t))
-        (else
-          (tutcode-do-commit-prediction pc i #f))))))
+      (begin
+        (case mode
+          ((tutcode-predicting-bushu)
+            (tutcode-do-commit-prediction-for-bushu pc i))
+          ((tutcode-predicting-interactive-bushu)
+            (tutcode-do-commit-prediction-for-interactive-bushu pc i))
+          ((tutcode-predicting-completion)
+            (tutcode-do-commit-prediction pc i #t))
+          (else
+            (tutcode-do-commit-prediction pc i #f)))
+        #t)
+      (eq? tutcode-commit-candidate-by-label-key 'always))))

 (define (tutcode-get-prediction-string pc idx)
   (tutcode-lib-get-nth-prediction pc idx))
@@ -2933,9 +2951,10 @@
            (rk-commit-flush)
            (tutcode-commit-raw pc key key-state))
           ;; Êä´°¸õÊäÍÑ¥é¥Ù¥ë¥­¡¼?
- ((and completing? (tutcode-heading-label-char-for-prediction? key))
-            (tutcode-commit-by-label-key-for-prediction pc
-              (charcode->string key) 'tutcode-predicting-completion))
+          ((and completing?
+                (tutcode-heading-label-char-for-prediction? key)
+                (tutcode-commit-by-label-key-for-prediction pc
+                  (charcode->string key) 'tutcode-predicting-completion)))
           ;; Àµ¤·¤¯¤Ê¤¤¥­¡¼¥·¡¼¥±¥ó¥¹¤ÏÁ´¤Æ¼Î¤Æ¤ë(tc2¤Ë¹ç¤ï¤»¤¿Æ°ºî)¡£
           ;; (rk-push-key!¤¹¤ë¤È¡¢ÅÓÃæ¤Þ¤Ç¤Î¥·¡¼¥±¥ó¥¹¤Ï¼Î¤Æ¤é¤ì¤ë¤¬¡¢
           ;; ´Ö°ã¤Ã¤¿¥­¡¼¤Ï»Ä¤Ã¤Æ¤·¤Þ¤¦¤Î¤Ç¡¢rk-push-key!¤Ï»È¤¨¤Ê¤¤)
@@ -4000,8 +4019,9 @@
       ;; next-candidate-key?¤Î¥Á¥§¥Ã¥¯¤è¤êÁ°¤Ëheading-label-char?¤ò¥Á¥§¥Ã¥¯
       ((and (not (and (modifier-key-mask key-state)
                       (not (shift-key-mask key-state))))
-            (tutcode-heading-label-char-for-kigou-mode? key))
- (tutcode-commit-by-label-key-for-kigou-mode pc (charcode->string key))
+            (tutcode-heading-label-char-for-kigou-mode? key)
+            (tutcode-commit-by-label-key-for-kigou-mode pc
+              (charcode->string key)))
         (if (eq? (tutcode-context-candidate-window pc)
                  'tutcode-candidate-window-kigou)
           (tutcode-select-candidate pc (tutcode-context-nth pc))))
@@ -4020,12 +4040,6 @@
           (- tutcode-nr-candidate-max-for-kigou-mode)))
       ((tutcode-commit-key? key key-state) ; return-key¤Ï¥¢¥×¥ê¤ËÅϤ¹
(tutcode-commit pc (tutcode-prepare-commit-string-for-kigou-mode pc)))
-      ((or
-        (symbol? key)
-        (and
-          (modifier-key-mask key-state)
-          (not (shift-key-mask key-state))))
-        (tutcode-commit-raw pc key key-state))
       (else
         (tutcode-commit-raw pc key key-state)))))

@@ -4049,8 +4063,9 @@
         (tutcode-flush pc))
       ((and (not (and (modifier-key-mask key-state)
                       (not (shift-key-mask key-state))))
-            (tutcode-heading-label-char-for-history? key))
- (tutcode-commit-by-label-key-for-history pc (charcode->string key)))
+            (tutcode-heading-label-char-for-history? key)
+            (tutcode-commit-by-label-key-for-history pc
+              (charcode->string key))))
       ((or (tutcode-commit-key? key key-state)
            (tutcode-return-key? key key-state))
         (let ((str (tutcode-prepare-commit-string-for-history pc)))
@@ -4185,9 +4200,10 @@
                (tutcode-flush pc)
                (tutcode-proc-state-on pc key key-state))))
           ;; ͽ¬ÆþÎϸõÊäÍÑ¥é¥Ù¥ë¥­¡¼?
- ((and predicting? (tutcode-heading-label-char-for-prediction? key))
-            (tutcode-commit-by-label-key-for-prediction pc
-              (charcode->string key) 'tutcode-predicting-prediction))
+          ((and predicting?
+                (tutcode-heading-label-char-for-prediction? key)
+                (tutcode-commit-by-label-key-for-prediction pc
+                  (charcode->string key) 'tutcode-predicting-prediction)))
           ((tutcode-context-latin-conv pc)
(if (tutcode-begin-conv-key? key key-state) ; space¥­¡¼¤Ç¤ÎÊÑ´¹³«»Ï?
              (if (not (null? head))
@@ -4407,9 +4423,10 @@
        (tutcode-flush pc)
        (tutcode-proc-state-on pc key key-state))
       ;; ͽ¬ÆþÎϸõÊäÍÑ¥é¥Ù¥ë¥­¡¼?
-      ((and predicting? (tutcode-heading-label-char-for-prediction? key))
-        (tutcode-commit-by-label-key-for-prediction pc
-          (charcode->string key) 'tutcode-predicting-bushu))
+      ((and predicting?
+            (tutcode-heading-label-char-for-prediction? key)
+            (tutcode-commit-by-label-key-for-prediction pc
+              (charcode->string key) 'tutcode-predicting-bushu)))
       ((not (rk-expect-key? rkc (charcode->string key)))
        (if (> (length (rk-context-seq rkc)) 0)
          (rk-flush rkc)
@@ -4561,9 +4578,10 @@
            (tutcode-flush pc)
            (tutcode-proc-state-on pc key key-state))
           ((and (tutcode-heading-label-char-for-prediction? key)
-                (= (length (rk-context-seq rkc)) 0))
-            (tutcode-commit-by-label-key-for-prediction pc
- (charcode->string key) 'tutcode-predicting-interactive-bushu))
+                (= (length (rk-context-seq rkc)) 0)
+                (tutcode-commit-by-label-key-for-prediction pc
+                  (charcode->string key)
+                  'tutcode-predicting-interactive-bushu)))
           ((not (rk-expect-key? rkc (charcode->string key)))
            (if (> (length (rk-context-seq rkc)) 0)
              (rk-flush rkc)
@@ -4784,12 +4802,17 @@
         (tutcode-mazegaki-proc-relimit-right pc))
       ((tutcode-mazegaki-relimit-left-key? key key-state)
         (tutcode-mazegaki-proc-relimit-left pc))
-      ((and tutcode-commit-candidate-by-label-key?
+      ((and (or (eq? tutcode-commit-candidate-by-label-key 'always)
+                (eq? tutcode-commit-candidate-by-label-key 'havecand)
+                (and (eq? tutcode-commit-candidate-by-label-key 'candwin)
+                     (not (eq? (tutcode-context-candidate-window pc)
+                               'tutcode-candidate-window-off))
+                     (not (tutcode-context-candwin-delay-waiting pc))))
             (not (and (modifier-key-mask key-state)
                       (not (shift-key-mask key-state))))
             (> (tutcode-context-nr-candidates pc) 1)
-            (tutcode-heading-label-char? key))
-        (tutcode-commit-by-label-key pc (charcode->string key)))
+            (tutcode-heading-label-char? key)
+            (tutcode-commit-by-label-key pc (charcode->string key))))
       (else
         (let* ((postfix-yomi-len (tutcode-context-postfix-yomi-len pc))
                (yomi (and (not (zero? postfix-yomi-len))

Reply via email to