34
34
(require "ustr.scm")
35
35
(require "japanese.scm")
36
36
(require "japanese-kana.scm")
37
(require "generic-key.scm")
40
(define anthy-use-candidate-window? #t)
41
(define anthy-candidate-op-count 1)
42
(define anthy-nr-candidate-max 10)
43
(define anthy-show-segment-separator? #f)
44
(define anthy-segment-separator "|")
47
(define-key anthy-on-key? '("<Control>j" "<Control>J" generic-on-key?))
48
(define-key anthy-latin-key? '("<Control>j" "<Control>J" generic-off-key?))
49
(define-key anthy-wide-latin-key? '())
50
;(define-key anthy-hankaku-kana-key? '("<Control>q" "<Control>Q"))
51
(define-key anthy-hankaku-kana-key? '())
52
(define-key anthy-kana-toggle-key? '())
53
(define-key anthy-commit-key? 'generic-commit-key?)
54
(define-key anthy-commit-as-opposite-kana-key? '())
55
(define-key anthy-commit-as-katakana-key? "F7")
56
(define-key anthy-commit-as-hankana-key? "F8")
57
(define-key anthy-commit-as-wide-latin-key? "F9")
58
(define-key anthy-commit-as-latin-key? "F10")
59
(define-key anthy-begin-conv-key? 'generic-begin-conv-key?)
60
(define-key anthy-extend-segment-key? '("<Control>o" "<Control>O" "<Shift>right"))
61
(define-key anthy-shrink-segment-key? '("<Control>i" "<Control>I" "<Shift>left"))
62
(define-key anthy-next-candidate-key? 'generic-next-candidate-key?)
63
(define-key anthy-prev-candidate-key? 'generic-prev-candidate-key?)
64
(define-key anthy-next-page-key? 'generic-next-page-key?)
65
(define-key anthy-prev-page-key? 'generic-prev-page-key?)
66
(define-key anthy-cancel-key? 'generic-cancel-key?)
67
(define-key anthy-backspace-key? 'generic-backspace-key?)
68
(define-key anthy-delete-key? 'generic-delete-key?)
69
(define-key anthy-kill-key? 'generic-kill-key?)
70
(define-key anthy-kill-backward-key? 'generic-kill-backward-key?)
71
(define-key anthy-go-left-key? 'generic-go-left-key?)
72
(define-key anthy-go-right-key? 'generic-go-right-key?)
73
(define-key anthy-beginning-of-preedit-key? 'generic-beginning-of-preedit-key?)
74
(define-key anthy-end-of-preedit-key? 'generic-end-of-preedit-key?)
75
(define-key anthy-next-segment-key? 'generic-go-right-key?)
76
(define-key anthy-prev-segment-key? 'generic-go-left-key?)
37
(require "japanese-azik.scm")
38
(require-custom "generic-key-custom.scm")
39
(require-custom "anthy-custom.scm")
40
(require-custom "anthy-key-custom.scm")
80
45
(define anthy-lib-initialized? #f)
82
(define anthy-type-hiragana 0)
83
(define anthy-type-katakana 1)
84
(define anthy-type-hankana 2)
86
(define anthy-mode-direct 0)
87
(define anthy-mode-hiragana 1)
88
(define anthy-mode-katakana 2)
89
(define anthy-mode-wide-latin 3)
90
(define anthy-mode-hankana 4)
47
(define anthy-type-hiragana 0)
48
(define anthy-type-katakana 1)
49
(define anthy-type-hankana 2)
50
(define anthy-type-latin 3)
51
(define anthy-type-wide-latin 4)
92
53
(define anthy-input-rule-roma 0)
93
54
(define anthy-input-rule-kana 1)
94
55
(define anthy-input-rule-azik 2)
57
(define anthy-prepare-activation
60
(anthy-update-preedit ac)))
62
(register-action 'action_anthy_hiragana
63
;; (indication-alist-indicator 'action_anthy_hiragana
64
;; anthy-input-mode-indication-alist)
65
(lambda (ac) ;; indication handler
71
(lambda (ac) ;; activity predicate
72
(and (anthy-context-on ac)
73
(= (anthy-context-kana-mode ac)
74
anthy-type-hiragana)))
76
(lambda (ac) ;; action handler
77
(anthy-prepare-activation ac)
78
(anthy-context-set-on! ac #t)
79
(anthy-context-set-kana-mode! ac anthy-type-hiragana)))
81
(register-action 'action_anthy_katakana
82
;; (indication-alist-indicator 'action_anthy_katakana
83
;; anthy-input-mode-indication-alist)
90
(and (anthy-context-on ac)
91
(= (anthy-context-kana-mode ac)
92
anthy-type-katakana)))
94
(anthy-prepare-activation ac)
95
(anthy-context-set-on! ac #t)
97
(if (= anthy-input-rule-kana
98
(anthy-context-input-rule ac))
99
(rk-context-set-rule! (anthy-context-rkc ac)
100
ja-kana-katakana-rule))
101
(anthy-context-set-kana-mode! ac anthy-type-katakana)))
103
(register-action 'action_anthy_hankana
104
;; (indication-alist-indicator 'action_anthy_hankana
105
;; anthy-input-mode-indication-alist)
110
"Ⱦ�ѥ����������ϥ⡼��"))
112
(and (anthy-context-on ac)
113
(= (anthy-context-kana-mode ac)
114
anthy-type-hankana)))
116
(anthy-prepare-activation ac)
117
(anthy-context-set-on! ac #t)
118
(anthy-context-set-kana-mode! ac anthy-type-hankana)))
120
(register-action 'action_anthy_direct
121
;; (indication-alist-indicator 'action_anthy_direct
122
;; anthy-input-mode-indication-alist)
129
(and (not (anthy-context-on ac))
130
(not (anthy-context-wide-latin ac))))
132
(anthy-prepare-activation ac)
133
(anthy-context-set-on! ac #f)
134
(anthy-context-set-wide-latin! ac #f)))
136
(register-action 'action_anthy_zenkaku
137
;; (indication-alist-indicator 'action_anthy_zenkaku
138
;; anthy-input-mode-indication-alist)
145
(and (not (anthy-context-on ac))
146
(anthy-context-wide-latin ac)))
148
(anthy-prepare-activation ac)
149
(anthy-context-set-on! ac #f)
150
(anthy-context-set-wide-latin! ac #t)))
152
(register-action 'action_anthy_roma
153
;; (indication-alist-indicator 'action_anthy_roma
154
;; anthy-kana-input-method-indication-alist)
161
(= (anthy-context-input-rule ac)
162
anthy-input-rule-roma))
164
(anthy-prepare-activation ac)
165
(rk-context-set-rule! (anthy-context-rkc ac)
167
(anthy-context-set-input-rule! ac anthy-input-rule-roma)))
169
(register-action 'action_anthy_kana
170
;; (indication-alist-indicator 'action_anthy_kana
171
;; anthy-kana-input-method-indication-alist)
178
(= (anthy-context-input-rule ac)
179
anthy-input-rule-kana))
181
(anthy-prepare-activation ac)
182
(rk-context-set-rule! (anthy-context-rkc ac)
183
(if (= (anthy-context-kana-mode ac)
185
ja-kana-katakana-rule
186
ja-kana-hiragana-rule))
188
(anthy-context-set-input-rule! ac anthy-input-rule-kana)
189
;;(define-key anthy-kana-toggle-key? "")
190
;;(define-key anthy-latin-key? generic-on-key?)
191
;;(define-key anthy-wide-latin-key? "")
194
(register-action 'action_anthy_azik
195
;; (indication-alist-indicator 'action_anthy_azik
196
;; anthy-kana-input-method-indication-alist)
201
"AZIK��ĥ���������ϥ⡼��"))
203
(= (anthy-context-input-rule ac)
204
anthy-input-rule-azik))
206
(anthy-prepare-activation ac)
207
(rk-context-set-rule! (anthy-context-rkc ac)
209
(anthy-context-set-input-rule! ac anthy-input-rule-azik)))
211
;; Update widget definitions based on action configurations. The
212
;; procedure is needed for on-the-fly reconfiguration involving the
214
(define anthy-configure-widgets
216
(register-widget 'widget_anthy_input_mode
217
(activity-indicator-new anthy-input-mode-actions)
218
(actions-new anthy-input-mode-actions))
220
(register-widget 'widget_anthy_kana_input_method
221
(activity-indicator-new anthy-kana-input-method-actions)
222
(actions-new anthy-kana-input-method-actions))
223
(context-list-replace-widgets! 'anthy anthy-widgets)))
96
225
(define anthy-context-rec-spec
101
230
(list 'converting #f)
231
(list 'transposing #f)
232
(list 'transposing-type 0)
102
233
(list 'ac-id #f) ;; anthy-context-id
103
234
(list 'preconv-ustr #f) ;; preedit strings
195
328
(ja-raw-string-list-to-valid-roma
197
330
(if (null? residual-kana)
332
(if (null? right-str)
334
(append right-str (list pending))))
201
337
(if (null? right-str)
203
(append (list pending) right-str))))))
339
(append right-str (list pending)))))))
206
342
(define anthy-init-handler
207
343
(lambda (id im arg)
208
(let ((ac (anthy-context-new id im)))
209
(im-clear-mode-list ac)
210
(im-pushback-mode-list ac "ľ������")
211
(im-pushback-mode-list ac "�Ҥ餬��")
212
(im-pushback-mode-list ac "��������")
213
(im-pushback-mode-list ac "���ѱѿ�")
214
(im-pushback-mode-list ac "Ⱦ�ѥ�������")
215
(im-update-mode-list ac)
216
(im-update-mode ac 0)
217
(anthy-update-prop-list ac)
344
(anthy-context-new id im)))
220
346
(define anthy-release-handler
222
348
(let ((ac-id (anthy-context-ac-id ac)))
223
(anthy-lib-free-context ac-id))))
225
(define anthy-mode-handler
229
((= mode anthy-mode-direct)
230
(anthy-context-set-on! ac #f)
231
(anthy-context-set-wide-latin! ac #f))
232
((= mode anthy-mode-hiragana)
233
(anthy-context-set-on! ac #t)
234
(anthy-context-set-kana-mode! ac anthy-type-hiragana))
235
((= mode anthy-mode-katakana)
236
(anthy-context-set-on! ac #t)
237
(anthy-context-set-kana-mode! ac anthy-type-katakana))
238
((= mode anthy-mode-wide-latin)
239
(anthy-context-set-on! ac #f)
240
(anthy-context-set-wide-latin! ac #t))
241
((= mode anthy-mode-hankana)
242
(anthy-context-set-on! ac #t)
243
(anthy-context-set-kana-mode! ac anthy-type-hankana)))
244
(anthy-update-preedit ac)
245
(anthy-update-prop-label ac)
246
(anthy-update-prop-list ac))
350
(anthy-lib-free-context ac-id)))))
249
352
(define anthy-flush
484
574
(anthy-flush ac)))
488
577
;; 2004-08-27 Takuro Ashie <ashie@homa.ne.jp>
489
578
;; * We should restore pending state of rk-context when the input-rule
491
;; * Behaviour of setting left and right string should be changed on
493
580
((anthy-go-left-key? key key-state)
495
(ustr-cursor-move-backward! preconv-str)
496
(ustr-cursor-move-backward! raw-str)))
581
(anthy-context-confirm-kana! ac)
582
(ustr-cursor-move-backward! preconv-str)
583
(ustr-cursor-move-backward! raw-str))
499
586
;; 2004-08-27 Takuro Ashie <ashie@homa.ne.jp>
500
587
;; * We should restore pending state of rk-context when the input-rule
502
;; * Behaviour of setting left and right string should be changed on
504
589
((anthy-go-right-key? key key-state)
506
(ustr-cursor-move-forward! preconv-str)
507
(ustr-cursor-move-forward! raw-str)))
590
(anthy-context-confirm-kana! ac)
591
(ustr-cursor-move-forward! preconv-str)
592
(ustr-cursor-move-forward! raw-str))
509
594
;; beginning-of-preedit
511
595
;; 2004-08-27 Takuro Ashie <ashie@homa.ne.jp>
512
;; * Behaviour of setting left and right string should be changed on
596
;; * We should restore pending state of rk-context when the input-rule
514
598
((anthy-beginning-of-preedit-key? key key-state)
599
(anthy-context-confirm-kana! ac)
515
600
(ustr-cursor-move-beginning! preconv-str))
517
602
;; end-of-preedit
519
603
;; 2004-08-27 Takuro Ashie <ashie@homa.ne.jp>
520
604
;; * We should restore pending state of rk-context when the input-rule
522
;; * Behaviour of setting left and right string should be changed on
524
606
((anthy-end-of-preedit-key? key key-state)
525
(ustr-cursor-move-end! preconv-str)
607
(anthy-context-confirm-kana! ac)
608
(ustr-cursor-move-end! preconv-str))
529
610
;; modifiers (except shift) => ignore
530
611
((and (modifier-key-mask key-state)
531
612
(not (shift-key-mask key-state)))
532
(anthy-commit-raw ac))
535
616
(let* ((key-str (charcode->string
567
659
(cons attr anthy-segment-separator)
662
(define anthy-context-transposing-state-preedit
664
(let* ((transposing-text (anthy-transposing-text ac)))
665
(list (cons preedit-underline transposing-text)
666
(cons preedit-cursor "")))))
668
(define anthy-transposing-text
670
(let* ((transposing-type (anthy-context-transposing-type ac)))
672
((= transposing-type anthy-type-katakana)
673
(anthy-make-whole-string ac #t multi-segment-type-katakana))
675
((= transposing-type anthy-type-hankana)
676
(anthy-make-whole-string ac #t multi-segment-type-hankana))
678
((= transposing-type anthy-type-latin)
679
(anthy-make-whole-raw-string ac #f))
681
((= transposing-type anthy-type-wide-latin)
682
(anthy-make-whole-raw-string ac #t))
570
685
(define anthy-converting-state-preedit
572
687
(let* ((ac-id (anthy-context-ac-id ac))
573
688
(segments (anthy-context-segments ac))
574
689
(cur-seg (ustr-cursor-pos segments))
575
690
(separator (anthy-separator ac)))
578
(map (lambda (seg-idx cand-idx)
579
(let* ((attr (if (= seg-idx cur-seg)
580
(bit-or preedit-reverse
583
(cand (anthy-lib-get-nth-candidate ac-id
585
(seg (list (cons attr cand))))
590
(iota (ustr-length segments))
591
(ustr-whole-seq segments))))))
692
(lambda (seg-idx cand-idx)
693
(let* ((attr (if (= seg-idx cur-seg)
694
(bit-or preedit-reverse
697
(cand (anthy-lib-get-nth-candidate ac-id seg-idx cand-idx))
698
(seg (list (cons attr cand))))
703
(iota (ustr-length segments))
704
(ustr-whole-seq segments)))))
593
706
(define anthy-input-state-preedit
821
971
; (anthy-move-segment ac 1)
822
972
(anthy-update-preedit ac)))
824
(define anthy-prop-handler
826
(let* ((rkc (anthy-context-rkc ac)))
828
(anthy-update-preedit ac)
831
"prop_anthy_hiragana")
833
(anthy-context-set-on! ac #t)
834
(anthy-context-set-kana-mode! ac anthy-type-hiragana)))
836
"prop_anthy_katakana")
838
(anthy-context-set-on! ac #t)
839
(anthy-context-set-kana-mode! ac anthy-type-katakana)))
841
"prop_anthy_hankana")
843
(anthy-context-set-on! ac #t)
844
(anthy-context-set-kana-mode! ac anthy-type-hankana)))
848
(anthy-context-set-on! ac #f)
849
(anthy-context-set-wide-latin! ac #f)))
851
"prop_anthy_zenkaku")
853
(anthy-context-set-on! ac #f)
854
(anthy-context-set-wide-latin! ac #t)))
858
(rk-context-set-rule! rkc ja-rk-rule)
859
(anthy-context-set-input-rule! ac anthy-input-rule-roma)))
863
(rk-context-set-rule! rkc ja-kana-rule)
864
(anthy-context-set-input-rule! ac anthy-input-rule-kana)
865
; (define-key anthy-kana-toggle-key? "")
866
; (define-key anthy-latin-key? generic-on-key?)
867
; (define-key anthy-wide-latin-key? "")
869
(anthy-update-mode ac)
870
(anthy-update-prop-label ac))))
872
(define anthy-update-prop-label
875
(kana (anthy-context-kana-mode ac))
876
(rule (anthy-context-input-rule ac)))
878
(if (anthy-context-on ac)
880
((= kana anthy-type-hiragana)
882
((= kana anthy-type-katakana)
884
((= kana anthy-type-hankana)
886
(if (anthy-context-wide-latin ac)
891
((= rule anthy-input-rule-roma)
892
(string-append str "��\t������\n"))
893
((= rule anthy-input-rule-kana)
894
(string-append str "��\t����\n"))))
895
(im-update-prop-label ac str))))
897
(define anthy-update-mode
899
(if (anthy-context-on ac)
900
(let ((kana (anthy-context-kana-mode ac)))
902
((= kana anthy-type-hiragana)
903
(im-update-mode ac anthy-mode-hiragana))
904
((= kana anthy-type-katakana)
905
(im-update-mode ac anthy-mode-katakana))
906
((= kana anthy-type-hankana)
907
(im-update-mode ac anthy-mode-hankana))))
908
(if (anthy-context-wide-latin ac)
909
(im-update-mode ac anthy-mode-wide-latin)
910
(im-update-mode ac anthy-mode-direct)))
911
(anthy-update-prop-label ac)
912
(anthy-update-prop-list ac)))
914
(define anthy-update-prop-list
916
(let* ((kana (anthy-context-kana-mode ac))
917
(rule (anthy-context-input-rule ac))
919
(set! str (string-append str
920
(if (anthy-context-on ac)
922
((= kana anthy-type-hiragana)
924
((= kana anthy-type-katakana)
926
((= kana anthy-type-hankana)
928
(if (anthy-context-wide-latin ac)
931
(set! str (string-append
933
"leaf\t��\t�Ҥ餬��\t�Ҥ餬�ʤǤ�\tprop_anthy_hiragana\t"
934
(if (and (anthy-context-on ac)
935
(= kana anthy-type-hiragana))
939
"leaf\t��\t��������\t�������ʤ����ϤǤ��ޤ�\tprop_anthy_katakana\t"
940
(if (and (anthy-context-on ac)
941
(= kana anthy-type-katakana))
945
"leaf\t��\tȾ�ѥ�������\tȾ�ѥ������ʤ����ϤǤ��ޤ�\tprop_anthy_hankana\t"
946
(if (and (anthy-context-on ac)
947
(= kana anthy-type-hankana))
951
"leaf\tA\tľ������\t�����쥯�ȤǤ�\tprop_anthy_direct\t"
952
(if (and (not (anthy-context-on ac))
953
(not (anthy-context-wide-latin ac)))
957
"leaf\t��\t���ѱѿ�\t���ѱѿ��⡼��\tprop_anthy_zenkaku\t"
958
(if (and (not (anthy-context-on ac))
959
(anthy-context-wide-latin ac))
964
(if (= rule anthy-input-rule-roma)
968
"leaf\t��\t������\t����������\tprop_anthy_roma\t"
969
(if (= rule anthy-input-rule-roma)
973
"leaf\t��\t����\t��������\tprop_anthy_kana\t"
974
(if (= rule anthy-input-rule-kana)
978
(im-update-prop-list ac str)
974
(anthy-configure-widgets)
985
(N_ "Japanese Kana Kanji Conversion Engine, Anthy")
987
983
anthy-init-handler
988
984
anthy-release-handler
990
986
anthy-press-key-handler
991
987
anthy-release-key-handler
992
988
anthy-reset-handler
993
989
anthy-get-candidate-handler
994
990
anthy-set-candidate-index-handler
991
context-prop-activate-handler