;; vi-telex.mim -- Input method for Vietnames with TELEX key sequence
-;; Copyright (C) 2003, 2004, 2005, 2006
+;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
;; National Institute of Advanced Industrial Science and Technology (AIST)
;; Registration Number H15PRO112
(input-method vi telex)
-(description "Vietnames input method using the TELEX key sequence.
-")
-
-(title "ắ")
-
-(macro
- (handle-mark
- (cond (V-PREV
- (delete @-)
- (move M)
- (cond ((| LAST-SPECIAL
- (& (= V-PREV ?i) (= C ?g))
- (& (= V-PREV ?u) (= C ?q)))
- (select SELECT))
- (1 (move @-) (select SELECT)))
- (move @>))
- (V-LAST
- (delete @-)
- (move M)
- (select SELECT)
- (move @>)))))
+(description (_"Vietnames input method using the TELEX key sequence.
+Typing Backslash ('\\') toggles the normal mode and English mode.
+The following variables are customizable:
+ tone-mark-on-last: control tone mark position in equivocal cases
+ backspace-is-undo: control the action of Backspace key (delete or undo)"))
+
+(title "Ắ(TLX)")
+
+(variable
+ (tone-mark-on-last
+ (_"Flag to control tone mark position in equivocal cases.
+If this variable is 0 (the default), put tone mark on the first vowel
+in such equivocal cases as \"oa\", \"oe\", \"uy\".
+Otherwise, put tone mark on the last vowel.")
+ 0 0 1)
+
+ (backspace-is-undo
+ (_"Flag to control the action of Backspace key (delete or undo).
+If this variable is 0 (the default), Backspace key deletes the previous
+character (e.g. \"q u a i s BS\" => \"quá\").
+If the value is 1, Backspace key undoes the previous key
+\(e.g. \"q u a i s BS\" => \"quai\").")
+ 0 0 1))
+
+(include (t nil vi-base) macro)
+(include (t nil vi-base) map)
(map
- (vowel
- ;; sfrxj
- ("a" ("aáàảãạ"))
- ("aa" ("âấầẩẫậ") (set SPECIAL 1))
- ("aw" ("ăắằẳẵặ") (set SPECIAL 1))
- ("e" ("eéèẻẽẹ"))
- ("ee" ("êếềểễệ") (set SPECIAL 1))
- ("i" ("iíìỉĩị"))
- ("o" ("oóòỏõọ"))
- ("oo" ("ôốồổỗộ") (set SPECIAL 1))
- ("ow" ("ơớờởỡợ") (set SPECIAL 1))
- ("u" ("uúùủũụ"))
- ("uw" ("ưứừửữự") (set SPECIAL 1))
- ("y" ("yýỳỷỹỵ"))
- ("A" ("AÁÀẢÃẠ"))
- ("AA" ("ÂẤẦẨẪẬ")) ("Aa" ("ÂẤẦẨẪẬ"))
- ("AW" ("ĂẮẰẲẴẶ")) ("Aw" ("ĂẮẰẲẴẶ"))
- ("E" ("EÉÈẺẼẸ"))
- ("EE" ("ÊẾỀỂỄỆ")) ("Ee" ("ÊẾỀỂỄỆ"))
- ("I" ("IÍÌỈĨỊ"))
- ("O" ("OÓÒỎÕỌ"))
- ("OO" ("ÔỐỒỔỖỘ")) ("Oo" ("ÔỐỒỔỖỘ"))
- ("OW" ("ƠỚỜỞỠỢ")) ("Ow" ("ƠỚỜỞỠỢ"))
- ("U" ("UÚÙỦŨỤ"))
- ("UW" ("ƯỨỪỬỮỰ")) ("Uw" ("ƯỨỪỬỮỰ"))
- ("Y" ("YÝỲỶỸỴ")))
-
- (diacritical
- ("z" (set SELECT 0) ?z (handle-mark))
- ("s" (set SELECT 1) ?s (handle-mark))
- ("f" (set SELECT 2) ?f (handle-mark))
- ("r" (set SELECT 3) ?r (handle-mark))
- ("x" (set SELECT 4) ?x (handle-mark))
- ("j" (set SELECT 5) ?j (handle-mark)))
-
- (double
- ("zz" (cond ((> V-LAST 0) (move M) (select 0) (move @>))) ?z)
- ("ss" (cond ((> V-LAST 0) (move M) (select 0) (move @>))) ?s)
- ("ff" (cond ((> V-LAST 0) (move M) (select 0) (move @>))) ?f)
- ("rr" (cond ((> V-LAST 0) (move M) (select 0) (move @>))) ?r)
- ("xx" (cond ((> V-LAST 0) (move M) (select 0) (move @>))) ?x)
- ("jj" (cond ((> V-LAST 0) (move M) (select 0) (move @>))) ?j))
-
- (consonant
- ("b" ?b) ("c" ?c) ("d" ?d) ("g" ?g) ("h" ?h) ("k" ?k) ("l" ?l) ("m" ?m)
- ("n" ?n) ("p" ?p) ("q" ?q) ("t" ?t) ("v" ?v)
- ("dd" ?đ)
- ("DD" ?Đ) ("Dd" ?Đ))
-
- (escape
- ("\\"))
-
- (backspace
- ((BackSpace))))
+ (vowel-ext
+ ("aa" ("âấầẩẫậ")) ("AA" ("ÂẤẦẨẪẬ")) ("Aa" ("ÂẤẦẨẪẬ"))
+ ("aw" ("ăắằẳẵặ")) ("AW" ("ĂẮẰẲẴẶ")) ("Aw" ("ĂẮẰẲẴẶ"))
+ ("ee" ("êếềểễệ")) ("EE" ("ÊẾỀỂỄỆ")) ("Ee" ("ÊẾỀỂỄỆ"))
+ ("oo" ("ôốồổỗộ")) ("OO" ("ÔỐỒỔỖỘ")) ("Oo" ("ÔỐỒỔỖỘ"))
+ ("ow" ("ơớờởỡợ")) ("OW" ("ƠỚỜỞỠỢ")) ("Ow" ("ƠỚỜỞỠỢ"))
+ ("uw" ("ưứừửữự")) ("UW" ("ƯỨỪỬỮỰ")) ("Uw" ("ƯỨỪỬỮỰ"))
+ ("w" (cond ((= V-1 0) ("ưứừửữự")) (1 "w"))) ; Works when it's the
+ ("W" (cond ((= V-1 0) ("ƯỨỪỬỮỰ")) (1 "W"))) ; first vowel (not seư)
+ ("ooo" ("oóòỏõọ") ("oóòỏõọ") (set V-2 V-1) (set V-1 ?o))
+ ("OOO" ("OÓÒỎÕỌ") ("OÓÒỎÕỌ") (set V-2 V-1) (set V-1 ?O))
+ ("Ooo" ("OÓÒỎÕỌ") ("oóòỏõọ") (set V-2 V-1) (set V-1 ?O)))
+
+ (consonant-ext
+ ("dd" ?đ) ("DD" ?Đ) ("Dd" ?Đ))
+ ;("dd" (cond ((= C-AFTER-V 0) "dd") (1 ?đ))) ; Works when
+ ;("DD" (cond ((= C-AFTER-V 0) "DD") (1 ?Đ))) ; it is the first
+ ;("Dd" (cond ((= C-AFTER-V 0) "Dd") (1 ?Đ)))) ; letter (not ađ)
+
+ (tone-mark
+ ("z" (set SELECT 0) ?z) ("Z" (set SELECT 0) ?Z)
+ ("s" (set SELECT 1) ?s) ("S" (set SELECT 1) ?S)
+ ("f" (set SELECT 2) ?f) ("F" (set SELECT 2) ?F)
+ ("r" (set SELECT 3) ?r) ("R" (set SELECT 3) ?R)
+ ("x" (set SELECT 4) ?x) ("X" (set SELECT 4) ?X)
+ ("j" (set SELECT 5) ?j) ("J" (set SELECT 5) ?J))
+
+ (consonant-or-tone-mark
+ ("z" ?z) ("s" ?s) ("f" ?f) ("r" ?r) ("x" ?x) ("j" ?j)
+ ("Z" ?Z) ("S" ?S) ("F" ?F) ("R" ?R) ("X" ?X) ("J" ?J))
+
+ (temporary-escape
+ ("aaa" "aa") ("AAA" "AA") ("Aaa" "Aa")
+ ("eee" "ee") ("EEE" "EE") ("Eee" "Ee")
+ ("ddd" "dd") ("DDD" "DD") ("Ddd" "Dd")
+ ("aww" "aw") ("AWW" "AW") ("Aww" "Aw")
+ ("uww" "uw") ("UWW" "UW") ("Uww" "Uw")
+ ("oww" "ow") ("OWW" "OW") ("Oww" "Ow")
+ ("ww" ?w) ("WW" ?W) ("Ww" ?W)
+ ("zz" ?z) ("ZZ" ?Z) ("Zz" ?Z)
+ ("ss" ?s) ("SS" ?S) ("Ss" ?S)
+ ("ff" ?f) ("FF" ?F) ("Ff" ?F)
+ ("rr" ?r) ("RR" ?R) ("Rr" ?R)
+ ("xx" ?x) ("XX" ?X) ("Xx" ?X)
+ ("jj" ?j) ("JJ" ?J) ("Jj" ?J)))
(state
(init
- ;; Initialize variables. V-LAST is a vowel typed lastly. In the
- ;; case of double vowel, V-PREV is the first one. V-LAST being 0
- ;; means that a vowel is not yet typed.
- (t (set C 0) (set V-LAST 0) (set V-PREV 0) (set SPECIAL 0))
-
- ;; Remeber the initial consonant in C.
- (consonant (set C @-))
-
- ;; Remember the preedit position after vowel in M.
- (vowel (mark M) (set V-LAST @-) (set SPECIAL-LAST SPECIAL) (shift after-v))
-
- (escape (shift escape))
-
- (backspace (undo)))
-
- ;; The state shifted to when the first vowel is typed.
+ ;; Initialize variables. C is the initial consonant. V-N is the
+ ;; (N-1)th vowel from the last. C-AFTER-V is a number of consonants
+ ;; typed after vowel. NST is 1 iff surrounding text is not supported.
+ (t (set C @-1) (set V-1 0) (set V-2 0) (set V-3 0) (set C-AFTER-V 0)
+ (set SELECT 0) (set NST (= @-0 -2)))
+
+ (consonant (set C @-1) (cond (NST (shift after-c))))
+ (consonant-ext (set C @-1) (cond (NST (shift after-c))))
+ (consonant-or-tone-mark
+ (cond ((| (= @-1 ?f) (= @-1 ?j) (= @-1 ?z) ; Invalid beginning consonants
+ (= @-1 ?F) (= @-1 ?J) (= @-1 ?Z)) (shift temporary-escape))
+ (1 (set C @-1) (cond (NST (shift after-c))))))
+
+ ;; Mark M remembers the preedit position after the last vowel.
+ (vowel (mark M) (set V-2 V-1) (set V-1 @-1) (shift after-v))
+ (vowel-ext (mark M) (set V-2 V-1) (set V-1 @-1) (shift after-v))
+ (temporary-escape (shift temporary-escape))
+ (permanent-escape (shift escape-in-normal-mode))
+ (smart-quotes))
+
+ ;; The state shifted to when an initial consonants is typed and
+ ;; surrounding text is not supported.
+ (after-c
+ (vowel (mark M) (set V-2 V-1) (set V-1 @-1) (shift after-v))
+ (vowel-ext (mark M) (set V-2 V-1) (set V-1 @-1) (shift after-v)))
+
+ ;; The state shifted to when a vowel is typed.
(after-v
- (t (set SPECIAL 0))
- (consonant (shift after-vc))
- (double (shift after-vc))
- (vowel (mark M) (set V-PREV V-LAST) (set V-LAST @-)
- (set SPECIAL-LAST SPECIAL) (shift after-vv))
- (diacritical)
- (backspace (undo 0)))
-
- ;; The state shifted to when the second vowel is typed.
- (after-vv
- (t (set SPECIAL 0))
- (consonant (shift after-vc))
- (double (shift after-vc))
- (diacritical)
- (backspace (delete @-) (set V-LAST V-PREV) (set V-PREV 0) (shift after-v)))
-
- ;; The state shifted to when one or two vowels and consonant are
- ;; typed.
+ (ending-1st-consonant (handle-mark) (shift after-vc)) ; toans/toasn->toán
+ (vowel (mark M) (set V-3 V-2) (set V-2 V-1) (set V-1 @-1)
+ (move T) (select 0) (handle-mark) (move M))
+ (vowel-ext (mark M) (set V-3 V-2) (set V-2 V-1) (set V-1 @-1)
+ (move T) (select 0) (handle-mark) (move M))
+ (ending-1st-notviet-consonant (shift temporary-escape)) ;; See ending-1st-notviet-consonant section in the vi-base.mim
+ (consonant-or-tone-mark (delete @-) (pushback 1) (shift after-t))
+ (backspace (delete @-)
+ (cond (V-3 (set V-1 V-2) (set V-2 V-3) (set V-3 0)
+ (cond ((> TPLACE 2) (set SELECT 0)))
+ (handle-mark))
+ (V-2 (set V-1 V-2) (set V-2 0)
+ (cond ((> TPLACE 1) (set SELECT 0)))
+ (handle-mark))
+ (1 (shift init)))))
+
+ ;; The state shifted to when a consonant is typed after a vowel.
(after-vc
- (t (set V-PREV-SAVE V-PREV) (set V-PREV 0) (set C-COUNT 1))
- (double)
- (consonant (add C-COUNT 1))
- (diacritical)
+ (t (set C-AFTER-V 1))
+ (ending-2nd-consonant
+ (cond ((| (= @-2 ?n) (= @-2 ?c) ; 1st ending consonant must be n/c
+ (= @-2 ?N) (= @-2 ?C)) (add C-AFTER-V 1))
+ (1 (shift temporary-escape))))
+ (ending-1st-notviet-consonant (shift temporary-escape)) ;; Expand notviet-consonant section in the vi-base.mim
+ (consonant-or-tone-mark (delete @-) (pushback 1) (shift after-t))
+ (vowel (shift temporary-escape)) ; There can only be one
+ (vowel-ext (shift temporary-escape)) ; main vowel in a word
(backspace (delete @-)
- (cond ((= C-COUNT 1)
- (set V-PREV V-PREV-SAVE)
- (cond ((> V-PREV 0) (shift after-vv))
- (1 (shift after-v)))))))
-
- (escape
- "ESC"
+ (sub C-AFTER-V 1)
+ (handle-mark)
+ (cond ((= C-AFTER-V 0) (shift after-v)))))
+
+ ;; The state shifted to when a tone-mark is typed.
+ (after-t
+ (t (set CURRENT-SELECT -1))
+ (tone-mark (cond ((= CURRENT-SELECT SELECT) (move T) (select 0) (move @>)
+ (shift temporary-escape))
+ (1 (delete @-) (handle-mark) (set CURRENT-SELECT SELECT))))
+ (nil (cond (C-AFTER-V (shift after-vc))
+ (1 (shift after-v)))))
+
+ (temporary-escape
+ "en"
+ (t (commit))
+ (alnum (commit)))
+
+ (escape-in-normal-mode
+ "EN"
+ (permanent-escape (insert "\\") (shift init))
+ ;; Any other key force shifting to permanent-escape.
+ (nil (shift permanent-escape)))
+
+ (permanent-escape
+ "EN"
+ (t (set ESCAPE 1))
+ (permanent-escape (shift escape-in-permanent-escape))
;; Unhandle any characters.
- (nil (shift init) (unhandle))))
+ (nil (unhandle)))
+
+ (escape-in-permanent-escape
+ "Ắ"
+ (permanent-escape (insert "\\") (commit) (shift permanent-escape))
+ ;; Any other key force shifting to init
+ ))
;; Local Variables:
;; coding: utf-8