118
121
;;; tutcode-context-new����ȿ�Ǥ��롣
119
122
(define tutcode-rule-userconfig ())
121
;;; ���������ѥ�٥�ʸ���Υꥹ��
124
;;; ���Ѵ����θ��������ѥ�٥�ʸ���Υꥹ��
122
125
(define tutcode-heading-label-char-list
123
126
'("1" "2" "3" "4" "5" "6" "7" "8" "9" "0"
124
127
"a" "b" "c" "d" "e" "f" "g" "h" "i" "j"
128
131
"K" "L" "M" "N" "O" "P" "Q" "R" "S" "T"
129
132
"U" "V" "W" "X" "Y" "Z"))
134
;;; �������ϥ⡼�ɻ��θ��������ѥ�٥�ʸ���Υꥹ��
135
;;; (���ѱѿ��⡼�ɤȤ��ƻȤ��ˤϡ�tutcode-kigoudic�ȹ�碌��ɬ�פ���)
136
(define tutcode-heading-label-char-list-for-kigou-mode
138
"1" "2" "3" "4" "5" "6" "7" "8" "9" "0"
139
"a" "b" "c" "d" "e" "f" "g" "h" "i" "j"
140
"k" "l" "m" "n" "o" "p" "q" "r" "s" "t"
141
"u" "v" "w" "x" "y" "z"
142
"-" "^" "\\" "@" "[" ";" ":" "]" "," "." "/"
143
"!" "\"" "#" "$" "%" "&" "'" "(" ")"
144
"A" "B" "C" "D" "E" "F" "G" "H" "I" "J"
145
"K" "L" "M" "N" "O" "P" "Q" "R" "S" "T"
146
"U" "V" "W" "X" "Y" "Z"
147
"=" "~" "|" "`" "{" "+" "*" "}" "<" ">" "?" "_"))
131
149
;;; implementations
133
151
;;; ���Ѵ�����ν����������äƤ��뤫�ɤ���
162
180
(and (tutcode-context-on? tc)
181
(not (eq? (tutcode-context-state tc)
182
'tutcode-state-kigou))
163
183
(not (tutcode-context-katakana-mode? tc))))
165
185
(tutcode-prepare-activation tc)
166
(if (not (tutcode-context-on? tc)) ; �Ѵ�����֤��ѹ����ʤ�
167
(tutcode-context-set-state! tc 'tutcode-state-on))
168
(tutcode-context-set-katakana-mode! tc #f)))
188
(not (tutcode-context-on? tc)) ; �Ѵ�����֤��ѹ����ʤ�
189
(eq? (tutcode-context-state tc) 'tutcode-state-kigou))
191
(tutcode-reset-candidate-window tc)
192
(tutcode-context-set-state! tc 'tutcode-state-on)))
193
(tutcode-context-set-katakana-mode! tc #f)
194
(tutcode-update-preedit tc)))
170
196
(register-action 'action_tutcode_katakana
177
203
(and (tutcode-context-on? tc)
204
(not (eq? (tutcode-context-state tc)
205
'tutcode-state-kigou))
178
206
(tutcode-context-katakana-mode? tc)))
180
208
(tutcode-prepare-activation tc)
181
(if (not (tutcode-context-on? tc)) ; �Ѵ�����֤��ѹ����ʤ�
182
(tutcode-context-set-state! tc 'tutcode-state-on))
183
(tutcode-context-set-katakana-mode! tc #t)))
211
(not (tutcode-context-on? tc)) ; �Ѵ�����֤��ѹ����ʤ�
212
(eq? (tutcode-context-state tc) 'tutcode-state-kigou))
214
(tutcode-reset-candidate-window tc)
215
(tutcode-context-set-state! tc 'tutcode-state-on)))
216
(tutcode-context-set-katakana-mode! tc #t)
217
(tutcode-update-preedit tc)))
219
(register-action 'action_tutcode_kigou
226
(eq? (tutcode-context-state tc) 'tutcode-state-kigou))
228
(tutcode-prepare-activation tc)
230
(not (eq? (tutcode-context-state tc) 'tutcode-state-kigou))
232
(tutcode-begin-kigou-mode tc)
233
(tutcode-update-preedit tc)))
185
235
;; Update widget definitions based on action configurations. The
186
236
;; procedure is needed for on-the-fly reconfiguration involving the
201
251
;;; 'tutcode-state-yomi ���Ѵ����ɤ�������
202
252
;;; 'tutcode-state-converting ���Ѵ��θ���������
203
253
;;; 'tutcode-state-bushu �������ϡ��Ѵ���
254
;;; 'tutcode-state-kigou �������ϥ⡼��
204
255
(state 'tutcode-state-off)
205
256
;;; �������ʥ⡼�ɤ��ɤ���
206
257
;;; #t: �������ʥ⡼�ɡ�#f: �Ҥ餬�ʥ⡼�ɡ�
303
354
n (tutcode-make-string head) "" "" #f)))
357
;;; �������ϥ⡼�ɻ���n���ܤθ�����֤���
358
;;; @param n �оݤθ����ֹ�
359
(define (tutcode-get-nth-candidate-for-kigou-mode pc n)
360
(car (nth n tutcode-kigoudic)))
306
362
;;; ���Ѵ���θ���������θ�����֤���
307
363
;;; @param pc ����ƥ����ȥꥹ��
308
364
(define (tutcode-get-current-candidate pc)
309
365
(tutcode-get-nth-candidate pc (tutcode-context-nth pc)))
367
;;; �������ϥ⡼�ɻ��θ���������θ�����֤���
368
(define (tutcode-get-current-candidate-for-kigou-mode pc)
369
(tutcode-get-nth-candidate-for-kigou-mode pc (tutcode-context-nth pc)))
311
371
;;; ���Ѵ��dz��ꤷ��ʸ������֤���
312
372
;;; @param pc ����ƥ����ȥꥹ��
313
373
(define (tutcode-prepare-commit-string pc)
326
386
(tutcode-flush pc)
329
;;; ���ꤵ�줿��٥�ʸ�����б�����������ꤹ��
389
;;; �������ϥ⡼�ɻ��˳��ꤷ��ʸ������֤���
390
(define (tutcode-prepare-commit-string-for-kigou-mode pc)
391
(tutcode-get-current-candidate-for-kigou-mode pc))
393
;;; ���Ѵ��θ���������ˡ����ꤵ�줿��٥�ʸ�����б�����������ꤹ��
330
394
(define (tutcode-commit-by-label-key pc ch)
395
;; ���߸��䥦����ɥ���ɽ������Ƥ��ʤ���٥�ʸ�������Ϥ�����硢
396
;; ���߰ʹߤθ�����ˤ��������ϥ�٥�ʸ�����б�����������ꤹ�롣
397
;; (�ؽ���ǽ�դˤ��Ƹ�����¤ӽ�����ˤ��ƻ��Ѥ�����ˡ�
398
;; next-page-key������餷��
399
;; �ʤ�٤����ʤ���������Ū�θ�������٤�褦�ˤ��뤿��)
331
400
(let* ((nr (tutcode-context-nr-candidates pc))
332
401
(nth (tutcode-context-nth pc))
334
403
((= tutcode-nr-candidate-max 0) 0)
336
405
(quotient nth tutcode-nr-candidate-max))))
406
;; ���߸��䥦����ɥ���ɽ����θ���ꥹ�Ȥ���Ƭ�θ����ֹ�
337
407
(cur-offset (* cur-page tutcode-nr-candidate-max))
338
408
(cur-labels (list-tail
339
409
tutcode-heading-label-char-list
353
423
(tutcode-context-set-nth! pc idx)
354
424
(im-commit pc (tutcode-prepare-commit-string pc))))))
426
;;; �������ϥ⡼�ɻ��ˡ����ꤵ�줿��٥�ʸ�����б�����������ꤹ��
427
(define (tutcode-commit-by-label-key-for-kigou-mode pc ch)
428
;; ���Ѵ����Ȱۤʤꡢ���ߤ�����θ������ꤹ���礢��
429
;; (���ѱѿ����ϥ⡼�ɤȤ��ƻȤ���褦�ˤ��뤿��)��
430
;; (�������ϥ⡼�ɻ��ϡ����ٳ��ꤷ�������Ϣ³�������ϤǤ���褦�ˡ�
431
;; ������ľ���θ�������Ƥ��뤬��
432
;; ���ΤȤ����Ѵ�����Ʊ�ͤθ��������Ԥ��ȡ�
433
;; ��٥�ʸ���ꥹ�Ȥ�2���ܤ��б�����������ꤷ�Ƥ��ޤ���礬����
434
;; (��:th���Ǥä���硢���ѱѿ����ϤȤ��Ƥϣ���ˤʤä��ߤ������������ˤʤ�)
435
;; ���ᡢ���Ѵ��Ȥϰۤʤ������������Ԥ�)
436
(let* ((nr (tutcode-context-nr-candidates pc))
437
(nth (tutcode-context-nth pc))
438
(labellen (length tutcode-heading-label-char-list-for-kigou-mode))
439
(cur-base (quotient nth labellen))
443
(member ch tutcode-heading-label-char-list-for-kigou-mode))))
444
(idx (+ (* cur-base labellen) offset)))
448
(tutcode-context-set-nth! pc idx)
449
(im-commit pc (tutcode-prepare-commit-string-for-kigou-mode pc))))))
356
451
;;; ���Ѵ����ɤ�/��������Ѵ�������(ʸ����ꥹ��head)��ʸ������ɲä��롣
357
452
;;; @param pc ����ƥ����ȥꥹ��
358
453
;;; @param str �ɲä���ʸ����
383
478
;(tutcode-flush pc) ; ����̵����flush��������Ϥ���ʸ���ä��Ƥ��ä���
482
;;; @param pc ����ƥ����ȥꥹ��
483
(define (tutcode-begin-kigou-mode pc)
484
(tutcode-context-set-nth! pc 0)
485
(tutcode-context-set-nr-candidates! pc (length tutcode-kigoudic))
486
(tutcode-context-set-state! pc 'tutcode-state-kigou)
487
(tutcode-check-candidate-window-begin pc)
488
(if (tutcode-context-candidate-window pc)
489
(im-select-candidate pc 0)))
386
491
;;; ���䥦����ɥ���ɽ���Ϥ���
387
492
(define (tutcode-check-candidate-window-begin pc)
388
493
(if (and (not (tutcode-context-candidate-window pc))
414
519
((tutcode-state-bushu)
415
520
(let ((h (tutcode-make-string (tutcode-context-head pc))))
417
(im-pushback-preedit pc preedit-none h)))))
522
(im-pushback-preedit pc preedit-none h))))
523
((tutcode-state-kigou)
524
;; ���䥦����ɥ���ɽ�����Ǥ��������Ǥ���褦��preeditɽ��
525
(im-pushback-preedit pc preedit-reverse
526
(tutcode-get-current-candidate-for-kigou-mode pc))))
418
527
(im-pushback-preedit pc preedit-cursor "")
419
528
(im-update-preedit pc)))
434
543
((tutcode-off-key? key key-state)
436
545
(tutcode-context-set-state! pc 'tutcode-state-off))
546
((tutcode-kigou-toggle-key? key key-state)
548
(tutcode-begin-kigou-mode pc))
437
549
((tutcode-kana-toggle-key? key key-state)
439
551
(tutcode-context-kana-toggle pc))
477
589
(tutcode-context-set-state! pc 'tutcode-state-on)
478
590
(im-commit-raw pc)))
592
;;; �������ϥ⡼�ɻ��Υ������Ϥ�������롣
593
;;; @param pc ����ƥ����ȥꥹ��
594
;;; @param key ���Ϥ��줿����
595
;;; @param key-state ����ȥ����륭�����ξ���
596
(define (tutcode-proc-state-kigou pc key key-state)
599
(tutcode-vi-escape-key? key key-state)
600
tutcode-use-with-vi?)
601
(tutcode-reset-candidate-window pc)
602
(tutcode-context-set-state! pc 'tutcode-state-off)
603
(im-commit-raw pc)) ; ESC�����ץ�ˤ��Ϥ�
604
((tutcode-off-key? key key-state)
605
(tutcode-reset-candidate-window pc)
606
(tutcode-context-set-state! pc 'tutcode-state-off))
607
((tutcode-kigou-toggle-key? key key-state)
608
(tutcode-reset-candidate-window pc)
609
(tutcode-context-set-state! pc 'tutcode-state-on))
610
;; ���ڡ������������ѥ��ڡ������ϲ�ǽ�Ȥ��뤿�ᡢ
611
;; next-candidate-key?�Υ����å��������heading-label-char?������å�
612
((and tutcode-commit-candidate-by-label-key?
613
(not (and (modifier-key-mask key-state)
614
(not (shift-key-mask key-state))))
615
(tutcode-heading-label-char-for-kigou-mode? key))
616
(tutcode-commit-by-label-key-for-kigou-mode pc (charcode->string key))
617
(if (tutcode-context-candidate-window pc)
618
(im-select-candidate pc (tutcode-context-nth pc))))
619
((tutcode-next-candidate-key? key key-state)
620
(tutcode-change-candidate-index pc 1))
621
((tutcode-prev-candidate-key? key key-state)
622
(tutcode-change-candidate-index pc -1))
623
((tutcode-cancel-key? key key-state)
624
(tutcode-reset-candidate-window pc)
625
(tutcode-begin-kigou-mode pc))
626
((tutcode-next-page-key? key key-state)
627
(tutcode-change-candidate-index pc tutcode-nr-candidate-max))
628
((tutcode-prev-page-key? key key-state)
629
(tutcode-change-candidate-index pc (- tutcode-nr-candidate-max)))
631
(tutcode-commit-key? key key-state)
632
(tutcode-return-key? key key-state))
633
(im-commit pc (tutcode-prepare-commit-string-for-kigou-mode pc)))
637
(modifier-key-mask key-state)
638
(not (shift-key-mask key-state))))
641
(im-commit-raw pc))))
480
643
;;; ���Ѵ����ɤ����Ͼ��֤ΤȤ��Υ������Ϥ�������롣
481
644
;;; @param pc ����ƥ����ȥꥹ��
482
645
;;; @param key ���Ϥ��줿����
665
828
(define (tutcode-heading-label-char? key)
666
829
(member (charcode->string key) tutcode-heading-label-char-list))
831
;;; ���Ϥ��줿�������������ϥ⡼�ɻ��θ����٥�ʸ�����ɤ�����Ĵ�٤�
832
;;; @param key ���Ϥ��줿����
833
(define (tutcode-heading-label-char-for-kigou-mode? key)
834
(member (charcode->string key) tutcode-heading-label-char-list-for-kigou-mode))
668
836
;;; ���Ѵ��θ���������֤ΤȤ��Υ������Ϥ�������롣
669
837
;;; @param pc ����ƥ����ȥꥹ��
670
838
;;; @param key ���Ϥ��줿����
812
980
;;; @param pc ����ƥ����ȥꥹ��
813
981
(define (tutcode-state-has-preedit? pc)
814
982
(memq (tutcode-context-state pc)
815
'(tutcode-state-yomi tutcode-state-bushu tutcode-state-converting)))
983
'(tutcode-state-yomi tutcode-state-bushu tutcode-state-converting
984
tutcode-state-kigou)))
817
986
;;; �����������줿�Ȥ��ν����ο���ʬ����Ԥ���
818
987
;;; @param pc ����ƥ����ȥꥹ��
828
997
(if (tutcode-state-has-preedit? pc)
829
998
;; ���Ѵ�����������Ѵ����ϡ����䢥��ɽ������
830
999
(tutcode-update-preedit pc)))
1000
((tutcode-state-kigou)
1001
(tutcode-proc-state-kigou pc key key-state)
1002
(tutcode-update-preedit pc))
831
1003
((tutcode-state-yomi)
832
1004
(tutcode-proc-state-yomi pc key key-state)
833
1005
(tutcode-update-preedit pc))
872
1044
;;; ���䥦����ɥ�������ʸ�����������뤿��˸Ƥִؿ�
873
1045
(define (tutcode-get-candidate-handler tc idx accel-enum-hint)
874
(let ((cand (tutcode-get-nth-candidate tc idx))
875
(n (remainder idx (length tutcode-heading-label-char-list))))
876
(list cand (nth n tutcode-heading-label-char-list) "")))
1047
((eq? (tutcode-context-state tc) 'tutcode-state-kigou)
1048
(let* ((cand (tutcode-get-nth-candidate-for-kigou-mode tc idx))
1050
idx (length tutcode-heading-label-char-list-for-kigou-mode)))
1051
(label (nth n tutcode-heading-label-char-list-for-kigou-mode)))
1052
;; XXX:annotationɽ���ϸ���̵��������Ƥ���Τǡ����""���֤��Ƥ���
1053
(list cand label "")))
1055
(let* ((cand (tutcode-get-nth-candidate tc idx))
1056
(n (remainder idx (length tutcode-heading-label-char-list)))
1057
(label (nth n tutcode-heading-label-char-list)))
1058
(list cand label "")))))
878
1060
;;; ���䥦����ɥ�������������Ȥ��˸Ƥִؿ�
879
1061
(define (tutcode-set-candidate-index-handler tc idx)