+ this.title = title;
+ }
+
+ public State (MInputMethod im, XmlNode node)
+ {
+ this.name = node.Attributes[Qsname].Value;
+ XmlAttribute attr = node.Attributes[Qtitle];
+ if (attr != null)
+ title = (MText) attr.Value;
+ keymap = new Keymap ();
+ for (node = node.FirstChild; node != null; node = node.NextSibling)
+ {
+ if (node.Name == Qstate_hook)
+ enter_actions = Xex.ParseTerms (im.domain, node.FirstChild);
+ else if (node.Name == Qcatch_all_branch)
+ fallback_actions = Xex.ParseTerms (im.domain, node.FirstChild);
+ else if (node.Name == Qbranch)
+ {
+ MSymbol mapname = node.Attributes[Qmname].Value;
+ Map map;
+ if (im.maps.TryGetValue (mapname, out map))
+ keymap.AddMap (map, Xex.ParseTerms (im.domain,
+ node.FirstChild));
+ else
+ throw new Exception ("Unknown map: " + mapname);
+ }
+ }
+ }
+
+ public State (MInputMethod im, MPlist plist)
+ {
+ if (! plist.IsSymbol)
+ throw new Exception ("Invalid state: " + plist);
+ this.name = plist.Symbol.Name;
+ plist = plist.next;
+ if (plist.IsMText)
+ {
+ this.title = plist.Text;
+ plist = plist.next;
+ }
+ keymap = new Keymap ();
+ for (; ! plist.IsEmpty; plist = plist.next)
+ {
+ if (! plist.IsPlist)
+ throw new Exception ("Invalid branch: " + plist);
+ MPlist p = plist.Plist;
+ if (! p.IsSymbol)
+ throw new Exception ("Invalid branch: " + p);
+ MSymbol mapname = p.Symbol;
+ if (mapname == MSymbol.t)
+ enter_actions = im.parse_actions (p.next);
+ else if (mapname == MSymbol.nil)
+ fallback_actions = im.parse_actions (p.next);
+ else
+ {
+ Map map;
+ if (im.maps.TryGetValue (mapname, out map))
+ keymap.AddMap (map, im.parse_actions (p.next));
+ else
+ throw new Exception ("Unknown map: " + mapname);
+ }
+ }