Author: deton.kih
Date: Sun Jan 13 19:31:35 2008
New Revision: 5123
Modified:
trunk/scm/tutcode-custom.scm
trunk/scm/tutcode-key-custom.scm
trunk/scm/tutcode.scm
Log:
* This commit add support of candidate window for tutcode
* scm/tutcode-key-custom.scm
- (tutcode-next-page-key, tutcode-prev-page-key): New custom key definition
* scm/tutcode-custom.scm
- (custom tutcode-use-candidate-window?, custom tutcode-candidate-op-count,
custom tutcode-nr-candidate-max): New custom variable
* scm/tutcode.scm
- (tutcode-context-rec-spec): Add context candidate-window.
- (tutcode-flush, tutcode-back-to-yomi-state):
Add call to reset candidate window.
- (tutcode-begin-conversion): Change to begin candidate window.
- (tutcode-check-candidate-window-begin, tutcode-reset-candidate-window,
tutcode-change-candidate-index): New function.
- (tutcode-proc-state-converting):
Change to use tutcode-change-candidate-index instead of
tutcode-incr-candidate-index or tutcode-decr-candidate-index directly.
Add support of tutcode-next-page-key, tutcode-prev-page-key.
- (tutcode-get-candidate-handler, tutcode-set-candidate-index-handler):
Implement
Modified: trunk/scm/tutcode-custom.scm
==============================================================================
--- trunk/scm/tutcode-custom.scm (original)
+++ trunk/scm/tutcode-custom.scm Sun Jan 13 19:31:35 2008
@@ -79,3 +79,36 @@
'(boolean)
(N_ "Use Dvorak keyboard")
(N_ "long description will be here."))
+
+;;
+;; candidate window
+;;
+
+(define-custom 'tutcode-use-candidate-window? #t
+ '(tutcode candwin)
+ '(boolean)
+ (N_ "Use candidate window")
+ (N_ "long description will be here."))
+
+(define-custom 'tutcode-candidate-op-count 5
+ '(tutcode candwin)
+ '(integer 0 99)
+ (N_ "Conversion key press count to show candidate window")
+ (N_ "long description will be here."))
+
+(define-custom 'tutcode-nr-candidate-max 10
+ '(tutcode candwin)
+ '(integer 1 20)
+ (N_ "Number of candidates in candidate window at a time")
+ (N_ "long description will be here."))
+
+;; activity dependency
+(custom-add-hook 'tutcode-candidate-op-count
+ 'custom-activity-hooks
+ (lambda ()
+ tutcode-use-candidate-window?))
+
+(custom-add-hook 'tutcode-nr-candidate-max
+ 'custom-activity-hooks
+ (lambda ()
+ tutcode-use-candidate-window?))
Modified: trunk/scm/tutcode-key-custom.scm
==============================================================================
--- trunk/scm/tutcode-key-custom.scm (original)
+++ trunk/scm/tutcode-key-custom.scm Sun Jan 13 19:31:35 2008
@@ -101,6 +101,18 @@
(N_ "[TUT-Code] previous candidate")
(N_ "long description will be here"))
+(define-custom 'tutcode-next-page-key '(generic-next-page-key)
+ '(tutcode-keys2)
+ '(key)
+ (N_ "[TUT-Code] next page of candidate window")
+ (N_ "long description will be here"))
+
+(define-custom 'tutcode-prev-page-key '(generic-prev-page-key)
+ '(tutcode-keys2)
+ '(key)
+ (N_ "[TUT-Code] previous page of candidate window")
+ (N_ "long description will be here"))
+
(define-custom 'tutcode-backspace-key '(generic-backspace-key)
'(tutcode-keys2)
'(key)
Modified: trunk/scm/tutcode.scm
==============================================================================
--- trunk/scm/tutcode.scm (original)
+++ trunk/scm/tutcode.scm Sun Jan 13 19:31:35 2008
@@ -58,7 +58,6 @@
;;; - ���ַ����Ѵ�
;;; - ���Ѵ�����ؤ���Ͽ�����
;;; - �ɤߤФ�����̤�ꤹ�뵡ǽ���ɤߤ��䴰��ǽ
-;;; - ���������ɥ��λ���
;;;
;;; ���������
;;; * ������ɽ�ΰ�����ѹ����������ϡ��㤨��~/.uim�ǰʲ��Τ褦�˵��Ҥ��롣
@@ -200,7 +199,9 @@
;;; ���Ѵ��������θ�����ֹ�
(nth 0)
;;; ���Ѵ��θ����
- (nr-candidates 0))))
+ (nr-candidates 0)
+ ;;; ���䥦����ɥ���ɽ���椫�ɤ���
+ (candidate-window #f))))
(define-record 'tutcode-context tutcode-context-rec-spec)
(define tutcode-context-new-internal tutcode-context-new)
(define tutcode-context-katakana-mode? tutcode-context-katakana-mode)
@@ -269,7 +270,8 @@
(if (tutcode-context-on? pc) ; ���ջ��˸ƤФ줿���ϥ���ˤ���������
(tutcode-context-set-state! pc 'tutcode-state-on)) ; �Ѵ����֤ꥢ����
(tutcode-context-set-head! pc ())
- (tutcode-context-set-nr-candidates! pc 0))
+ (tutcode-context-set-nr-candidates! pc 0)
+ (tutcode-reset-candidate-window pc))
;;; �Ѵ��оݤ�ʸ����ꥹ�Ȥ���ʸ������롣
;;; @param sl ʸ����ꥹ��
@@ -325,12 +327,28 @@
(tutcode-context-set-nr-candidates! pc
(skk-lib-get-nr-candidates yomi "" "" #f))
(tutcode-context-set-state! pc 'tutcode-state-converting)
- ;; ���䤬1�Ĥ����ʤ����ϼ�ưŪ�˳��ꤹ��
(if (= (tutcode-context-nr-candidates pc) 1)
- (im-commit pc (tutcode-prepare-commit-string pc))))
- ;(tutcode-flush pc) ; flush��������Ϥ���ʸ���ä��Ƥ��ä���
+ ;; ���䤬1�Ĥ����ʤ����ϼ�ưŪ�˳��ꤹ��
+ (im-commit pc (tutcode-prepare-commit-string pc))
+ (begin
+ (tutcode-check-candidate-window-begin pc)
+ (if (tutcode-context-candidate-window pc)
+ (im-select-candidate pc 0)))))
+ ;(tutcode-flush pc) ; ����̵����flush��������Ϥ���ʸ���ä��Ƥ��ä���
)))
+;;; ���䥦����ɥ���ɽ���Ϥ���
+(define (tutcode-check-candidate-window-begin pc)
+ (if (and (not (tutcode-context-candidate-window pc))
+ tutcode-use-candidate-window?
+ (>= (tutcode-context-nth pc) (- tutcode-candidate-op-count 1)))
+ (begin
+ (tutcode-context-set-candidate-window! pc #t)
+ (im-activate-candidate-selector
+ pc
+ (tutcode-context-nr-candidates pc)
+ tutcode-nr-candidate-max))))
+
;;; preeditɽ�������롣
;;; @param pc ����ƥ����ȥꥹ��
(define (tutcode-update-preedit pc)
@@ -579,9 +597,28 @@
(if (>= (- nth 1) 0)
(tutcode-context-set-nth! pc (- nth 1)))))
+;;; ���Ѵ�����������ֹ��+1��-1���롣
+;;; @param pc ����ƥ����ȥꥹ��
+;;; @param incr #t:+1��, #f:-1��
+(define (tutcode-change-candidate-index pc incr)
+ (if incr
+ (tutcode-incr-candidate-index pc)
+ (tutcode-decr-candidate-index pc))
+ (tutcode-check-candidate-window-begin pc)
+ (if (tutcode-context-candidate-window pc)
+ (im-select-candidate pc (tutcode-context-nth pc))))
+
+;;; ���䥦����ɥ����Ĥ���
+(define (tutcode-reset-candidate-window pc)
+ (if (tutcode-context-candidate-window pc)
+ (begin
+ (im-deactivate-candidate-selector pc)
+ (tutcode-context-set-candidate-window! pc #f))))
+
;;; ���Ѵ��θ��������֤��顢�ɤ����Ͼ��֤��᤹��
;;; @param pc ����ƥ����ȥꥹ��
(define (tutcode-back-to-yomi-state pc)
+ (tutcode-reset-candidate-window pc)
(tutcode-context-set-state! pc 'tutcode-state-yomi)
(tutcode-context-set-nr-candidates! pc 0))
@@ -592,11 +629,17 @@
(define (tutcode-proc-state-converting pc key key-state)
(cond
((tutcode-next-candidate-key? key key-state)
- (tutcode-incr-candidate-index pc))
+ (tutcode-change-candidate-index pc #t))
((tutcode-prev-candidate-key? key key-state)
- (tutcode-decr-candidate-index pc))
+ (tutcode-change-candidate-index pc #f))
((tutcode-cancel-key? key key-state)
(tutcode-back-to-yomi-state pc))
+ ((tutcode-next-page-key? key key-state)
+ (if (tutcode-context-candidate-window pc)
+ (im-shift-page-candidate pc #t)))
+ ((tutcode-prev-page-key? key key-state)
+ (if (tutcode-context-candidate-window pc)
+ (im-shift-page-candidate pc #f)))
((or
(tutcode-commit-key? key key-state)
(tutcode-return-key? key key-state))
@@ -782,8 +825,17 @@
(define tutcode-place-handler tutcode-focus-in-handler)
(define tutcode-displace-handler tutcode-focus-out-handler)
-(define (tutcode-get-candidate-handler tc idx) #f)
-(define (tutcode-set-candidate-index-handler tc idx) #f)
+;;; ���䥦����ɥ�������ʸ����������뤿��˸Ƥִؿ�
+(define (tutcode-get-candidate-handler tc idx accel-enum-hint)
+ (let ((cand (tutcode-get-nth-candidate tc idx)))
+ (list cand (digit->string (+ idx 1)) "")))
+
+;;; ���䥦����ɥ������������Ȥ��˸Ƥִؿ�
+(define (tutcode-set-candidate-index-handler tc idx)
+ (if (tutcode-context-candidate-window tc)
+ (begin
+ (tutcode-context-set-nth! tc idx)
+ (tutcode-update-preedit tc))))
(tutcode-configure-widgets)