Several rule deleted. Add BackSpace handling.
[m17n/m17n-contrib.git] / im / tai-sonla.mim
index 78db76d..0070d0d 100644 (file)
@@ -1,6 +1,9 @@
 ;; tai-sonla.mim -- Tai Viet input method with Phonetic sequence
 ;; Copyright (C) 2007
-;; Thua Thien Hue Center of Information Technology (HueCIT, Vietnam)
+;;   Thua Thien Hue Center of Information Technology (HueCIT, Vietnam)
+;; Copyright (C) 2007
+;;   National Institute of Advanced Industrial Science and Technology (AIST)
+;;   Registration Number H15PRO112
 
 ;; This file is part of the m17n contrib; a sub-part of the m17n
 ;; library.
 
 (title "꫞")
 
-(description "Tai Viet input method using the phonetic key sequence, accord with the Tai Son La keyboard.
+(description (_"Tai Viet input method using the phonetic key sequence using the Tai Son La keyboard layout.
 The phonetic key sequence means that you type a syllable in this order:
   C W? V v? F? T?
 where
   C is an initial consonant,
   W is a label to labializing C ('ꪫ'),
-  V is a vowel (prefix, postfix, or combining),
-  v is the second vowel of a digraph vowel (in that case V is 'ꪹ'),
+  V is a vowel (V1:prefix, V2:combining, or V3:postfix),
+  v is the second vowel of a digraph vowel
+        (in the case that V is 'ꪹ' and v is 'ꪸ', 'ꪷ', or 'ꪱ'),
   F is a final consonant,
-  T is a tonemark (spacing or combining).")
+  T is a tonemark (spacing or combining).
+
+You can type special symbols by these keys:
+  '$' -> 'ꫛ'
+  '#' -> 'ꫜ'
+  '%' -> 'ꫝ'
+  '!' -> '꫞'
+  '@' -> '꫟'
+"))
+
+(macro
+ (adjust-tone
+  (set TT @-1)
+  (delete @-)
+  (cond ((| (= T ?ꫀ) (= T ?ꫂ)) (delete @-) (move @>))
+       ((> T 0) (move M) (delete @-) (move @>)))
+  (set T TT)
+  (cond ((| (= T ?ꫀ) (= T ?ꫂ)) (insert T))
+       ((> T 0) (move M) (insert T) (mark M) (move @>)))))
 
 (map
  (consonant
@@ -100,12 +122,11 @@ where
   ("V" "ꪫ"))  
 
  (special
-  ("!" "ꫛ")
-  ("@" "ꫜ")
-  ("#" "ꫝ")
-  ("coon" "ꫛ")
-  ("mootj" "ꫜ")
-  ("sawmj" "ꫝ"))
+  ("$" "ꫛ")
+  ("#" "ꫜ")
+  ("%" "ꫝ")
+  ("!" "꫞")
+  ("@" "꫟"))
 
  (vowel-pre
   ("e" "ꪵ")
@@ -113,10 +134,7 @@ where
   ("E" "ꪹ")
   ("Y" "ꪻ")
   ("y" "ꪼ")
-  ("o^" "ꪶ")
-  ("wow" "ꪹ")                  ; that is "ươ"
-  ("auw" "ꪻ")                  ; that is "aư", note:"aw" is used for "ă"
-  ("ay" "ꪼ"))
+  ("o^" "ꪶ"))
 
  (vowel-combining
   ("}" "ꪰ")
@@ -124,38 +142,36 @@ where
   ("U" "ꪳ")
   ("u" "ꪴ")
   ("[" "ꪷ")
-  ("I" "ꪹ")
+  ("I" "ꪸ")
   ("{" "ꪾ")
-  ("ia" "ꪸ")
-  ("iee" "ꪸ")
-  ("ie^" "ꪸ")
-  ("aw" "ꪰ") ;; that is “ă”
-  ("uw" "ꪳ")
-  ("awm" "꪿"))
+  ("awm" "ꪾ"))
 
  (vowel-post
   ("a" "ꪱ")
   ;; ("A" "ꪱꪲ")
   ("<" "ꪺ")
   ("]" "ꪽ")
-  ("ua" "ꪻ")
-  ("uo^" "ꪻ")
-  ("uoo" "ꪻ")
-  ("awn" "ꪽ"))
+  ;; Note: "ꪮ" and "ꪯ" can be consonant and vowel. 
+  ("o" "ꪮ")
+  ("O" "ꪯ"))
 
  (vowel-digraph
   ("r" "ꪸ")
-  ("R" "ꪰ"))
+  ("R" "ꪷ")
+  ("A" "ꪱ"))
 
- (tone-spacing
+ (tone
   (":" "ꫀ")
-  (";" "ꫂ"))
-
- (tone-combining
+  (";" "ꫂ")
   ("\"" "꪿")
   ("'" "꫁"))
 
  (punctuation
+  ("!!" "!")
+  ("@@" "@")
+  ("##" "#")
+  ("$$" "$")
+  ("%%" "%")
   (",," ",")
   (".." ".")
   (";;" ";")
@@ -172,43 +188,52 @@ where
   ("{{" "{")
   ("}}" "}")
   ("<<" "<")
-  (">>" ">")))
+  (">>" ">"))
+
+ (backspace
+  ((BackSpace) (sub K 1) (undo K))))
 
 (state
  (init
-  (t (mark M) (set U 0))
+  (t (set K 0))
   (consonant (mark M) (shift after-c))
   (special)
   (punctuation)
   (vowel-pre)
   (vowel-post)
   (vowel-combining)
-  (tone-spacing)
-  (tone-combining))
+  (tone))
 
  (after-c
+  (t (mark M) (set V2 0) (set K @@))
   (high-v (mark M))
-  (vowel-pre (set V @-1)
+  (vowel-pre (set V1 @-1)
             (delete @-)
-            (move @<) (insert V) (move @>) (shift after-c-vpre))
-  (vowel-combining (set U @-1) (mark M) (shift after-c-v))
+            (move @<) (insert V1) (move @>) (shift after-c-vpre))
+  (vowel-combining (cond ((> V2 0) (move @-) (delete @-) (move @>))
+                        (1 (set K @@)))
+                  (set V2 @-1) (mark M))
   (vowel-post (shift after-c-v))
-  (vowel-digraph (set U @-1) (mark M) (move @-) (insert "ꪹ") (move @>)
-                (shift after-c-v)))
+  (vowel-digraph (mark M) (move @<) (insert "ꪹ") (move @>)
+                (shift after-c-v))
+  (final-c (delete @-) (pushback 1) (shift init))
+  (backspace)
+  (nil (shift after-c-v)))
   
  (after-c-vpre
-  (vowel-combining (set U @-1) (mark M) (shift after-c-v))
+  (t (set K @@))
+  (vowel-combining (set V2 @-1) (mark M) (shift after-c-v))
   (vowel-post (shift after-c-v))
+  (backspace)
   (nil (shift after-c-v)))
 
  (after-c-v
-  (tone-spacing (shift init))
-  (tone-combining (set T @-1) (delete @-) (move M) (insert T) (move @>)
-                 (shift init))
-  (final-c (cond ((> U 0) (move M) (delete @-) (move @>) insert U))
-          (shift after-c-v-f)))
+  (t (set T 0) (set K @@))
+  (tone (cond ((= T 0) (set K @@))) (adjust-tone))
+  (final-c (shift after-c-v-f))
+  (backspace))
 
  (after-c-v-f
-  (tone-spacing (shift init))
-  (tone-combining (set T @-1) (delete @-) (move M) (insert T) (move @>)
-                 (shift init))))
+  (t (set K @@))
+  (tone (adjust-tone))
+  (backspace)))