[Anthy-dev 414] uim-skkでcommitとreturnを区別するように

Back to archive index

YamaKen yamak****@bp*****
2004年 1月 14日 (水) 01:38:50 JST


ヤマケンです。

uim-skkでreturnを押した時の挙動を普通のSKKに合わせてみました。

現在の実装ではreturnはC-jと同じ機能ですが、通常のSKKでは「変換中
文字列を確定し、さらにreturnを入力する」という仕様になっていて便
利なのでそれに合わせました。

現在のuim-skkでは以下のような動作をしますが、

  ▼とうきょうとちよだく[東京都▼千代田区]
    ↓ RET(C-j)
  ▼とうきょうとちよだく[東京都千代田区]
    ↓ RET
  東京都千代田区

  ▼牛丼
    ↓ RET
  牛丼I      ("I"はカーソル)


添付のパッチを当てると次のようになります。

  ▼とうきょうとちよだく[東京都▼千代田区]
    ↓ RET
  東京都千代田区


  ▼牛丼
    ↓ RET
  牛丼
  I          ("I"はカーソル)


ついでに再帰学習時もC-mをreturnの代わりに使えるようにし、
'skk-state-kanjiや'skk-state-okuriの時もreturnで確定できるように
しました。上記の全ての挙動はddskkと同様である事を確認してありま
す。

-------------------------------
ヤマケン yamak****@bp*****
-------------- next part --------------
Index: generic-key.scm
===================================================================
--- generic-key.scm	(revision 352)
+++ generic-key.scm	(working copy)
@@ -14,14 +14,18 @@
      (and
       (= (to-lower-char key) 112)
       (control-key-mask key-state)))))
+(define generic-return-key
+  (lambda (key key-state)
+    (or
+     (and (= (to-lower-char key) 109)
+	  (control-key-mask key-state))
+     (= key 'return))))
 (define generic-commit-key
   (lambda (key key-state)
     (or
      (and (= (to-lower-char key) 106)
 	  (control-key-mask key-state))
-     (and (= (to-lower-char key) 109)
-	  (control-key-mask key-state))
-     (= key 'return))))
+     (generic-return-key key key-state))))
 (define generic-cancel-key
   (lambda (key key-state)
     (or
Index: skk-editor.scm
===================================================================
--- skk-editor.scm	(revision 352)
+++ skk-editor.scm	(working copy)
@@ -99,7 +99,7 @@
 		      ec (cdr cur)))
 		 #f)
 	       #t)
-	   (if (= key 'return)
+	   (if (skk-return-key key key-state)
 	       (begin
 		 (skk-lib-learn-word
 		  (skk-make-string (skk-context-head sc) #t)
Index: skk.scm
===================================================================
--- skk.scm	(revision 352)
+++ skk.scm	(working copy)
@@ -46,9 +46,13 @@
      (and (= (to-lower-char key) 106)
 	  (control-key-mask key-state))
      (generic-on-key key key-state))))
+(define skk-return-key
+  (lambda (key key-state)
+    (generic-return-key key key-state)))
 (define skk-commit-key
   (lambda (key key-state)
-    (generic-commit-key key key-state)))
+    (and (= (to-lower-char key) 106)
+	 (control-key-mask key-state))))
 (define skk-next-candidate-key
   (lambda (key key-state)
     (generic-next-candidate-key key key-state)))
@@ -310,8 +314,8 @@
     (let ((psc (skk-context-parent-context sc)))
       (if psc
 	  (skk-editor-commit-raw
-	   (skk-context-editor
-	    psc) key key-state)
+	   (skk-context-editor psc)
+	   key key-state)
 	  (im-commit-raw id)))))
 
 ;; commit string
@@ -609,7 +613,9 @@
 		       (skk-flush sc))))
 	     #f)
 	   #t)
-       (if (skk-commit-key key key-state)
+       (if (or
+	    (skk-commit-key key key-state)
+	    (skk-return-key key key-state))
 	   (begin
 	     (skk-commit sc id (skk-make-string
 				(skk-context-head sc)
@@ -617,6 +623,8 @@
 	     (skk-flush sc)
 	     (skk-context-set-state! sc 'skk-state-direct)
 	     (skk-update-mode id sc)
+	     (if (skk-return-key key key-state)
+		 (skk-proc-state-direct c key key-state))
 	     #f)
 	   #t)
        (if (skk-context-latin-conv sc)
@@ -765,7 +773,9 @@
 	     (skk-back-to-kanji-state sc id)
 	     #f)
 	   #t)
-       (if (skk-commit-key key key-state)
+       (if (or
+	    (skk-commit-key key key-state)
+	    (skk-return-key key key-state))
 	   (begin
 	     (set! res (skk-get-current-candidate sc))
 	     (set!
@@ -786,6 +796,11 @@
 	     (skk-flush sc)
 	     (skk-context-set-state! sc 'skk-state-direct)
 	     (skk-update-mode id sc)
+	     (if (skk-return-key key key-state)
+		 (begin
+		   (skk-commit sc id res)
+		   (set! res ())
+		   (skk-proc-state-direct c key key-state)))
 	     #f)
 	   #t)
        (begin
@@ -838,6 +853,21 @@
 		       (skk-context-set-state! sc 'skk-state-kanji)))))
 	     #f)
 	   #t)
+       ;; committing incomplete head: conformed the behavior to ddskk
+       (if (or
+	    (skk-commit-key key key-state)
+	    (skk-return-key key key-state))
+	   (begin
+	     (skk-commit sc id (skk-make-string
+				(skk-context-head sc)
+				(skk-context-kana-mode sc)))
+	     (skk-flush sc)
+	     (skk-context-set-state! sc 'skk-state-direct)
+	     (skk-update-mode id sc)
+	     (if (skk-return-key key key-state)
+		 (skk-proc-state-direct c key key-state))
+	     #f)
+	   #t)
        (begin
 	 (set! res
 	       (rk-push-key!


Anthy-dev メーリングリストの案内
Back to archive index