[uim-commit] r1203 - in trunk: fep scm

yamamoto at freedesktop.org yamamoto at freedesktop.org
Mon Aug 15 10:58:07 PDT 2005


Author: yamamoto
Date: 2005-08-15 10:58:02 -0700 (Mon, 15 Aug 2005)
New Revision: 1203

Modified:
   trunk/fep/uim-fep.c
   trunk/scm/anthy-key-custom.scm
   trunk/scm/canna-custom.scm
   trunk/scm/canna-key-custom.scm
   trunk/scm/canna.scm
Log:
* scm/anthy-key-custom.scm :
  Change place of anthy-transpose-as-hiragana-key.

* scm/canna-key-custom.scm :
  Add following keys.
  canna-transpose-as-hiragana-key
  canna-transpose-as-katakana-key
  canna-transpose-as-hankana-key 
  canna-next-page-key
  canna-prev-page-key
  canna-kill-key
  canna-kill-backward-key
  canna-vi-escape-key

* scm/canna-custom.scm
  Add canna-select-candidate-by-numeral-key? and canna-use-with-vi?.

* scm/canna.scm
  Add following features.
  transpose preedit
  page shift of candidate window
  kill preedit and kill-backward preedit
  vi-firendly mode

* fep/uim-fep.c (usage) : show version information


Modified: trunk/fep/uim-fep.c
===================================================================
--- trunk/fep/uim-fep.c	2005-08-15 15:19:43 UTC (rev 1202)
+++ trunk/fep/uim-fep.c	2005-08-15 17:58:02 UTC (rev 1203)
@@ -1076,6 +1076,7 @@
   uim_init();
   context = uim_create_context(NULL, get_enc(), NULL, NULL, uim_iconv, commit_cb);
 
+  printf("uim-fep %s\n", PACKAGE_VERSION);
   printf("usage: uim-fep [OPTIONS]\n"
       "\n"
       "-u <input method>                         input method      [default=%s]\n"

Modified: trunk/scm/anthy-key-custom.scm
===================================================================
--- trunk/scm/anthy-key-custom.scm	2005-08-15 15:19:43 UTC (rev 1202)
+++ trunk/scm/anthy-key-custom.scm	2005-08-15 17:58:02 UTC (rev 1203)
@@ -81,6 +81,12 @@
 	       (_ "[Anthy] convert to fullwidth alphanumeric")
 	       (_ "long description will be here"))
 
+(define-custom 'anthy-transpose-as-hiragana-key '("F6")
+               '(anthy-keys1)
+	       '(key)
+	       (_ "[Anthy] convert to hiragana")
+	       (_ "long description will be here"))
+
 (define-custom 'anthy-transpose-as-katakana-key '("F7")
                '(anthy-keys1)
 	       '(key)
@@ -93,12 +99,6 @@
 	       (_ "[Anthy] convert to halfwidth katakana")
 	       (_ "long description will be here"))
 
-(define-custom 'anthy-transpose-as-hiragana-key '("F6")
-               '(anthy-keys1)
-	       '(key)
-	       (_ "[Anthy] convert to hiragana")
-	       (_ "long description will be here"))
-
 (define-custom 'anthy-commit-as-opposite-kana-key '()
                '(anthy-keys1)
 	       '(key)

Modified: trunk/scm/canna-custom.scm
===================================================================
--- trunk/scm/canna-custom.scm	2005-08-15 15:19:43 UTC (rev 1202)
+++ trunk/scm/canna-custom.scm	2005-08-15 17:58:02 UTC (rev 1203)
@@ -87,6 +87,12 @@
   (_ "Number of candidates in candidate window at a time")
   (_ "long description will be here."))
 
+(define-custom 'canna-select-candidate-by-numeral-key? #f
+  '(canna candwin)
+  '(boolean)
+  (_ "Select candidate by numeral keys")
+  (_ "long description will be here."))
+
 ;; activity dependency
 (custom-add-hook 'canna-candidate-op-count
 		 'custom-activity-hooks
@@ -350,3 +356,9 @@
 (custom-add-hook 'custom-preserved-canna-server-name
 		 'custom-literalize-hooks
 		 custom-hook-literalize-preserved-canna-server-name)
+
+(define-custom 'canna-use-with-vi? #f
+  '(canna special-op)
+  '(boolean)
+  (_ "Friendly for vi user")
+  (_ "long description will be here."))

Modified: trunk/scm/canna-key-custom.scm
===================================================================
--- trunk/scm/canna-key-custom.scm	2005-08-15 15:19:43 UTC (rev 1202)
+++ trunk/scm/canna-key-custom.scm	2005-08-15 17:58:02 UTC (rev 1203)
@@ -69,6 +69,24 @@
 	       (_ "[Canna] shrink segment")
 	       (_ "long description will be here"))
 
+(define-custom 'canna-transpose-as-hiragana-key '("F6")
+               '(canna-keys1)
+	       '(key)
+	       (_ "[Canna] convert to hiragana")
+	       (_ "long description will be here"))
+
+(define-custom 'canna-transpose-as-katakana-key '("F7")
+               '(canna-keys1)
+	       '(key)
+	       (_ "[Canna] convert to katakana")
+	       (_ "long description will be here"))
+
+(define-custom 'canna-transpose-as-hankana-key '("F8")
+               '(canna-keys1)
+	       '(key)
+	       (_ "[Canna] convert to halfwidth katakana")
+	       (_ "long description will be here"))
+
 (define-custom 'canna-commit-as-opposite-kana-key '("<IgnoreCase><Shift>q")  ;; "Q"
                '(canna-keys1)
 	       '(key)
@@ -139,17 +157,17 @@
 	       (_ "[Canna] previous candidate")
 	       (_ "long description will be here"))
 
-;;(define-custom 'canna-next-page-key '(generic-next-page-key)
-;;             '(canna-keys2)
-;;	       '(key)
-;;	       (_ "[Canna] next page of candidate window")
-;;	       (_ "long description will be here"))
+(define-custom 'canna-next-page-key '(generic-next-page-key)
+             '(canna-keys2)
+	       '(key)
+	       (_ "[Canna] next page of candidate window")
+	       (_ "long description will be here"))
 
-;;(define-custom 'canna-prev-page-key '(generic-prev-page-key)
-;;               '(canna-keys2)
-;;	       '(key)
-;;	       (_ "[Canna] previous page of candidate window")
-;;	       (_ "long description will be here"))
+(define-custom 'canna-prev-page-key '(generic-prev-page-key)
+               '(canna-keys2)
+	       '(key)
+	       (_ "[Canna] previous page of candidate window")
+	       (_ "long description will be here"))
 
 ;;
 ;; overriding generic keys (advanced)
@@ -166,17 +184,17 @@
 	       (_ "[Canna] end of preedit")
 	       (_ "long description will be here"))
 
-;;(define-custom 'canna-kill-key '(generic-kill-key)
-;;               '(canna-keys3)
-;;	       '(key)
-;;	       (_ "[Canna] erase after cursor")
-;;	       (_ "long description will be here"))
+(define-custom 'canna-kill-key '(generic-kill-key)
+               '(canna-keys3)
+	       '(key)
+	       (_ "[Canna] erase after cursor")
+	       (_ "long description will be here"))
 
-;;(define-custom 'canna-kill-backward-key '(generic-kill-backward-key)
-;;               '(canna-keys3)
-;;	       '(key)
-;;	       (_ "[Canna] erase before cursor")
-;;	       (_ "long description will be here"))
+(define-custom 'canna-kill-backward-key '(generic-kill-backward-key)
+               '(canna-keys3)
+	       '(key)
+	       (_ "[Canna] erase before cursor")
+	       (_ "long description will be here"))
 
 (define-custom 'canna-backspace-key '(generic-backspace-key)
                '(canna-keys3)
@@ -201,3 +219,9 @@
 	       '(key)
 	       (_ "[Canna] go right")
 	       (_ "long description will be here"))
+
+(define-custom 'canna-vi-escape-key '("escape" "<Control>[")
+               '(canna-keys3)
+	       '(key)
+	       (_ "[Canna] canna-vi-escape-key?")
+	       (_ "long description will be here"))

Modified: trunk/scm/canna.scm
===================================================================
--- trunk/scm/canna.scm	2005-08-15 15:19:43 UTC (rev 1202)
+++ trunk/scm/canna.scm	2005-08-15 17:58:02 UTC (rev 1203)
@@ -193,6 +193,8 @@
    (list
     (list 'on                 #f)
     (list 'state              ())
+    (list 'transposing        #f)
+    (list 'transposing-type    0)
     (list 'cc-id              ()) ;; canna-context-id
     (list 'left-string        ()) ;; preedit strings in the left of cursor
     (list 'right-string       ())
@@ -246,6 +248,7 @@
   (canna-context-set-right-string! cc '())
   (canna-context-set-state! cc #f)
   (canna-context-set-index-list! cc ())
+  (canna-context-set-transposing! cc #f)
   (canna-context-set-candidate-window! cc #f)
   (canna-context-set-candidate-op-count! cc 0))
 
@@ -256,9 +259,11 @@
 
 (define (canna-update-preedit cc)
   (if (canna-context-on cc)
-      (if (canna-context-state cc)
-	  (canna-compose-state-preedit cc)
-	  (canna-input-state-preedit cc))
+      (if (canna-context-transposing cc)
+          (canna-context-transposing-state-preedit cc)
+          (if (canna-context-state cc)
+              (canna-compose-state-preedit cc)
+              (canna-input-state-preedit cc)))
       (begin
 	(im-clear-preedit cc)
 	(im-update-preedit cc))))
@@ -304,6 +309,14 @@
        (direct (ja-direct (charcode->string key)))
        (rule (canna-context-input-rule cc)))
     (cond
+     ((and canna-use-with-vi?
+           (canna-vi-escape-key? key key-state))
+      (begin
+        (canna-flush cc)
+        (canna-context-set-on! cc #f)
+        (canna-context-set-wide-latin! cc #f)
+        (canna-commit-raw cc)))
+
      ((canna-wide-latin-key? key key-state)
       (begin
 	(canna-flush cc)
@@ -357,7 +370,26 @@
    (> (length (canna-context-right-string cc)) 0)
    (> (length (rk-pending (canna-context-rkc cc))) 0)))
 
+(define canna-proc-transposing-state
+  (lambda (cc key key-state)
+    (cond
+     ((canna-transpose-as-hiragana-key? key key-state)
+      (canna-context-set-transposing-type! cc multi-segment-type-hiragana))
 
+     ((canna-transpose-as-katakana-key? key key-state)
+      (canna-context-set-transposing-type! cc multi-segment-type-katakana))
+
+     ((canna-transpose-as-hankana-key? key key-state)
+      (canna-context-set-transposing-type! cc multi-segment-type-hankana))
+
+     (else
+      (begin
+	; commit
+	(im-commit cc (canna-transposing-text cc))
+	(canna-flush cc)
+	(if (not (canna-commit-key? key key-state))
+	      (canna-proc-input-state cc key key-state)))))))
+
 (define (canna-proc-input-state-with-preedit cc key key-state)
   (let ((rkc (canna-context-rkc cc))
 	(cc-id (canna-context-cc-id cc))
@@ -387,6 +419,17 @@
 	      (canna-context-set-right-string!
 	       cc
 	       (cdr (canna-context-right-string cc))))))
+
+       ;; kill
+     ((canna-kill-key? key key-state)
+      (canna-context-set-right-string! cc ()))
+     
+     ;; kill-backward
+     ((canna-kill-backward-key? key key-state)
+      (begin
+        (rk-flush rkc)
+        (canna-context-set-left-string! cc ())))
+       
      ;; ¤Ò¤é¤¬¤Ê¥â¡¼¥É¤Ç¥«¥¿¥«¥Ê¤ò³ÎÄꤹ¤ë
      ((canna-commit-as-opposite-kana-key? key key-state)
       (begin
@@ -398,6 +441,15 @@
 	  (multi-segment-make-right-string (canna-context-right-string cc)
 					   (canna-opposite-kana kana))))
 	(canna-flush cc)))
+
+       ;; Transposing¾õÂ֤ذܹÔ
+     ((or (canna-transpose-as-hiragana-key?   key key-state)
+          (canna-transpose-as-katakana-key?   key key-state)
+          (canna-transpose-as-hankana-key?    key key-state))
+      (begin
+        (canna-context-set-transposing! cc #t)
+        (canna-proc-transposing-state cc key key-state)))
+
      ;; ¸½ºß¤Î¤«¤Ê¤ò³ÎÄê¸å¡¢¤Ò¤é¤¬¤Ê/¥«¥¿¥«¥Ê¥â¡¼¥É¤òÀڤ괹¤¨¤ë
      ((canna-kana-toggle-key? key key-state)
       (begin
@@ -497,6 +549,27 @@
       (canna-proc-input-state-with-preedit cc key key-state)
       (canna-proc-input-state-no-preedit cc key key-state)))
 
+(define canna-context-transposing-state-preedit
+  (lambda (cc)
+    (let ((transposing-text (canna-transposing-text cc)))
+      (im-clear-preedit cc)
+      (im-pushback-preedit
+        cc
+        preedit-underline
+        transposing-text)
+      (im-pushback-preedit
+        cc
+        preedit-cursor
+        "")
+      (im-update-preedit cc))))
+
+(define canna-transposing-text
+  (lambda (cc)
+    (let ((transposing-type (canna-context-transposing-type cc)))
+      (string-append
+        (multi-segment-make-left-string (canna-context-left-string cc) transposing-type)
+        (multi-segment-make-right-string (canna-context-right-string cc) transposing-type)))))
+
 (define (canna-pushback-preedit-segment-rec cc idx nseg)
   (let ((cc-id (canna-context-cc-id cc)))
     (if (< idx nseg)
@@ -619,6 +692,32 @@
     (if (canna-context-candidate-window cc)
 	(im-select-candidate cc n))))
 
+(define canna-move-candidate-in-page
+  (lambda (cc numeralc)
+    (let* ((cc-id (canna-context-cc-id cc))
+	   (cur-seg (canna-context-cur-seg cc))
+	   (max (canna-lib-get-nr-candidates cc-id cur-seg))
+           (n (nth cur-seg (canna-context-index-list cc)))
+	   (cur-page (if (= canna-nr-candidate-max 0)
+	   		 0
+			 (quotient n canna-nr-candidate-max)))
+	   (pageidx (- (numeral-char->number numeralc) 1))
+	   (compensated-pageidx (cond
+				 ((< pageidx 0) ; pressing key_0
+				  (+ pageidx 10))
+				 (else
+				  pageidx)))
+	   (idx (+ (* cur-page canna-nr-candidate-max) compensated-pageidx))
+	   (compensated-idx (cond
+			     ((>= idx max)
+			      (- max 1))
+			     (else
+			      idx)))
+	   (new-op-count (+ 1 (canna-context-candidate-op-count cc))))
+      (set-car! (nthcdr cur-seg (canna-context-index-list cc)) compensated-idx)
+      (canna-context-set-candidate-op-count! cc new-op-count)
+      (im-select-candidate cc compensated-idx))))
+
 (define (canna-reset-candidate-window cc)
   (if (canna-context-candidate-window cc)
       (begin
@@ -644,6 +743,14 @@
 (define (canna-proc-compose-state cc key key-state)
   (let ((cc-id (canna-context-cc-id cc)))
     (cond
+     ((canna-prev-page-key? key key-state)
+      (if (canna-context-candidate-window cc)
+	  (im-shift-page-candidate cc #f)))
+
+     ((canna-next-page-key? key key-state)
+      (if (canna-context-candidate-window cc)
+	  (im-shift-page-candidate cc #t)))
+
      ((canna-commit-key? key key-state)
       (canna-do-commit cc))
 
@@ -680,6 +787,11 @@
 	(canna-reset-candidate-window cc)
 	(canna-lib-reset-conversion cc-id)))
 
+     ((and canna-select-candidate-by-numeral-key?
+	   (numeral-char? key)
+	   (canna-context-candidate-window cc))
+      (canna-move-candidate-in-page cc key))
+
      ((and (modifier-key-mask key-state)
 	   (not (shift-key-mask key-state)))
       #f)
@@ -697,6 +809,13 @@
 	 (w (or (ja-direct char)
 		(ja-wide char))))
     (cond
+     ((and canna-use-with-vi?
+           (canna-vi-escape-key? key key-state))
+      (begin
+        (canna-flush cc)
+        (canna-context-set-wide-latin! cc #f)
+        (canna-commit-raw cc)))
+
      ((canna-on-key? key key-state)
       (canna-flush cc)
       (canna-context-set-on! cc #t))
@@ -713,9 +832,11 @@
   (if (control-char? key)
       (im-commit-raw cc)
       (if (canna-context-on cc)
-	  (if (canna-context-state cc)
-	      (canna-proc-compose-state cc key key-state)
-	      (canna-proc-input-state cc key key-state))
+          (if (canna-context-transposing cc)
+              (canna-proc-transposing-state cc key key-state)
+              (if (canna-context-state cc)
+                  (canna-proc-compose-state cc key key-state)
+                  (canna-proc-input-state cc key key-state)))
 	  (if (canna-context-wide-latin cc)
 	      (canna-proc-wide-latin cc key key-state)
 	      (canna-proc-raw-state cc key key-state))))



More information about the uim-commit mailing list