*** empty log message ***
authorhanda <handa>
Tue, 23 Feb 2010 15:59:50 +0000 (15:59 +0000)
committerhanda <handa>
Tue, 23 Feb 2010 15:59:50 +0000 (15:59 +0000)
el-kbd.mimx [new file with mode: 0644]
vi-base.mimx [new file with mode: 0644]
vi-tcvn.mimx [new file with mode: 0644]
vi-telex.mimx [new file with mode: 0644]
vi-viqr.mimx [new file with mode: 0644]
vi-vni.mimx [new file with mode: 0644]
xex.html
xex.js

diff --git a/el-kbd.mimx b/el-kbd.mimx
new file mode 100644 (file)
index 0000000..fd011a6
--- /dev/null
@@ -0,0 +1,647 @@
+<?xml version='1.0'?>
+<input-method xmlns="http://www.m17n.org/MIM">
+  <tags>
+    <language>el</language>
+    <name>kbd</name>
+  </tags>
+  <description>Greek input method simulating the Greek keyboard.
+    1!  2@  3#  4$  5%  6^  7&amp;  8*  9(  0)  -_  =+  `~ 
+      ;:  ςΣ  εΕ  ρΡ  τΤ  υΥ  θΘ  ιΙ  οΟ  πΠ  [{  ]} 
+       αΑ  σΣ  δΔ  φΦ  γΓ  ηΗ  ξΞ  κΚ  λΛ  ΄¨  '"  \| 
+         ζΖ  χΧ  ψΨ  ωΩ  βΒ  νΝ  μΜ  ,&lt;  .&gt;  /?
+</description>
+  <title>Ψ</title>
+  <map-list>
+    <map mname="map-map">
+      <rule>
+        <keyseq>
+          <string>q</string>
+        </keyseq>
+        <insert>
+          <integer>59</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>w</string>
+        </keyseq>
+        <insert>
+          <integer>962</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>e</string>
+        </keyseq>
+        <insert>
+          <integer>949</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>r</string>
+        </keyseq>
+        <insert>
+          <integer>961</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>t</string>
+        </keyseq>
+        <insert>
+          <integer>964</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>y</string>
+        </keyseq>
+        <insert>
+          <integer>965</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>u</string>
+        </keyseq>
+        <insert>
+          <integer>952</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>i</string>
+        </keyseq>
+        <insert>
+          <integer>953</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>o</string>
+        </keyseq>
+        <insert>
+          <integer>959</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>p</string>
+        </keyseq>
+        <insert>
+          <integer>960</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>[</string>
+        </keyseq>
+        <insert>
+          <integer>91</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>]</string>
+        </keyseq>
+        <insert>
+          <integer>93</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>a</string>
+        </keyseq>
+        <insert>
+          <integer>945</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>s</string>
+        </keyseq>
+        <insert>
+          <integer>963</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>d</string>
+        </keyseq>
+        <insert>
+          <integer>948</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>f</string>
+        </keyseq>
+        <insert>
+          <integer>966</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>g</string>
+        </keyseq>
+        <insert>
+          <integer>947</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>h</string>
+        </keyseq>
+        <insert>
+          <integer>951</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>j</string>
+        </keyseq>
+        <insert>
+          <integer>958</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>k</string>
+        </keyseq>
+        <insert>
+          <integer>954</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>l</string>
+        </keyseq>
+        <insert>
+          <integer>955</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>;</string>
+        </keyseq>
+        <insert>
+          <integer>900</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>z</string>
+        </keyseq>
+        <insert>
+          <integer>950</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>x</string>
+        </keyseq>
+        <insert>
+          <integer>967</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>c</string>
+        </keyseq>
+        <insert>
+          <integer>968</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>v</string>
+        </keyseq>
+        <insert>
+          <integer>969</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>b</string>
+        </keyseq>
+        <insert>
+          <integer>946</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>n</string>
+        </keyseq>
+        <insert>
+          <integer>957</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>m</string>
+        </keyseq>
+        <insert>
+          <integer>956</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Q</string>
+        </keyseq>
+        <insert>
+          <integer>58</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>W</string>
+        </keyseq>
+        <insert>
+          <integer>931</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>E</string>
+        </keyseq>
+        <insert>
+          <integer>917</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>R</string>
+        </keyseq>
+        <insert>
+          <integer>929</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>T</string>
+        </keyseq>
+        <insert>
+          <integer>932</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Y</string>
+        </keyseq>
+        <insert>
+          <integer>933</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>U</string>
+        </keyseq>
+        <insert>
+          <integer>920</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>I</string>
+        </keyseq>
+        <insert>
+          <integer>921</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>O</string>
+        </keyseq>
+        <insert>
+          <integer>927</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>P</string>
+        </keyseq>
+        <insert>
+          <integer>928</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>A</string>
+        </keyseq>
+        <insert>
+          <integer>913</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>S</string>
+        </keyseq>
+        <insert>
+          <integer>931</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>D</string>
+        </keyseq>
+        <insert>
+          <integer>916</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>F</string>
+        </keyseq>
+        <insert>
+          <integer>934</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>G</string>
+        </keyseq>
+        <insert>
+          <integer>915</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>H</string>
+        </keyseq>
+        <insert>
+          <integer>919</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>J</string>
+        </keyseq>
+        <insert>
+          <integer>926</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>K</string>
+        </keyseq>
+        <insert>
+          <integer>922</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>L</string>
+        </keyseq>
+        <insert>
+          <integer>923</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>:</string>
+        </keyseq>
+        <insert>
+          <integer>168</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Z</string>
+        </keyseq>
+        <insert>
+          <integer>918</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>X</string>
+        </keyseq>
+        <insert>
+          <integer>935</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>C</string>
+        </keyseq>
+        <insert>
+          <integer>936</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>V</string>
+        </keyseq>
+        <insert>
+          <integer>937</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>B</string>
+        </keyseq>
+        <insert>
+          <integer>914</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>N</string>
+        </keyseq>
+        <insert>
+          <integer>925</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>M</string>
+        </keyseq>
+        <insert>
+          <integer>924</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>;a</string>
+        </keyseq>
+        <insert>
+          <integer>940</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>;e</string>
+        </keyseq>
+        <insert>
+          <integer>941</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>;h</string>
+        </keyseq>
+        <insert>
+          <integer>942</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>;i</string>
+        </keyseq>
+        <insert>
+          <integer>943</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>;o</string>
+        </keyseq>
+        <insert>
+          <integer>972</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>;y</string>
+        </keyseq>
+        <insert>
+          <integer>973</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>;v</string>
+        </keyseq>
+        <insert>
+          <integer>974</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>;A</string>
+        </keyseq>
+        <insert>
+          <integer>902</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>;E</string>
+        </keyseq>
+        <insert>
+          <integer>904</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>;H</string>
+        </keyseq>
+        <insert>
+          <integer>905</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>;I</string>
+        </keyseq>
+        <insert>
+          <integer>906</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>;O</string>
+        </keyseq>
+        <insert>
+          <integer>908</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>;Y</string>
+        </keyseq>
+        <insert>
+          <integer>910</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>;V</string>
+        </keyseq>
+        <insert>
+          <integer>911</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>:i</string>
+        </keyseq>
+        <insert>
+          <integer>970</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>:y</string>
+        </keyseq>
+        <insert>
+          <integer>971</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>:I</string>
+        </keyseq>
+        <insert>
+          <integer>938</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>:Y</string>
+        </keyseq>
+        <insert>
+          <integer>939</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>;:i</string>
+        </keyseq>
+        <insert>
+          <integer>912</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>:;i</string>
+        </keyseq>
+        <insert>
+          <integer>912</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>;:y</string>
+        </keyseq>
+        <insert>
+          <integer>944</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>:;y</string>
+        </keyseq>
+        <insert>
+          <integer>944</integer>
+        </insert>
+      </rule>
+    </map>
+  </map-list>
+  <state-list>
+    <state sname="state-init">
+      <branch mname="map-map"/>
+    </state>
+  </state-list>
+</input-method>
\ No newline at end of file
diff --git a/vi-base.mimx b/vi-base.mimx
new file mode 100644 (file)
index 0000000..0ba8ec2
--- /dev/null
@@ -0,0 +1,1345 @@
+<?xml version='1.0'?>
+<input-method xmlns="http://www.m17n.org/MIM">
+  <tags>
+    <language>t</language>
+    <name>nil</name>
+    <extra-id>vi-base</extra-id>
+  </tags>
+  <description>Provide bases for Vietnamese input methods.
+This is acutually not a standalone input method, but is expected
+to be included in the other Vietnamese input method (e.g. vi-telex, vi-vni).
+</description>
+  <macro-list>
+    <defmacro fname="macro-handle-mark">
+      <move>
+        <marker>T</marker>
+      </move>
+      <select>
+        <integer>0</integer>
+      </select>
+      <move>
+        <marker>M</marker>
+      </move>
+      <cond>
+        <list>
+          <varref vname="V-3"/>
+          <cond>
+            <list>
+              <or>
+                <eq>
+                  <varref vname="V-1"/>
+                  <integer>234</integer>
+                </eq>
+                <eq>
+                  <varref vname="V-1"/>
+                  <integer>417</integer>
+                </eq>
+                <eq>
+                  <varref vname="V-1"/>
+                  <integer>202</integer>
+                </eq>
+                <eq>
+                  <varref vname="V-1"/>
+                  <integer>416</integer>
+                </eq>
+              </or>
+              <set vname="TPLACE">
+                <integer>3</integer>
+              </set>
+            </list>
+            <list>
+              <integer>1</integer>
+              <move>
+                <marker>@-</marker>
+              </move>
+              <set vname="TPLACE">
+                <integer>2</integer>
+              </set>
+            </list>
+          </cond>
+        </list>
+        <list>
+          <varref vname="V-2"/>
+          <cond>
+            <list>
+              <or>
+                <gt>
+                  <varref vname="V-1"/>
+                  <integer>127</integer>
+                </gt>
+                <and>
+                  <or>
+                    <eq>
+                      <varref vname="C"/>
+                      <integer>103</integer>
+                    </eq>
+                    <eq>
+                      <varref vname="C"/>
+                      <integer>71</integer>
+                    </eq>
+                  </or>
+                  <or>
+                    <eq>
+                      <varref vname="V-2"/>
+                      <integer>105</integer>
+                    </eq>
+                    <eq>
+                      <varref vname="V-2"/>
+                      <integer>73</integer>
+                    </eq>
+                  </or>
+                </and>
+                <and>
+                  <or>
+                    <eq>
+                      <varref vname="C"/>
+                      <integer>113</integer>
+                    </eq>
+                    <eq>
+                      <varref vname="C"/>
+                      <integer>81</integer>
+                    </eq>
+                  </or>
+                  <or>
+                    <eq>
+                      <varref vname="V-2"/>
+                      <integer>117</integer>
+                    </eq>
+                    <eq>
+                      <varref vname="V-2"/>
+                      <integer>85</integer>
+                    </eq>
+                  </or>
+                </and>
+                <and>
+                  <or>
+                    <varref vname="tone-mark-on-last"/>
+                    <gt>
+                      <varref vname="C-AFTER-V"/>
+                      <integer>0</integer>
+                    </gt>
+                  </or>
+                  <or>
+                    <and>
+                      <or>
+                        <eq>
+                          <varref vname="V-2"/>
+                          <integer>111</integer>
+                        </eq>
+                        <eq>
+                          <varref vname="V-2"/>
+                          <integer>79</integer>
+                        </eq>
+                      </or>
+                      <or>
+                        <eq>
+                          <varref vname="V-1"/>
+                          <integer>97</integer>
+                        </eq>
+                        <eq>
+                          <varref vname="V-1"/>
+                          <integer>65</integer>
+                        </eq>
+                        <eq>
+                          <varref vname="V-1"/>
+                          <integer>101</integer>
+                        </eq>
+                        <eq>
+                          <varref vname="V-1"/>
+                          <integer>69</integer>
+                        </eq>
+                        <eq>
+                          <varref vname="V-1"/>
+                          <integer>111</integer>
+                        </eq>
+                        <eq>
+                          <varref vname="V-1"/>
+                          <integer>79</integer>
+                        </eq>
+                      </or>
+                    </and>
+                    <and>
+                      <or>
+                        <eq>
+                          <varref vname="V-2"/>
+                          <integer>117</integer>
+                        </eq>
+                        <eq>
+                          <varref vname="V-2"/>
+                          <integer>85</integer>
+                        </eq>
+                      </or>
+                      <or>
+                        <eq>
+                          <varref vname="V-1"/>
+                          <integer>121</integer>
+                        </eq>
+                        <eq>
+                          <varref vname="V-1"/>
+                          <integer>89</integer>
+                        </eq>
+                      </or>
+                    </and>
+                  </or>
+                </and>
+              </or>
+              <set vname="TPLACE">
+                <integer>2</integer>
+              </set>
+            </list>
+            <list>
+              <integer>1</integer>
+              <move>
+                <marker>@-</marker>
+              </move>
+              <set vname="TPLACE">
+                <integer>1</integer>
+              </set>
+            </list>
+          </cond>
+        </list>
+        <list>
+          <integer>1</integer>
+          <set vname="TPLACE">
+            <integer>1</integer>
+          </set>
+        </list>
+      </cond>
+      <select>
+        <varref vname="SELECT"/>
+      </select>
+      <mark>
+        <marker>T</marker>
+      </mark>
+      <move>
+        <marker>@&gt;</marker>
+      </move>
+    </defmacro>
+  </macro-list>
+  <map-list>
+    <map mname="map-vowel">
+      <rule>
+        <keyseq>
+          <string>a</string>
+        </keyseq>
+        <insert-candidates>
+          <string>aáàảãạ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>A</string>
+        </keyseq>
+        <insert-candidates>
+          <string>AÁÀẢÃẠ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>e</string>
+        </keyseq>
+        <insert-candidates>
+          <string>eéèẻẽẹ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>E</string>
+        </keyseq>
+        <insert-candidates>
+          <string>EÉÈẺẼẸ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>i</string>
+        </keyseq>
+        <insert-candidates>
+          <string>iíìỉĩị</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>I</string>
+        </keyseq>
+        <insert-candidates>
+          <string>IÍÌỈĨỊ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>o</string>
+        </keyseq>
+        <insert-candidates>
+          <string>oóòỏõọ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>O</string>
+        </keyseq>
+        <insert-candidates>
+          <string>OÓÒỎÕỌ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>u</string>
+        </keyseq>
+        <insert-candidates>
+          <string>uúùủũụ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>U</string>
+        </keyseq>
+        <insert-candidates>
+          <string>UÚÙỦŨỤ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>y</string>
+        </keyseq>
+        <insert-candidates>
+          <string>yýỳỷỹỵ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Y</string>
+        </keyseq>
+        <insert-candidates>
+          <string>YÝỲỶỸỴ</string>
+        </insert-candidates>
+      </rule>
+    </map>
+    <map mname="map-consonant">
+      <rule>
+        <keyseq>
+          <string>b</string>
+        </keyseq>
+        <insert>
+          <integer>98</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>c</string>
+        </keyseq>
+        <insert>
+          <integer>99</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>d</string>
+        </keyseq>
+        <insert>
+          <integer>100</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>g</string>
+        </keyseq>
+        <insert>
+          <integer>103</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>h</string>
+        </keyseq>
+        <insert>
+          <integer>104</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>k</string>
+        </keyseq>
+        <insert>
+          <integer>107</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>l</string>
+        </keyseq>
+        <insert>
+          <integer>108</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>m</string>
+        </keyseq>
+        <insert>
+          <integer>109</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>n</string>
+        </keyseq>
+        <insert>
+          <integer>110</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>p</string>
+        </keyseq>
+        <insert>
+          <integer>112</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>q</string>
+        </keyseq>
+        <insert>
+          <integer>113</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>t</string>
+        </keyseq>
+        <insert>
+          <integer>116</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>v</string>
+        </keyseq>
+        <insert>
+          <integer>118</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>B</string>
+        </keyseq>
+        <insert>
+          <integer>66</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>C</string>
+        </keyseq>
+        <insert>
+          <integer>67</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>D</string>
+        </keyseq>
+        <insert>
+          <integer>68</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>G</string>
+        </keyseq>
+        <insert>
+          <integer>71</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>H</string>
+        </keyseq>
+        <insert>
+          <integer>72</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>K</string>
+        </keyseq>
+        <insert>
+          <integer>75</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>L</string>
+        </keyseq>
+        <insert>
+          <integer>76</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>M</string>
+        </keyseq>
+        <insert>
+          <integer>77</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>N</string>
+        </keyseq>
+        <insert>
+          <integer>78</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>P</string>
+        </keyseq>
+        <insert>
+          <integer>80</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Q</string>
+        </keyseq>
+        <insert>
+          <integer>81</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>T</string>
+        </keyseq>
+        <insert>
+          <integer>84</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>V</string>
+        </keyseq>
+        <insert>
+          <integer>86</integer>
+        </insert>
+      </rule>
+    </map>
+    <map mname="map-ending-1st-notviet-consonant">
+      <rule>
+        <keyseq>
+          <string>q</string>
+        </keyseq>
+        <insert>
+          <integer>113</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Q</string>
+        </keyseq>
+        <insert>
+          <integer>81</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>d</string>
+        </keyseq>
+        <insert>
+          <integer>100</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>D</string>
+        </keyseq>
+        <insert>
+          <integer>68</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>g</string>
+        </keyseq>
+        <insert>
+          <integer>103</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>G</string>
+        </keyseq>
+        <insert>
+          <integer>71</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>h</string>
+        </keyseq>
+        <insert>
+          <integer>104</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>H</string>
+        </keyseq>
+        <insert>
+          <integer>72</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>k</string>
+        </keyseq>
+        <insert>
+          <integer>107</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>K</string>
+        </keyseq>
+        <insert>
+          <integer>75</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>l</string>
+        </keyseq>
+        <insert>
+          <integer>108</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>L</string>
+        </keyseq>
+        <insert>
+          <integer>76</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>v</string>
+        </keyseq>
+        <insert>
+          <integer>118</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>V</string>
+        </keyseq>
+        <insert>
+          <integer>86</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>b</string>
+        </keyseq>
+        <insert>
+          <integer>98</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>B</string>
+        </keyseq>
+        <insert>
+          <integer>66</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>z</string>
+        </keyseq>
+        <insert>
+          <integer>122</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Z</string>
+        </keyseq>
+        <insert>
+          <integer>90</integer>
+        </insert>
+      </rule>
+    </map>
+    <map mname="map-ending-1st-consonant">
+      <rule>
+        <keyseq>
+          <string>c</string>
+        </keyseq>
+        <insert>
+          <integer>99</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>m</string>
+        </keyseq>
+        <insert>
+          <integer>109</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>n</string>
+        </keyseq>
+        <insert>
+          <integer>110</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>p</string>
+        </keyseq>
+        <insert>
+          <integer>112</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>t</string>
+        </keyseq>
+        <insert>
+          <integer>116</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>C</string>
+        </keyseq>
+        <insert>
+          <integer>67</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>M</string>
+        </keyseq>
+        <insert>
+          <integer>77</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>N</string>
+        </keyseq>
+        <insert>
+          <integer>78</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>P</string>
+        </keyseq>
+        <insert>
+          <integer>80</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>T</string>
+        </keyseq>
+        <insert>
+          <integer>84</integer>
+        </insert>
+      </rule>
+    </map>
+    <map mname="map-ending-2nd-consonant">
+      <rule>
+        <keyseq>
+          <string>g</string>
+        </keyseq>
+        <insert>
+          <integer>103</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>h</string>
+        </keyseq>
+        <insert>
+          <integer>104</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>G</string>
+        </keyseq>
+        <insert>
+          <integer>71</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>H</string>
+        </keyseq>
+        <insert>
+          <integer>72</integer>
+        </insert>
+      </rule>
+    </map>
+    <map mname="map-alnum">
+      <rule>
+        <keyseq>
+          <string>a</string>
+        </keyseq>
+        <insert>
+          <integer>97</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>b</string>
+        </keyseq>
+        <insert>
+          <integer>98</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>c</string>
+        </keyseq>
+        <insert>
+          <integer>99</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>d</string>
+        </keyseq>
+        <insert>
+          <integer>100</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>e</string>
+        </keyseq>
+        <insert>
+          <integer>101</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>f</string>
+        </keyseq>
+        <insert>
+          <integer>102</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>g</string>
+        </keyseq>
+        <insert>
+          <integer>103</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>h</string>
+        </keyseq>
+        <insert>
+          <integer>104</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>i</string>
+        </keyseq>
+        <insert>
+          <integer>105</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>j</string>
+        </keyseq>
+        <insert>
+          <integer>106</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>k</string>
+        </keyseq>
+        <insert>
+          <integer>107</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>l</string>
+        </keyseq>
+        <insert>
+          <integer>108</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>m</string>
+        </keyseq>
+        <insert>
+          <integer>109</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>n</string>
+        </keyseq>
+        <insert>
+          <integer>110</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>o</string>
+        </keyseq>
+        <insert>
+          <integer>111</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>p</string>
+        </keyseq>
+        <insert>
+          <integer>112</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>q</string>
+        </keyseq>
+        <insert>
+          <integer>113</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>r</string>
+        </keyseq>
+        <insert>
+          <integer>114</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>s</string>
+        </keyseq>
+        <insert>
+          <integer>115</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>t</string>
+        </keyseq>
+        <insert>
+          <integer>116</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>u</string>
+        </keyseq>
+        <insert>
+          <integer>117</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>v</string>
+        </keyseq>
+        <insert>
+          <integer>118</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>w</string>
+        </keyseq>
+        <insert>
+          <integer>119</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>x</string>
+        </keyseq>
+        <insert>
+          <integer>120</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>y</string>
+        </keyseq>
+        <insert>
+          <integer>121</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>z</string>
+        </keyseq>
+        <insert>
+          <integer>122</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>A</string>
+        </keyseq>
+        <insert>
+          <integer>65</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>B</string>
+        </keyseq>
+        <insert>
+          <integer>66</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>C</string>
+        </keyseq>
+        <insert>
+          <integer>67</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>D</string>
+        </keyseq>
+        <insert>
+          <integer>68</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>E</string>
+        </keyseq>
+        <insert>
+          <integer>69</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>F</string>
+        </keyseq>
+        <insert>
+          <integer>70</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>G</string>
+        </keyseq>
+        <insert>
+          <integer>71</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>H</string>
+        </keyseq>
+        <insert>
+          <integer>72</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>I</string>
+        </keyseq>
+        <insert>
+          <integer>73</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>J</string>
+        </keyseq>
+        <insert>
+          <integer>74</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>K</string>
+        </keyseq>
+        <insert>
+          <integer>75</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>L</string>
+        </keyseq>
+        <insert>
+          <integer>76</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>M</string>
+        </keyseq>
+        <insert>
+          <integer>77</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>N</string>
+        </keyseq>
+        <insert>
+          <integer>78</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>O</string>
+        </keyseq>
+        <insert>
+          <integer>79</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>P</string>
+        </keyseq>
+        <insert>
+          <integer>80</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Q</string>
+        </keyseq>
+        <insert>
+          <integer>81</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>R</string>
+        </keyseq>
+        <insert>
+          <integer>82</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>S</string>
+        </keyseq>
+        <insert>
+          <integer>83</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>T</string>
+        </keyseq>
+        <insert>
+          <integer>84</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>U</string>
+        </keyseq>
+        <insert>
+          <integer>85</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>V</string>
+        </keyseq>
+        <insert>
+          <integer>86</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>W</string>
+        </keyseq>
+        <insert>
+          <integer>87</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>X</string>
+        </keyseq>
+        <insert>
+          <integer>88</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Y</string>
+        </keyseq>
+        <insert>
+          <integer>89</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Z</string>
+        </keyseq>
+        <insert>
+          <integer>90</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>0</string>
+        </keyseq>
+        <insert>
+          <integer>48</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>1</string>
+        </keyseq>
+        <insert>
+          <integer>49</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>2</string>
+        </keyseq>
+        <insert>
+          <integer>50</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>3</string>
+        </keyseq>
+        <insert>
+          <integer>51</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>4</string>
+        </keyseq>
+        <insert>
+          <integer>52</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>5</string>
+        </keyseq>
+        <insert>
+          <integer>53</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>6</string>
+        </keyseq>
+        <insert>
+          <integer>54</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>7</string>
+        </keyseq>
+        <insert>
+          <integer>55</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>8</string>
+        </keyseq>
+        <insert>
+          <integer>56</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>9</string>
+        </keyseq>
+        <insert>
+          <integer>57</integer>
+        </insert>
+      </rule>
+    </map>
+    <map mname="map-smart-quotes">
+      <rule>
+        <keyseq>
+          <string>'</string>
+        </keyseq>
+        <insert>
+          <integer>39</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>''</string>
+        </keyseq>
+        <insert>
+          <string>‘’</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>"</string>
+        </keyseq>
+        <insert>
+          <integer>34</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>""</string>
+        </keyseq>
+        <insert>
+          <string>“”</string>
+        </insert>
+      </rule>
+    </map>
+    <map mname="map-permanent-escape">
+      <rule>
+        <keyseq>
+          <string>\</string>
+        </keyseq>
+      </rule>
+    </map>
+    <map mname="map-backspace">
+      <rule>
+        <keyseq>
+          <list>
+            <symbol>BackSpace</symbol>
+          </list>
+        </keyseq>
+        <cond>
+          <list>
+            <varref vname="backspace-is-undo"/>
+            <undo/>
+          </list>
+        </cond>
+      </rule>
+    </map>
+  </map-list>
+</input-method>
\ No newline at end of file
diff --git a/vi-tcvn.mimx b/vi-tcvn.mimx
new file mode 100644 (file)
index 0000000..69026ff
--- /dev/null
@@ -0,0 +1,1039 @@
+<?xml version='1.0'?>
+<input-method xmlns="http://www.m17n.org/MIM">
+  <tags>
+    <language>vi</language>
+    <name>tcvn</name>
+  </tags>
+  <description>
+    <gettext>Vietnames input method using the TCVN6064 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)</gettext>
+  </description>
+  <title>Ắ(TCVN)</title>
+  <variable-list>
+    <defvar vname="tone-mark-on-last">
+      <description>
+        <gettext>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.</gettext>
+      </description>
+      <integer>0</integer>
+      <possible-value>
+        <integer>0</integer>
+        <integer>1</integer>
+      </possible-value>
+    </defvar>
+    <defvar vname="backspace-is-undo">
+      <description>
+        <gettext>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" =&gt; "quá").
+If the value is 1, Backspace key undoes the previous key
+(e.g. "q u a i s BS" =&gt; "quai").</gettext>
+      </description>
+      <integer>0</integer>
+      <possible-value>
+        <integer>0</integer>
+        <integer>1</integer>
+      </possible-value>
+    </defvar>
+  </variable-list>
+  <macro-list>
+    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="xml" href="vi-base.mimx" xpointer="xmlns(mim=http://www.m17n.org/MIM)xpointer(//mim:defmacro)">
+      <tags>
+        <language>t</language>
+        <name>nil</name>
+        <extra-id>vi-base</extra-id>
+      </tags>
+      <section>macro</section>
+    </xi:include>
+  </macro-list>
+  <map-list>
+    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="xml" href="vi-base.mimx" xpointer="xmlns(mim=http://www.m17n.org/MIM)xpointer(//mim:map)">
+      <tags>
+        <language>t</language>
+        <name>nil</name>
+        <extra-id>vi-base</extra-id>
+      </tags>
+      <section>map</section>
+    </xi:include>
+    <map mname="map-vowel-ext">
+      <rule>
+        <keyseq>
+          <string>2</string>
+        </keyseq>
+        <insert-candidates>
+          <string>âấầẩẫậ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>@</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ÂẤẦẨẪẬ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>1</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ăắằẳẵặ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>!</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ĂẮẰẲẴẶ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>3</string>
+        </keyseq>
+        <insert-candidates>
+          <string>êếềểễệ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>#</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ÊẾỀỂỄỆ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>4</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ôốồổỗộ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>$</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ÔỐỒỔỖỘ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>]</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ơớờởỡợ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>}</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ƠỚỜỞỠỢ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>[</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ưứừửữự</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>{</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ƯỨỪỬỮỰ</string>
+        </insert-candidates>
+      </rule>
+    </map>
+    <map mname="map-consonant-ext">
+      <rule>
+        <keyseq>
+          <string>0</string>
+        </keyseq>
+        <insert>
+          <integer>273</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>)</string>
+        </keyseq>
+        <insert>
+          <integer>272</integer>
+        </insert>
+      </rule>
+    </map>
+    <map mname="map-tone-mark">
+      <rule>
+        <keyseq>
+          <string>8</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>1</integer>
+        </set>
+        <insert>
+          <integer>49</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>5</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>2</integer>
+        </set>
+        <insert>
+          <integer>50</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>6</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>3</integer>
+        </set>
+        <insert>
+          <integer>51</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>7</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>4</integer>
+        </set>
+        <insert>
+          <integer>52</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>9</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>5</integer>
+        </set>
+        <insert>
+          <integer>53</integer>
+        </insert>
+      </rule>
+    </map>
+    <map mname="map-misc">
+      <rule>
+        <keyseq>
+          <string>=</string>
+        </keyseq>
+        <insert>
+          <integer>8363</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>==</string>
+        </keyseq>
+        <insert>
+          <integer>61</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <symbol>A-1</symbol>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>49</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <symbol>A-2</symbol>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>50</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <symbol>A-3</symbol>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>51</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <symbol>A-4</symbol>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>52</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <symbol>A-5</symbol>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>53</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <symbol>A-6</symbol>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>54</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <symbol>A-7</symbol>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>55</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <symbol>A-8</symbol>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>56</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <symbol>A-9</symbol>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>57</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <symbol>A-0</symbol>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>48</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <symbol>A--</symbol>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>45</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <string>A-=</string>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>61</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <string>A-\</string>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>92</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <string>A-[</string>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>91</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <string>A-]</string>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>93</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <string>A-!</string>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>33</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <string>A-@</string>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>64</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <string>A-#</string>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>35</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <string>A-$</string>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>36</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <string>A-%</string>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>37</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <string>A-^</string>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>94</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <string>A-&amp;</string>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>38</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <string>A-*</string>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>42</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <string>A-(</string>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>40</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <string>A-)</string>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>41</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <symbol>A-_</symbol>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>95</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <string>A-+</string>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>43</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <string>A-|</string>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>124</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <string>A-{</string>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>123</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <list>
+            <string>A-}</string>
+          </list>
+        </keyseq>
+        <insert>
+          <integer>125</integer>
+        </insert>
+      </rule>
+    </map>
+    <map mname="map-temporary-escape">
+      <rule>
+        <keyseq>
+          <string>22</string>
+        </keyseq>
+        <insert>
+          <string>2</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>@@</string>
+        </keyseq>
+        <insert>
+          <string>@</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>11</string>
+        </keyseq>
+        <insert>
+          <string>1</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>!!</string>
+        </keyseq>
+        <insert>
+          <string>!</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>33</string>
+        </keyseq>
+        <insert>
+          <string>3</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>##</string>
+        </keyseq>
+        <insert>
+          <string>##</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>44</string>
+        </keyseq>
+        <insert>
+          <string>4</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>$$</string>
+        </keyseq>
+        <insert>
+          <string>$</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>]]</string>
+        </keyseq>
+        <insert>
+          <string>]</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>}}</string>
+        </keyseq>
+        <insert>
+          <string>}</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>[[</string>
+        </keyseq>
+        <insert>
+          <string>[</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>{{</string>
+        </keyseq>
+        <insert>
+          <string>{</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>00</string>
+        </keyseq>
+        <insert>
+          <string>0</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>))</string>
+        </keyseq>
+        <insert>
+          <string>)</string>
+        </insert>
+      </rule>
+    </map>
+  </map-list>
+  <state-list>
+    <state sname="state-init">
+      <state-hook>
+        <set vname="C">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <set vname="V-1">
+          <integer>0</integer>
+        </set>
+        <set vname="V-2">
+          <integer>0</integer>
+        </set>
+        <set vname="V-3">
+          <integer>0</integer>
+        </set>
+        <set vname="C-AFTER-V">
+          <integer>0</integer>
+        </set>
+        <set vname="SELECT">
+          <integer>0</integer>
+        </set>
+      </state-hook>
+      <branch mname="map-consonant">
+        <set vname="C">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+      </branch>
+      <branch mname="map-consonant-ext">
+        <set vname="C">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+      </branch>
+      <branch mname="map-vowel">
+        <mark>
+          <marker>M</marker>
+        </mark>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <shift>
+          <symbol>state-after-v</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-vowel-ext">
+        <mark>
+          <marker>M</marker>
+        </mark>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <shift>
+          <symbol>state-after-v</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-temporary-escape">
+        <shift>
+          <symbol>state-temporary-escape</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-permanent-escape">
+        <shift>
+          <symbol>state-escape-in-normal-mode</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-misc"/>
+      <branch mname="map-smart-quotes"/>
+    </state>
+    <state sname="state-after-v">
+      <branch mname="map-consonant">
+        <shift>
+          <symbol>state-after-vc</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-consonant-ext">
+        <shift>
+          <symbol>state-after-vc</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-vowel">
+        <mark>
+          <marker>M</marker>
+        </mark>
+        <set vname="V-3">
+          <varref vname="V-2"/>
+        </set>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <move>
+          <marker>T</marker>
+        </move>
+        <select>
+          <integer>0</integer>
+        </select>
+        <funcall fname="macro-handle-mark"/>
+        <move>
+          <marker>M</marker>
+        </move>
+      </branch>
+      <branch mname="map-vowel-ext">
+        <mark>
+          <marker>M</marker>
+        </mark>
+        <set vname="V-3">
+          <varref vname="V-2"/>
+        </set>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <move>
+          <marker>T</marker>
+        </move>
+        <select>
+          <integer>0</integer>
+        </select>
+        <funcall fname="macro-handle-mark"/>
+        <move>
+          <marker>M</marker>
+        </move>
+      </branch>
+      <branch mname="map-tone-mark">
+        <delete>
+          <marker>@-</marker>
+        </delete>
+        <pushback>
+          <integer>1</integer>
+        </pushback>
+        <shift>
+          <symbol>state-after-t</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-backspace">
+        <delete>
+          <marker>@-</marker>
+        </delete>
+        <cond>
+          <list>
+            <varref vname="V-3"/>
+            <set vname="V-1">
+              <varref vname="V-2"/>
+            </set>
+            <set vname="V-2">
+              <varref vname="V-3"/>
+            </set>
+            <set vname="V-3">
+              <integer>0</integer>
+            </set>
+            <cond>
+              <list>
+                <gt>
+                  <varref vname="TPLACE"/>
+                  <integer>2</integer>
+                </gt>
+                <set vname="SELECT">
+                  <integer>0</integer>
+                </set>
+              </list>
+            </cond>
+          </list>
+          <list>
+            <varref vname="V-2"/>
+            <set vname="V-1">
+              <varref vname="V-2"/>
+            </set>
+            <set vname="V-2">
+              <integer>0</integer>
+            </set>
+            <cond>
+              <list>
+                <gt>
+                  <varref vname="TPLACE"/>
+                  <integer>1</integer>
+                </gt>
+                <set vname="SELECT">
+                  <integer>0</integer>
+                </set>
+              </list>
+            </cond>
+          </list>
+          <list>
+            <integer>1</integer>
+            <shift>
+              <symbol>state-init</symbol>
+            </shift>
+          </list>
+        </cond>
+      </branch>
+    </state>
+    <state sname="state-after-vc">
+      <state-hook>
+        <set vname="C-AFTER-V">
+          <integer>1</integer>
+        </set>
+      </state-hook>
+      <branch mname="map-consonant">
+        <add vname="C-AFTER-V">
+          <integer>1</integer>
+        </add>
+      </branch>
+      <branch mname="map-consonant-ext">
+        <add vname="C-AFTER-V">
+          <integer>1</integer>
+        </add>
+      </branch>
+      <branch mname="map-tone-mark">
+        <delete>
+          <marker>@-</marker>
+        </delete>
+        <pushback>
+          <integer>1</integer>
+        </pushback>
+        <shift>
+          <symbol>state-after-t</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-backspace">
+        <delete>
+          <marker>@-</marker>
+        </delete>
+        <sub vname="C-AFTER-V">
+          <integer>1</integer>
+        </sub>
+        <cond>
+          <list>
+            <eq>
+              <varref vname="C-AFTER-V"/>
+              <integer>0</integer>
+            </eq>
+            <shift>
+              <symbol>state-after-v</symbol>
+            </shift>
+          </list>
+        </cond>
+      </branch>
+    </state>
+    <state sname="state-after-t">
+      <state-hook>
+        <set vname="CURRENT-SELECT">
+          <integer>-1</integer>
+        </set>
+      </state-hook>
+      <branch mname="map-tone-mark">
+        <cond>
+          <list>
+            <eq>
+              <varref vname="CURRENT-SELECT"/>
+              <varref vname="SELECT"/>
+            </eq>
+            <move>
+              <marker>T</marker>
+            </move>
+            <select>
+              <integer>0</integer>
+            </select>
+            <move>
+              <marker>@&gt;</marker>
+            </move>
+            <shift>
+              <symbol>state-temporary-escape</symbol>
+            </shift>
+          </list>
+          <list>
+            <integer>1</integer>
+            <delete>
+              <marker>@-</marker>
+            </delete>
+            <funcall fname="macro-handle-mark"/>
+            <set vname="CURRENT-SELECT">
+              <varref vname="SELECT"/>
+            </set>
+          </list>
+        </cond>
+      </branch>
+      <catch-all-branch>
+        <cond>
+          <list>
+            <varref vname="C-AFTER-V"/>
+            <shift>
+              <symbol>state-after-vc</symbol>
+            </shift>
+          </list>
+          <list>
+            <integer>1</integer>
+            <shift>
+              <symbol>state-after-v</symbol>
+            </shift>
+          </list>
+        </cond>
+      </catch-all-branch>
+    </state>
+    <state sname="state-temporary-escape">
+      <title>en</title>
+      <state-hook>
+        <commit/>
+      </state-hook>
+      <branch mname="map-alnum">
+        <commit/>
+      </branch>
+    </state>
+    <state sname="state-escape-in-normal-mode">
+      <title>EN</title>
+      <branch mname="map-permanent-escape">
+        <insert>
+          <string>\</string>
+        </insert>
+        <shift>
+          <symbol>state-init</symbol>
+        </shift>
+      </branch>
+      <catch-all-branch>
+        <shift>
+          <symbol>state-permanent-escape</symbol>
+        </shift>
+      </catch-all-branch>
+    </state>
+    <state sname="state-permanent-escape">
+      <title>EN</title>
+      <state-hook>
+        <set vname="ESCAPE">
+          <integer>1</integer>
+        </set>
+      </state-hook>
+      <branch mname="map-permanent-escape">
+        <shift>
+          <symbol>state-escape-in-permanent-escape</symbol>
+        </shift>
+      </branch>
+      <catch-all-branch>
+        <unhandle/>
+      </catch-all-branch>
+    </state>
+    <state sname="state-escape-in-permanent-escape">
+      <title>Ắ</title>
+      <branch mname="map-permanent-escape">
+        <insert>
+          <string>\</string>
+        </insert>
+        <commit/>
+        <shift>
+          <symbol>state-permanent-escape</symbol>
+        </shift>
+      </branch>
+    </state>
+  </state-list>
+</input-method>
\ No newline at end of file
diff --git a/vi-telex.mimx b/vi-telex.mimx
new file mode 100644 (file)
index 0000000..1953ce1
--- /dev/null
@@ -0,0 +1,1351 @@
+<?xml version='1.0'?>
+<input-method xmlns="http://www.m17n.org/MIM">
+  <tags>
+    <language>vi</language>
+    <name>telex</name>
+  </tags>
+  <description>
+    <gettext>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)</gettext>
+  </description>
+  <title>Ắ(TLX)</title>
+  <variable-list>
+    <defvar vname="tone-mark-on-last">
+      <description>
+        <gettext>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.</gettext>
+      </description>
+      <integer>0</integer>
+      <possible-value>
+        <integer>0</integer>
+        <integer>1</integer>
+      </possible-value>
+    </defvar>
+    <defvar vname="backspace-is-undo">
+      <description>
+        <gettext>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" =&gt; "quá").
+If the value is 1, Backspace key undoes the previous key
+(e.g. "q u a i s BS" =&gt; "quai").</gettext>
+      </description>
+      <integer>0</integer>
+      <possible-value>
+        <integer>0</integer>
+        <integer>1</integer>
+      </possible-value>
+    </defvar>
+  </variable-list>
+  <macro-list>
+    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="xml" href="vi-base.mimx" xpointer="xmlns(mim=http://www.m17n.org/MIM)xpointer(//mim:defmacro)">
+      <tags>
+        <language>t</language>
+        <name>nil</name>
+        <extra-id>vi-base</extra-id>
+      </tags>
+      <section>macro</section>
+    </xi:include>
+  </macro-list>
+  <map-list>
+    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="xml" href="vi-base.mimx" xpointer="xmlns(mim=http://www.m17n.org/MIM)xpointer(//mim:map)">
+      <tags>
+        <language>t</language>
+        <name>nil</name>
+        <extra-id>vi-base</extra-id>
+      </tags>
+      <section>map</section>
+    </xi:include>
+    <map mname="map-vowel-ext">
+      <rule>
+        <keyseq>
+          <string>aa</string>
+        </keyseq>
+        <insert-candidates>
+          <string>âấầẩẫậ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>AA</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ÂẤẦẨẪẬ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Aa</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ÂẤẦẨẪẬ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>aw</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ăắằẳẵặ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>AW</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ĂẮẰẲẴẶ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Aw</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ĂẮẰẲẴẶ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>ee</string>
+        </keyseq>
+        <insert-candidates>
+          <string>êếềểễệ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>EE</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ÊẾỀỂỄỆ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Ee</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ÊẾỀỂỄỆ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>oo</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ôốồổỗộ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>OO</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ÔỐỒỔỖỘ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Oo</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ÔỐỒỔỖỘ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>ow</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ơớờởỡợ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>OW</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ƠỚỜỞỠỢ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Ow</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ƠỚỜỞỠỢ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>uw</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ưứừửữự</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>UW</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ƯỨỪỬỮỰ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Uw</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ƯỨỪỬỮỰ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>w</string>
+        </keyseq>
+        <cond>
+          <list>
+            <eq>
+              <varref vname="V-1"/>
+              <integer>0</integer>
+            </eq>
+            <insert-candidates>
+              <string>ưứừửữự</string>
+            </insert-candidates>
+          </list>
+          <list>
+            <integer>1</integer>
+            <insert>
+              <string>w</string>
+            </insert>
+          </list>
+        </cond>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>W</string>
+        </keyseq>
+        <cond>
+          <list>
+            <eq>
+              <varref vname="V-1"/>
+              <integer>0</integer>
+            </eq>
+            <insert-candidates>
+              <string>ƯỨỪỬỮỰ</string>
+            </insert-candidates>
+          </list>
+          <list>
+            <integer>1</integer>
+            <insert>
+              <string>W</string>
+            </insert>
+          </list>
+        </cond>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>ooo</string>
+        </keyseq>
+        <insert-candidates>
+          <string>oóòỏõọ</string>
+        </insert-candidates>
+        <insert-candidates>
+          <string>oóòỏõọ</string>
+        </insert-candidates>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <integer>111</integer>
+        </set>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>OOO</string>
+        </keyseq>
+        <insert-candidates>
+          <string>OÓÒỎÕỌ</string>
+        </insert-candidates>
+        <insert-candidates>
+          <string>OÓÒỎÕỌ</string>
+        </insert-candidates>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <integer>79</integer>
+        </set>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Ooo</string>
+        </keyseq>
+        <insert-candidates>
+          <string>OÓÒỎÕỌ</string>
+        </insert-candidates>
+        <insert-candidates>
+          <string>oóòỏõọ</string>
+        </insert-candidates>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <integer>79</integer>
+        </set>
+      </rule>
+    </map>
+    <map mname="map-consonant-ext">
+      <rule>
+        <keyseq>
+          <string>dd</string>
+        </keyseq>
+        <insert>
+          <integer>273</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>DD</string>
+        </keyseq>
+        <insert>
+          <integer>272</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Dd</string>
+        </keyseq>
+        <insert>
+          <integer>272</integer>
+        </insert>
+      </rule>
+    </map>
+    <map mname="map-tone-mark">
+      <rule>
+        <keyseq>
+          <string>z</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>0</integer>
+        </set>
+        <insert>
+          <integer>122</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Z</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>0</integer>
+        </set>
+        <insert>
+          <integer>90</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>s</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>1</integer>
+        </set>
+        <insert>
+          <integer>115</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>S</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>1</integer>
+        </set>
+        <insert>
+          <integer>83</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>f</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>2</integer>
+        </set>
+        <insert>
+          <integer>102</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>F</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>2</integer>
+        </set>
+        <insert>
+          <integer>70</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>r</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>3</integer>
+        </set>
+        <insert>
+          <integer>114</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>R</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>3</integer>
+        </set>
+        <insert>
+          <integer>82</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>x</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>4</integer>
+        </set>
+        <insert>
+          <integer>120</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>X</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>4</integer>
+        </set>
+        <insert>
+          <integer>88</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>j</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>5</integer>
+        </set>
+        <insert>
+          <integer>106</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>J</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>5</integer>
+        </set>
+        <insert>
+          <integer>74</integer>
+        </insert>
+      </rule>
+    </map>
+    <map mname="map-consonant-or-tone-mark">
+      <rule>
+        <keyseq>
+          <string>z</string>
+        </keyseq>
+        <insert>
+          <integer>122</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>s</string>
+        </keyseq>
+        <insert>
+          <integer>115</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>f</string>
+        </keyseq>
+        <insert>
+          <integer>102</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>r</string>
+        </keyseq>
+        <insert>
+          <integer>114</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>x</string>
+        </keyseq>
+        <insert>
+          <integer>120</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>j</string>
+        </keyseq>
+        <insert>
+          <integer>106</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Z</string>
+        </keyseq>
+        <insert>
+          <integer>90</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>S</string>
+        </keyseq>
+        <insert>
+          <integer>83</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>F</string>
+        </keyseq>
+        <insert>
+          <integer>70</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>R</string>
+        </keyseq>
+        <insert>
+          <integer>82</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>X</string>
+        </keyseq>
+        <insert>
+          <integer>88</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>J</string>
+        </keyseq>
+        <insert>
+          <integer>74</integer>
+        </insert>
+      </rule>
+    </map>
+    <map mname="map-temporary-escape">
+      <rule>
+        <keyseq>
+          <string>aaa</string>
+        </keyseq>
+        <insert>
+          <string>aa</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>AAA</string>
+        </keyseq>
+        <insert>
+          <string>AA</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Aaa</string>
+        </keyseq>
+        <insert>
+          <string>Aa</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>eee</string>
+        </keyseq>
+        <insert>
+          <string>ee</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>EEE</string>
+        </keyseq>
+        <insert>
+          <string>EE</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Eee</string>
+        </keyseq>
+        <insert>
+          <string>Ee</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>ddd</string>
+        </keyseq>
+        <insert>
+          <string>dd</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>DDD</string>
+        </keyseq>
+        <insert>
+          <string>DD</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Ddd</string>
+        </keyseq>
+        <insert>
+          <string>Dd</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>aww</string>
+        </keyseq>
+        <insert>
+          <string>aw</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>AWW</string>
+        </keyseq>
+        <insert>
+          <string>AW</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Aww</string>
+        </keyseq>
+        <insert>
+          <string>Aw</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>uww</string>
+        </keyseq>
+        <insert>
+          <string>uw</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>UWW</string>
+        </keyseq>
+        <insert>
+          <string>UW</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Uww</string>
+        </keyseq>
+        <insert>
+          <string>Uw</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>oww</string>
+        </keyseq>
+        <insert>
+          <string>ow</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>OWW</string>
+        </keyseq>
+        <insert>
+          <string>OW</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Oww</string>
+        </keyseq>
+        <insert>
+          <string>Ow</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>ww</string>
+        </keyseq>
+        <insert>
+          <integer>119</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>WW</string>
+        </keyseq>
+        <insert>
+          <integer>87</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Ww</string>
+        </keyseq>
+        <insert>
+          <integer>87</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>zz</string>
+        </keyseq>
+        <insert>
+          <integer>122</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>ZZ</string>
+        </keyseq>
+        <insert>
+          <integer>90</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Zz</string>
+        </keyseq>
+        <insert>
+          <integer>90</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>ss</string>
+        </keyseq>
+        <insert>
+          <integer>115</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>SS</string>
+        </keyseq>
+        <insert>
+          <integer>83</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Ss</string>
+        </keyseq>
+        <insert>
+          <integer>83</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>ff</string>
+        </keyseq>
+        <insert>
+          <integer>102</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>FF</string>
+        </keyseq>
+        <insert>
+          <integer>70</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Ff</string>
+        </keyseq>
+        <insert>
+          <integer>70</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>rr</string>
+        </keyseq>
+        <insert>
+          <integer>114</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>RR</string>
+        </keyseq>
+        <insert>
+          <integer>82</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Rr</string>
+        </keyseq>
+        <insert>
+          <integer>82</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>xx</string>
+        </keyseq>
+        <insert>
+          <integer>120</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>XX</string>
+        </keyseq>
+        <insert>
+          <integer>88</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Xx</string>
+        </keyseq>
+        <insert>
+          <integer>88</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>jj</string>
+        </keyseq>
+        <insert>
+          <integer>106</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>JJ</string>
+        </keyseq>
+        <insert>
+          <integer>74</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Jj</string>
+        </keyseq>
+        <insert>
+          <integer>74</integer>
+        </insert>
+      </rule>
+    </map>
+  </map-list>
+  <state-list>
+    <state sname="state-init">
+      <state-hook>
+        <set vname="C">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <set vname="V-1">
+          <integer>0</integer>
+        </set>
+        <set vname="V-2">
+          <integer>0</integer>
+        </set>
+        <set vname="V-3">
+          <integer>0</integer>
+        </set>
+        <set vname="C-AFTER-V">
+          <integer>0</integer>
+        </set>
+        <set vname="SELECT">
+          <integer>0</integer>
+        </set>
+      </state-hook>
+      <branch mname="map-consonant">
+        <set vname="C">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+      </branch>
+      <branch mname="map-consonant-ext">
+        <set vname="C">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+      </branch>
+      <branch mname="map-consonant-or-tone-mark">
+        <cond>
+          <list>
+            <logior>
+              <eq>
+                <char-at>
+                  <marker>@-1</marker>
+                </char-at>
+                <integer>102</integer>
+              </eq>
+              <eq>
+                <char-at>
+                  <marker>@-1</marker>
+                </char-at>
+                <integer>106</integer>
+              </eq>
+              <eq>
+                <char-at>
+                  <marker>@-1</marker>
+                </char-at>
+                <integer>122</integer>
+              </eq>
+              <eq>
+                <char-at>
+                  <marker>@-1</marker>
+                </char-at>
+                <integer>70</integer>
+              </eq>
+              <eq>
+                <char-at>
+                  <marker>@-1</marker>
+                </char-at>
+                <integer>74</integer>
+              </eq>
+              <eq>
+                <char-at>
+                  <marker>@-1</marker>
+                </char-at>
+                <integer>90</integer>
+              </eq>
+            </logior>
+            <shift>
+              <symbol>state-temporary-escape</symbol>
+            </shift>
+          </list>
+          <list>
+            <integer>1</integer>
+            <set vname="C">
+              <char-at>
+                <marker>@-1</marker>
+              </char-at>
+            </set>
+          </list>
+        </cond>
+      </branch>
+      <branch mname="map-vowel">
+        <mark>
+          <marker>M</marker>
+        </mark>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <shift>
+          <symbol>state-after-v</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-vowel-ext">
+        <mark>
+          <marker>M</marker>
+        </mark>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <shift>
+          <symbol>state-after-v</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-temporary-escape">
+        <shift>
+          <symbol>state-temporary-escape</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-permanent-escape">
+        <shift>
+          <symbol>state-escape-in-normal-mode</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-smart-quotes"/>
+    </state>
+    <state sname="state-after-v">
+      <branch mname="map-ending-1st-consonant">
+        <funcall fname="macro-handle-mark"/>
+        <shift>
+          <symbol>state-after-vc</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-vowel">
+        <mark>
+          <marker>M</marker>
+        </mark>
+        <set vname="V-3">
+          <varref vname="V-2"/>
+        </set>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <move>
+          <marker>T</marker>
+        </move>
+        <select>
+          <integer>0</integer>
+        </select>
+        <funcall fname="macro-handle-mark"/>
+        <move>
+          <marker>M</marker>
+        </move>
+      </branch>
+      <branch mname="map-vowel-ext">
+        <mark>
+          <marker>M</marker>
+        </mark>
+        <set vname="V-3">
+          <varref vname="V-2"/>
+        </set>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <move>
+          <marker>T</marker>
+        </move>
+        <select>
+          <integer>0</integer>
+        </select>
+        <funcall fname="macro-handle-mark"/>
+        <move>
+          <marker>M</marker>
+        </move>
+      </branch>
+      <branch mname="map-ending-1st-notviet-consonant">
+        <shift>
+          <symbol>state-temporary-escape</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-consonant-or-tone-mark">
+        <delete>
+          <marker>@-</marker>
+        </delete>
+        <pushback>
+          <integer>1</integer>
+        </pushback>
+        <shift>
+          <symbol>state-after-t</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-backspace">
+        <delete>
+          <marker>@-</marker>
+        </delete>
+        <cond>
+          <list>
+            <varref vname="V-3"/>
+            <set vname="V-1">
+              <varref vname="V-2"/>
+            </set>
+            <set vname="V-2">
+              <varref vname="V-3"/>
+            </set>
+            <set vname="V-3">
+              <integer>0</integer>
+            </set>
+            <cond>
+              <list>
+                <gt>
+                  <varref vname="TPLACE"/>
+                  <integer>2</integer>
+                </gt>
+                <set vname="SELECT">
+                  <integer>0</integer>
+                </set>
+              </list>
+            </cond>
+            <funcall fname="macro-handle-mark"/>
+          </list>
+          <list>
+            <varref vname="V-2"/>
+            <set vname="V-1">
+              <varref vname="V-2"/>
+            </set>
+            <set vname="V-2">
+              <integer>0</integer>
+            </set>
+            <cond>
+              <list>
+                <gt>
+                  <varref vname="TPLACE"/>
+                  <integer>1</integer>
+                </gt>
+                <set vname="SELECT">
+                  <integer>0</integer>
+                </set>
+              </list>
+            </cond>
+            <funcall fname="macro-handle-mark"/>
+          </list>
+          <list>
+            <integer>1</integer>
+            <shift>
+              <symbol>state-init</symbol>
+            </shift>
+          </list>
+        </cond>
+      </branch>
+    </state>
+    <state sname="state-after-vc">
+      <state-hook>
+        <set vname="C-AFTER-V">
+          <integer>1</integer>
+        </set>
+      </state-hook>
+      <branch mname="map-ending-2nd-consonant">
+        <cond>
+          <list>
+            <logior>
+              <eq>
+                <char-at>
+                  <marker>@-2</marker>
+                </char-at>
+                <integer>110</integer>
+              </eq>
+              <eq>
+                <char-at>
+                  <marker>@-2</marker>
+                </char-at>
+                <integer>99</integer>
+              </eq>
+              <eq>
+                <char-at>
+                  <marker>@-2</marker>
+                </char-at>
+                <integer>78</integer>
+              </eq>
+              <eq>
+                <char-at>
+                  <marker>@-2</marker>
+                </char-at>
+                <integer>67</integer>
+              </eq>
+            </logior>
+            <add vname="C-AFTER-V">
+              <integer>1</integer>
+            </add>
+          </list>
+          <list>
+            <integer>1</integer>
+            <shift>
+              <symbol>state-temporary-escape</symbol>
+            </shift>
+          </list>
+        </cond>
+      </branch>
+      <branch mname="map-ending-1st-notviet-consonant">
+        <shift>
+          <symbol>state-temporary-escape</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-consonant-or-tone-mark">
+        <delete>
+          <marker>@-</marker>
+        </delete>
+        <pushback>
+          <integer>1</integer>
+        </pushback>
+        <shift>
+          <symbol>state-after-t</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-vowel">
+        <shift>
+          <symbol>state-temporary-escape</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-vowel-ext">
+        <shift>
+          <symbol>state-temporary-escape</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-backspace">
+        <delete>
+          <marker>@-</marker>
+        </delete>
+        <sub vname="C-AFTER-V">
+          <integer>1</integer>
+        </sub>
+        <funcall fname="macro-handle-mark"/>
+        <cond>
+          <list>
+            <eq>
+              <varref vname="C-AFTER-V"/>
+              <integer>0</integer>
+            </eq>
+            <shift>
+              <symbol>state-after-v</symbol>
+            </shift>
+          </list>
+        </cond>
+      </branch>
+    </state>
+    <state sname="state-after-t">
+      <state-hook>
+        <set vname="CURRENT-SELECT">
+          <integer>-1</integer>
+        </set>
+      </state-hook>
+      <branch mname="map-tone-mark">
+        <cond>
+          <list>
+            <eq>
+              <varref vname="CURRENT-SELECT"/>
+              <varref vname="SELECT"/>
+            </eq>
+            <move>
+              <marker>T</marker>
+            </move>
+            <select>
+              <integer>0</integer>
+            </select>
+            <move>
+              <marker>@&gt;</marker>
+            </move>
+            <shift>
+              <symbol>state-temporary-escape</symbol>
+            </shift>
+          </list>
+          <list>
+            <integer>1</integer>
+            <delete>
+              <marker>@-</marker>
+            </delete>
+            <funcall fname="macro-handle-mark"/>
+            <set vname="CURRENT-SELECT">
+              <varref vname="SELECT"/>
+            </set>
+          </list>
+        </cond>
+      </branch>
+      <catch-all-branch>
+        <cond>
+          <list>
+            <varref vname="C-AFTER-V"/>
+            <shift>
+              <symbol>state-after-vc</symbol>
+            </shift>
+          </list>
+          <list>
+            <integer>1</integer>
+            <shift>
+              <symbol>state-after-v</symbol>
+            </shift>
+          </list>
+        </cond>
+      </catch-all-branch>
+    </state>
+    <state sname="state-temporary-escape">
+      <title>en</title>
+      <state-hook>
+        <commit/>
+      </state-hook>
+      <branch mname="map-alnum">
+        <commit/>
+      </branch>
+    </state>
+    <state sname="state-escape-in-normal-mode">
+      <title>EN</title>
+      <branch mname="map-permanent-escape">
+        <insert>
+          <string>\</string>
+        </insert>
+        <shift>
+          <symbol>state-init</symbol>
+        </shift>
+      </branch>
+      <catch-all-branch>
+        <shift>
+          <symbol>state-permanent-escape</symbol>
+        </shift>
+      </catch-all-branch>
+    </state>
+    <state sname="state-permanent-escape">
+      <title>EN</title>
+      <state-hook>
+        <set vname="ESCAPE">
+          <integer>1</integer>
+        </set>
+      </state-hook>
+      <branch mname="map-permanent-escape">
+        <shift>
+          <symbol>state-escape-in-permanent-escape</symbol>
+        </shift>
+      </branch>
+      <catch-all-branch>
+        <unhandle/>
+      </catch-all-branch>
+    </state>
+    <state sname="state-escape-in-permanent-escape">
+      <title>Ắ</title>
+      <branch mname="map-permanent-escape">
+        <insert>
+          <string>\</string>
+        </insert>
+        <commit/>
+        <shift>
+          <symbol>state-permanent-escape</symbol>
+        </shift>
+      </branch>
+    </state>
+  </state-list>
+</input-method>
\ No newline at end of file
diff --git a/vi-viqr.mimx b/vi-viqr.mimx
new file mode 100644 (file)
index 0000000..e6f5a29
--- /dev/null
@@ -0,0 +1,722 @@
+<?xml version='1.0'?>
+<input-method xmlns="http://www.m17n.org/MIM">
+  <tags>
+    <language>vi</language>
+    <name>viqr</name>
+  </tags>
+  <description>
+    <gettext>Vietnames input method using the VIQR 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)</gettext>
+  </description>
+  <title>Ắ(VIQR)</title>
+  <variable-list>
+    <defvar vname="tone-mark-on-last">
+      <description>
+        <gettext>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.</gettext>
+      </description>
+      <integer>0</integer>
+      <possible-value>
+        <integer>0</integer>
+        <integer>1</integer>
+      </possible-value>
+    </defvar>
+    <defvar vname="backspace-is-undo">
+      <description>
+        <gettext>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" =&gt; "quá").
+If the value is 1, Backspace key undoes the previous key
+(e.g. "q u a i s BS" =&gt; "quai").</gettext>
+      </description>
+      <integer>0</integer>
+      <possible-value>
+        <integer>0</integer>
+        <integer>1</integer>
+      </possible-value>
+    </defvar>
+  </variable-list>
+  <macro-list>
+    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="xml" href="vi-base.mimx" xpointer="xmlns(mim=http://www.m17n.org/MIM)xpointer(//mim:defmacro)">
+      <tags>
+        <language>t</language>
+        <name>nil</name>
+        <extra-id>vi-base</extra-id>
+      </tags>
+      <section>macro</section>
+    </xi:include>
+  </macro-list>
+  <map-list>
+    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="xml" href="vi-base.mimx" xpointer="xmlns(mim=http://www.m17n.org/MIM)xpointer(//mim:map)">
+      <tags>
+        <language>t</language>
+        <name>nil</name>
+        <extra-id>vi-base</extra-id>
+      </tags>
+      <section>map</section>
+    </xi:include>
+    <map mname="map-vowel-ext">
+      <rule>
+        <keyseq>
+          <string>a^</string>
+        </keyseq>
+        <insert-candidates>
+          <string>âấầẩẫậ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>A^</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ÂẤẦẨẪẬ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>a(</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ăắằẳẵặ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>A(</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ĂẮẰẲẴẶ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>e^</string>
+        </keyseq>
+        <insert-candidates>
+          <string>êếềểễệ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>E^</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ÊẾỀỂỄỆ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>o^</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ôốồổỗộ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>O^</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ÔỐỒỔỖỘ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>o+</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ơớờởỡợ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>O+</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ƠỚỜỞỠỢ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>u+</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ưứừửữự</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>U+</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ƯỨỪỬỮỰ</string>
+        </insert-candidates>
+      </rule>
+    </map>
+    <map mname="map-consonant-ext">
+      <rule>
+        <keyseq>
+          <string>dd</string>
+        </keyseq>
+        <insert>
+          <integer>273</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>DD</string>
+        </keyseq>
+        <insert>
+          <integer>272</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>Dd</string>
+        </keyseq>
+        <insert>
+          <integer>272</integer>
+        </insert>
+      </rule>
+    </map>
+    <map mname="map-tone-mark">
+      <rule>
+        <keyseq>
+          <string>0</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>0</integer>
+        </set>
+        <insert>
+          <integer>48</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>'</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>1</integer>
+        </set>
+        <insert>
+          <integer>39</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>`</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>2</integer>
+        </set>
+        <insert>
+          <integer>96</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>?</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>3</integer>
+        </set>
+        <insert>
+          <integer>63</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>~</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>4</integer>
+        </set>
+        <insert>
+          <integer>126</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>.</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>5</integer>
+        </set>
+        <insert>
+          <integer>46</integer>
+        </insert>
+      </rule>
+    </map>
+    <map mname="map-temporary-escape">
+      <rule>
+        <keyseq>
+          <string>a^^</string>
+        </keyseq>
+        <insert>
+          <string>a^</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>A^^</string>
+        </keyseq>
+        <insert>
+          <string>A^</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>a((</string>
+        </keyseq>
+        <insert>
+          <string>a(</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>A((</string>
+        </keyseq>
+        <insert>
+          <string>A(</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>e^^</string>
+        </keyseq>
+        <insert>
+          <string>e^</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>E^^</string>
+        </keyseq>
+        <insert>
+          <string>E^</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>o^^</string>
+        </keyseq>
+        <insert>
+          <string>o^</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>O^^</string>
+        </keyseq>
+        <insert>
+          <string>O^</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>o++</string>
+        </keyseq>
+        <insert>
+          <string>o+</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>O++</string>
+        </keyseq>
+        <insert>
+          <string>O+</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>u++</string>
+        </keyseq>
+        <insert>
+          <string>u+</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>U++</string>
+        </keyseq>
+        <insert>
+          <string>U+</string>
+        </insert>
+      </rule>
+    </map>
+  </map-list>
+  <state-list>
+    <state sname="state-init">
+      <state-hook>
+        <set vname="C">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <set vname="V-1">
+          <integer>0</integer>
+        </set>
+        <set vname="V-2">
+          <integer>0</integer>
+        </set>
+        <set vname="V-3">
+          <integer>0</integer>
+        </set>
+        <set vname="C-AFTER-V">
+          <integer>0</integer>
+        </set>
+        <set vname="SELECT">
+          <integer>0</integer>
+        </set>
+      </state-hook>
+      <branch mname="map-consonant">
+        <set vname="C">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+      </branch>
+      <branch mname="map-consonant-ext">
+        <set vname="C">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+      </branch>
+      <branch mname="map-vowel">
+        <mark>
+          <marker>M</marker>
+        </mark>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <shift>
+          <symbol>state-after-v</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-vowel-ext">
+        <mark>
+          <marker>M</marker>
+        </mark>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <shift>
+          <symbol>state-after-v</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-temporary-escape">
+        <shift>
+          <symbol>state-temporary-escape</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-permanent-escape">
+        <shift>
+          <symbol>state-escape-in-normal-mode</symbol>
+        </shift>
+      </branch>
+    </state>
+    <state sname="state-after-v">
+      <branch mname="map-consonant">
+        <shift>
+          <symbol>state-after-vc</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-consonant-ext">
+        <shift>
+          <symbol>state-after-vc</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-vowel">
+        <mark>
+          <marker>M</marker>
+        </mark>
+        <set vname="V-3">
+          <varref vname="V-2"/>
+        </set>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <move>
+          <marker>T</marker>
+        </move>
+        <select>
+          <integer>0</integer>
+        </select>
+        <funcall fname="macro-handle-mark"/>
+        <move>
+          <marker>M</marker>
+        </move>
+      </branch>
+      <branch mname="map-vowel-ext">
+        <mark>
+          <marker>M</marker>
+        </mark>
+        <set vname="V-3">
+          <varref vname="V-2"/>
+        </set>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <move>
+          <marker>T</marker>
+        </move>
+        <select>
+          <integer>0</integer>
+        </select>
+        <funcall fname="macro-handle-mark"/>
+        <move>
+          <marker>M</marker>
+        </move>
+      </branch>
+      <branch mname="map-tone-mark">
+        <delete>
+          <marker>@-</marker>
+        </delete>
+        <pushback>
+          <integer>1</integer>
+        </pushback>
+        <shift>
+          <symbol>state-after-t</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-backspace">
+        <delete>
+          <marker>@-</marker>
+        </delete>
+        <cond>
+          <list>
+            <varref vname="V-3"/>
+            <set vname="V-1">
+              <varref vname="V-2"/>
+            </set>
+            <set vname="V-2">
+              <varref vname="V-3"/>
+            </set>
+            <set vname="V-3">
+              <integer>0</integer>
+            </set>
+            <cond>
+              <list>
+                <gt>
+                  <varref vname="TPLACE"/>
+                  <integer>2</integer>
+                </gt>
+                <set vname="SELECT">
+                  <integer>0</integer>
+                </set>
+              </list>
+            </cond>
+          </list>
+          <list>
+            <varref vname="V-2"/>
+            <set vname="V-1">
+              <varref vname="V-2"/>
+            </set>
+            <set vname="V-2">
+              <integer>0</integer>
+            </set>
+            <cond>
+              <list>
+                <gt>
+                  <varref vname="TPLACE"/>
+                  <integer>1</integer>
+                </gt>
+                <set vname="SELECT">
+                  <integer>0</integer>
+                </set>
+              </list>
+            </cond>
+          </list>
+          <list>
+            <integer>1</integer>
+            <shift>
+              <symbol>state-init</symbol>
+            </shift>
+          </list>
+        </cond>
+      </branch>
+    </state>
+    <state sname="state-after-vc">
+      <state-hook>
+        <set vname="C-AFTER-V">
+          <integer>1</integer>
+        </set>
+      </state-hook>
+      <branch mname="map-consonant">
+        <add vname="C-AFTER-V">
+          <integer>1</integer>
+        </add>
+      </branch>
+      <branch mname="map-consonant-ext">
+        <add vname="C-AFTER-V">
+          <integer>1</integer>
+        </add>
+      </branch>
+      <branch mname="map-tone-mark">
+        <delete>
+          <marker>@-</marker>
+        </delete>
+        <pushback>
+          <integer>1</integer>
+        </pushback>
+        <shift>
+          <symbol>state-after-t</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-backspace">
+        <delete>
+          <marker>@-</marker>
+        </delete>
+        <sub vname="C-AFTER-V">
+          <integer>1</integer>
+        </sub>
+        <cond>
+          <list>
+            <eq>
+              <varref vname="C-AFTER-V"/>
+              <integer>0</integer>
+            </eq>
+            <shift>
+              <symbol>state-after-v</symbol>
+            </shift>
+          </list>
+        </cond>
+      </branch>
+    </state>
+    <state sname="state-after-t">
+      <state-hook>
+        <set vname="CURRENT-SELECT">
+          <integer>-1</integer>
+        </set>
+      </state-hook>
+      <branch mname="map-tone-mark">
+        <cond>
+          <list>
+            <eq>
+              <varref vname="CURRENT-SELECT"/>
+              <varref vname="SELECT"/>
+            </eq>
+            <move>
+              <marker>T</marker>
+            </move>
+            <select>
+              <integer>0</integer>
+            </select>
+            <move>
+              <marker>@&gt;</marker>
+            </move>
+            <shift>
+              <symbol>state-temporary-escape</symbol>
+            </shift>
+          </list>
+          <list>
+            <integer>1</integer>
+            <delete>
+              <marker>@-</marker>
+            </delete>
+            <funcall fname="macro-handle-mark"/>
+            <set vname="CURRENT-SELECT">
+              <varref vname="SELECT"/>
+            </set>
+          </list>
+        </cond>
+      </branch>
+      <catch-all-branch>
+        <cond>
+          <list>
+            <varref vname="C-AFTER-V"/>
+            <shift>
+              <symbol>state-after-vc</symbol>
+            </shift>
+          </list>
+          <list>
+            <integer>1</integer>
+            <shift>
+              <symbol>state-after-v</symbol>
+            </shift>
+          </list>
+        </cond>
+      </catch-all-branch>
+    </state>
+    <state sname="state-temporary-escape">
+      <title>en</title>
+      <state-hook>
+        <commit/>
+      </state-hook>
+      <branch mname="map-alnum">
+        <commit/>
+      </branch>
+    </state>
+    <state sname="state-escape-in-normal-mode">
+      <title>EN</title>
+      <branch mname="map-permanent-escape">
+        <insert>
+          <string>\</string>
+        </insert>
+        <shift>
+          <symbol>state-init</symbol>
+        </shift>
+      </branch>
+      <catch-all-branch>
+        <shift>
+          <symbol>state-permanent-escape</symbol>
+        </shift>
+      </catch-all-branch>
+    </state>
+    <state sname="state-permanent-escape">
+      <title>EN</title>
+      <state-hook>
+        <set vname="ESCAPE">
+          <integer>1</integer>
+        </set>
+      </state-hook>
+      <branch mname="map-permanent-escape">
+        <shift>
+          <symbol>state-escape-in-permanent-escape</symbol>
+        </shift>
+      </branch>
+      <catch-all-branch>
+        <unhandle/>
+      </catch-all-branch>
+    </state>
+    <state sname="state-escape-in-permanent-escape">
+      <title>Ắ</title>
+      <branch mname="map-permanent-escape">
+        <insert>
+          <string>\</string>
+        </insert>
+        <commit/>
+        <shift>
+          <symbol>state-permanent-escape</symbol>
+        </shift>
+      </branch>
+    </state>
+  </state-list>
+</input-method>
\ No newline at end of file
diff --git a/vi-vni.mimx b/vi-vni.mimx
new file mode 100644 (file)
index 0000000..96a74cf
--- /dev/null
@@ -0,0 +1,715 @@
+<?xml version='1.0'?>
+<input-method xmlns="http://www.m17n.org/MIM">
+  <tags>
+    <language>vi</language>
+    <name>vni</name>
+  </tags>
+  <description>
+    <gettext>Vietnames input method using the VNI 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)</gettext>
+  </description>
+  <title>Ắ(VNI)</title>
+  <variable-list>
+    <defvar vname="tone-mark-on-last">
+      <description>
+        <gettext>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.</gettext>
+      </description>
+      <integer>0</integer>
+      <possible-value>
+        <integer>0</integer>
+        <integer>1</integer>
+      </possible-value>
+    </defvar>
+    <defvar vname="backspace-is-undo">
+      <description>
+        <gettext>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" =&gt; "quá").
+If the value is 1, Backspace key undoes the previous key
+(e.g. "q u a i s BS" =&gt; "quai").</gettext>
+      </description>
+      <integer>0</integer>
+      <possible-value>
+        <integer>0</integer>
+        <integer>1</integer>
+      </possible-value>
+    </defvar>
+  </variable-list>
+  <macro-list>
+    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="xml" href="vi-base.mimx" xpointer="xmlns(mim=http://www.m17n.org/MIM)xpointer(//mim:defmacro)">
+      <tags>
+        <language>t</language>
+        <name>nil</name>
+        <extra-id>vi-base</extra-id>
+      </tags>
+      <section>macro</section>
+    </xi:include>
+  </macro-list>
+  <map-list>
+    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="xml" href="vi-base.mimx" xpointer="xmlns(mim=http://www.m17n.org/MIM)xpointer(//mim:map)">
+      <tags>
+        <language>t</language>
+        <name>nil</name>
+        <extra-id>vi-base</extra-id>
+      </tags>
+      <section>map</section>
+    </xi:include>
+    <map mname="map-vowel-ext">
+      <rule>
+        <keyseq>
+          <string>a6</string>
+        </keyseq>
+        <insert-candidates>
+          <string>âấầẩẫậ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>A6</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ÂẤẦẨẪẬ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>a8</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ăắằẳẵặ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>A8</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ĂẮẰẲẴẶ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>e6</string>
+        </keyseq>
+        <insert-candidates>
+          <string>êếềểễệ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>E6</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ÊẾỀỂỄỆ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>o6</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ôốồổỗộ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>O6</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ÔỐỒỔỖỘ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>o7</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ơớờởỡợ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>O7</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ƠỚỜỞỠỢ</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>u7</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ưứừửữự</string>
+        </insert-candidates>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>U7</string>
+        </keyseq>
+        <insert-candidates>
+          <string>ƯỨỪỬỮỰ</string>
+        </insert-candidates>
+      </rule>
+    </map>
+    <map mname="map-consonant-ext">
+      <rule>
+        <keyseq>
+          <string>d9</string>
+        </keyseq>
+        <insert>
+          <integer>273</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>D9</string>
+        </keyseq>
+        <insert>
+          <integer>272</integer>
+        </insert>
+      </rule>
+    </map>
+    <map mname="map-tone-mark">
+      <rule>
+        <keyseq>
+          <string>0</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>0</integer>
+        </set>
+        <insert>
+          <integer>48</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>1</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>1</integer>
+        </set>
+        <insert>
+          <integer>49</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>2</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>2</integer>
+        </set>
+        <insert>
+          <integer>50</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>3</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>3</integer>
+        </set>
+        <insert>
+          <integer>51</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>4</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>4</integer>
+        </set>
+        <insert>
+          <integer>52</integer>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>5</string>
+        </keyseq>
+        <set vname="SELECT">
+          <integer>5</integer>
+        </set>
+        <insert>
+          <integer>53</integer>
+        </insert>
+      </rule>
+    </map>
+    <map mname="map-temporary-escape">
+      <rule>
+        <keyseq>
+          <string>a66</string>
+        </keyseq>
+        <insert>
+          <string>a6</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>A66</string>
+        </keyseq>
+        <insert>
+          <string>A6</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>a88</string>
+        </keyseq>
+        <insert>
+          <string>a8</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>A88</string>
+        </keyseq>
+        <insert>
+          <string>A8</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>e66</string>
+        </keyseq>
+        <insert>
+          <string>e6</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>E66</string>
+        </keyseq>
+        <insert>
+          <string>E6</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>o66</string>
+        </keyseq>
+        <insert>
+          <string>o6</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>O66</string>
+        </keyseq>
+        <insert>
+          <string>O6</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>o77</string>
+        </keyseq>
+        <insert>
+          <string>o7</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>O77</string>
+        </keyseq>
+        <insert>
+          <string>O7</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>u77</string>
+        </keyseq>
+        <insert>
+          <string>u7</string>
+        </insert>
+      </rule>
+      <rule>
+        <keyseq>
+          <string>U77</string>
+        </keyseq>
+        <insert>
+          <string>U7</string>
+        </insert>
+      </rule>
+    </map>
+  </map-list>
+  <state-list>
+    <state sname="state-init">
+      <state-hook>
+        <set vname="C">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <set vname="V-1">
+          <integer>0</integer>
+        </set>
+        <set vname="V-2">
+          <integer>0</integer>
+        </set>
+        <set vname="V-3">
+          <integer>0</integer>
+        </set>
+        <set vname="C-AFTER-V">
+          <integer>0</integer>
+        </set>
+        <set vname="SELECT">
+          <integer>0</integer>
+        </set>
+      </state-hook>
+      <branch mname="map-consonant">
+        <set vname="C">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+      </branch>
+      <branch mname="map-consonant-ext">
+        <set vname="C">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+      </branch>
+      <branch mname="map-vowel">
+        <mark>
+          <marker>M</marker>
+        </mark>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <shift>
+          <symbol>state-after-v</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-vowel-ext">
+        <mark>
+          <marker>M</marker>
+        </mark>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <shift>
+          <symbol>state-after-v</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-temporary-escape">
+        <shift>
+          <symbol>state-temporary-escape</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-permanent-escape">
+        <shift>
+          <symbol>state-escape-in-normal-mode</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-smart-quotes"/>
+    </state>
+    <state sname="state-after-v">
+      <branch mname="map-consonant">
+        <shift>
+          <symbol>state-after-vc</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-consonant-ext">
+        <shift>
+          <symbol>state-after-vc</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-vowel">
+        <mark>
+          <marker>M</marker>
+        </mark>
+        <set vname="V-3">
+          <varref vname="V-2"/>
+        </set>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <move>
+          <marker>T</marker>
+        </move>
+        <select>
+          <integer>0</integer>
+        </select>
+        <funcall fname="macro-handle-mark"/>
+        <move>
+          <marker>M</marker>
+        </move>
+      </branch>
+      <branch mname="map-vowel-ext">
+        <mark>
+          <marker>M</marker>
+        </mark>
+        <set vname="V-3">
+          <varref vname="V-2"/>
+        </set>
+        <set vname="V-2">
+          <varref vname="V-1"/>
+        </set>
+        <set vname="V-1">
+          <char-at>
+            <marker>@-1</marker>
+          </char-at>
+        </set>
+        <move>
+          <marker>T</marker>
+        </move>
+        <select>
+          <integer>0</integer>
+        </select>
+        <funcall fname="macro-handle-mark"/>
+        <move>
+          <marker>M</marker>
+        </move>
+      </branch>
+      <branch mname="map-tone-mark">
+        <delete>
+          <marker>@-</marker>
+        </delete>
+        <pushback>
+          <integer>1</integer>
+        </pushback>
+        <shift>
+          <symbol>state-after-t</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-backspace">
+        <delete>
+          <marker>@-</marker>
+        </delete>
+        <cond>
+          <list>
+            <varref vname="V-3"/>
+            <set vname="V-1">
+              <varref vname="V-2"/>
+            </set>
+            <set vname="V-2">
+              <varref vname="V-3"/>
+            </set>
+            <set vname="V-3">
+              <integer>0</integer>
+            </set>
+            <cond>
+              <list>
+                <gt>
+                  <varref vname="TPLACE"/>
+                  <integer>2</integer>
+                </gt>
+                <set vname="SELECT">
+                  <integer>0</integer>
+                </set>
+              </list>
+            </cond>
+          </list>
+          <list>
+            <varref vname="V-2"/>
+            <set vname="V-1">
+              <varref vname="V-2"/>
+            </set>
+            <set vname="V-2">
+              <integer>0</integer>
+            </set>
+            <cond>
+              <list>
+                <gt>
+                  <varref vname="TPLACE"/>
+                  <integer>1</integer>
+                </gt>
+                <set vname="SELECT">
+                  <integer>0</integer>
+                </set>
+              </list>
+            </cond>
+          </list>
+          <list>
+            <integer>1</integer>
+            <shift>
+              <symbol>state-init</symbol>
+            </shift>
+          </list>
+        </cond>
+      </branch>
+    </state>
+    <state sname="state-after-vc">
+      <state-hook>
+        <set vname="C-AFTER-V">
+          <integer>1</integer>
+        </set>
+      </state-hook>
+      <branch mname="map-consonant">
+        <add vname="C-AFTER-V">
+          <integer>1</integer>
+        </add>
+      </branch>
+      <branch mname="map-consonant-ext">
+        <add vname="C-AFTER-V">
+          <integer>1</integer>
+        </add>
+      </branch>
+      <branch mname="map-tone-mark">
+        <delete>
+          <marker>@-</marker>
+        </delete>
+        <pushback>
+          <integer>1</integer>
+        </pushback>
+        <shift>
+          <symbol>state-after-t</symbol>
+        </shift>
+      </branch>
+      <branch mname="map-backspace">
+        <delete>
+          <marker>@-</marker>
+        </delete>
+        <sub vname="C-AFTER-V">
+          <integer>1</integer>
+        </sub>
+        <cond>
+          <list>
+            <eq>
+              <varref vname="C-AFTER-V"/>
+              <integer>0</integer>
+            </eq>
+            <shift>
+              <symbol>state-after-v</symbol>
+            </shift>
+          </list>
+        </cond>
+      </branch>
+    </state>
+    <state sname="state-after-t">
+      <state-hook>
+        <set vname="CURRENT-SELECT">
+          <integer>-1</integer>
+        </set>
+      </state-hook>
+      <branch mname="map-tone-mark">
+        <cond>
+          <list>
+            <eq>
+              <varref vname="CURRENT-SELECT"/>
+              <varref vname="SELECT"/>
+            </eq>
+            <move>
+              <marker>T</marker>
+            </move>
+            <select>
+              <integer>0</integer>
+            </select>
+            <move>
+              <marker>@&gt;</marker>
+            </move>
+            <shift>
+              <symbol>state-temporary-escape</symbol>
+            </shift>
+          </list>
+          <list>
+            <integer>1</integer>
+            <delete>
+              <marker>@-</marker>
+            </delete>
+            <funcall fname="macro-handle-mark"/>
+            <set vname="CURRENT-SELECT">
+              <varref vname="SELECT"/>
+            </set>
+          </list>
+        </cond>
+      </branch>
+      <catch-all-branch>
+        <cond>
+          <list>
+            <varref vname="C-AFTER-V"/>
+            <shift>
+              <symbol>state-after-vc</symbol>
+            </shift>
+          </list>
+          <list>
+            <integer>1</integer>
+            <shift>
+              <symbol>state-after-v</symbol>
+            </shift>
+          </list>
+        </cond>
+      </catch-all-branch>
+    </state>
+    <state sname="state-temporary-escape">
+      <title>en</title>
+      <state-hook>
+        <commit/>
+      </state-hook>
+      <branch mname="map-alnum">
+        <commit/>
+      </branch>
+    </state>
+    <state sname="state-escape-in-normal-mode">
+      <title>EN</title>
+      <branch mname="map-permanent-escape">
+        <insert>
+          <string>\</string>
+        </insert>
+        <shift>
+          <symbol>state-init</symbol>
+        </shift>
+      </branch>
+      <catch-all-branch>
+        <shift>
+          <symbol>state-permanent-escape</symbol>
+        </shift>
+      </catch-all-branch>
+    </state>
+    <state sname="state-permanent-escape">
+      <title>EN</title>
+      <state-hook>
+        <set vname="ESCAPE">
+          <integer>1</integer>
+        </set>
+      </state-hook>
+      <branch mname="map-permanent-escape">
+        <shift>
+          <symbol>state-escape-in-permanent-escape</symbol>
+        </shift>
+      </branch>
+      <catch-all-branch>
+        <unhandle/>
+      </catch-all-branch>
+    </state>
+    <state sname="state-escape-in-permanent-escape">
+      <title>Ắ</title>
+      <branch mname="map-permanent-escape">
+        <insert>
+          <string>\</string>
+        </insert>
+        <commit/>
+        <shift>
+          <symbol>state-permanent-escape</symbol>
+        </shift>
+      </branch>
+    </state>
+  </state-list>
+</input-method>
\ No newline at end of file
index 618db49..20a7605 100644 (file)
--- a/xex.html
+++ b/xex.html
@@ -19,9 +19,9 @@
 <table><tr><td style="font-size: large; font-weight: bold;">text</td><td><form><input type="text"></form></td></tr></table>
 <div style="font-weight: bold;">debug Info</div>
 <table border="1">
-<tr><th>key</th><th>keycode</th><th>status</th><th>keyseq</th><th>preedit</th></tr>
-<tr><th>down</th><td id="keydown">0</td><td id="status0"><td id="keyseq0"></td><td id="preedit0"></td></tr>
-<tr><th>press</th><td id="keypress">0</td><td id="status1"><td id="keyseq1"></td><td id="preedit1"></td></tr>
+<tr><th>key</th><th>keycode</th><th>status</th><th>keymap</th><th>preedit</th></tr>
+<tr><th>down</th><td id="keydown">0</td><td id="status0"><td id="keymap0"></td><td id="preedit0"></td></tr>
+<tr><th>press</th><td id="keypress">0</td><td id="status1"><td id="keymap1"></td><td id="preedit1"></td></tr>
 </table>
 <textarea style="font-size: small; width:100%" rows="10"id="log"></textarea>
 </body>
diff --git a/xex.js b/xex.js
index 8be7f9d..c76fce3 100644 (file)
--- a/xex.js
+++ b/xex.js
@@ -393,7 +393,7 @@ Xex.Domain.prototype = {
     var func = this.functions[name];
     if (! func)
       throw new Xex.ErrTerm (Xex.Error.UnknownFunction,
-                            "Unknown function: " + this + ':' + name);
+                            "Unknown function: " + name);
     return func;
   },
   CopyFunc: function (domain, name)
@@ -483,10 +483,12 @@ Xex.ParseTermList = function (domain, node)
        if (n.nodeName == 'defun' || n.nodeName == 'defmacro')
          Xex.parse_defun_head (domain, n);
       }
-  var terms = new Array ();
+  var terms = false;
   for (var n = node; n; n = n.nextSibling)
     if (n.nodeType == 1)
       {
+       if (! terms)
+         terms = new Array ();
        if (n.nodeName == 'defun' || n.nodeName == 'defmacro')
          Xex.parse_defun_body (domain, n);
        else if (n.nodeName == 'defvar')
@@ -795,7 +797,7 @@ Xex.LstTerm = function (list) { this.val = list; };
       return result;
     if (result.IsTrue)
       return args[1].Eval (domain);
-    if (args.Length == 2)
+    if (args.length == 2)
       return Zero;
     return args[2].Eval (domain);
   }
@@ -1299,6 +1301,7 @@ MIM.Action.prototype.Run = function (domain)
 
 MIM.Keymap = function ()
 {
+  this.name = 'TOP';
   this.submaps = null;
   this.actions = null;
 };
@@ -1309,12 +1312,14 @@ MIM.Keymap = function ()
   {
     var keyseq = rule.keyseq;
     var len = keyseq.val.length;
+    var name = '';
 
     for (var i = 0; i < len; i++)
       {
        var key = keyseq.val[i];
        var sub = false;
 
+       name += key.key;
        if (! keymap.submaps)
          keymap.submaps = {};
        else
@@ -1322,6 +1327,7 @@ MIM.Keymap = function ()
        if (! sub)
          keymap.submaps[key.key] = sub = new MIM.Keymap ();
        keymap = sub;
+       keymap.name = name;
       }
     keymap.actions = rule.actions;
   }
@@ -1405,7 +1411,22 @@ MIM.im_domain.DefType (MIM.State.prototype);
 
   function Finsert (domain, vari, args)
   {
-    domain.context.insert (args[0].val, null);
+    var text;
+    if (args[0].type == 'integer')
+      text = String.fromCharCode (args[0].val);
+    else
+      text = args[0].val;
+    domain.context.insert (text, null);
+  }
+
+  function Finsert_candidates (domain, vari, args)
+  {
+    var ic = domain.context;
+    var candidates = new Candidates (args, column);
+    var candidate = candidates.Current ();
+    
+    if (
+
   }
 
   im_domain.DefSubr (Finsert, "insert", false, 1, 1);
@@ -1551,6 +1572,232 @@ MIM.im_domain.DefType (MIM.State.prototype);
     this.table.length = 0;
   }
 
+  function Block (index, term)
+  {
+    this.Index = index;
+    if (term.IsStr)
+      this.Data = term.val;
+    else if (term.IsList)
+      {
+       this.Data = new Array ();
+       for (var i = 0; i < term.val.length; i++)
+         this.Data.push (term.val[i].val);
+      }
+  }
+
+  Block.prototype.Count = function () { return this.Data.length; }
+  Block.prototype.get = function (i)
+  {
+    return (this.Data instanceof Array ? this.Data[i] : this.Data.charAt (i));
+  }
+
+  function fill_group (start)
+  {
+    var nitems = this.group.length;
+    var r = this.row;
+    var b = this.blocks[r];
+
+    if (start < b.Index)
+      while (start < b.Index)
+       b = this.blocks[--r];
+    else
+      while (start >= b.Index + b.Count ())
+       b = this.blocks[++r];
+    this.row = r;
+
+    var count = b.Count ();
+    start -= b.Index;
+    for (var i = 0; i < nitems; i++, start++)
+      {
+       if (start >= count)
+         {
+           r++;
+           if (r == this.blocks.Length)
+             return i;
+           b = this.blocks[r];
+           count = b.Count ();
+           start = 0;
+         }
+       this.group[i] = b.get (start);
+      }
+    return nitems;
+  }
+
+  function Candidates (candidates, column)
+  {
+    this.column = column;
+    this.row = 0;
+    this.index = 0;
+    this.total = 0;
+    this.blocks = new Array ();
+
+    for (var i = 0; i < candidates.length; i++)
+      {
+       var block = new Block (this.total, candidates[i]);
+       this.blocks.push (block);
+       this.total += block.Count ();
+      }
+  }
+
+  Candidates.prototype.Column = function ()
+  {
+    return (this.column > 0 ? this.index % this.column
+           : this.index - this.blocks[this.row].Index);
+  }
+
+  Candidates.prototype.GroupLength = function ()
+  {
+    if (this.column > 0)
+      {
+       var nitems = this.group.length;
+       var start = this.index - (this.index % nitems);
+       return (start + this.column <= this.total ? this.column
+               : this.total - start);
+      }
+    return this.blocks[this.row].Count;
+  }
+
+  Candidates.prototype.Current = function ()
+  {
+    var b = this.blocks[this.row];
+    return b.get (this.index - b.Index);
+  }
+
+  Candidates.prototype.PrevGroup ()
+  {
+    var col = this.Column ();
+    var nitems;
+    if (this.column > 0)
+      {
+       this.index -= this.column;
+       if (this.index >= 0)
+         nitems = this.column;
+       else
+         {
+           var lastcol = (this.total - 1) % this.column;
+           this.index = (col < lastcol ? this.total - lastcol + col
+                         : this.total - 1);
+           this.row = this.blocks.length - 1;
+           nitems = lastcol + 1;
+         }
+       while (this.blocks[this.row].Index > this.index)
+         this.row--;
+      }
+    else
+      {
+       this.row = this.row > 0 ? this.row - 1 : this.blocks.length - 1;
+       nitems = this.blocks[this.row].Count;
+       this.index = (this.blocks[this.row].Index
+                     + (col < nitems ? col : nitems - 1));
+      }
+    return nitems;
+  }
+
+  Candidates.prototype.NextGroup = function ()
+  {
+    var col = this.Column ();
+    var nitems;
+    if (this.column > 0)
+      {
+       this.index += this.column - col;
+       if (this.index < this.total)
+         {
+           if (this.index + col >= this.total)
+             {
+               nitems = this.total - this.index;
+               this.index = this.total - 1;
+             }
+           else
+             {
+               nitems = this.column;
+               this.index += col;
+             }
+         }
+       else
+         {
+           this.index = col;
+           this.row = 0;
+         }
+       while (this.blocks[this.row].Index > this.index)
+         this.row++;
+      }
+    else
+      {
+       this.row = this.row < this.blocks.length - 1 ? this.row + 1 : 0;
+       nitems = this.blocks[this.row].Count;
+       this.index = (this.blocks[this.row].Index
+                     + (col < nitems ? col : nitems - 1));
+      }
+    return nitems;
+  }
+
+  Candidates.prototype.Prev = function ()
+  {
+    var col = this.Column ();
+
+    if (col == 0)
+      {
+       int nitems = this.PrevGroup ();
+       this.index += col < nitems - 1 ? col : nitems - 1;
+      }
+    else
+      this.index--;
+  }
+
+  Candidates.prototype.Next = function ()
+  {
+    int col = this.Column ();
+    int nitems = this.GroupLength ();
+
+    if (col == nitems - 1)
+      {
+       nitems = this.NextGroup ();
+       this.index -= this.Column ();
+      }
+    else
+      this.index++;
+  }
+
+  Candidates.prototype.First = function () { this.index -= this.Column (); }
+
+  Candidates.prototype.Last = function ()
+  {
+    this.index += this.GroupLength () - (this.Column + 1);
+  }
+
+  Candidates.prototype.Select = funciton (selector)
+  {
+    if (selector instanceof MIM.Selector)
+      {
+       switch (selector.val)
+         {
+         case '@<': this.First (); break;
+         case '@>': this.Last (); break;
+         case '@-': this.Prev (); break;
+         case '@+': this.Next (); break;
+         case '@[': this.PrevGroup (); break;
+         case '@]': this.NextGroup (); break;
+         default: break;
+         }
+       return this.Current ();
+      }
+    var maxcol = this.GroupLength () - 1;
+    if (selector > maxcol)
+      selector = maxcol;
+    this.index = this.index - this.Column () + selector;
+    return this.Current ();
+  }
+
+  function detach_candidates (ic)
+  {
+    ic.candidate_table.clear ();
+    ic.candidates = null;
+    ic.changed |= (MIM.ChangedStatus.Preedit | MIM.ChangedStatus.CursorPos
+                  | ChangedStatus.CandidateList
+                  | ChangedStatus.CandidateIndex
+                  | ChangedStatus.CandidateShow);
+  }
+
   function set_cursor (prefix, pos)
   {
     this.cursor_pos = pos;
@@ -1582,7 +1829,7 @@ MIM.im_domain.DefType (MIM.State.prototype);
     var branch_actions = this.state.keymap.actions;
 
     MIM.log ('handling ' + this.keys.val[this.key_head]
-            + ' in ' + this.state.name);
+            + ' in ' + this.state.name + ':' + this.keymap.name);
     this.key_head = out.index;
     if (sub != this.keymap)
       {
@@ -1590,20 +1837,22 @@ MIM.im_domain.DefType (MIM.State.prototype);
        restore_state.call (this);
        this.keymap = sub;
        MIM.log ('submap found');
-       if (this.keymap.actions != null)
+       if (this.keymap.actions)
          {
            MIM.log ('taking map actions:');
            if (! this.take_actions (this.keymap.actions))
              return false;
          }
-       else if (this.keymap.submaps != null)
+       else if (this.keymap.submaps)
          {
-           MIM.log ('no map actions, inserting key:');
+           MIM.log ('no map actions');
            for (var i = this.state_key_head; i < this.key_head; i++)
-             this.preedit_replace (this.cursor_pos, this.cursor_pos,
-                                   this.keys.val[i].key, null);
+             {
+               MIM.log ('inserting key:' + this.keys.val[i].key);
+               this.insert (this.keys.val[i].key, null);
+             }
          }
-       if (this.keymap.submaps == null)
+       if (! this.keymap.submaps)
          {
            MIM.log ('terminal:');
            if (this.keymap.branch_actions != null)
@@ -1618,23 +1867,29 @@ MIM.im_domain.DefType (MIM.State.prototype);
       }
     else
       {
-       MIM.log ("no submap");
+       MIM.log ('no submap');
        var current_state = this.state;
+       var map = this.keymap;
 
        if (branch_actions)
          {
-           MIM.log ("branch actions");
+           MIM.log ('branch actions');
            if (! this.take_actions (this.keymap.branch_actions))
              return false;
          }
-       if (this.state == current_state)
+
+       if (map == this.keymap)
          {
-           if (this.state == this.initial_state
+           MIM.log ('no state change');
+           if (map == this.initial_state.keymap
                && this.key_head < this.keys.val.length)
-             return false;
-           if (this.keymap != this.state.keymap)
-             this.shift (this.state);
-           else if (this.keymap.branch_actions == null)
+             {
+               MIM.log ('unhandled');
+               return false;
+             }
+           if (this.keymap != current_state.keymap)
+             this.shift (current_state);
+           else if (this.keymap.actions == null)
              this.shift (this.initial_state);
          }
       }
@@ -1642,10 +1897,11 @@ MIM.im_domain.DefType (MIM.State.prototype);
   }
 
   proto = {
-    init: function ()
+    reset: function ()
     {
       this.produced = null;
       this.preedit = '';
+      this.preedit_saved = '';
       this.cursor_pos = 0;
       this.marker_positions = {};
       this.candidates = null;
@@ -1666,18 +1922,13 @@ MIM.im_domain.DefType (MIM.State.prototype);
       this.changed = MIM.ChangedStatus.None;
       this.error_message = '';
       this.title = this.initial_state.title;
-      this.produced = null;
+      this.produced = '';
       this.preedit = '';
+      this.preedit_saved = '';
       this.marker_positions = {};
       this.candidate_table = new MIM.CandidateTable ();
       this.candidates = null;
       this.candidate_show = false;
-    },
-
-    reset: function ()
-    {
-      this.init ();
-      this.state_var_values = {};
       this.shift (this.initial_state);
     },
 
@@ -1816,46 +2067,45 @@ MIM.im_domain.DefType (MIM.State.prototype);
       {
        this.candidate_table.clear ();
        this.produced += this.preedit;
-       this.preedit_replace.call (this, 0, this.preedit.Length, '', null);
+       this.preedit_replace.call (this, 0, this.preedit.length, '', null);
       }
     },
 
     shift: function (state)
     {
       if (state == null)
-      {
-       MIM.log ("shifting back to previous");
-       if (this.prev_state == null)
-         return;
-       state = this.prev_state;
-      }
+        {
+         MIM.log ("shifting back to previous");
+         if (this.prev_state == null)
+           return;
+         state = this.prev_state;
+       }
       else
        MIM.log ("shifting to " + state.name);
 
       if (state == this.initial_state)
         {
-         this.commit ();
-         this.keys.val.splice (0, this.key_head);
-         this.key_head = 0;
-         if (state != this.state)
+         if (this.state)
            {
-             this.domain.RestoreValues (this.state_initial_var_values);
-             if (state.enter_actions != null)
-               take_actions.call (state.enter_actions);
+             this.commit ();
+             this.keys.val.splice (0, this.key_head);
+             this.key_head = 0;
+             this.prev_state = null;
            }
-         this.prev_state = null;
        }
       else
-        {
-         if (state != this.state && state.enter_actions != null)
-           take_actions.call (state.enter_actions);
-         this.prev_state = this.state;
+       {
+         if (state != this.state)
+           this.prev_state = this.state;
        }
-      save_state.call (this);
+      if (state != this.state && state.enter_actions)
+       take_actions.call (state.enter_actions);
       if (! this.state || this.state.title != state.title)
        this.changed |= MIM.ChangedStatus.StateTitle;
       this.state = state;
       this.keymap = state.keymap;
+      this.state_key_head = this.key_head;
+      save_state.call (this);
     },
 
     Filter: function (key)
@@ -1877,16 +2127,29 @@ MIM.im_domain.DefType (MIM.State.prototype);
        {
          if (! handle_key.call (this))
            {
-             this.unhandled_key = this.keys.val[this.key_head++];
+             if (this.key_head < this.keys.val.length)
+               {
+                 this.unhandled_key = this.keys.val[this.key_head];
+                 this.keys.val.splice (this.key_head, this.key_head + 1);
+               }
              this.key_unhandled = true;
              break;
            }
          if (++count == 10)
-           break;
+           {
+             this.reset ();
+             this.key_unhandled = true;
+             break;
+           }
        }
-      this.keys.val.splice (0, this.key_head);
-      this.key_head = 0;
-      return (! this.key_unhandled && this.produced.length == 0);
+      if (this.key_unhandled)
+       {
+         this.keys.val.length = 0;
+         this.key_head = this.state_key_head = this.commit_key_head = 0;
+       }
+      return (! this.key_unhandled
+             && this.produced.length == 0
+             && this.preedit.length == 0);
     }
   }
 
@@ -1980,9 +2243,7 @@ MIM.add_event_listener
 MIM.log = function (msg)
 {
   var node = document.getElementById ('log');
-  node.value += msg + "\n";
-  var len = node.value.length;
-  node.setSelectionRange (len, len);
+  node.value = msg + "\n" + node.value;
 }
 
 MIM.debug_print = function (event, ic)
@@ -1996,8 +2257,8 @@ MIM.debug_print = function (event, ic)
       MIM.debug_nodes['keypress'] = document.getElementById ('keypress');
       MIM.debug_nodes['status0'] = document.getElementById ('status0');
       MIM.debug_nodes['status1'] = document.getElementById ('status1');
-      MIM.debug_nodes['keyseq0'] = document.getElementById ('keyseq0');
-      MIM.debug_nodes['keyseq1'] = document.getElementById ('keyseq1');
+      MIM.debug_nodes['keymap0'] = document.getElementById ('keymap0');
+      MIM.debug_nodes['keymap1'] = document.getElementById ('keymap1');
       MIM.debug_nodes['preedit0'] = document.getElementById ('preedit0');
       MIM.debug_nodes['preedit1'] = document.getElementById ('preedit1');
     }
@@ -2013,7 +2274,7 @@ MIM.debug_print = function (event, ic)
     MIM.debug_nodes['status' + index].innerHTML = ic.im.load_status;
   else
     MIM.debug_nodes['status' + index].innerHTML = 'no IM';
-  MIM.debug_nodes['keyseq' + index].innerHTML = ic.keys;
+  MIM.debug_nodes['keymap' + index].innerHTML = ic.keymap.name;
   MIM.debug_nodes['preedit' + index].innerHTML = ic.preedit;
 };
 
@@ -2038,15 +2299,17 @@ MIM.get_range = function (target, range)
 
 MIM.set_caret = function (target, ic)
 {
-  if (target.selectionStart != null) // Mozilla
+  if (target.setSelectionRange)        // Mozilla
     {
-      target.focus ();
+      var scrollTop = target.scrollTop;
       target.setSelectionRange (ic.spot, ic.spot + ic.preedit.length);
+      target.scrollTop = scrollTop;
     }
   else                         // IE
     {
       var range = target.createTextRange ();
-      range.move ('character', pos);
+      range.moveStart ('character', ic.spot);
+      range.moveEnd ('character', ic.spot + ic.preedit.length);
       range.select ();
     }
 };
@@ -2057,30 +2320,40 @@ MIM.set_caret = function (target, ic)
   MIM.check_range = function (target, ic)
   {
     MIM.get_range (target, range);
-    if (range[0] != ic.spot || range[1] - range[0] != ic.preedit.length)
+    if (range[0] != ic.spot || range[1] - range[0] != ic.preedit.length
+       || target.value.substring (range[0], range[1]) != ic.preedit)
       {
+       MIM.log ('reset:' + ic.spot + '-' + (ic.spot + ic.preedit.length)
+                + '/' + range[0] + '-' + range[1]);
        ic.reset ();
-       ic.spot = range[0];
       }
+    target.value = (target.value.substring (0, range[0])
+                   + target.value.substring (range[1]));
+    ic.spot = range[0];
   }
 }) ();
 
-MIM.update = function (target, ic, prevlen)
+MIM.update = function (target, ic)
 {
   var text = target.value;
   target.value = (text.substring (0, ic.spot)
                  + ic.produced
                  + ic.preedit
-                 + text.substring (ic.spot + prevlen));
+                 + text.substring (ic.spot));
   ic.spot += ic.produced.length;
   MIM.set_caret (target, ic);
 };
 
 MIM.reset_ic = function (event)
 {
-  var ic = event.target.mim_ic;
-  if (ic)
-    ic.reset ();
+  if (event.target.mim_ic)
+    {
+      var ic = event.target.mim_ic;
+      var pos = ic.spot + ic.preedit.length;
+      ic.reset ();
+      if (pos > ic.spot)
+       event.target.setSelectionRange (pos, pos);
+    }
 };
 
 MIM.keydown = function (event)
@@ -2092,6 +2365,7 @@ MIM.keydown = function (event)
   var ic = target.mim_ic;
   if (! ic || ic.im != MIM.current)
     {
+      MIM.log ('creating IC');
       ic = new MIM.IC (MIM.current);
       target.mim_ic = ic;
       MIM.add_event_listener (target, 'blur', MIM.reset_ic);
@@ -2112,7 +2386,6 @@ MIM.keypress = function (event)
   var i;
 
   try {
-    MIM.log (ic.im.name);
     if (ic.im.load_status != MIM.LoadStatus.Loaded)
       return;
     if (! ic.key)
@@ -2123,10 +2396,11 @@ MIM.keypress = function (event)
        return;
       }
     
-    var prevlen = ic.preedit.length;
     MIM.log ("filtering " + ic.key);
     var result = ic.Filter (ic.key);
-    MIM.update (target, ic, prevlen);
+    MIM.update (event.target, ic);
+    if (! ic.key_unhandled)
+      event.preventDefault ();
   } finally {
     MIM.debug_print (event, ic);
   }
@@ -2140,17 +2414,20 @@ MIM.select_im = function (event)
     target = target.parentNode;
   var idx = 0;
   var im = false;
-  for (var lang in MIM.list)
-    for (var name in MIM.list[lang])
+  for (var lang in MIM.im_list)
+    for (var name in MIM.im_list[lang])
       if (idx++ == target.selectedIndex)
        {
-         im = MIM.list[lang][name];
+         im = MIM.im_list[lang][name];
          break;
        }
   document.getElementsByTagName ('body')[0].removeChild (target);
   target.target.focus ();
   if (im && im != MIM.current)
-    MIM.current = MIM.load_sync (im);
+    {
+      MIM.current = im;
+      MIM.log ('select IM: ' + im.name);
+    }
 };
 
 MIM.destroy_menu = function (event)
@@ -2175,15 +2452,15 @@ MIM.select_menu = function (event)
   sel.style.top = (event.clientY - 10) + "px";
   sel.target = target;
   var idx = 0;
-  for (var lang in MIM.list)
-    for (var name in MIM.list[lang])
+  for (var lang in MIM.im_list)
+    for (var name in MIM.im_list[lang])
       {
        var option = document.createElement ('option');
        var imname = lang + "-" + name;
        option.appendChild (document.createTextNode (imname));
        option.value = imname;
        sel.appendChild (option);
-       if (MIM.list[lang][name] == MIM.current)
+       if (MIM.im_list[lang][name] == MIM.current)
          sel.selectedIndex = idx;
        idx++;
       }
@@ -2221,7 +2498,7 @@ MIM.init = function ()
   MIM.add_event_listener (window, 'mousedown', MIM.select_menu);
   if (window.location == 'http://localhost/mim/index.html')
     MIM.server = 'http://localhost/mim';
-  MIM.current = MIM.im_list['t']['latn-post'];
+  MIM.current = MIM.im_list['vi']['telex'];
 };
 
 MIM.init_debug = function ()