2 new revisions:

Revision: 265f32cf09e9
Author:   KIHARA Hideto <deton....@gmail.com>
Date:     Sun Apr 29 14:33:54 2012
Log: Support pseudo table style candidate window by adding wrapper layer....
http://code.google.com/p/uim/source/detail?r=265f32cf09e9

Revision: 232469c79018
Author:   KIHARA Hideto <deton....@gmail.com>
Date:     Sat May 12 16:49:54 2012
Log:      Support multiple pages for pseudo table style....
http://code.google.com/p/uim/source/detail?r=232469c79018

==============================================================================
Revision: 265f32cf09e9
Author:   KIHARA Hideto <deton....@gmail.com>
Date:     Sun Apr 29 14:33:54 2012
Log: Support pseudo table style candidate window by adding wrapper layer.

* scm/tutcode.scm
  - (tutcode-context-rec-spec): Add pseudo-table-cands.
  - (tutcode-activate-candidate-window): Support pseudo table style.
  - (tutcode-pseudo-table-style-setup): New.
  - (tutcode-stroke-help-make, tutcode-auto-help-make):
    Move making of pseudo table style candidates
    to tutcode-pseudo-table-style-setup.
  - (tutcode-auto-help-dump):
    Follow the change of pseudo table style candidates.
  - (tutcode-get-candidate-handler):
    Add check of pseudo table style.
  - (tutcode-get-candidate-handler-internal):
    New function extracted from tutcode-get-candidate-handler.
  - (tutcode-delay-activating-handler): Support pseudo table style.

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

Modified:
 /scm/tutcode.scm

=======================================
--- /scm/tutcode.scm    Fri Apr 27 21:44:54 2012
+++ /scm/tutcode.scm    Sun Apr 29 14:33:54 2012
@@ -819,6 +819,8 @@
      (list 'candwin-delay-waiting #f)
      ;;; ¸õÊ䥦¥£¥ó¥É¥¦¤ÎÃÙ±äɽ¼¨ÂÔ¤ÁÃæ¤ËÁªÂò¤µ¤ì¤¿¸õÊä¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹ÈÖ¹æ
      (list 'candwin-delay-selected-index -1)
+     ;;; µ¼»÷ɽ·Á¼°¸õÊäɽ¼¨ÍѤθõÊä¥ê¥¹¥È
+     (list 'pseudo-table-cands ())
      ;;; ¥¹¥È¥í¡¼¥¯É½
;;; ¼¡¤ËÆþÎϤ¹¤ë¥­¡¼¤Èʸ»ú¤ÎÂбþ¤Î¡¢get-candidate-handlerÍÑ·Á¼°¤Ç¤Î¥ê¥¹¥È
      (list 'stroke-help ())
@@ -1808,7 +1810,12 @@
       (im-delay-activate-candidate-selector pc delay))
     (begin
       (tutcode-context-set-candwin-delay-waiting! pc #f)
-      (im-activate-candidate-selector pc nr display-limit))))
+      (if (and tutcode-use-pseudo-table-style?
+               (>= nr 0))
+        (let ((pnr-pdl
+ (tutcode-pseudo-table-style-setup pc type nr display-limit)))
+          (im-activate-candidate-selector pc (car pnr-pdl) (cadr pnr-pdl)))
+        (im-activate-candidate-selector pc nr display-limit)))))

 ;;; ¸õÊ䥦¥£¥ó¥É¥¦¤ÎÃÙ±äɽ¼¨¤ò¹Ô¤¦¤«¤É¤¦¤«¤òÊÖ¤¹
 ;;; @param delay ÃÙ±ä»þ´Ö¡£0¤Î¾ì¹ç¤ÏÃÙ±äɽ¼¨¤Ï¤·¤Ê¤¤¡£
@@ -1817,6 +1824,30 @@
        (im-delay-activate-candidate-selector-supported? pc)
        (> delay 0)))

+;;; µ¼»÷ɽ·Á¼°¸õÊäɽ¼¨ÍѤθõÊä¥ê¥¹¥È¤òºîÀ®¤¹¤ë
+;;; @param type ¸õÊ䥦¥£¥ó¥É¥¦¥¿¥¤¥×
+;;; @param delay ¸õÊ䥦¥£¥ó¥É¥¦É½¼¨¤Þ¤Ç¤ÎÂÔ¤Á»þ´Ö[s]
+;;; @param nr ¸õÊä¿ô¡£delay¸å¤Ë·×»»¤¹¤ë¾ì¹ç¤Ï-1
+;;; @param display-limit ¥Ú¡¼¥¸Æâ¸õÊä¿ô
+;;; @return '(nr display-limit) µ¼»÷ɽ·Á¼°¤Î¸õÊä¥ê¥¹¥È¤Î¸õÊä¿ô¤È¥Ú¡¼¥¸Æâ¸õÊä¿ô
+(define (tutcode-pseudo-table-style-setup pc type nr display-limit)
+  (let* ((cands
+          (let loop
+            ((idx 0)
+             (cands ()))
+            (if (or (>= idx display-limit) (>= idx nr))
+              (reverse cands)
+              (loop
+                (+ idx 1)
+                (cons (tutcode-get-candidate-handler-internal pc idx 0)
+                      cands)))))
+         (pcands (tutcode-table-in-vertical-candwin cands))
+         (pdl (length pcands))
+         (nr-page (+ (quotient nr display-limit)
+                     (if (= 0 (remainder nr display-limit)) 0 1))))
+    (tutcode-context-set-pseudo-table-cands! pc pcands)
+    (list (* nr-page pdl) pdl)))
+
 ;;; ¸õÊ䥦¥£¥ó¥É¥¦¾å¤Ç¸õÊä¤òÁªÂò¤¹¤ë
 ;;; @param idx ÁªÂò¤¹¤ë¸õÊä¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹ÈÖ¹æ
 (define (tutcode-select-candidate pc idx)
@@ -1893,15 +1924,10 @@
           ()))))
     (if (null? label-cand-alist)
       ()
-      (let
-        ((stroke-help
-          (map
-            (lambda (elem)
-              (list (cadr elem) (car elem) ""))
-            (reverse label-cand-alist))))
-        (if tutcode-use-pseudo-table-style?
-          (tutcode-table-in-vertical-candwin stroke-help)
-          stroke-help)))))
+      (map
+        (lambda (elem)
+          (list (cadr elem) (car elem) ""))
+        (reverse label-cand-alist)))))

 ;;; ²¾ÁÛ¸°ÈפÎɽ¼¨¤ò³«»Ï¤¹¤ë
 (define (tutcode-check-stroke-help-window-begin pc)
@@ -2280,16 +2306,10 @@
(tutcode-auto-help-update-stroke-alist-normal pc () helpstrlist)))))
     (if (null? label-cands-alist)
       ()
-      (let
-        ((auto-help
-          (map
-            (lambda (elem)
-              (list (string-list-concat (cdr elem)) (car elem) ""))
-            label-cands-alist)))
-        (if (and tutcode-use-pseudo-table-style?
-                 (not tutcode-auto-help-with-real-keys?))
-          (tutcode-table-in-vertical-candwin auto-help)
-          auto-help)))))
+      (map
+        (lambda (elem)
+          (list (string-list-concat (cdr elem)) (car elem) ""))
+        label-cands-alist))))

 ;;; Éô¼ó¹çÀ®ÊÑ´¹¡¦¸ò¤¼½ñ¤­ÊÑ´¹¤Ç³ÎÄꤷ¤¿Ê¸»ú¤ÎÂǤÁÊý¤òɽ¼¨¤¹¤ë¡£
 ;;; @param strlist ³ÎÄꤷ¤¿Ê¸»úÎó¤Î¥ê¥¹¥È(µÕ½ç)
@@ -2606,9 +2626,7 @@
                 (append-map
                   (lambda (elem)
                     (list (car elem) "\n"))
-                  (if tutcode-use-pseudo-table-style?
-                    help
-                    (tutcode-table-in-vertical-candwin help)))))
+                  (tutcode-table-in-vertical-candwin help))))
           (tutcode-commit pc (apply string-append linecands) #t #t))))))

 ;;; preeditɽ¼¨¤ò¹¹¿·¤¹¤ë¡£
@@ -5847,100 +5865,107 @@
 ;;; ¸õÊ䥦¥£¥ó¥É¥¦¤¬¸õÊäʸ»úÎó¤ò¼èÆÀ¤¹¤ë¤¿¤á¤Ë¸Æ¤Ö´Ø¿ô
 (define (tutcode-get-candidate-handler c idx accel-enum-hint)
   (let ((tc (tutcode-find-descendant-context c)))
-    (cond
-      ;; µ­¹æÆþÎÏ
-      ((eq? (tutcode-context-state tc) 'tutcode-state-kigou)
-        (let* ((cand (tutcode-get-nth-candidate-for-kigou-mode tc idx))
-               (n (remainder idx
- (length tutcode-heading-label-char-list-for-kigou-mode))) - (label (nth n tutcode-heading-label-char-list-for-kigou-mode))) - ;; XXX:annotationɽ¼¨¤Ï¸½¾õ̵¸ú²½¤µ¤ì¤Æ¤¤¤ë¤Î¤Ç¡¢¾ï¤Ë""¤òÊÖ¤·¤Æ¤ª¤¯
-          (list cand label "")))
-      ;; ¥Ò¥¹¥È¥êÆþÎÏ
-      ((eq? (tutcode-context-state tc) 'tutcode-state-history)
-        (let* ((cand (tutcode-get-nth-candidate-for-history tc idx))
-               (n (remainder idx
-                    (length tutcode-heading-label-char-list-for-history)))
-               (label (nth n tutcode-heading-label-char-list-for-history)))
-          (list cand label "")))
-      ;; Êä´°/ͽ¬ÆþÎϸõÊä
-      ((eq? (tutcode-context-candidate-window tc)
-            'tutcode-candidate-window-predicting)
-        (let*
-          ((nr-in-page (tutcode-context-prediction-nr-in-page tc))
-           (page-limit (tutcode-context-prediction-page-limit tc))
-           (pages (quotient idx page-limit))
-           (idx-in-page (remainder idx page-limit)))
- ;; ³Æ¥Ú¡¼¥¸¤Ë¤Ï¡¢nr-in-page¸Ä¤ÎÊä´°/ͽ¬ÆþÎϸõÊä¤È¡¢½Ï¸ì¥¬¥¤¥É¤òɽ¼¨
-          (if (< idx-in-page nr-in-page)
-            ;; Êä´°/ͽ¬ÆþÎϸõÊäʸ»úÎó
-            (let*
-              ((nr-predictions (tutcode-lib-get-nr-predictions tc))
-               (p-idx (+ idx-in-page (* pages nr-in-page)))
-               (i (remainder p-idx nr-predictions))
-               (cand (tutcode-lib-get-nth-prediction tc i))
-               (word (and (eq? (tutcode-context-predicting tc)
-                               'tutcode-predicting-bushu)
-                          (tutcode-lib-get-nth-word tc i)))
-               (cand-guide
-                (if word
-                  (string-append cand "(" word ")")
-                  cand))
-               (n (remainder p-idx
- (length tutcode-heading-label-char-list-for-prediction))) - (label (nth n tutcode-heading-label-char-list-for-prediction)))
-              (list cand-guide label ""))
-            ;; ½Ï¸ì¥¬¥¤¥É
-            (let*
-              ((guide (tutcode-context-guide tc))
-               (guide-len (length guide)))
-              (if (= guide-len 0)
-                (list "" "" "")
-                (let*
-                  ((guide-idx-in-page (- idx-in-page nr-in-page))
-                   (nr-guide-in-page (- page-limit nr-in-page))
- (guide-idx (+ guide-idx-in-page (* pages nr-guide-in-page)))
-                   (n (remainder guide-idx guide-len))
-                   (label-cands-alist (nth n guide))
-                   (label (car label-cands-alist))
-                   (cands (cdr label-cands-alist))
-                   (cand
-                    (string-list-concat
-                      (append cands (list tutcode-guide-mark)))))
-                  (list cand label "")))))))
-      ;; ²¾ÁÛ¸°È×
-      ((eq? (tutcode-context-candidate-window tc)
-            'tutcode-candidate-window-stroke-help)
-        (nth idx (tutcode-context-stroke-help tc)))
-      ;; ¼«Æ°¥Ø¥ë¥×
-      ((eq? (tutcode-context-candidate-window tc)
-            'tutcode-candidate-window-auto-help)
-        (nth idx (tutcode-context-auto-help tc)))
-      ;; ÂÐÏÃŪÉô¼ó¹çÀ®ÊÑ´¹
-      ((eq? (tutcode-context-state tc) 'tutcode-state-interactive-bushu)
-        (let*
-          ;; ͽ¬ÆþÎϸõÊäÍÑÊÑ¿ô¤òήÍÑ
-          ((nr-in-page (tutcode-context-prediction-nr-in-page tc))
-           (page-limit (tutcode-context-prediction-page-limit tc))
-           (pages (quotient idx page-limit))
-           (idx-in-page (remainder idx page-limit))
-           (nr-predictions (tutcode-lib-get-nr-predictions tc))
-           (p-idx (+ idx-in-page (* pages nr-in-page)))
-           (i (remainder p-idx nr-predictions))
-           (cand (tutcode-lib-get-nth-prediction tc i))
-           (n (remainder p-idx
-                (length tutcode-heading-label-char-list-for-prediction)))
-           (label (nth n tutcode-heading-label-char-list-for-prediction)))
-          (list cand label "")))
-      ;; ¸ò¤¼½ñ¤­ÊÑ´¹
-      ((eq? (tutcode-context-candidate-window tc)
-            'tutcode-candidate-window-converting)
-        (let* ((cand (tutcode-get-nth-candidate tc idx))
-               (n (remainder idx (length tutcode-heading-label-char-list)))
-               (label (nth n tutcode-heading-label-char-list)))
-          (list cand label "")))
-      (else
-        (list "" "" "")))))
+    (if tutcode-use-pseudo-table-style?
+      (nth idx (tutcode-context-pseudo-table-cands tc))
+      (tutcode-get-candidate-handler-internal tc idx accel-enum-hint))))
+
+;;; ¸õÊ䥦¥£¥ó¥É¥¦¤¬¸õÊäʸ»úÎó¤ò¼èÆÀ¤¹¤ë¤¿¤á¤Ë¸Æ¤Ö´Ø¿ô
+;;; (tutcode-pseudo-table-stype-setup¤«¤é¤Î¸Æ¤Ó½Ð¤·ÍÑ)
+(define (tutcode-get-candidate-handler-internal tc idx accel-enum-hint)
+  (cond
+    ;; µ­¹æÆþÎÏ
+    ((eq? (tutcode-context-state tc) 'tutcode-state-kigou)
+      (let* ((cand (tutcode-get-nth-candidate-for-kigou-mode tc idx))
+             (n (remainder idx
+                  (length tutcode-heading-label-char-list-for-kigou-mode)))
+ (label (nth n tutcode-heading-label-char-list-for-kigou-mode)))
+        ;; XXX:annotationɽ¼¨¤Ï¸½¾õ̵¸ú²½¤µ¤ì¤Æ¤¤¤ë¤Î¤Ç¡¢¾ï¤Ë""¤òÊÖ¤·¤Æ¤ª¤¯
+        (list cand label "")))
+    ;; ¥Ò¥¹¥È¥êÆþÎÏ
+    ((eq? (tutcode-context-state tc) 'tutcode-state-history)
+      (let* ((cand (tutcode-get-nth-candidate-for-history tc idx))
+             (n (remainder idx
+                  (length tutcode-heading-label-char-list-for-history)))
+             (label (nth n tutcode-heading-label-char-list-for-history)))
+        (list cand label "")))
+    ;; Êä´°/ͽ¬ÆþÎϸõÊä
+    ((eq? (tutcode-context-candidate-window tc)
+          'tutcode-candidate-window-predicting)
+      (let*
+        ((nr-in-page (tutcode-context-prediction-nr-in-page tc))
+         (page-limit (tutcode-context-prediction-page-limit tc))
+         (pages (quotient idx page-limit))
+         (idx-in-page (remainder idx page-limit)))
+ ;; ³Æ¥Ú¡¼¥¸¤Ë¤Ï¡¢nr-in-page¸Ä¤ÎÊä´°/ͽ¬ÆþÎϸõÊä¤È¡¢½Ï¸ì¥¬¥¤¥É¤òɽ¼¨
+        (if (< idx-in-page nr-in-page)
+          ;; Êä´°/ͽ¬ÆþÎϸõÊäʸ»úÎó
+          (let*
+            ((nr-predictions (tutcode-lib-get-nr-predictions tc))
+             (p-idx (+ idx-in-page (* pages nr-in-page)))
+             (i (remainder p-idx nr-predictions))
+             (cand (tutcode-lib-get-nth-prediction tc i))
+             (word (and (eq? (tutcode-context-predicting tc)
+                             'tutcode-predicting-bushu)
+                        (tutcode-lib-get-nth-word tc i)))
+             (cand-guide
+              (if word
+                (string-append cand "(" word ")")
+                cand))
+             (n (remainder p-idx
+                  (length tutcode-heading-label-char-list-for-prediction)))
+ (label (nth n tutcode-heading-label-char-list-for-prediction)))
+            (list cand-guide label ""))
+          ;; ½Ï¸ì¥¬¥¤¥É
+          (let*
+            ((guide (tutcode-context-guide tc))
+             (guide-len (length guide)))
+            (if (= guide-len 0)
+              (list "" "" "")
+              (let*
+                ((guide-idx-in-page (- idx-in-page nr-in-page))
+                 (nr-guide-in-page (- page-limit nr-in-page))
+ (guide-idx (+ guide-idx-in-page (* pages nr-guide-in-page)))
+                 (n (remainder guide-idx guide-len))
+                 (label-cands-alist (nth n guide))
+                 (label (car label-cands-alist))
+                 (cands (cdr label-cands-alist))
+                 (cand
+                  (string-list-concat
+                    (append cands (list tutcode-guide-mark)))))
+                (list cand label "")))))))
+    ;; ²¾ÁÛ¸°È×
+    ((eq? (tutcode-context-candidate-window tc)
+          'tutcode-candidate-window-stroke-help)
+      (nth idx (tutcode-context-stroke-help tc)))
+    ;; ¼«Æ°¥Ø¥ë¥×
+    ((eq? (tutcode-context-candidate-window tc)
+          'tutcode-candidate-window-auto-help)
+      (nth idx (tutcode-context-auto-help tc)))
+    ;; ÂÐÏÃŪÉô¼ó¹çÀ®ÊÑ´¹
+    ((eq? (tutcode-context-state tc) 'tutcode-state-interactive-bushu)
+      (let*
+        ;; ͽ¬ÆþÎϸõÊäÍÑÊÑ¿ô¤òήÍÑ
+        ((nr-in-page (tutcode-context-prediction-nr-in-page tc))
+         (page-limit (tutcode-context-prediction-page-limit tc))
+         (pages (quotient idx page-limit))
+         (idx-in-page (remainder idx page-limit))
+         (nr-predictions (tutcode-lib-get-nr-predictions tc))
+         (p-idx (+ idx-in-page (* pages nr-in-page)))
+         (i (remainder p-idx nr-predictions))
+         (cand (tutcode-lib-get-nth-prediction tc i))
+         (n (remainder p-idx
+              (length tutcode-heading-label-char-list-for-prediction)))
+         (label (nth n tutcode-heading-label-char-list-for-prediction)))
+        (list cand label "")))
+    ;; ¸ò¤¼½ñ¤­ÊÑ´¹
+    ((eq? (tutcode-context-candidate-window tc)
+          'tutcode-candidate-window-converting)
+      (let* ((cand (tutcode-get-nth-candidate tc idx))
+             (n (remainder idx (length tutcode-heading-label-char-list)))
+             (label (nth n tutcode-heading-label-char-list)))
+        (list cand label "")))
+    (else
+      (list "" "" ""))))

 ;;; ¸õÊ䥦¥£¥ó¥É¥¦¤¬¸õÊä¤òÁªÂò¤·¤¿¤È¤­¤Ë¸Æ¤Ö´Ø¿ô¡£
 ;;; ɽ¼¨Ãæ¤Î¸õÊ䤬ÁªÂò¤µ¤ì¤¿¾ì¹ç¡¢³ºÅö¤¹¤ë¸õÊä¤ò³ÎÄꤹ¤ë¡£
@@ -6105,7 +6130,13 @@
           (else
             (list tutcode-nr-candidate-max 0)))))
       (reverse
-        (cons (tutcode-context-candwin-delay-selected-index tc) res)))))
+        (cons (tutcode-context-candwin-delay-selected-index tc)
+              (if tutcode-use-pseudo-table-style?
+                (reverse
+                  (tutcode-pseudo-table-style-setup tc
+                    (tutcode-context-candidate-window tc)
+                    (cadr res) (car res)))
+                res))))))

 (tutcode-configure-widgets)


==============================================================================
Revision: 232469c79018
Author:   KIHARA Hideto <deton....@gmail.com>
Date:     Sat May 12 16:49:54 2012
Log:      Support multiple pages for pseudo table style.

* scm/tutcode-custom.scm
  - (tutcode-custom-adjust-nr-candidate-max):
    New function extracted from candidate-window-style hook.
  - (candidate-window-style):
    Change hook to call tutcode-custom-adjust-nr-candidate-max.
  - (tutcode-use-pseudo-table-style?): New set hook.
* scm/tutcode.scm
  - (tutcode-context-rec-spec):
    Change initial value of pseudo-table-cands to #f
  - (tutcode-context-new):
    Treat tutcode-use-pseudo-table-style? same as
    table style candidate window.
  - (tutcode-activate-candidate-window):
    Follow the argument change of tutcode-pseudo-table-style-setup.
  - (tutcode-pseudo-table-style-setup):
    Remove unused argument.
  - (tutcode-pseudo-table-style-make-new-page): New.
  - (tutcode-candwin-limit-nr-nth): New.
  - (tutcode-pseudo-table-style-make-page):
    New function extracted from tutcode-pseudo-table-style-setup.
  - (tutcode-pseudo-table-style-candwin-index): New.
  - (tutcode-pseudo-table-style-scm-index): New.
  - (tutcode-select-candidate):
    Change to call tutcode-pseudo-table-select-candidate.
  - (tutcode-pseudo-table-select-candidate): New.
  - (tutcode-reset-candidate-window): Add reset of pseudo-table-cands.
  - (tutcode-get-candidate-handler):
    Support multiple pages for pseudo table style.
  - (tutcode-set-candidate-index-handler):
    Support pseudo table style candidate window.
  - (tutcode-delay-activating-handler):
    Support selecting candidate for pseudo table style.

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

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

=======================================
--- /scm/tutcode-custom.scm     Fri Apr 27 21:44:54 2012
+++ /scm/tutcode-custom.scm     Sat May 12 16:49:54 2012
@@ -429,32 +429,38 @@
                 (lambda ()
                   tutcode-use-auto-help-window?))

+(define (tutcode-custom-adjust-nr-candidate-max)
+ (if (or (eq? candidate-window-style 'table) tutcode-use-pseudo-table-style?)
+    (begin
+      (custom-set-value! 'tutcode-nr-candidate-max
+        (length tutcode-table-heading-label-char-list))
+      (custom-set-value!
+        'tutcode-nr-candidate-max-for-kigou-mode
+        (length tutcode-table-heading-label-char-list-for-kigou-mode))
+      (custom-set-value!
+        'tutcode-nr-candidate-max-for-prediction
+        (length tutcode-heading-label-char-list-for-prediction))
+      (custom-set-value!
+        'tutcode-nr-candidate-max-for-guide
+        (- (length tutcode-table-heading-label-char-list-for-kigou-mode)
+           (length tutcode-heading-label-char-list-for-prediction)))
+      (custom-set-value!
+        'tutcode-nr-candidate-max-for-history
+        (length tutcode-table-heading-label-char-list)))
+    (begin
+      (custom-set-value! 'tutcode-nr-candidate-max 10)
+      (custom-set-value! 'tutcode-nr-candidate-max-for-kigou-mode 10)
+      (custom-set-value! 'tutcode-nr-candidate-max-for-prediction 10)
+      (custom-set-value! 'tutcode-nr-candidate-max-for-guide 10)
+      (custom-set-value! 'tutcode-nr-candidate-max-for-history 10))))
+
 (custom-add-hook 'candidate-window-style
   'custom-set-hooks
-  (lambda ()
-    (if (eq? candidate-window-style 'table)
-      (begin
-        (custom-set-value! 'tutcode-nr-candidate-max
-          (length tutcode-table-heading-label-char-list))
-        (custom-set-value!
-          'tutcode-nr-candidate-max-for-kigou-mode
-          (length tutcode-table-heading-label-char-list-for-kigou-mode))
-        (custom-set-value!
-          'tutcode-nr-candidate-max-for-prediction
-          (length tutcode-heading-label-char-list-for-prediction))
-        (custom-set-value!
-          'tutcode-nr-candidate-max-for-guide
-          (- (length tutcode-table-heading-label-char-list-for-kigou-mode)
-             (length tutcode-heading-label-char-list-for-prediction)))
-        (custom-set-value!
-          'tutcode-nr-candidate-max-for-history
-          (length tutcode-table-heading-label-char-list)))
-      (begin
-        (custom-set-value! 'tutcode-nr-candidate-max 10)
-        (custom-set-value! 'tutcode-nr-candidate-max-for-kigou-mode 10)
-        (custom-set-value! 'tutcode-nr-candidate-max-for-prediction 10)
-        (custom-set-value! 'tutcode-nr-candidate-max-for-guide 10)
-        (custom-set-value! 'tutcode-nr-candidate-max-for-history 10)))))
+  tutcode-custom-adjust-nr-candidate-max)
+
+(custom-add-hook 'tutcode-use-pseudo-table-style?
+  'custom-set-hooks
+  tutcode-custom-adjust-nr-candidate-max)

 (custom-add-hook 'tutcode-candidate-window-table-layout
                 'custom-activity-hooks
=======================================
--- /scm/tutcode.scm    Sun Apr 29 14:33:54 2012
+++ /scm/tutcode.scm    Sat May 12 16:49:54 2012
@@ -819,8 +819,8 @@
      (list 'candwin-delay-waiting #f)
      ;;; ¸õÊ䥦¥£¥ó¥É¥¦¤ÎÃÙ±äɽ¼¨ÂÔ¤ÁÃæ¤ËÁªÂò¤µ¤ì¤¿¸õÊä¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹ÈÖ¹æ
      (list 'candwin-delay-selected-index -1)
-     ;;; µ¼»÷ɽ·Á¼°¸õÊäɽ¼¨ÍѤθõÊä¥ê¥¹¥È
-     (list 'pseudo-table-cands ())
+     ;;; µ¼»÷ɽ·Á¼°¸õÊäɽ¼¨ÍѤθõÊävector(³ÆÍ×ÁǤ¬³Æ¥Ú¡¼¥¸¤Î¸õÊä¥ê¥¹¥È)
+     (list 'pseudo-table-cands #f)
      ;;; ¥¹¥È¥í¡¼¥¯É½
;;; ¼¡¤ËÆþÎϤ¹¤ë¥­¡¼¤Èʸ»ú¤ÎÂбþ¤Î¡¢get-candidate-handlerÍÑ·Á¼°¤Ç¤Î¥ê¥¹¥È
      (list 'stroke-help ())
@@ -933,7 +933,8 @@
         (tutcode-rule-commit-sequences! tutcode-rule-userconfig)))
     ;; ɽ·Á¼°¸õÊ䥦¥£¥ó¥É¥¦ÍÑÀßÄê
     (if (null? tutcode-heading-label-char-list)
-      (if (eq? candidate-window-style 'table)
+      (if (or (eq? candidate-window-style 'table)
+              tutcode-use-pseudo-table-style?)
         (set! tutcode-heading-label-char-list
           (case tutcode-candidate-window-table-layout
             ((qwerty-jis) tutcode-table-heading-label-char-list-qwerty-jis)
@@ -946,7 +947,8 @@
       (set! tutcode-heading-label-char-list-for-history
         tutcode-heading-label-char-list))
     (if (null? tutcode-heading-label-char-list-for-kigou-mode)
-      (if (eq? candidate-window-style 'table)
+      (if (or (eq? candidate-window-style 'table)
+              tutcode-use-pseudo-table-style?)
         (begin
           (set! tutcode-heading-label-char-list-for-kigou-mode
             tutcode-table-heading-label-char-list-for-kigou-mode)
@@ -1812,8 +1814,7 @@
       (tutcode-context-set-candwin-delay-waiting! pc #f)
       (if (and tutcode-use-pseudo-table-style?
                (>= nr 0))
-        (let ((pnr-pdl
- (tutcode-pseudo-table-style-setup pc type nr display-limit))) + (let ((pnr-pdl (tutcode-pseudo-table-style-setup pc nr display-limit)))
           (im-activate-candidate-selector pc (car pnr-pdl) (cadr pnr-pdl)))
         (im-activate-candidate-selector pc nr display-limit)))))

@@ -1824,29 +1825,106 @@
        (im-delay-activate-candidate-selector-supported? pc)
        (> delay 0)))

-;;; µ¼»÷ɽ·Á¼°¸õÊäɽ¼¨ÍѤθõÊä¥ê¥¹¥È¤òºîÀ®¤¹¤ë
-;;; @param type ¸õÊ䥦¥£¥ó¥É¥¦¥¿¥¤¥×
-;;; @param delay ¸õÊ䥦¥£¥ó¥É¥¦É½¼¨¤Þ¤Ç¤ÎÂÔ¤Á»þ´Ö[s]
-;;; @param nr ¸õÊä¿ô¡£delay¸å¤Ë·×»»¤¹¤ë¾ì¹ç¤Ï-1
+;;; µ¼»÷ɽ·Á¼°¸õÊäɽ¼¨ÍѤκǽé¤Î¥Ú¡¼¥¸¤Î¸õÊä¥ê¥¹¥È¤òºîÀ®¤·¤Æ
+;;; pseudo-table-cands¤Ëset¤¹¤ë
+;;; @param nr ¸õÊä¿ô
 ;;; @param display-limit ¥Ú¡¼¥¸Æâ¸õÊä¿ô
;;; @return '(nr display-limit) µ¼»÷ɽ·Á¼°¤Î¸õÊä¥ê¥¹¥È¤Î¸õÊä¿ô¤È¥Ú¡¼¥¸Æâ¸õÊä¿ô
-(define (tutcode-pseudo-table-style-setup pc type nr display-limit)
-  (let* ((cands
+(define (tutcode-pseudo-table-style-setup pc nr display-limit)
+  (if (= nr 0)
+    '(0 0)
+ (let* ((pcands (tutcode-pseudo-table-style-make-page pc 0 display-limit nr))
+           (pdl (length pcands))
+           (nr-page (+ (quotient nr display-limit)
+                       (if (= 0 (remainder nr display-limit)) 0 1)))
+           (pnr (* nr-page pdl))
+           (pcands-all (make-vector nr-page #f)))
+      (vector-set! pcands-all 0 pcands)
+      (tutcode-context-set-pseudo-table-cands! pc pcands-all)
+      (list pnr pdl))))
+
+;;; µ¼»÷ɽ·Á¼°¸õÊäɽ¼¨ÍѤο·¥Ú¡¼¥¸¤Î¸õÊä¥ê¥¹¥È¤òºîÀ®¤·¤ÆÊÖ¤¹
+(define (tutcode-pseudo-table-style-make-new-page pc)
+  (let*
+    ((dl-nr-nth (tutcode-candwin-limit-nr-nth pc))
+     (dl (list-ref dl-nr-nth 0))
+     (nr (list-ref dl-nr-nth 1))
+     (nth (list-ref dl-nr-nth 2))
+     (page (quotient nth dl))
+     (start-index (* page dl))
+     (end-index (+ start-index dl)))
+    (tutcode-pseudo-table-style-make-page pc start-index end-index nr)))
+
+;;; ¸õÊ䥦¥£¥ó¥É¥¦¤Ëɽ¼¨¡¦ÁªÂòÃæ¤Î¸õÊä¤Î¾ðÊó¤òÊÖ¤¹
+;;; @return (<¥Ú¡¼¥¸Æâ¸õÊä¿ô(display-limit)> <Á´¸õÊä¿ô> <ÁªÂòÃæ¤Î¸õÊäÈÖ¹æ>)
+(define (tutcode-candwin-limit-nr-nth pc)
+  (cond
+    ((eq? (tutcode-context-state pc) 'tutcode-state-kigou)
+      (list tutcode-nr-candidate-max-for-kigou-mode
+            (tutcode-context-nr-candidates pc)
+            (tutcode-context-nth pc)))
+    ((eq? (tutcode-context-state pc) 'tutcode-state-history)
+      (list tutcode-nr-candidate-max-for-history
+            (tutcode-context-nr-candidates pc)
+            (tutcode-context-nth pc)))
+    ((eq? (tutcode-context-candidate-window pc)
+          'tutcode-candidate-window-predicting)
+      (list (tutcode-context-prediction-page-limit pc)
+            (tutcode-context-prediction-nr-all pc)
+            (tutcode-context-prediction-index pc)))
+    ((eq? (tutcode-context-candidate-window pc)
+          'tutcode-candidate-window-stroke-help)
+      (list tutcode-nr-candidate-max-for-kigou-mode
+            (length (tutcode-context-stroke-help pc))
+            0))
+    ((eq? (tutcode-context-candidate-window pc)
+          'tutcode-candidate-window-auto-help)
+      (list tutcode-nr-candidate-max-for-kigou-mode
+            (length (tutcode-context-auto-help pc))
+            0))
+    ((eq? (tutcode-context-state pc) 'tutcode-state-interactive-bushu)
+      (list (tutcode-context-prediction-page-limit pc)
+            (tutcode-context-prediction-nr-all pc)
+            (tutcode-context-prediction-index pc)))
+    ((eq? (tutcode-context-candidate-window pc)
+          'tutcode-candidate-window-converting)
+      (list tutcode-nr-candidate-max
+            (tutcode-context-nr-candidates pc)
+            (tutcode-context-nth pc)))
+    (else
+      (list tutcode-nr-candidate-max 0 0))))
+
+;;; µ¼»÷ɽ·Á¼°¸õÊäɽ¼¨ÍѤλØÄꤷ¤¿³«»ÏÈÖ¹æ¤Î¥Ú¡¼¥¸¤Î¸õÊä¥ê¥¹¥È¤òºîÀ®¤·¤ÆÊÖ¤¹
+;;; @param start-index ³«»ÏÈÖ¹æ
+;;; @param end-index ½ªÎ»ÈÖ¹æ
+(define (tutcode-pseudo-table-style-make-page pc start-index end-index nr)
+  (let ((cands
           (let loop
-            ((idx 0)
+            ((idx start-index)
              (cands ()))
-            (if (or (>= idx display-limit) (>= idx nr))
+            (if (or (>= idx end-index) (>= idx nr))
               (reverse cands)
               (loop
                 (+ idx 1)
                 (cons (tutcode-get-candidate-handler-internal pc idx 0)
-                      cands)))))
-         (pcands (tutcode-table-in-vertical-candwin cands))
-         (pdl (length pcands))
-         (nr-page (+ (quotient nr display-limit)
-                     (if (= 0 (remainder nr display-limit)) 0 1))))
-    (tutcode-context-set-pseudo-table-cands! pc pcands)
-    (list (* nr-page pdl) pdl)))
+                      cands))))))
+    (tutcode-table-in-vertical-candwin cands)))
+
+;;; ¸õÊä¥ê¥¹¥È¾å¤Î¸õÊäÈÖ¹æ¤ò¡¢µ¼»÷ɽ·Á¼°¾å¤Î¸õÊäÈÖ¹æ¤ËÊÑ´¹
+(define (tutcode-pseudo-table-style-candwin-index pc idx)
+  (let* ((vec (tutcode-context-pseudo-table-cands pc))
+         (display-limit (length (vector-ref vec 0)))
+         (page-limit (list-ref (tutcode-candwin-limit-nr-nth pc) 0))
+         (page (quotient idx page-limit)))
+    (* page display-limit))) ; XXX:candwin¤Î¥Ú¡¼¥¸Ã±°Ì¤Î¤ßÂбþ
+
+;;; µ¼»÷ɽ·Á¼°¾å¤Î¸õÊäÈÖ¹æ¤ò¡¢¸õÊä¥ê¥¹¥È¾å¤Î¸õÊäÈÖ¹æ¤ËÊÑ´¹
+(define (tutcode-pseudo-table-style-scm-index pc idx)
+  (let* ((vec (tutcode-context-pseudo-table-cands pc))
+         (display-limit (length (vector-ref vec 0)))
+         (page-limit (list-ref (tutcode-candwin-limit-nr-nth pc) 0))
+         (page (quotient idx display-limit)))
+    (* page page-limit))) ; XXX:candwin¤Î¥Ú¡¼¥¸Ã±°Ì¤Î¤ßÂбþ

 ;;; ¸õÊ䥦¥£¥ó¥É¥¦¾å¤Ç¸õÊä¤òÁªÂò¤¹¤ë
 ;;; @param idx ÁªÂò¤¹¤ë¸õÊä¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹ÈÖ¹æ
@@ -1856,6 +1934,13 @@
;; (XXX (uim api-doc¤Ë¹ç¤ï¤»¤Æ)candwin¦¤ÇÂн褷¤¿Êý¤¬¤¤¤¤¤«¤â¤·¤ì¤Ê¤¤¤¬¡¢
     ;;      shift-page¤È¤Îº®ºß»þ¤Î·×»»¤¬ÌÌÅݤʤΤǡ¢¤È¤ê¤¢¤¨¤ºscm¦¤Ç¡£)
     (tutcode-context-set-candwin-delay-selected-index! pc idx)
+    (tutcode-pseudo-table-select-candidate pc idx)))
+
+;;; ¸õÊ䥦¥£¥ó¥É¥¦¾å¤Ç¸õÊä¤òÁªÂò¤¹¤ë(µ¼»÷ɽ·Á¼°¸õÊäɽ¼¨Âбþ)
+;;; @param idx ÁªÂò¤¹¤ë¸õÊä¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹ÈÖ¹æ
+(define (tutcode-pseudo-table-select-candidate pc idx)
+  (if tutcode-use-pseudo-table-style?
+ (im-select-candidate pc (tutcode-pseudo-table-style-candwin-index pc idx))
     (im-select-candidate pc idx)))

 ;;; ²¾ÁÛ¸°ÈפËɽ¼¨¤¹¤ë¸õÊä¥ê¥¹¥È¤òºî¤Ã¤ÆÊÖ¤¹
@@ -5003,6 +5088,7 @@
       (im-deactivate-candidate-selector pc)
(tutcode-context-set-candidate-window! pc 'tutcode-candidate-window-off)
       (tutcode-context-set-predicting! pc 'tutcode-predicting-off)
+      (tutcode-context-set-pseudo-table-cands! pc #f)
       (tutcode-context-set-candwin-delay-waiting! pc #f)
       (tutcode-context-set-candwin-delay-selected-index! pc -1))))

@@ -5866,11 +5952,20 @@
 (define (tutcode-get-candidate-handler c idx accel-enum-hint)
   (let ((tc (tutcode-find-descendant-context c)))
     (if tutcode-use-pseudo-table-style?
-      (nth idx (tutcode-context-pseudo-table-cands tc))
+      (let* ((vec (tutcode-context-pseudo-table-cands tc))
+             (dl (length (vector-ref vec 0)))
+             (page (quotient idx dl))
+             (pcands (vector-ref vec page))
+             (cands
+              (or pcands
+ (let ((cands (tutcode-pseudo-table-style-make-new-page tc)))
+                    (vector-set! vec page cands)
+                    cands))))
+        (list-ref cands (remainder idx dl)))
       (tutcode-get-candidate-handler-internal tc idx accel-enum-hint))))

 ;;; ¸õÊ䥦¥£¥ó¥É¥¦¤¬¸õÊäʸ»úÎó¤ò¼èÆÀ¤¹¤ë¤¿¤á¤Ë¸Æ¤Ö´Ø¿ô
-;;; (tutcode-pseudo-table-stype-setup¤«¤é¤Î¸Æ¤Ó½Ð¤·ÍÑ)
+;;; (tutcode-pseudo-table-style-setup¤«¤é¤Î¸Æ¤Ó½Ð¤·ÍÑ)
 (define (tutcode-get-candidate-handler-internal tc idx accel-enum-hint)
   (cond
     ;; µ­¹æÆþÎÏ
@@ -5971,9 +6066,14 @@
 ;;; ɽ¼¨Ãæ¤Î¸õÊ䤬ÁªÂò¤µ¤ì¤¿¾ì¹ç¡¢³ºÅö¤¹¤ë¸õÊä¤ò³ÎÄꤹ¤ë¡£
 ;;; ɽ¼¨¤µ¤ì¤Æ¤¤¤Ê¤¤¸õÊ䤬ÁªÂò¤µ¤ì¤¿(¸õÊ䥦¥£¥ó¥É¥¦Â¦¤Ç
 ;;; ¥Ú¡¼¥¸°ÜÆ°Áàºî¤¬¹Ô¤ï¤ì¤¿)¾ì¹ç¡¢ÆâÉô¤ÎÁªÂò¸õÊäÈÖ¹æ¤ò¹¹¿·¤¹¤ë¤À¤±¡£
-(define (tutcode-set-candidate-index-handler c idx)
+(define (tutcode-set-candidate-index-handler c pidx)
   (let* ((pc (tutcode-find-descendant-context c))
          (candwin (tutcode-context-candidate-window pc))
+         (idx (if tutcode-use-pseudo-table-style?
+                ;; XXX:µ¼»÷ɽ·Á¼°¤Ç¤Ï¡¢¥Þ¥¦¥¹¤Ë¤è¤ë¸õÊäÁªÂò¤Ï̤Âбþ¡£
+ ;; candwin¥Ú¡¼¥¸Æâ¤Î¥¯¥ê¥Ã¥¯»þ¤Ï¡¢¥Ú¡¼¥¸ÆâºÇ½é¤Î¸õÊä³ÎÄê
+                (tutcode-pseudo-table-style-scm-index pc pidx)
+                pidx))
          ;; ²¾ÁÛ¸°È×¾å¤Î¥¯¥ê¥Ã¥¯¤ò¥­¡¼ÆþÎϤȤ·¤Æ½èÍý(¥½¥Õ¥È¥­¡¼¥Ü¡¼¥É)
          (label-to-key-press
           (lambda (label)
@@ -6065,7 +6165,8 @@
 ;;; ¼èÆÀ¤¹¤ë¤¿¤á¤Ë¸Æ¤Ö´Ø¿ô
 ;;; @return (nr display-limit selected-index)
 (define (tutcode-delay-activating-handler c)
-  (let ((tc (tutcode-find-descendant-context c)))
+  (let* ((tc (tutcode-find-descendant-context c))
+ (selected-index (tutcode-context-candwin-delay-selected-index tc)))
     (tutcode-context-set-candwin-delay-waiting! tc #f)
     (let
       ((res
@@ -6130,13 +6231,14 @@
           (else
             (list tutcode-nr-candidate-max 0)))))
       (reverse
-        (cons (tutcode-context-candwin-delay-selected-index tc)
-              (if tutcode-use-pseudo-table-style?
-                (reverse
-                  (tutcode-pseudo-table-style-setup tc
-                    (tutcode-context-candidate-window tc)
-                    (cadr res) (car res)))
-                res))))))
+        (if (and tutcode-use-pseudo-table-style?
+                 (> (cadr res) 0)) ; nr¤¬0¤Î¾ì¹ç¤Ïcandwin¤Ïɽ¼¨¤µ¤ì¤Ê¤¤
+          (let ((pres
+ (tutcode-pseudo-table-style-setup tc (cadr res) (car res))))
+            ;; candwin-index¤Ïsetup¸Æ½Ð¸å¤Ë¸Æ¤ÖɬÍפ¢¤ê
+ (cons (tutcode-pseudo-table-style-candwin-index tc selected-index)
+                    (reverse pres)))
+          (cons selected-index res))))))

 (tutcode-configure-widgets)

Reply via email to