[uim-commit] r269 - in trunk: scm uim
ekato@freedesktop.org
ekato@freedesktop.org
Wed Jan 12 10:08:58 PST 2005
Author: ekato
Date: 2005-01-12 10:08:56 -0800 (Wed, 12 Jan 2005)
New Revision: 269
Modified:
trunk/scm/custom-vars.scm
trunk/scm/generic.scm
trunk/scm/skk.scm
trunk/scm/util.scm
trunk/uim/slib.c
Log:
* scm/generic.scm (generic-commit-by-numkey) : Fix typo.
* uim/slib.c (Quotient) : Add comment.
(Remainder) : New function for r5rs. Exported as remainder for
scheme.
* scm/util.scm (quotient) : New for r5rs. This is an alias of '/'
in siod.
* scm/skk.scm : Update copyright.
(skk-commit-candidate-by-label-key?) : New custom
variable. Default is #f.
(skk-context-rec-spec) : Add new member nr-candidates in order to
reduce complexity of calling skk-lib-get-nr-candidates many
times.
(skk-begin-conversion) : Reset skk-context-nr-candidates here.
(skk-check-candidate-window-begin) : Call
skk-lib-get-nr-candidates only at here and store it to
skk-context-nr-candidates.
(skk-commit-by-label-key) : New function. Commit candidate
by key denoted by its heading label. Only numeric key handling
is enabled yet.
(skk-change-candidate-index) : Simplify using
skk-context-nr-candidates.
(skk-heading-label-char?) : New function. Currently only handles
numeric characters.
(skk-proc-state-converting) : Add candidate committing facility
using label keys.
(skk-get-candidate-handler) : Change to use remainder as label.
* scm/custom-vars.scm (skk-commit-candidate-by-label-key?) : New
custom variable for uim-skk.
Modified: trunk/scm/custom-vars.scm
===================================================================
--- trunk/scm/custom-vars.scm 2005-01-12 17:39:59 UTC (rev 268)
+++ trunk/scm/custom-vars.scm 2005-01-12 18:08:56 UTC (rev 269)
@@ -541,6 +541,12 @@
(_ "Friendly for vi user")
(_ "long description will be here."))
+(define-custom 'skk-commit-candidate-by-label-key? #t
+ '(skk advanced)
+ '(boolean)
+ (_ "Commit candidate by heading label keys")
+ (_ "long description will be here."))
+
(define-custom 'skk-dic-file-name (string-append (sys-datadir)
"/skk/SKK-JISYO.L")
'(skk)
Modified: trunk/scm/generic.scm
===================================================================
--- trunk/scm/generic.scm 2005-01-12 17:39:59 UTC (rev 268)
+++ trunk/scm/generic.scm 2005-01-12 18:08:56 UTC (rev 269)
@@ -171,7 +171,7 @@
(+ pageidx 10))
(else
pageidx)))
- (idx (+ (* cur-page anthy-nr-candidate-max) compensated-pageidx)))
+ (idx (+ (* cur-page generic-nr-candidate-max) compensated-pageidx)))
(im-commit pc (nth idx (cadr cs)))
(im-deactivate-candidate-selector pc)
(rk-flush rkc))))
Modified: trunk/scm/skk.scm
===================================================================
--- trunk/scm/skk.scm 2005-01-12 17:39:59 UTC (rev 268)
+++ trunk/scm/skk.scm 2005-01-12 18:08:56 UTC (rev 269)
@@ -1,5 +1,5 @@
;;;
-;;; Copyright (c) 2003,2004 uim Project http://uim.freedesktop.org/
+;;; Copyright (c) 2003-2005 uim Project http://uim.freedesktop.org/
;;;
;;; All rights reserved.
;;;
@@ -65,6 +65,7 @@
(define skk-style 'skk-style-ddskk-like)
(define skk-use-with-vi? #f)
(define skk-use-numeric-conversion? #t)
+(define skk-commit-candidate-by-label-key? #f)
;; key defs
(define-key skk-latin-key? '("l" generic-off-key?))
@@ -289,6 +290,7 @@
(list 'okuri "")
;;(list 'candidates ())
(list 'nth ())
+ (list 'nr-candidates ())
(list 'rk-context ())
(list 'candidate-op-count ())
(list 'candidate-window ())
@@ -603,6 +605,7 @@
(if res
(begin
(skk-context-set-nth! sc 0)
+ (skk-context-set-nr-candidates! sc 0)
(skk-check-candidate-window-begin sc)
(if (skk-context-candidate-window sc)
(im-select-candidate sc 0))
@@ -913,7 +916,7 @@
;; For special exception, don't commit native space if
;; this key sequcence produce zenkaku space.
(if (not (and res
- (string=? (car res) "¡¡")))
+ (string=? (car res) "¡¡")))
(skk-commit-raw-with-preedit-update sc key key-state))
#f)
#t)
@@ -1189,24 +1192,53 @@
;; store numeric strings to check #4
(let ((numlst (skk-lib-store-replaced-numstr
(skk-make-string head skk-type-hiragana))))
+ (skk-context-set-nr-candidates!
+ sc
+ (skk-lib-get-nr-candidates
+ (skk-lib-replace-numeric
+ (skk-make-string head skk-type-hiragana))
+ (skk-context-okuri-head sc)
+ (skk-make-string (skk-context-okuri sc) skk-type-hiragana)
+ numlst))
(im-activate-candidate-selector
sc
+ (skk-context-nr-candidates sc)
+ skk-nr-candidate-max))
+ (begin
+ (skk-context-set-nr-candidates!
+ sc
(skk-lib-get-nr-candidates
- (skk-lib-replace-numeric
- (skk-make-string head skk-type-hiragana))
+ (skk-make-string head skk-type-hiragana)
(skk-context-okuri-head sc)
(skk-make-string (skk-context-okuri sc) skk-type-hiragana)
- numlst)
- skk-nr-candidate-max))
- (im-activate-candidate-selector
- sc
- (skk-lib-get-nr-candidates
- (skk-make-string head skk-type-hiragana)
- (skk-context-okuri-head sc)
- (skk-make-string (skk-context-okuri sc) skk-type-hiragana)
- #f)
- skk-nr-candidate-max)))))))
+ #f))
+ (im-activate-candidate-selector
+ sc
+ (skk-context-nr-candidates sc)
+ skk-nr-candidate-max))))))))
+(define skk-commit-by-label-key
+ (lambda (sc key)
+ (let ((nr (skk-context-nr-candidates sc))
+ (cur-page (quotient (skk-context-nth sc) skk-nr-candidate-max))
+ (idx -1)
+ (res #f))
+ (if (numeral-char? key)
+ (let ((num (numeral-char->number key)))
+ (if (= num 0)
+ (set! num 9) ; pressing key_0
+ (set! num (- num 1)))
+ (if (< num skk-nr-candidate-max)
+ (set! idx (+ (* cur-page skk-nr-candidate-max) num))))
+ ;; FIXME: add code to handle labels other than number here
+ )
+ (if (and (>= idx 0)
+ (< idx nr))
+ (begin
+ (skk-context-set-nth! sc idx)
+ (set! res (skk-prepare-commit-string sc))))
+ res)))
+
(define skk-change-candidate-index
(lambda (sc incr)
(let ((head (skk-context-head sc)))
@@ -1220,30 +1252,9 @@
(begin
(if (> (skk-context-nth sc) 0)
(skk-context-set-nth! sc (- (skk-context-nth sc) 1))
- (begin
- (if skk-use-numeric-conversion?
- ;; store original number for numeric conversion
- (let ((numlst (skk-lib-store-replaced-numstr
- (skk-make-string head skk-type-hiragana))))
- (skk-context-set-nth! sc (- (skk-lib-get-nr-candidates
- (skk-lib-replace-numeric
- (skk-make-string
- head skk-type-hiragana))
- (skk-context-okuri-head sc)
- (skk-make-string
- (skk-context-okuri sc)
- skk-type-hiragana)
- numlst)
- 1)))
- (skk-context-set-nth! sc (- (skk-lib-get-nr-candidates
- (skk-make-string
- head skk-type-hiragana)
- (skk-context-okuri-head sc)
- (skk-make-string
- (skk-context-okuri sc)
- skk-type-hiragana)
- #f)
- 1)))))))
+ (skk-context-set-nth!
+ sc
+ (- (skk-context-nr-candidates sc) 1)))))
(if (not (skk-get-current-candidate sc))
(begin
(skk-context-set-nth! sc 0)
@@ -1344,6 +1355,12 @@
(skk-proc-state-kanji c key key-state)))
#f)))
+(define skk-heading-label-char?
+ (lambda (key)
+ (if (numeral-char? key) ;; FIXME: should handle key other than number
+ #t
+ #f)))
+
(define skk-proc-state-converting
(lambda (c key key-state)
(let ((sc (skk-find-descendant-context c))
@@ -1390,6 +1407,15 @@
(skk-proc-state-direct c key key-state))))))
#f)
#t)
+ (if (and skk-commit-candidate-by-label-key?
+ (skk-heading-label-char? key)
+ (skk-context-candidate-window sc))
+ (begin
+ (set! res (skk-commit-by-label-key sc key))
+ (if res
+ #f
+ #t))
+ #t)
(begin
(skk-context-set-state! sc 'skk-state-direct)
(set! res (skk-prepare-commit-string sc))
@@ -1561,7 +1587,8 @@
(string-append cand
(skk-make-string okuri skk-type-hiragana))
cand)
- (digit->string (+ idx 1))
+ ;; FIXME make sure to enable lable other than number
+ (digit->string (+ (remainder idx skk-nr-candidate-max) 1))
""))))
(define skk-set-candidate-index-handler
Modified: trunk/scm/util.scm
===================================================================
--- trunk/scm/util.scm 2005-01-12 17:39:59 UTC (rev 268)
+++ trunk/scm/util.scm 2005-01-12 18:08:56 UTC (rev 269)
@@ -198,6 +198,8 @@
(define for-each map)
+(define quotient /) ;; / in siod is quotient actually
+
;;(define list-tail
;; (lambda (lst n)
;; (if (= n 0)
Modified: trunk/uim/slib.c
===================================================================
--- trunk/uim/slib.c 2005-01-12 17:39:59 UTC (rev 268)
+++ trunk/uim/slib.c 2005-01-12 18:08:56 UTC (rev 269)
@@ -1598,7 +1598,7 @@
(x) my_err ("wta(1st) to quotient", x);
if NULLP
(y)
- return (intcons (1 / INTNM (x)));
+ return (intcons (1 / INTNM (x))); /* XXX divided by 0 actually */
else
{
if NINTNUMP
@@ -1608,6 +1608,22 @@
}
static LISP
+Remainder (LISP x, LISP y)
+{
+ if NINTNUMP
+ (x) my_err ("wta(1st) to remainder", x);
+ if NULLP
+ (y)
+ return (intcons (1 % INTNM (x))); /* XXX divided by 0 actually */
+ else
+ {
+ if NINTNUMP
+ (y) my_err ("wta(2nd) to remainder", y);
+ return (intcons (INTNM (x) % INTNM (y)));
+ }
+}
+
+static LISP
lllabs (LISP x)
{
double v;
@@ -4555,6 +4571,7 @@
init_subr_2n ("-", difference);
init_subr_2n ("*", ltimes);
init_subr_2n ("/", Quotient);
+ init_subr_2n ("remainder", Remainder);
init_subr_2n ("min", lmin);
init_subr_2n ("max", lmax);
init_subr_1 ("abs", lllabs);
More information about the Uim-commit
mailing list