[uim-commit] r847 - trunk/scm

kzk at freedesktop.org kzk at freedesktop.org
Wed May 25 12:10:54 PDT 2005


Author: kzk
Date: 2005-05-25 12:10:48 -0700 (Wed, 25 May 2005)
New Revision: 847

Modified:
   trunk/scm/anthy-key-custom.scm
   trunk/scm/anthy.scm
Log:
* This commit aims to introduce preedit-transposing 
  between latin, wide-latin, katakana and hankana
  on anthy.

* scm/anthy.scm
  - (anthy-type-latin): new variable
  - (anthy-type-wide-latin): new variable
  - (anthy-context::transposing): new variable
  - (anthy-context::transposing-type): new variable
  - (anthy-update-preedit): using
    anthy-context-transposing-preedit when the state
    is transposing-state
  - (anthy-proc-transposing-state): new function
  - (anthy-proc-input-state-with-preedit): change the
    state when transposing trigger keys are pressed
  - (anthy-context-transposing-state-preedit): new func
  - (anthy-transposing-text): new func
  - (anthy-press-key-handler) :
    call anthy-proc-transposing-state when the state is
    transposing state.

* scm/anthy-key-custom.scm
  - (anthy-transpose-as-latin-key)
      : renamed from anthy-commit-as-latin-key
  - (anthy-transpose-as-wide-latin-key)
      : renamed from anthy-commit-as-wide-latin-key
  - (anthy-transpose-as-katakana-key)
      : renamed from anthy-commit-as-katakana-key
  - (anthy-transpose-as-hankana-key)
      : renamed from anthy-commit-as-hankana-key



Modified: trunk/scm/anthy-key-custom.scm
===================================================================
--- trunk/scm/anthy-key-custom.scm	2005-05-25 10:20:31 UTC (rev 846)
+++ trunk/scm/anthy-key-custom.scm	2005-05-25 19:10:48 UTC (rev 847)
@@ -69,25 +69,25 @@
 	       (_ "[Anthy] shrink segment")
 	       (_ "long description will be here"))
 
-(define-custom 'anthy-commit-as-latin-key '("F10")
+(define-custom 'anthy-transpose-as-latin-key '("F10")
                '(anthy-keys1)
 	       '(key)
 	       (_ "[Anthy] commit as halfwidth alphanumeric")
 	       (_ "long description will be here"))
 
-(define-custom 'anthy-commit-as-wide-latin-key '("F9")
+(define-custom 'anthy-transpose-as-wide-latin-key '("F9")
                '(anthy-keys1)
 	       '(key)
 	       (_ "[Anthy] commit as fullwidth alphanumeric")
 	       (_ "long description will be here"))
 
-(define-custom 'anthy-commit-as-katakana-key '("F7")
+(define-custom 'anthy-transpose-as-katakana-key '("F7")
                '(anthy-keys1)
 	       '(key)
 	       (_ "[Anthy] commit as katakana")
 	       (_ "long description will be here"))
 
-(define-custom 'anthy-commit-as-hankana-key '("F8")
+(define-custom 'anthy-transpose-as-hankana-key '("F8")
                '(anthy-keys1)
 	       '(key)
 	       (_ "[Anthy] commit as halfwidth katakana")

Modified: trunk/scm/anthy.scm
===================================================================
--- trunk/scm/anthy.scm	2005-05-25 10:20:31 UTC (rev 846)
+++ trunk/scm/anthy.scm	2005-05-25 19:10:48 UTC (rev 847)
@@ -44,9 +44,11 @@
 
 (define anthy-lib-initialized? #f)
 
-(define anthy-type-hiragana 0)
-(define anthy-type-katakana 1)
-(define anthy-type-hankana 2)
+(define anthy-type-hiragana   0)
+(define anthy-type-katakana   1)
+(define anthy-type-hankana    2)
+(define anthy-type-latin      3)
+(define anthy-type-wide-latin 4)
 
 (define anthy-input-rule-roma 0)
 (define anthy-input-rule-kana 1)
@@ -226,6 +228,8 @@
    (list
     (list 'on                 #f)
     (list 'converting         #f)
+    (list 'transposing        #f)
+    (list 'transposing-type    0)
     (list 'ac-id              #f) ;; anthy-context-id
     (list 'preconv-ustr       #f) ;; preedit strings
     (list 'rkc                #f)
@@ -366,9 +370,11 @@
   (lambda (ac)
     (if (not (anthy-context-commit-raw ac))
 	(let ((segments (if (anthy-context-on ac)
-			    (if (anthy-context-converting ac)
-				(anthy-converting-state-preedit ac)
-				(anthy-input-state-preedit ac))
+			    (if (anthy-context-transposing ac)
+				(anthy-context-transposing-state-preedit ac)
+				(if (anthy-context-converting ac)
+				    (anthy-converting-state-preedit ac)
+				    (anthy-input-state-preedit ac)))
 			    ())))
 	  (context-update-preedit ac segments))
 	(anthy-context-set-commit-raw! ac #f))))
@@ -465,6 +471,31 @@
     (or (not (ustr-empty? (anthy-context-preconv-ustr ac)))
 	(> (length (rk-pending (anthy-context-rkc ac))) 0))))
 
+(define anthy-proc-transposing-state
+  (lambda (ac key key-state)
+    (cond
+     ((anthy-transpose-as-katakana-key? key key-state)
+      (anthy-context-set-transposing-type! ac anthy-type-katakana))
+
+     ((anthy-transpose-as-hankana-key? key key-state)
+      (anthy-context-set-transposing-type! ac anthy-type-hankana))
+
+     ((anthy-transpose-as-latin-key? key key-state)
+      (anthy-context-set-transposing-type! ac anthy-type-latin))
+
+     ((anthy-transpose-as-wide-latin-key? key key-state)
+      (anthy-context-set-transposing-type! ac anthy-type-wide-latin))
+
+     ((anthy-commit-key? key key-state)
+      (begin
+	(im-commit ac (anthy-transposing-text ac))
+	(anthy-flush ac)))
+
+     (else
+      (begin
+	(anthy-context-set-transposing! ac #f)
+	(anthy-proc-input-state-with-preedit ac key key-state))))))
+
 (define anthy-proc-input-state-with-preedit
   (lambda (ac key key-state)
     (let ((preconv-str (anthy-context-preconv-ustr ac))
@@ -473,7 +504,7 @@
 	  (kana (anthy-context-kana-mode ac))
 	  (rule (anthy-context-input-rule ac)))
       (cond
-       
+
        ;; begin conversion
        ((anthy-begin-conv-key? key key-state)
 	(anthy-begin-conv ac))
@@ -510,38 +541,15 @@
 	   (anthy-make-whole-string ac #t (multi-segment-opposite-kana kana)))
 	  (anthy-flush ac)))
 
-       ;; ¥«¥¿¥«¥Ê¥â¡¼¥É¤Ç¤«¤Ê¤ò³ÎÄꤹ¤ë
-       ((anthy-commit-as-katakana-key? key key-state)
+       ;; Transposing¾õÂ֤ذܹÔ
+       ((or (anthy-transpose-as-katakana-key?   key key-state)
+	    (anthy-transpose-as-hankana-key?    key key-state)
+	    (anthy-transpose-as-latin-key?      key key-state)
+	    (anthy-transpose-as-wide-latin-key? key key-state))
 	(begin
-	  (im-commit
-	   ac
-	   (anthy-make-whole-string ac #t multi-segment-type-katakana))
-	  (anthy-flush ac)))
+	  (anthy-context-set-transposing! ac #t)
+	  (anthy-proc-transposing-state ac key key-state)))
 
-       ;; Ⱦ³Ñ¥«¥¿¥«¥Ê¥â¡¼¥É¤Ç¤«¤Ê¤ò³ÎÄꤹ¤ë
-       ((anthy-commit-as-hankana-key? key key-state)
-	(begin
-	  (im-commit
-	   ac
-	   (anthy-make-whole-string ac #t multi-segment-type-hankana))
-	  (anthy-flush ac)))
-
-       ;; ¤«¤Ê¤ò±Ñ¿ô»ú¤ËÌᤷ¤Æ³ÎÄꤹ¤ë
-       ((anthy-commit-as-latin-key? key key-state)
-	(begin
-	  (im-commit
-	   ac
-           (anthy-make-whole-raw-string ac #f))
-	  (anthy-flush ac)))
-
-       ;; ¤«¤Ê¤òÁ´³Ñ±Ñ¿ô»ú¤ËÌᤷ¤Æ³ÎÄꤹ¤ë
-       ((anthy-commit-as-wide-latin-key? key key-state)
-	(begin
-	  (im-commit
-	   ac
-           (anthy-make-whole-raw-string ac #t))
-	  (anthy-flush ac)))
-
        ;; Commit current preedit string, then toggle hiragana/katakana mode.
        ((anthy-kana-toggle-key? key key-state)
 	(begin
@@ -649,6 +657,29 @@
 	  (cons attr anthy-segment-separator)
 	  #f))))
 
+(define anthy-context-transposing-state-preedit
+  (lambda (ac)
+    (let* ((transposing-text (anthy-transposing-text ac)))
+      (list (cons preedit-underline transposing-text)
+	    (cons preedit-cursor "")))))
+
+(define anthy-transposing-text
+  (lambda (ac)
+    (let* ((transposing-type (anthy-context-transposing-type ac)))
+      (cond
+       ((= transposing-type anthy-type-katakana)
+	(anthy-make-whole-string ac #t multi-segment-type-katakana))
+
+       ((= transposing-type anthy-type-hankana)
+	(anthy-make-whole-string ac #t multi-segment-type-hankana))
+
+       ((= transposing-type anthy-type-latin)
+	(anthy-make-whole-raw-string ac #f))
+
+       ((= transposing-type anthy-type-wide-latin)
+	(anthy-make-whole-raw-string ac #t))
+       ))))
+
 (define anthy-converting-state-preedit
   (lambda (ac)
     (let* ((ac-id (anthy-context-ac-id ac))
@@ -896,14 +927,17 @@
     (if (control-char? key)
 	(im-commit-raw ac)
 	(if (anthy-context-on ac)
-	    (if (anthy-context-converting ac)
-		(anthy-proc-converting-state ac key key-state)
-		(anthy-proc-input-state ac key key-state))
+	    (if (anthy-context-transposing ac)
+		(anthy-proc-transposing-state ac key key-state)
+		(if (anthy-context-converting ac)
+		    (anthy-proc-converting-state ac key key-state)
+		    (anthy-proc-input-state ac key key-state)))
 	    (if (anthy-context-wide-latin ac)
 		(anthy-proc-wide-latin ac key key-state)
 		(anthy-proc-raw-state ac key key-state))))
     ;; preedit
-    (anthy-update-preedit ac)))
+    (anthy-update-preedit ac)
+))
 
 
 (define anthy-release-key-handler



More information about the uim-commit mailing list