using System.Collections.Generic;
using System.IO;
using System.Xml;
-using System.Xml.Expression;
using M17N;
using M17N.Core;
using M17N.Input;
-using Xex = System.Xml.Expression.Xexpression;
+using Xex = System.Xml.Xexpression;
public class Test
{
public static void Main(string[] args)
{
- //M17n.debug = true;
- Xex.debug_level = 10;
- MDatabase.ApplicationDir = "/usr/local/share/m17n-xml";
- MInputMethod im = MInputMethod.Find ("zh", "py-b5");
- MInputMethod.Context ic = new MInputMethod.Context (im);
- MText str = args[0];
+ // M17n.debug = true;
+ // Xex.DebugDepth = 10;
+ int argc = 0;
+ if (args[0] == "xml")
+ {
+ MDatabase.ApplicationDir = "/usr/local/share/m17n-xml";
+ argc++;
+ }
+ else
+ MDatabase.ApplicationDir = "/usr/local/share/m17n";
+ MInputMethod im = MInputMethod.Find (args[argc], args[argc + 1]);
+ MText mt = new MText ();
+ MInputMethod.Session session = new MInputMethod.Session (im, mt, 0);
+
+ MText str = args[argc + 2];
for (int i = 0; i < str.Length; i++)
- ic.Filter (new MInputMethod.Key (str[i]));
+ {
+ MInputMethod.Key key = new MInputMethod.Key (str[i]);
+ session.HandleKey (key);
+ int pos = session.CurrentPos;
+ Console.WriteLine ("{0} -> \"{1}|{2}|{3}\"",
+ str[i, i + 1],
+ mt[0, pos],
+ session.Preedit,
+ mt[pos, mt.Length]);
+ }
}
}