2 using System.Collections.Generic;
8 using Xex = System.Xml.Xexpression;
12 private static void print (char key, MText head, MText preedit, MText tail)
14 Console.Write ("{0} -> \"{1}|{2}|{3}\" (", key, head, preedit, tail);
15 for (int j = 0; j < head.Length; j++)
16 Console.Write ("{0}U+{1:X4}", j == 0 ? "(" : " ", head[j]);
19 for (int j = 0; j < preedit.Length; j++)
20 Console.Write ("{0}U+{1:X4}", j == 0 ? "" : " ", preedit[j]);
22 for (int j = 0; j < tail.Length; j++)
23 Console.Write ("{0}U+{1:X4}", j == 0 ? "" : " ", tail[j]);
24 Console.WriteLine (")");
27 public static void Main(string[] args)
31 string appdir = "/usr/local/share/m17n";
34 while (argc < args.Length && args[argc][0] == '-')
36 if (args[argc] == "-trace")
38 else if (args[argc] == "-xml")
39 appdir = "/usr/local/share/m17n-xml";
42 if (argc + 2 >= args.Length)
44 Console.WriteLine ("Usage: mono [--debug] input.exe"
45 + " [-trace] [-xml] LANG NAME KEY-SEQUECE");
49 Xex.TraceDepth = trace_depth;
50 MDatabase.ApplicationDir = appdir;
51 MInputMethod im = MInputMethod.Find (args[argc], args[argc + 1]);
52 MText mt = new MText ();
53 MInputMethod.Session session = new MInputMethod.Session (im, mt, 0);
55 MText str = args[argc + 2];
56 MInputMethod.Key left = new MInputMethod.Key ("left");
57 MInputMethod.Key right = new MInputMethod.Key ("right");
59 for (int i = 0; i < str.Length; i++)
62 = (str[i] == '<' ? left
63 : str[i] == '>' ? right
64 : new MInputMethod.Key (str[i]));
65 bool result = session.HandleKey (ref key);
66 int pos = session.CurrentPos;
72 session.CurrentPos = --pos;
74 else if (key == right)
77 session.CurrentPos = ++pos;
82 session.CurrentPos = ++pos;
85 print ((char) str[i], mt[0, pos], session.Preedit, mt[pos, mt.Length]);
87 if (! session.Close ())
89 int pos = session.CurrentPos;
90 print (' ', mt[0, pos], null, mt[pos, mt.Length]);