Revision: 7353
Author:   deton.kih
Date:     Mon Oct 31 04:08:08 2011
Log:      * Add function to show help for char at current position
  using surrounding text API
* scm/tutcode-key-custom.scm
  - (tutcode-help-sequence): New key custom.
* scm/tutcode.scm
  - (tutcode-stroke-help-update-alist-with-rule):
    Add label for help key sequence.
  - (tutcode-check-auto-help-window-begin):
    Add optional argument.
    Change to show help immediately if opt-immediate? argument is #t.
  - (tutcode-help): New function.
  - (tutcode-proc-state-on): Add check of help key sequence.
  - (tutcode-custom-set-mazegaki/bushu-start-sequence!):
    Add help key sequence.

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

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

=======================================
--- /trunk/scm/tutcode-key-custom.scm   Fri Oct 28 04:12:43 2011
+++ /trunk/scm/tutcode-key-custom.scm   Mon Oct 31 04:08:08 2011
@@ -239,6 +239,12 @@
               (N_ "[TUT-Code] display last auto help")
               (N_ "long description will be here"))

+(define-custom 'tutcode-help-sequence ""
+               '(tutcode-keys1)
+              '(string ".*")
+              (N_ "[TUT-Code] display help for char at current position")
+              (N_ "long description will be here"))
+
 (define-custom 'tutcode-undo-sequence ""
                '(tutcode-keys1)
               '(string ".*")
=======================================
--- /trunk/scm/tutcode.scm      Mon Oct 31 04:01:34 2011
+++ /trunk/scm/tutcode.scm      Mon Oct 31 04:08:08 2011
@@ -157,6 +157,9 @@
 ;;;    tutcode-auto-help-redisplay-sequence¤Ë°Ê²¼¤Î¤è¤¦¤Ë¥­¡¼¥·¡¼¥±¥ó¥¹¤ò
 ;;;    ÀßÄꤹ¤ë¤È»ÈÍѲÄǽ¤Ë¤Ê¤ê¤Þ¤¹¡£
 ;;;      (define tutcode-auto-help-redisplay-sequence "al-")
+;;; * ʸ»ú¥Ø¥ë¥×ɽ¼¨µ¡Ç½
+;;;   ¥«¡¼¥½¥ë°ÌÃÖľÁ°¤Îʸ»ú¤Î¥Ø¥ë¥×¤òɽ¼¨¤·¤Þ¤¹¡£
+;;;   (uim¤Îsurrounding text API¤ò»È¤Ã¤Æ¥«¡¼¥½¥ë°ÌÃÖľÁ°¤Îʸ»ú¤ò¼èÆÀ)
 ;;;
 ;;; ¡ÚÊä´°/ͽ¬ÆþÎÏ¡¦½Ï¸ì¥¬¥¤¥É¡Û
 ;;; +¡ÖÊä´°¡×:³ÎÄêºÑʸ»úÎó¤ËÂФ·¤Æ¡¢Â³¤¯Ê¸»úÎó¤Î¸õÊä¤òɽ¼¨¤·¤Þ¤¹¡£
@@ -1867,6 +1870,7 @@
             ((tutcode-postfix-mazegaki-inflection-8-start) "¡½8")
             ((tutcode-postfix-mazegaki-inflection-9-start) "¡½9")
             ((tutcode-auto-help-redisplay) "¢ã")
+            ((tutcode-help) "¡©")
             ((tutcode-undo) "¢Î")
             (else cand)))
          (cand-hint
@@ -1975,14 +1979,16 @@
 ;;; Éô¼ó¹çÀ®ÊÑ´¹¡¦¸ò¤¼½ñ¤­ÊÑ´¹¤Ç³ÎÄꤷ¤¿Ê¸»ú¤ÎÂǤÁÊý¤òɽ¼¨¤¹¤ë¡£
 ;;; @param strlist ³ÎÄꤷ¤¿Ê¸»úÎó¤Î¥ê¥¹¥È(µÕ½ç)
 ;;; @param yomilist ÊÑ´¹Á°¤ÎÆÉ¤ß¤Îʸ»úÎó¤Î¥ê¥¹¥È(µÕ½ç)
-(define (tutcode-check-auto-help-window-begin pc strlist yomilist)
+;;; @param opt-immediate? ÃÙ±ä̵¤·¤Ç¤¹¤°¤Ëɽ¼¨¤¹¤ë¤«¤É¤¦¤«(¥ª¥×¥·¥ç¥ó)
+(define (tutcode-check-auto-help-window-begin pc strlist yomilist . opt-immediate?)
   (if (and (eq? (tutcode-context-candidate-window pc)
                 'tutcode-candidate-window-off)
            tutcode-use-auto-help-window?)
-    (begin
+    (let ((immediate? (:optional opt-immediate? #f)))
       (tutcode-context-set-guide-chars! pc ())
-      (if (tutcode-candidate-window-enable-delay? pc
-            tutcode-candidate-window-activate-delay-for-auto-help)
+      (if (and (not immediate?)
+               (tutcode-candidate-window-enable-delay? pc
+                tutcode-candidate-window-activate-delay-for-auto-help))
         (begin
(tutcode-context-set-auto-help! pc (list 'delaytmp strlist yomilist))
           (tutcode-activate-candidate-window pc
@@ -1999,6 +2005,13 @@
                 (length auto-help)
                 tutcode-nr-candidate-max-for-kigou-mode))))))))

+;;; ¥«¡¼¥½¥ë°ÌÃ֤ξÁ°¤Ë¤¢¤ëʸ»ú¤ÎÂǤÁÊý¤òɽ¼¨¤¹¤ë¡£
+;;; (surrounding text API¤ò»È¤Ã¤Æ¥«¡¼¥½¥ë°ÌÃ֤ξÁ°¤Ë¤¢¤ëʸ»ú¤ò¼èÆÀ)
+(define (tutcode-help pc)
+  (let ((former-seq (tutcode-postfix-acquire-text pc 1)))
+    (if (positive? (length former-seq))
+      (tutcode-check-auto-help-window-begin pc former-seq () #t))))
+
 ;;; ¼«Æ°¥Ø¥ë¥×¤Îɽ·Á¼°É½¼¨¤Ë»È¤¦alist¤ò¹¹¿·¤¹¤ë¡£
;;; alist¤Ï°Ê²¼¤Î¤è¤¦¤ËÂǸ°¤ò¼¨¤¹¥é¥Ù¥ëʸ»ú¤È¡¢³ºÅö¥»¥ë¤Ëɽ¼¨¤¹¤ëʸ»úÎó¤Î¥ê¥¹¥È
 ;;;  Îã:(("y" "2" "1") ("t" "3")) ; ("y" "y" "t")¤È¤¤¤¦¥¹¥È¥í¡¼¥¯¤òɽ¤¹¡£
@@ -2822,6 +2835,8 @@
                 (tutcode-begin-history pc))
               ((eq? res 'tutcode-undo)
                 (tutcode-undo pc))
+              ((eq? res 'tutcode-help)
+                (tutcode-help pc))
               ((eq? res 'tutcode-auto-help-redisplay)
                 (tutcode-auto-help-redisplay pc))))))))))

@@ -5254,6 +5269,8 @@
             '(tutcode-postfix-mazegaki-inflection-9-start))
           (make-subrule tutcode-auto-help-redisplay-sequence
             '(tutcode-auto-help-redisplay))
+          (make-subrule tutcode-help-sequence
+            '(tutcode-help))
           (make-subrule tutcode-undo-sequence
             '(tutcode-undo)))))))

Reply via email to