[uim-commit] r1079 - trunk/scm

tkng at freedesktop.org tkng at freedesktop.org
Sun Jul 31 15:12:58 EST 2005


Author: tkng
Date: 2005-07-30 22:12:55 -0700 (Sat, 30 Jul 2005)
New Revision: 1079

Modified:
   trunk/scm/m17nlib.scm
Log:
* scm/m17nlib.scm:
 -(m17nlib-push-key): Call m17nlib-translate-ukey-to-mkey
  also when key is not a symbol.
 -(m17nlib-key-translation-alist): Data to translate symbol
   key to m17n-lib key.
 -(m17nlib-construct-modifier): New function.
 -(m17nlib-translate-ukey-to-mkey): Corresponded when key isn't
  a symbol key.


Modified: trunk/scm/m17nlib.scm
===================================================================
--- trunk/scm/m17nlib.scm	2005-07-31 04:53:40 UTC (rev 1078)
+++ trunk/scm/m17nlib.scm	2005-07-31 05:12:55 UTC (rev 1079)
@@ -174,17 +174,18 @@
 	  (im-select-candidate mc (m17nlib-lib-get-candidate-index mid))))))
 
 
-(define m17nlib-append-modifiers
-  (lambda (key key-state key-str)
-    (if (shift-key-mask key-state)
-	(set! key-str (string-append "S-" key-str)))
-    (if (control-key-mask key-state)
-	(set! key-str (string-append "C-" key-str)))
-    (if (alt-key-mask key-state)
-	(set! key-str (string-append "A-" key-str)))
-    (if (meta-key-mask key-state)
-	(set! key-str (string-append "M-" key-str)))
-    key-str))
+(define m17nlib-construct-modifier
+  (lambda (key-state)
+    (let ((key-str ""))
+      (if (shift-key-mask key-state)
+	  (set! key-str (string-append "S-" key-str)))
+      (if (control-key-mask key-state)
+	  (set! key-str (string-append "C-" key-str)))
+      (if (alt-key-mask key-state)
+	  (set! key-str (string-append "A-" key-str)))
+      (if (meta-key-mask key-state)
+	  (set! key-str (string-append "M-" key-str)))
+      key-str)))
 
 (define m17nlib-proc-direct-state
   (lambda (mc key key-state)
@@ -196,52 +197,55 @@
   (lambda (mc)
     (im-commit-raw mc)))
 
-
+(define m17nlib-key-translation-alist
+  '((backspace       . "BackSpace")
+    (delete          . "Delete")
+    (escape          . "Escape")
+    (return          . "Return")
+    (tab             . "Tab")
+    (left            . "Left")
+    (up              . "Up")
+    (right           . "Right")
+    (down            . "Down")
+    (prior           . "Page_Down")
+    (next            . "Page_Up")
+    (home            . "Home")
+    (end             . "End")
+    (zenkaku-hankaku . "")
+    (Multi_key       . "")
+    (Mode_switch     . "")
+    (Henkan_Mode     . "")
+    (Muhenkan        . "")
+    (F1              . "F1")
+    (F2              . "F2")
+    (F3              . "F3")
+    (F4              . "F4")
+    (F5              . "F5")
+    (F6              . "F6")
+    (F7              . "F7")
+    (F8              . "F8")
+    (F9              . "F9")
+    (F10             . "F10")
+    (F11             . "F11")
+    (F12             . "F12")
+    (F13             . "F13")
+    (F14             . "F14")
+    (F15             . "F15")
+    (F16             . "F16")
+    (F17             . "F17")
+    (F18             . "F18")
+    (F19             . "F19")
+    (F20             . "F20")))
+  
 ; Unfortunatelly, we don't have simple way to translate...
 (define m17nlib-translate-ukey-to-mkey
   (lambda (key key-state)
-    (m17nlib-append-modifiers
-     key key-state
-     (cdr (assq key
-		'((backspace       . "BackSpace")
-		  (delete          . "Delete")
-		  (escape          . "Escape")
-		  (return          . "Return")
-		  (tab             . "Tab")
-		  (left            . "Left")
-		  (up              . "Up")
-		  (right           . "Right")
-		  (down            . "Down")
-		  (prior           . "Page_Down")
-		  (next            . "Page_Up")
-		  (home            . "Home")
-		  (end             . "End")
-		  (zenkaku-hankaku . "")
-		  (Multi_key       . "")
-		  (Mode_switch     . "")
-		  (Henkan_Mode     . "")
-		  (Muhenkan        . "")
-		  (F1              . "F1")
-		  (F2              . "F2")
-		  (F3              . "F3")
-		  (F4              . "F4")
-		  (F5              . "F5")
-		  (F6              . "F6")
-		  (F7              . "F7")
-		  (F8              . "F8")
-		  (F9              . "F9")
-		  (F10             . "F10")
-		  (F11             . "F11")
-		  (F12             . "F12")
-		  (F13             . "F13")
-		  (F14             . "F14")
-		  (F15             . "F15")
-		  (F16             . "F16")
-		  (F17             . "F17")
-		  (F18             . "F18")
-		  (F19             . "F19")
-		  (F20             . "F20")))))))
-  
+    (string-append 
+     (m17nlib-construct-modifier key-state)
+     (if (symbol? key)
+	 (cdr (assq key m17nlib-key-translation-alist))
+	 (charcode->string key)))))
+
 (define m17nlib-init-handler
   (lambda (id im arg)
     (m17nlib-context-new id im arg)))
@@ -258,11 +262,8 @@
 	(m17nlib-context-set-on! mc #f)
 	#t) ;; #t means key event was consumed.
        (else
-	(if (symbol? key)
-	    (let ((mkey (m17nlib-translate-ukey-to-mkey key key-state)))
-	      (m17nlib-lib-push-symbol-key mid mkey))
-	    (let ((mkey (m17nlib-append-modifiers key key-state (charcode->string key))))
-	      (m17nlib-lib-push-symbol-key mid mkey))))))))
+	(let ((mkey (m17nlib-translate-ukey-to-mkey key key-state)))
+	  (m17nlib-lib-push-symbol-key mid mkey)))))))
 
 (define m17nlib-press-key-handler
   (lambda (mc key key-state)



More information about the uim-commit mailing list