Revision: abbfb3a290dc
Author: Etsushi Kato <ek.k...@gmail.com>
Date: Tue Jul 24 21:07:54 2012
Log: Support sticky key for uim-skk by anyakichi
(https://gist.github.com/1241544)
* scm/skk.scm
- (skk-proc-state-direct-no-preedit) : Handle sticky keys.
- (skk-proc-state-direct) : Ditto.
- (skk-proc-state-kanji) : Ditto.
- (skk-proc-state-okuri) : Ditto.
* scm/skk-key-custom.scm
- (skk-sticky-key) : New custom variable.
http://code.google.com/p/uim/source/detail?r=abbfb3a290dc
Modified:
/scm/skk-key-custom.scm
/scm/skk.scm
=======================================
--- /scm/skk-key-custom.scm Wed Jan 11 00:17:24 2012
+++ /scm/skk-key-custom.scm Tue Jul 24 21:07:54 2012
@@ -146,6 +146,12 @@
(N_ "[SKK] cancel")
(N_ "long description will be here"))
+(define-custom 'skk-sticky-key '()
+ '(skk-keys1)
+ '(key)
+ (N_ "[SKK] sticky")
+ (N_ "long description will be here"))
+
;;
;; advanced 1
;;
=======================================
--- /scm/skk.scm Wed Jan 11 00:17:24 2012
+++ /scm/skk.scm Tue Jul 24 21:07:54 2012
@@ -1047,6 +1047,10 @@
(skk-context-set-state! sc 'skk-state-kanji)
(skk-context-set-latin-conv! sc #t)
#f)
+ ((skk-sticky-key? key key-state)
+ (skk-context-set-state! sc 'skk-state-kanji)
+ (skk-context-set-latin-conv! sc #f)
+ #f)
((skk-kanji-mode-key? key key-state)
(skk-context-set-state! sc 'skk-state-kanji)
(skk-context-set-latin-conv! sc #f)
@@ -1158,6 +1162,15 @@
(skk-context-set-latin-conv! sc #t)
#f)
#t)
+ (if (and (skk-sticky-key? key key-state)
+ (not (rk-expect-key? rkc key-str)))
+ (let* ((residual-kana (rk-push-key-last! rkc)))
+ (if residual-kana
+ (skk-commit sc (skk-get-string sc residual-kana kana)))
+ (skk-context-set-state! sc 'skk-state-kanji)
+ (skk-context-set-latin-conv! sc #f)
+ #f)
+ #t)
(if (and (skk-kanji-mode-key? key key-state)
(not (rk-expect-key? rkc key-str)))
(let* ((residual-kana (rk-push-key-last! rkc)))
@@ -1529,6 +1542,16 @@
(skk-begin-conversion sc)
#f)
#t)
+ (if (skk-sticky-key? key key-state)
+ (if (null? (skk-context-head sc))
+ (begin
+ (skk-commit sc (charcode->string key))
+ (skk-flush sc)
+ #f)
+ (begin
+ (skk-context-set-state! sc 'skk-state-okuri)
+ #f))
+ #t)
(if (and (skk-ichar-upper-case? key)
(not (null? (skk-context-head sc))))
(let ((key-str (charcode->string (skk-ichar-downcase key))))
@@ -2071,6 +2094,14 @@
#f)
#t)
(begin
+ (if (string=? (skk-context-okuri-head sc) "")
+ (if (skk-rk-pending? sc)
+ (skk-context-set-okuri-head-using-alist!
+ sc
+ (car (reverse (rk-context-seq rkc))))
+ (skk-context-set-okuri-head-using-alist!
+ sc
+ (charcode->string (skk-ichar-downcase key)))))
(set! res
(rk-push-key!
rkc