Skip to content
Newer
Older
100644 552 lines (489 sloc) 18.1 KB
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
1 ;;; elatin.scm -- Emacs-style Latin characters translation
2 ;;;
6a30dfc * Update copyright by svn ls -R | egrep -v '/$' | xargs perl -i -pe '…
ek.kato authored Jan 11, 2012
3 ;;; Copyright (c) 2003-2012 uim Project http://code.google.com/p/uim/
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
4 ;;;
5 ;;; All rights reserved.
6 ;;;
7 ;;; Redistribution and use in source and binary forms, with or without
8 ;;; modification, are permitted provided that the following conditions
9 ;;; are met:
10 ;;; 1. Redistributions of source code must retain the above copyright
11 ;;; notice, this list of conditions and the following disclaimer.
12 ;;; 2. Redistributions in binary form must reproduce the above copyright
13 ;;; notice, this list of conditions and the following disclaimer in the
14 ;;; documentation and/or other materials provided with the distribution.
15 ;;; 3. Neither the name of authors nor the names of its contributors
16 ;;; may be used to endorse or promote products derived from this software
17 ;;; without specific prior written permission.
18 ;;;
19 ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
20 ;;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 ;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
23 ;;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 ;;; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 ;;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 ;;; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 ;;; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 ;;; SUCH DAMAGE.
30 ;;;;
31
32 ;; This input method implements character composition rules for the
33 ;; Latin letters used in European languages. The rules, defined in
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
34 ;; the file elatin-rules.scm, have been adapted from GNU Emacs 23.1.
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
35
36 (require "util.scm")
37 (require "rk.scm")
38 (require "elatin-rules.scm")
c8962ae * scm/elatin.scm: Fix to include generic-key-custom.scm for
ek.kato authored Jun 24, 2008
39 (require-custom "generic-key-custom.scm")
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
40 (require-custom "elatin-custom.scm")
41
42 (define elatin-context-rec-spec
43 (append
44 context-rec-spec
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
45 '((on? #f)
46 (rkc ())
47 (completions #f)
48 (completion-no 0)
49 (jump-to-top-on-tab? #f)
50 (translations #f)
51 (translation-no 0)
52 (preedit ""))))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
53 (define-record 'elatin-context elatin-context-rec-spec)
54 (define elatin-context-new-internal elatin-context-new)
55
56 (define (elatin-context-new id im)
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
57 (let* ((lc (elatin-context-new-internal id im))
58 (rules (begin (or (symbol-bound? elatin-rules)
59 (begin (display "uim-elatin: [warning] ")
60 (write elatin-rules)
61 (display " unavailable, falling back on ")
62 (write elatin-default-rules) (newline)
63 (display "uim-elatin: [warning] use customization tool and fix the latin characters keyboard layout\n")
64 (custom-set-value!
65 'elatin-rules elatin-default-rules)))
66 (symbol-value elatin-rules)))
67 (rkc (rk-context-new rules #f #f)))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
68 (elatin-context-set-widgets! lc elatin-widgets)
69 (elatin-context-set-rkc! lc rkc)
70 lc))
71
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
72 (define (elatin-current-translations lc)
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
73 (let ((rkc (elatin-context-rkc lc)))
74 (or (rk-peek-terminal-match rkc)
75 (and (not (null? (rk-context-seq rkc)))
76 (list (rk-pending rkc))))))
77
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
78 (define (elatin-close-window lc)
79 (if (or (elatin-context-translations lc)
80 (elatin-context-completions lc))
81 (begin (im-deactivate-candidate-selector lc)
82 (elatin-context-set-translations! lc #f)
83 (elatin-context-set-completions! lc #f))))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
84
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
85 (define (elatin-context-reset lc)
86 (rk-flush (elatin-context-rkc lc))
87 (elatin-close-window lc))
88
89 (define (elatin-commit lc str)
90 (elatin-close-window lc)
91 (im-commit lc str))
92
93 (define (elatin-reset-and-commit lc str)
94 (elatin-context-reset lc)
95 (im-commit lc str))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
96
97 (define (elatin-context-flush lc)
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
98 (let ((trans (elatin-current-translations lc)))
99 (elatin-context-reset lc)
100 (if trans (im-commit lc (car trans)))))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
101
102 (define (elatin-update-preedit lc)
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
103 (let* ((trans (or (elatin-context-translations lc)
104 (elatin-current-translations lc)))
105 (new-preedit (if trans (car trans) "")))
106 (or (string=? new-preedit (elatin-context-preedit lc))
107 (begin (im-clear-preedit lc)
108 (or (string=? new-preedit "")
109 (im-pushback-preedit lc
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
110 preedit-underline
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
111 new-preedit))
112 (im-pushback-preedit lc
113 preedit-cursor
114 "")
115 (im-update-preedit lc)
116 (elatin-context-set-preedit! lc new-preedit)))))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
117
118 (define (elatin-prepare-activation lc)
119 (elatin-context-flush lc)
120 (elatin-update-preedit lc))
121
122 (register-action 'action_elatin_off
123 (lambda (lc)
124 (list
125 'off
126 "a"
127 (N_ "ELatin mode off")
128 (N_ "ELatin composition off")))
129 (lambda (lc)
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
130 (not (elatin-context-on? lc)))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
131 (lambda (lc)
132 (elatin-prepare-activation lc)
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
133 (elatin-context-set-on?! lc #f)))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
134
135 (register-action 'action_elatin_on
136 (lambda (lc)
137 (list
138 'on
139 "à"
140 (N_ "ELatin mode on")
141 (N_ "ELatin composition on")))
142 (lambda (lc)
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
143 (elatin-context-on? lc))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
144 (lambda (lc)
145 (elatin-prepare-activation lc)
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
146 (elatin-context-set-on?! lc #t)))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
147
148 (define elatin-input-mode-actions
149 '(action_elatin_off action_elatin_on))
150
151 (define elatin-widgets '(widget_elatin_input_mode))
152
153 (define default-widget_elatin_input_mode 'action_elatin_off)
154
155 (register-widget 'widget_elatin_input_mode
156 (activity-indicator-new elatin-input-mode-actions)
157 (actions-new elatin-input-mode-actions))
158
159 (define elatin-context-list '())
160
161 (define (elatin-init-handler id im arg)
162 (let ((lc (elatin-context-new id im)))
163 (set! elatin-context-list (cons lc elatin-context-list))
164 lc))
165
166 (define (elatin-release-handler lc)
167 (let ((rkc (elatin-context-rkc lc)))
168 (set! elatin-context-list
169 ;; (delete lc elatin-context-list eq?) does not work
170 (remove (lambda (c) (eq? (elatin-context-rkc c) rkc))
171 elatin-context-list))))
172
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
173 (define (elatin-open-translations-window lc trans)
174 (let ((ntrans (length trans)))
175 (if (elatin-context-completions lc)
176 (im-deactivate-candidate-selector lc))
177 (elatin-context-set-translations! lc trans)
178 (elatin-context-set-translation-no! lc 0)
179 (im-activate-candidate-selector lc ntrans ntrans)
180 (im-select-candidate lc 0)))
181
182 (define (elatin-set-completions lc matches)
183 (let* ((seq (reverse (rk-context-seq (elatin-context-rkc lc))))
184 (completions (elatin-context-completions lc))
185 (completion-no (elatin-context-completion-no lc))
186 (n (or (list-index (lambda (elt) (equal? (caar elt) seq))
187 matches)
188 (and completions
189 (let ((highlighted (list-ref completions completion-no)))
190 (list-index (lambda (elt) (eq? elt highlighted))
191 matches)))
192 0)))
193 (elatin-context-set-completions! lc matches)
194 (elatin-context-set-completion-no! lc n)
195 (elatin-context-set-jump-to-top-on-tab?! lc #t)))
196
db0e652 * scm/elatin.scm
jhyeon authored Jul 18, 2010
197 (define (elatin-find-partial-matches seq rule)
198 (let ((partials (rk-lib-find-partial-seqs seq rule))
199 (full (rk-lib-find-seq seq rule)))
200 (if full (cons full partials) partials)))
201
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
202 (define (elatin-update-completions lc)
203 (if (elatin-context-completions lc)
204 (let* ((rkc (elatin-context-rkc lc))
205 (seq (reverse (rk-context-seq rkc)))
206 (rule (rk-context-rule rkc))
207 (matches (elatin-find-partial-matches seq rule)))
208 (elatin-set-completions lc matches)
209 (or (elatin-context-translations lc)
210 (begin
211 (im-deactivate-candidate-selector lc)
212 (im-activate-candidate-selector
213 lc (length matches) elatin-nr-candidates-max)
214 (im-select-candidate lc (elatin-context-completion-no lc)))))))
215
216 (define (elatin-push-keys lc str-list)
217 (let ((rkc (elatin-context-rkc lc)))
218 (for-each (lambda (str) (rk-push-key! rkc str)) str-list)))
219
220 (define (elatin-do-rkc lc)
221 (let ((rkc (elatin-context-rkc lc))
222 (trans (elatin-current-translations lc)))
223 (if (rk-partial? rkc)
224 (begin (if (and trans (> (length trans) 1))
225 (elatin-open-translations-window lc trans))
226 (elatin-update-completions lc))
227 (if (> (length trans) 1)
228 (begin (elatin-context-reset lc)
229 (elatin-open-translations-window lc trans))
230 (elatin-reset-and-commit lc (car trans))))))
231
232 (define (elatin-take-common-head matches)
233 (let ((common '())
234 (keys-list (map caar matches)))
235 (let loop-horiz ((first (car keys-list)))
236 (cond ((null? first)
237 (reverse common))
238 ((let loop-vert ((rest (cdr keys-list)))
239 (cond ((null? rest)
240 #t)
241 ((null? (car rest))
242 #f)
243 ((equal? (car first) (caar rest))
244 (set-car! rest (cdar rest))
245 (loop-vert (cdr rest)))
246 (else
247 #f)))
248 (set! common (cons (car first) common))
249 (loop-horiz (cdr first)))
250 (else
251 (reverse common))))))
252
253 (define (elatin-open-completions-window lc matches)
254 (elatin-set-completions lc matches)
255 (im-activate-candidate-selector lc (length matches) elatin-nr-candidates-max)
256 (im-select-candidate lc (elatin-context-completion-no lc)))
257
258 (define (elatin-start-completion lc)
259 (let* ((rkc (elatin-context-rkc lc))
260 (seq (reverse (rk-context-seq rkc)))
261 (lseq (length seq))
262 (rule (rk-context-rule rkc))
263 (matches (elatin-find-partial-matches seq rule)))
264 (if (= (length matches) 1)
265 (begin (elatin-push-keys lc (drop (caaar matches) lseq))
266 (elatin-do-rkc lc))
267 (let ((common (elatin-take-common-head matches)))
268 (if (equal? common seq)
269 (elatin-open-completions-window lc matches)
270 (begin
271 (elatin-push-keys lc (drop common lseq))
272 (let ((trans (elatin-current-translations lc)))
273 (if (and elatin-show-all-if-ambiguous?
274 (not (and trans (> (length trans) 1)
275 (begin (elatin-set-completions lc matches)
276 #t))))
277 (elatin-open-completions-window lc matches)
278 (elatin-do-rkc lc)))))))))
279
280 (define (elatin-commit-completion lc)
281 (let* ((highlighted (list-ref (elatin-context-completions lc)
282 (elatin-context-completion-no lc)))
283 (trans (cadr highlighted)))
284 (if (> (length trans) 1)
285 (begin (elatin-context-reset lc)
286 (elatin-open-translations-window lc trans))
287 (elatin-reset-and-commit lc (car trans)))))
288
289 (define (elatin-move-completion-highlight lc offset)
290 (let* ((completions (elatin-context-completions lc))
291 (max (length completions))
292 (n (+ (elatin-context-completion-no lc) offset))
293 (compensated-n (cond
294 ((>= n max) 0)
295 ((< n 0) (- max 1))
296 (else n))))
297 (elatin-context-set-completion-no! lc compensated-n)
298 (im-select-candidate lc compensated-n)))
299
300 (define (elatin-move-translation-highlight lc offset)
301 (let* ((translations (elatin-context-translations lc))
302 (max (length translations))
303 (n (+ (elatin-context-translation-no lc) offset))
304 (compensated-n (cond
305 ((>= n max) 0)
306 ((< n 0) (- max 1))
307 (else n))))
308 (elatin-context-set-translation-no! lc compensated-n)
309 (im-select-candidate lc compensated-n)))
310
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
311 (define elatin-control-key?
312 (let ((shift-or-no-modifier? (make-key-predicate '("<Shift>" ""))))
313 (lambda (key key-state)
314 (not (shift-or-no-modifier? -1 key-state)))))
315
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
316 (define (elatin-cond-default lc key key-state)
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
317 (let ((rkc (elatin-context-rkc lc))
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
318 (cur-trans (elatin-current-translations lc)))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
319 (cond
320
321 ((or (elatin-off-key? key key-state)
322 (and elatin-esc-turns-off? (eq? key 'escape)))
323 (elatin-context-flush lc)
324 (if (eq? key 'escape)
325 (im-commit-raw lc))
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
326 (elatin-context-set-on?! lc #f))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
327
328 ((elatin-backspace-key? key key-state)
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
329 (if (rk-backspace rkc)
330 (if (null? (rk-context-seq rkc))
331 (elatin-close-window lc)
332 (elatin-do-rkc lc))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
333 (im-commit-raw lc)))
334
335 ((elatin-control-key? key key-state)
336 (elatin-context-flush lc)
337 (im-commit-raw lc))
338
339 (else
340 (let* ((key-str (if (symbol? key)
341 (symbol->string key)
342 (charcode->string key)))
343 (cur-seq (rk-context-seq rkc))
344 (res (rk-push-key! rkc key-str))
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
345 (new-seq (rk-context-seq rkc)))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
346 (if (equal? new-seq (cons key-str cur-seq))
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
347 (elatin-do-rkc lc)
348 (begin (or (null? cur-seq)
349 (elatin-commit lc (car cur-trans)))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
350 (if (null? new-seq) (im-commit-raw lc)))))))))
351
352 (define (elatin-proc-off-state lc key key-state)
353 (if (elatin-on-key? key key-state)
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
354 (elatin-context-set-on?! lc #t)
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
355 (im-commit-raw lc)))
356
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
357 (define (elatin-proc-normal-state lc key key-state)
358 (cond
359 ((and elatin-use-completion?
360 (elatin-completion-key? key key-state)
361 (not (null? (rk-context-seq (elatin-context-rkc lc)))))
362 (elatin-start-completion lc))
363 (else
364 (elatin-cond-default lc key key-state))))
365
366 (define (elatin-proc-completion-state lc key key-state)
367 (let* ((rkc (elatin-context-rkc lc))
368 (completions (elatin-context-completions lc))
369 (ncompletions (length completions))
370 (completion-no (elatin-context-completion-no lc))
371 (jump? (elatin-context-jump-to-top-on-tab? lc)))
372
373 (elatin-context-set-jump-to-top-on-tab?! lc #f)
374
375 (cond
376
377 ((elatin-completion-key? key key-state)
378 (let* ((seq (reverse (rk-context-seq rkc)))
379 (lseq (length seq)))
380 (if (= ncompletions 1)
381 (begin (elatin-push-keys lc (drop (caaar completions) lseq))
382 (elatin-do-rkc lc))
383 (let ((common (elatin-take-common-head completions)))
384 (if (equal? common seq)
385 (if (and jump? (>= completion-no elatin-nr-candidates-max))
386 (begin (elatin-context-set-completion-no! lc 0)
387 (im-select-candidate lc 0))
388 (im-shift-page-candidate lc #t))
389 (begin (elatin-push-keys lc (drop common lseq))
390 (elatin-do-rkc lc)))))))
391
392 ((elatin-cancel-key? key key-state)
393 (im-deactivate-candidate-selector lc)
394 (elatin-context-set-completions! lc #f))
395 ((elatin-prev-page-key? key key-state)
396 (im-shift-page-candidate lc #f))
397 ((elatin-next-page-key? key key-state)
398 (im-shift-page-candidate lc #t))
399 ((elatin-prev-candidate-key? key key-state)
400 (elatin-move-completion-highlight lc -1))
401 ((elatin-next-candidate-key? key key-state)
402 (elatin-move-completion-highlight lc 1))
403 ((elatin-commit-key? key key-state)
404 (elatin-commit-completion lc))
405 ((and (ichar-numeric? key)
406 (let* ((keyidx (- (numeric-ichar->integer key) 1))
407 (page (if (= elatin-nr-candidates-max 0)
408 0
409 (quotient completion-no elatin-nr-candidates-max)))
410 (idx (* page elatin-nr-candidates-max)))
411 (if (= keyidx -1) (set! keyidx 9))
412 (set! idx (+ idx keyidx))
413 (and (>= idx 0) (< idx ncompletions)
414 (begin (elatin-context-set-completion-no! lc idx)
415 (elatin-commit-completion lc)
416 #t)))))
417
418 (else
419 (elatin-cond-default lc key key-state)))))
420
421 (define (elatin-proc-translation-state lc key key-state)
422 (let ((seq (rk-context-seq (elatin-context-rkc lc)))
423 (trans (elatin-context-translations lc))
424 (translation-no (elatin-context-translation-no lc)))
425
426 (cond
427
428 ((and elatin-use-completion?
429 (elatin-completion-key? key key-state)
430 (not (null? seq)))
431 (elatin-context-set-translations! lc #f)
432 (if (elatin-context-completions lc)
433 (elatin-update-completions lc)
434 (begin
435 (im-deactivate-candidate-selector lc)
436 (elatin-start-completion lc))))
437
438 ((elatin-cancel-key? key key-state)
439 (if (null? seq)
440 (elatin-commit lc (car trans))
441 (begin
442 (elatin-context-set-translations! lc #f)
443 (if (elatin-context-completions lc)
444 (elatin-update-completions lc)
445 (im-deactivate-candidate-selector lc)))))
446 ((elatin-prev-page-key? key key-state)
447 (im-shift-page-candidate lc #f))
448 ((elatin-next-page-key? key key-state)
449 (im-shift-page-candidate lc #t))
450 ((elatin-prev-candidate-key? key key-state)
451 (elatin-move-translation-highlight lc -1))
452 ((elatin-next-candidate-key? key key-state)
453 (elatin-move-translation-highlight lc 1))
454 ((elatin-commit-key? key key-state)
455 (elatin-reset-and-commit lc (list-ref trans translation-no)))
456 ((and (ichar-numeric? key)
457 (let* ((keyidx (- (numeric-ichar->integer key) 1))
458 (page (if (= elatin-nr-candidates-max 0)
459 0
460 (quotient translation-no elatin-nr-candidates-max)))
461 (idx (* page elatin-nr-candidates-max)))
462 (if (= keyidx -1) (set! keyidx 9))
463 (set! idx (+ idx keyidx))
464 (and (>= idx 0) (< idx (length trans))
465 (begin (elatin-reset-and-commit lc (list-ref trans idx))
466 #t)))))
467
468 (else
469 (if (null? seq)
470 (elatin-commit lc (car trans))
471 (begin (elatin-context-set-translations! lc #f)
472 (or (elatin-context-completions lc)
473 (im-deactivate-candidate-selector lc))))
474 (elatin-cond-default lc key key-state)))))
475
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
476 (define (elatin-key-press-handler lc key key-state)
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
477 (if (elatin-context-on? lc)
478 (cond
479 ((elatin-context-translations lc)
480 (elatin-proc-translation-state lc key key-state))
481 ((elatin-context-completions lc)
482 (elatin-proc-completion-state lc key key-state))
483 (else
484 (elatin-proc-normal-state lc key key-state)))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
485 (elatin-proc-off-state lc key key-state))
486 (elatin-update-preedit lc))
487
488 (define (elatin-key-release-handler lc key key-state)
a8e9aaa * scm/elatin.scm
jhyeon authored Mar 28, 2010
489 ;; don't discard any key release event for apps
490 (im-commit-raw lc))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
491
492 (define (elatin-reset-handler lc)
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
493 (elatin-context-reset lc))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
494
495 (define (elatin-get-candidate-handler lc idx accel-enum-hint)
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
496 (let ((candidates (or (elatin-context-translations lc)
497 (elatin-context-completions lc))))
498 (let* ((item (list-ref candidates idx))
499 (desc
500 (if (string? item)
501 item
502 (apply string-append
503 (append (caar item) '(" ")
504 (append-map (lambda (str) (list " " str))
505 (cadr item))))))
506 (num (number->string (+ idx 1))))
507 (list desc num ""))))
508
509 (define (elatin-set-candidate-index-handler lc idx)
510 (if (elatin-context-translations lc)
511 (elatin-context-set-translation-no! lc idx)
512 (elatin-context-set-completion-no! lc idx)))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
513
514 (define (elatin-focus-out-handler lc)
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
515 (elatin-context-flush lc)
516 (elatin-update-preedit lc))
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
517
518 (define (elatin-place-handler lc)
519 (elatin-update-preedit lc))
520
521 (define (elatin-displace-handler lc)
522 (elatin-context-flush lc)
523 (elatin-update-preedit lc))
524
525 (register-im
526 'elatin
527 ""
528 "UTF-8"
529 elatin-im-name-label
530 elatin-im-short-desc
531 #f
532 elatin-init-handler
533 elatin-release-handler
534 context-mode-handler
535 elatin-key-press-handler
536 elatin-key-release-handler
537 elatin-reset-handler
538 elatin-get-candidate-handler
bc96b06 A major revision of elatin for incorporating TeX style rules (which
jhyeon authored Mar 6, 2010
539 elatin-set-candidate-index-handler
583139f * scm/elatin.scm
jhyeon authored Jan 4, 2008
540 context-prop-activate-handler
541 #f
542 #f
543 elatin-focus-out-handler
544 elatin-place-handler
545 elatin-displace-handler
546 )
547
548 ;; Local Variables:
549 ;; mode: scheme
550 ;; coding: utf-8
551 ;; End:
Something went wrong with that request. Please try again.