Improve the original one (was in m17n-db package).
[m17n/m17n-contrib.git] / im / bo-ewts.mim
1 ;; bo-ewts.mim -- Tibetan input method with EWTS
2 ;; Copyright (C) 2007
3 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
4 ;;   Registration Number H15PRO112
5 ;; Copyright (C) 2010 Hugues MOISY <hugues.moisy@gmail.com>
6
7 ;; This file is part of the m17n database; a sub-part of the m17n
8 ;; library.
9
10 ;; The m17n library is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU Lesser General Public License
12 ;; as published by the Free Software Foundation; either version 2.1 of
13 ;; the License, or (at your option) any later version.
14
15 ;; The m17n library is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 ;; Lesser General Public License for more details.
19
20 ;; You should have received a copy of the GNU Lesser General Public
21 ;; License along with the m17n library; if not, write to the Free
22 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
24
25 (input-method bo ewts)
26
27 (description "Tibetan input method based on EWTS.
28 This implementation is based on THDL Extended Wylie Transliteration Scheme
29 Version 2.0 <http://www.thdl.org/collections/langling/ewts/ewts.php>.")
30
31 (title "ཀ")
32
33 (variable
34  (precomposed
35   (_"Flag to tell whether or not to generate precomposed characters.
36 If 1, generate precomposed characters if available (e.g. \"ྲྀ\"(U+0F76).
37 If 0, generate only decomposed characters (e.g. \"ྲྀ\" (U+0FB2 U+0F80).")
38   0 0 1))
39
40 (map
41  ;; This map is used also for subjoined consonants.
42  (consonant
43   ("k" "ཀ")
44   ("kh" "ཁ")
45   ("g" "ག")
46   ("gh" "གྷ")
47   ("ng" "ང")
48   ("c" "ཅ")
49   ("ch" "ཆ")
50   ("j" "ཇ")
51   ("ny" "ཉ")
52   ("T" "ཊ")
53   ("Th" "ཋ")
54   ("D" "ཌ")
55   ("Dh" "ཌྷ")
56   ("N" "ཎ")
57   ("t" "ཏ")
58   ("th" "ཐ")
59   ("d" "ད")
60   ("dh" "དྷ")
61   ("n" "ན")
62   ("p" "པ")
63   ("ph" "ཕ")
64   ("b" "བ")
65   ("bh" "བྷ")
66   ("m" "མ")
67   ("ts" "ཙ")
68   ("tsh" "ཚ")
69   ("dz" "ཛ")
70   ("dzh" "ཛྷ")
71   ("w" "ཝ")
72   ("zh" "ཞ")
73   ("z" "ཟ")
74   ("'" "འ")
75   ("y" "ཡ")
76   ("r" "ར")
77   ("l" "ལ")
78   ("sh" "ཤ")
79   ("Sh" "ཥ")
80   ("s" "ས")
81   ("h" "ཧ")
82   ("a" "ཨ")
83
84 )
85
86  ;; Standard Tibetan Stacks listed at:
87  ;; <http://www.thdl.org/collections/langling/tibstacks.html>
88  (standard-stack
89   ("kl" "ཀླ")
90   ("kr" "ཀྲ")
91   ("kw" "ཀྭ")
92   ("ky" "ཀྱ")
93   ("khr" "ཁྲ")
94   ("khw" "ཁྭ")
95   ("khy" "ཁྱ")
96   ("gl" "གླ")
97   ("gr" "གྲ")
98   ("grw" "གྲྭ")
99   ("gw" "གྭ")
100   ("gy" "གྱ")
101   ("cw" "ཅྭ")
102   ("nyw" "ཉྭ")
103   ("tr" "ཏྲ")
104   ("tw" "ཏྭ")
105   ("thr" "ཐྲ")
106   ("dr" "དྲ")
107   ("drw" "དྲྭ")
108   ("dw" "དྭ")
109   ("pr" "པྲ")
110   ("py" "པྱ")
111   ("phr" "ཕྲ")
112   ("phy" "ཕྱ")
113   ("phyw" "ཕྱྭ")
114   ("bl" "བླ")
115   ("br" "བྲ")
116   ("by" "བྱ")
117   ("mr" "མྲ")
118   ("my" "མྱ")
119   ("tsw" "ཙྭ")
120   ("tshw" "ཚྭ")
121   ("zhw" "ཞྭ")
122   ("zl" "ཟླ")
123   ("zw" "ཟྭ")
124   ("rb" "རྦ")
125   ("rd" "རྡ")
126   ("rdz" "རྫ")
127   ("rg" "རྒ")
128   ("rgw" "རྒྭ")
129   ("rgy" "རྒྱ")
130   ("rj" "རྗ")
131   ("rk" "རྐ")
132   ("rky" "རྐྱ")
133   ("rl" "རླ")
134   ("rm" "རྨ")
135   ("rmy" "རྨྱ")
136   ("rn" "རྣ")
137   ("rng" "རྔ")
138   ("rny" "རྙ")
139   ("rt" "རྟ")
140   ("rts" "རྩ")
141   ("rtsw" "རྩྭ")
142   ("rw" "རྭ")
143   ("lb" "ལྦ")
144   ("lc" "ལྕ")
145   ("ld" "ལྡ")
146   ("lg" "ལྒ")
147   ("lh" "ལྷ")
148   ("lj" "ལྗ")
149   ("lk" "ལྐ")
150   ("lng" "ལྔ")
151   ("lp" "ལྤ")
152   ("lt" "ལྟ")
153   ("shr" "ཤྲ")
154   ("shw" "ཤྭ")
155   ("sb" "སྦ")
156   ("sbr" "སྦྲ")
157   ("sby" "སྦྱ")
158   ("sd" "སྡ")
159   ("sg" "སྒ")
160   ("sgr" "སྒྲ")
161   ("sgy" "སྒྱ")
162   ("sk" "སྐ")
163   ("skr" "སྐྲ")
164   ("sky" "སྐྱ")
165   ("sl" "སླ")
166   ("sm" "སྨ")
167   ("smr" "སྨྲ")
168   ("smy" "སྨྱ")
169   ("sn" "སྣ")
170   ("sng" "སྔ")
171   ("snr" "སྣྲ")
172   ("sny" "སྙ")
173   ("sp" "སྤ")
174   ("spr" "སྤྲ")
175   ("spy" "སྤྱ")
176   ("sr" "སྲ")
177   ("st" "སྟ")
178   ("sts" "སྩ")
179   ("sw" "སྭ")
180   ("hr" "ཧྲ")
181   ("hw" "ཧྭ")
182   ("brk" "བརྐ")
183   ("brky" "བརྐྱ")
184   ("brg" "བརྒ")
185   ("brgy" "བརྒྱ")
186   ("brgw" "བརྒྭ")
187   ("rng" "བརྔ")
188   ("brj" "བརྗ")
189   ("brny" "བརྙ")
190   ("brt" "བརྟ")
191   ("brd" "བརྡ")
192   ("brn" "བརྣ")
193   ("brts" "བརྩ")
194   ("brtsw" "བརྩྭ")
195   ("brdz" "བརྫ")
196   ("blt" "བལྟ")
197   ("bld" "བལྡ")
198 )
199
200  (sanskrit
201   ("oM" (cond (precomposed "ༀ") (1 "ཨོཾ")))
202   ("R+" "ཪ"))
203
204  (force-stack
205   ("+"))
206
207  (break-stack
208   ("."))
209
210  (special-subjoined
211   ("h" (cond ((= precomposed 0) "ྷ")
212              ((= @-1 ?ག) (delete @-1) "གྷ")
213              ((= @-1 ?ད) (delete @-1)  "དྷ")
214              ((= @-1 ?བ) (delete @-1)  "བྷ")
215              ((= @-1 ?ཛ) (delete @-1)  "ཛྷ")
216              (1 "ྷ")))
217   ("Sh" (cond ((= precomposed 0) "ྵ")
218               ((= @-1 ?ཀ) (delete @-1) "ཀྵ")
219               (1 "ྵ")))
220   ("W" "ྺ")
221   ("Y" "ྻ")
222   ("R" "ྼ")
223   ("Z" "༹"))
224
225  (vowel
226   ("a" "")
227   ("i" "ི")
228   ("u" "ུ")
229   ("e" "ེ")
230   ("o" "ོ")
231   ("-i" (cond ((= precomposed 0) "ྀ")
232               ((= @-1 ?ྲ) "ྲྀ")
233               ((= @-1 ?ླ) "ླྀ")
234               (1 "ྀ")))
235   ("A" "ཱ")
236   ("I" "ཱི")
237   ("U" "ཱུ")
238   ("ai" "ཻ")
239   ("au" "ཽ")
240   ("uo" "ོུ")
241   ("ui" "ིུ")
242   ("ue" "ེུ")
243   ("r-I" "ཷ")
244   ("l-I" "ཹ")
245   ("-I" (cond ((= precomposed 0) "ཱྀ")
246               ((= @-1 ?ྲ) "ཷ")
247               ((= @-1 ?ླ) "ཹ")
248               (1 "ཱྀ"))))
249
250  (others
251   ;; Numbers
252   ("0" "༠")
253   ("1" "༡")
254   ("2" "༢")
255   ("3" "༣")
256   ("4" "༤")
257   ("5" "༥")
258   ("6" "༦")
259   ("7" "༧")
260   ("8" "༨")
261   ("9" "༩")
262   ;; These half numbers are not in EWTS but for convenience.
263   ("-1" "༪")
264   ("-2" "༫")
265   ("-3" "༬")
266   ("-4" "༭")
267   ("-5" "༮")
268   ("-6" "༯")
269   ("-7" "༰")
270   ("-8" "༱")
271   ("-9" "༲")
272   ("-0" "༳")
273   ;; Sanskrit-related marks
274   ("H" "ཿ")
275   ("M" "ཾ")
276   ("~M" "ྃ")
277   ("~M`" "ྂ")
278   ("?" "྄")
279   ("&" "྅")
280   ;; Intersyllabic marks
281   (" " "་")
282   ("*" "༌")
283   ;; Phrase deliminating marks
284   ("/" "།")
285   ("//" "༎")
286   (";" "༏")
287   ("|" "༑")
288   ("!" "༈")
289   (":" "༔")
290   ("_" " ")
291   ("=" "༴")
292   ;; Head marks
293   ("@" "༄")
294   ("#" "༅")
295   ("$" "༆")
296   ("%" "༇")
297   ;; Paired punctuation marks (brackets)
298   ("<" "༺")
299   (">" "༻")
300   ("(" "༼")
301   (")" "༽")
302   ;; Miscellaneous
303   ("~X" "༵")
304   ("X" "༷")
305   ("^" "༹"))
306  
307  (escape
308   ("\\" (mark BEG) "\\"))
309
310  (non-tibetan
311   ("["))
312
313  (unicode
314   ("u" "u" (set MAX-COUNT 4))
315   ("U" "U" (set MAX-COUNT 8)))
316
317  (unescape
318   ("]"))
319
320  (hexadigit
321   ("0" "0")
322   ("1" "1")
323   ("2" "2")
324   ("3" "3")
325   ("4" "4")
326   ("5" "5")
327   ("6" "6")
328   ("7" "7")
329   ("8" "8")
330   ("9" "9")
331   ("A" "A") ("a" "A")
332   ("B" "B") ("b" "B")
333   ("C" "C") ("c" "C")
334   ("D" "D") ("d" "D")
335   ("E" "E") ("e" "E")
336   ("F" "F") ("f" "F"))
337
338  (backspace
339   ((Backspace) (undo))))
340
341 (state
342  (init
343   (consonant (shift after-consonant))
344   (standard-stack (shift after-consonant))
345   (sanskrit (shift after-consonant))
346   (vowel (move @<) "ཨ" (move @>) (shift after-vowel))
347   (others)
348   (escape (shift dispatch-escape))
349   (non-tibetan (shift non-tibetan))
350   (backspace))
351
352  (after-consonant
353   (force-stack (shift consonant-stack))
354   (break-stack (shift init))
355   (vowel (shift after-vowel)))
356   
357  (consonant-stack
358   "ཀ+"
359   (special-subjoined (shift after-consonant))
360   (consonant (set C @-1) (delete @-1) (add C #x50) (insert C)
361              (shift after-consonant))
362   (force-stack)
363   (nil (pop)))
364
365  (after-vowel
366   (force-stack (shift vowel-stack)))
367
368  (vowel-stack
369   "ཀ+"
370   (vowel (shift after-vowel)))
371
372  (dispatch-escape
373   (unicode (shift unicode))
374   (nil (delete BEG) (shift init) (unhandle)))
375
376  (unicode
377   "ཀu"
378   (t (set COUNT 0) (set UNICODE 0))
379   (hexadigit (cond ((> @-1 ?9) (set UNICODE (+ (* UNICODE 16) (- @-1 55))))
380                    (1 (set UNICODE (+ (* UNICODE 16) (- @-1 48)))))
381              (set COUNT (+ COUNT 1))
382              (cond ((= COUNT MAX-COUNT) (delete BEG) (insert UNICODE)
383                     (shift init)))))
384
385  (non-tibetan
386   "ཀA"
387   (unescape (shift init))
388   (nil (unhandle))))
389
390 ;; Local Variables:
391 ;; mode: lisp
392 ;; End: