1 ;; th-kesmanee.mim -- Thai input method with Kesmanee keyboard layout
2 ;; Copyright (C) 2003, 2004, 2005, 2006, 2007
3 ;; National Institute of Advanced Industrial Science and Technology (AIST)
4 ;; Registration Number H15PRO112
6 ;; This file is part of the m17n database; a sub-part of the m17n
9 ;; The m17n library is free software; you can redistribute it and/or
10 ;; modify it under the terms of the GNU Lesser General Public License
11 ;; as published by the Free Software Foundation; either version 2.1 of
12 ;; the License, or (at your option) any later version.
14 ;; The m17n library is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ;; Lesser General Public License for more details.
19 ;; You should have received a copy of the GNU Lesser General Public
20 ;; License along with the m17n library; if not, write to the Free
21 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
24 (input-method th kesmanee)
26 (description "Thai input method simulating the Kesmanee keyboard
27 with WTT 2.0 input sequence correction.
28 The correction algorithm follows the one shown in the following
29 <http://linux.thai.net/~thep/th-xim/>
35 (level (_"Acceptance level
36 The level of character sequence acceptance defined in WTT 2.0.
37 0 accepts any key sequence. 2 accepts only orthographic ones.
38 1 is somewhere between.")
43 ;; input global variables : arg1, arg2
44 ;; output global variable : ret
52 ;; input global variables : arg1, arg2
53 ;; output global variable : ret
63 ;; Level 1 & 2 composability
68 ;; next = BV1|BV2|BD|AD3|AV1|AV2|AV3, previous = CONS
70 (& (>= arg2 0x0E34) (<= arg2 0x0E3A))
73 ((| (& (>= arg1 0x0E01) (<= arg1 0x0E23))
75 (& (>= arg1 0x0E27) (<= arg1 0x0E2E)))
78 ;; next = TONE, previous = CONS|BV1|BV2|AV1|AV2|AV3
79 ((& (>= arg2 0x0E48) (<= arg2 0x0E4B))
81 ((| (& (>= arg1 0x0E01) (<= arg1 0x0E23))
83 (& (>= arg1 0x0E27) (<= arg1 0x0E2E))
85 (& (>= arg1 0x0E34) (<= arg1 0x0E39)))
88 ;; next = AD1, previous = CONS|BV1|AV1
89 ((& (>= arg2 0x0E4C) (<= arg2 0x0E4D))
91 ((| (& (>= arg1 0x0E01) (<= arg1 0x0E23))
93 (& (>= arg1 0x0E27) (<= arg1 0x0E2E))
98 ;; next = AD2, previous = TONE| AV3
101 ((| (& (>= arg1 0x0E01) (<= arg1 0x0E23))
103 (& (>= arg1 0x0E27) (<= arg1 0x0E2E))
108 ;; Level 1 acceptance
113 (& (>= arg2 0x0E34) (<= arg2 0x0E3A))
114 (& (>= arg2 0x0E47) (<= arg2 0x0E4E)))
117 ;; Level 2 acceptance
122 ;; next = CTRL|CONS, previous = *
124 (& (>= arg2 0x0080) (<= arg2 0x009F))
125 (& (>= arg2 0x0E01) (<= arg2 0x0E23))
127 (& (>= arg2 0x0E27) (<= arg2 0x0E2E)))
130 ;; next = NON|LV, previous = ~LV,
131 ((| (& (>= arg2 0x0020) (<= arg2 0x007E))
132 (& (>= arg2 0x00A0) (<= arg2 0x0E00))
134 (& (>= arg2 0x0E3F) (<= arg2 0x0E44))
138 ((| (< arg1 0x0E40) (> arg1 0x0E44))
141 ;; next = FV1, previous = CONS|FV1|FV2|BV1|TONE
142 ((| (= arg2 0x0E30) (= arg2 0x0E32) (= arg2 0x0E33))
144 ((| (& (>= arg1 0x0E01) (<= arg1 0x0E23))
146 (& (>= arg1 0x0E27) (<= arg1 0x0E2E))
152 (& (>= arg1 0x0E48) (<= arg1 0x0E4B)))
155 ;; next = FV2, previous = FV3|TONE
160 (& (>= arg1 0x0E48) (<= arg1 0x0E4B)))
163 ;; next = FV3, previous = ~LV~FV3
164 ((| (= arg2 0x0E24) (= arg2 0x0E26))
166 ((& (| (< arg1 0x0E40) (> arg1 0x0E44))
268 ;; CTRL : 0000..0020, 007F..009F
269 ;; NON : 0021..007E, 00A0..0E00
270 ;; CONS : 0E01..0E23, 0E25, 0E27..0E2E
272 ;; FV1 : 0E30, 0E32, 0E33
304 ((= ret 1)) ;; CP(y,z) succeeded.
308 ((= ret 1)) ;; AC(y,z) succeeded.
310 ;; WTT-based input sequence correction starts here.
344 ;; elif y is FV1 and z is TONE then
345 ((& (| (= y 0x0E30) (= y 0x0E32) (= y 0x0E33))
369 ;; Only Thai characters should be replaced.
370 (& (>= y 0x0E01) (<= y 0x0E5B))
371 (& (>= z 0x0E01) (<= z 0x0E5B)))
388 ;; Now we commit the preedit chars that are fixed.
391 ;; If surrounding text is supported, commit the only char in preedit.
395 ;; If the last char is CTRL or NON, we can commit everything.
396 ((| (& (>= w 0x0000) (<= w 0x0E00))
403 ;; If the last char is CONS, we can commit everything but the last
404 ;; unless the second last is FV3.
405 ((| (& (>= w 0x0E01) (<= w 0x0E23))
407 (& (>= w 0x0E27) (<= w 0x0E2E)))
409 ((| (= @-2 0x0E24) (= @-2 0x0E26))
417 ;; If the last char is LV, FV2 or FV3, we can commit
418 ;; everything but the last.
419 ((| (& (>= w 0x0E40) (<= w 0x0E45))
426 ;; If the last char is FV1 (excluding AM) and ...
427 ((| (= w 0x0E30) (= w 0x0E32))
432 ;; ... the before last is CONS, we can commit other than the
434 ((| (& (>= v 0x0E01) (<= v 0x0E23))
436 (& (>= v 0x0E27) (<= v 0x0E2E)))
442 ;; ... else if the before last is not CONS, we can commit
443 ;; everything but the last.