New file. Modified from ru-kbd.png.
[m17n/m17n-db.git] / MIM / vi-telex.mim
1 ;; vi-telex.mim -- Input method for Vietnames with TELEX key sequence
2 ;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
3 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
4 ;;   Registration Number H15PRO112
5
6 ;; This file is part of the m17n database; a sub-part of the m17n
7 ;; library.
8
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.
13
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.
18
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.
23
24 (input-method vi telex)
25
26 (description (_"Vietnames input method using the TELEX key sequence.
27 Typing Backslash ('\\') toggles the normal mode and English mode.
28 The following variables are customizable:
29   tone-mark-on-last: control tone mark position in equivocal cases
30   backspace-is-undo: control the action of Backspace key (delete or undo)"))
31
32 (title "Ắ(TLX)")
33
34 (variable
35  (tone-mark-on-last
36   (_"Flag to control tone mark position in equivocal cases.
37 If this variable is 0 (the default), put tone mark on the first vowel
38 in such equivocal cases as \"oa\", \"oe\", \"uy\".
39 Otherwise, put tone mark on the last vowel.")
40   0 0 1)
41
42  (backspace-is-undo
43   (_"Flag to control the action of Backspace key (delete or undo).
44 If this variable is 0 (the default), Backspace key deletes the previous
45 character (e.g. \"q u a i s BS\" => \"quá\").
46 If the value is 1, Backspace key undoes the previous key
47 \(e.g. \"q u a i s BS\" => \"quai\").")
48   0 0 1))
49
50 (include (t nil vi-base) macro)
51 (include (t nil vi-base) map)
52
53 (map
54  (vowel-ext
55   ("aa" ("âấầẩẫậ")) ("AA" ("ÂẤẦẨẪẬ")) ("Aa" ("ÂẤẦẨẪẬ"))
56   ("aw" ("ăắằẳẵặ")) ("AW" ("ĂẮẰẲẴẶ")) ("Aw" ("ĂẮẰẲẴẶ"))
57   ("ee" ("êếềểễệ")) ("EE" ("ÊẾỀỂỄỆ")) ("Ee" ("ÊẾỀỂỄỆ"))
58   ("oo" ("ôốồổỗộ")) ("OO" ("ÔỐỒỔỖỘ")) ("Oo" ("ÔỐỒỔỖỘ"))
59   ("ow" ("ơớờởỡợ")) ("OW" ("ƠỚỜỞỠỢ")) ("Ow" ("ƠỚỜỞỠỢ"))
60   ("uw" ("ưứừửữự")) ("UW" ("ƯỨỪỬỮỰ")) ("Uw" ("ƯỨỪỬỮỰ"))
61   ("w"  (cond ((= V-1 0) ("ưứừửữự")) (1 "w"))) ; Works when it's the
62   ("W"  (cond ((= V-1 0) ("ƯỨỪỬỮỰ")) (1 "W"))) ; first vowel (not seư)
63   ("ooo" ("oóòỏõọ") ("oóòỏõọ") (set V-2 V-1) (set V-1 ?o))
64   ("OOO" ("OÓÒỎÕỌ") ("OÓÒỎÕỌ") (set V-2 V-1) (set V-1 ?O))
65   ("Ooo" ("OÓÒỎÕỌ") ("oóòỏõọ") (set V-2 V-1) (set V-1 ?O)))
66
67  (consonant-ext
68   ("dd" ?đ) ("DD" ?Đ) ("Dd" ?Đ))
69   ;("dd" (cond ((= C-AFTER-V 0) "dd") (1 ?đ))) ; Works when
70   ;("DD" (cond ((= C-AFTER-V 0) "DD") (1 ?Đ))) ; it is the first
71   ;("Dd" (cond ((= C-AFTER-V 0) "Dd") (1 ?Đ)))) ; letter (not ađ)
72
73  (tone-mark
74   ("z" (set SELECT 0) ?z) ("Z" (set SELECT 0) ?Z)
75   ("s" (set SELECT 1) ?s) ("S" (set SELECT 1) ?S)
76   ("f" (set SELECT 2) ?f) ("F" (set SELECT 2) ?F)
77   ("r" (set SELECT 3) ?r) ("R" (set SELECT 3) ?R)
78   ("x" (set SELECT 4) ?x) ("X" (set SELECT 4) ?X)
79   ("j" (set SELECT 5) ?j) ("J" (set SELECT 5) ?J))
80
81  (consonant-or-tone-mark
82   ("z" ?z) ("s" ?s) ("f" ?f) ("r" ?r) ("x" ?x) ("j" ?j)
83   ("Z" ?Z) ("S" ?S) ("F" ?F) ("R" ?R) ("X" ?X) ("J" ?J))
84
85  (temporary-escape
86   ("aaa" "aa") ("AAA" "AA") ("Aaa" "Aa")
87   ("eee" "ee") ("EEE" "EE") ("Eee" "Ee")
88   ("ddd" "dd") ("DDD" "DD") ("Ddd" "Dd")
89   ("aww" "aw") ("AWW" "AW") ("Aww" "Aw")
90   ("uww" "uw") ("UWW" "UW") ("Uww" "Uw")
91   ("oww" "ow") ("OWW" "OW") ("Oww" "Ow")
92   ("ww" ?w) ("WW" ?W) ("Ww" ?W)
93   ("zz" ?z) ("ZZ" ?Z) ("Zz" ?Z)
94   ("ss" ?s) ("SS" ?S) ("Ss" ?S)
95   ("ff" ?f) ("FF" ?F) ("Ff" ?F)
96   ("rr" ?r) ("RR" ?R) ("Rr" ?R)
97   ("xx" ?x) ("XX" ?X) ("Xx" ?X)
98   ("jj" ?j) ("JJ" ?J) ("Jj" ?J)))
99
100 (state
101  (init
102   ;; Initialize variables.  C is the initial consonant.  V-N is the
103   ;; (N-1)th vowel from the last.  C-AFTER-V is a number of consonants
104   ;; typed after vowel.  NST is 1 iff surrounding text is not supported.
105   (t (set C @-1) (set V-1 0) (set V-2 0) (set V-3 0) (set C-AFTER-V 0)
106      (set SELECT 0) (set NST (= @-0 -2)))
107
108   (consonant (set C @-1) (cond (NST (shift after-c))))
109   (consonant-ext (set C @-1) (cond (NST (shift after-c))))
110   (consonant-or-tone-mark
111    (cond ((| (= @-1 ?f) (= @-1 ?j) (= @-1 ?z) ; Invalid beginning consonants
112              (= @-1 ?F) (= @-1 ?J) (= @-1 ?Z)) (shift temporary-escape))
113          (1 (set C @-1) (cond (NST (shift after-c))))))
114
115   ;; Mark M remembers the preedit position after the last vowel.
116   (vowel (mark M) (set V-2 V-1) (set V-1 @-1) (shift after-v))
117   (vowel-ext (mark M) (set V-2 V-1) (set V-1 @-1) (shift after-v))
118   (temporary-escape (shift temporary-escape))
119   (permanent-escape (shift escape-in-normal-mode))
120   (smart-quotes))
121
122  ;; The state shifted to when an initial consonants is typed and
123  ;; surrounding text is not supported.
124  (after-c
125   (vowel (mark M) (set V-2 V-1) (set V-1 @-1) (shift after-v))
126   (vowel-ext (mark M) (set V-2 V-1) (set V-1 @-1) (shift after-v)))
127
128  ;; The state shifted to when a vowel is typed.
129  (after-v
130   (ending-1st-consonant (handle-mark) (shift after-vc)) ; toans/toasn->toán
131   (vowel (mark M) (set V-3 V-2) (set V-2 V-1) (set V-1 @-1)
132          (move T) (select 0) (handle-mark) (move M))
133   (vowel-ext (mark M) (set V-3 V-2) (set V-2 V-1) (set V-1 @-1)
134              (move T) (select 0) (handle-mark) (move M))
135   (ending-1st-notviet-consonant (shift temporary-escape)) ;; See ending-1st-notviet-consonant section in the vi-base.mim 
136   (consonant-or-tone-mark (delete @-) (pushback 1) (shift after-t))
137   (backspace (delete @-)
138              (cond (V-3 (set V-1 V-2) (set V-2 V-3) (set V-3 0)
139                         (cond ((> TPLACE 2) (set SELECT 0)))
140                         (handle-mark))
141                    (V-2 (set V-1 V-2) (set V-2 0)
142                         (cond ((> TPLACE 1) (set SELECT 0)))
143                         (handle-mark))
144                    (1 (shift init)))))
145
146  ;; The state shifted to when a consonant is typed after a vowel.
147  (after-vc
148   (t (set C-AFTER-V 1))
149   (ending-2nd-consonant
150    (cond ((| (= @-2 ?n) (= @-2 ?c) ; 1st ending consonant must be n/c
151              (= @-2 ?N) (= @-2 ?C)) (add C-AFTER-V 1))
152          (1 (shift temporary-escape))))
153   (ending-1st-notviet-consonant (shift temporary-escape)) ;; Expand notviet-consonant section in the vi-base.mim 
154   (consonant-or-tone-mark (delete @-) (pushback 1) (shift after-t))
155   (vowel (shift temporary-escape))      ; There can only be one
156   (vowel-ext (shift temporary-escape))  ; main vowel in a word
157   (backspace (delete @-)
158              (sub C-AFTER-V 1)
159              (handle-mark)
160              (cond ((= C-AFTER-V 0) (shift after-v)))))
161
162  ;; The state shifted to when a tone-mark is typed.
163  (after-t
164   (t (set CURRENT-SELECT -1))
165   (tone-mark (cond ((= CURRENT-SELECT SELECT) (move T) (select 0) (move @>)
166                     (shift temporary-escape))
167                    (1 (delete @-) (handle-mark) (set CURRENT-SELECT SELECT))))
168   (nil (cond (C-AFTER-V (shift after-vc))
169              (1 (shift after-v)))))
170
171  (temporary-escape
172   "en"
173   (t (commit))
174   (alnum (commit)))
175
176  (escape-in-normal-mode
177   "EN"
178   (permanent-escape (insert "\\") (shift init))
179   ;; Any other key force shifting to permanent-escape.
180   (nil (shift permanent-escape)))
181
182  (permanent-escape
183   "EN"
184   (t (set ESCAPE 1))
185   (permanent-escape (shift escape-in-permanent-escape))
186   ;; Unhandle any characters.
187   (nil (unhandle)))
188
189  (escape-in-permanent-escape
190   "Ắ"
191   (permanent-escape (insert "\\") (commit) (shift permanent-escape))
192   ;; Any other key force shifting to init
193   ))
194
195 ;; Local Variables:
196 ;; coding: utf-8
197 ;; mode: emacs-lisp
198 ;; End: