private static MSymbol Mvariable = "variable";
private static MSymbol Mcommand = "command";
private static MSymbol Mmodule = "module";
- private static MSymbol Mmodule_list = "module-list";
private static MSymbol Mtitle = "title";
private static MSymbol Minclude = "include";
private static MSymbol Mmacro = "macro";
- private static MSymbol Mmacro_list = "macro-list";
private static MSymbol Mmap = "map";
private static MSymbol Mmap_list = "map-list";
private static MSymbol Mstate = "state";
- private static MSymbol Mstate_list = "state-list";
internal static MSymbol Mcandidates = "candidates";
private static MSymbol Minsert = "insert";
private static MSymbol Mdelete = "delete";
internal static MInputMethod im_global = null;
- // Sub classes
- private class Exception : System.Exception
- {
- bool error;
-
- public Exception (string msg) : base (msg)
- {
- error = true;
- }
-
- public Exception (string fmt, params object[] args)
- : base (String.Format (fmt, args))
- {
- error = true;
- }
-
- public Exception (string msg, bool error) : base (msg)
- {
- this.error = error;
- }
- }
-
[FlagsAttribute]
private enum LoadStatus
{
List<MDatabase> list = MDatabase.List (tag);
M17n.DebugPrint ("Found {0} input methods\n", list.Count);
foreach (MDatabase mdb in list)
- {
- im_table[mdb.tag] = new MInputMethod (mdb.tag);
- }
- tag = new MDatabase.Tag (Minput_method, MSymbol.t, MSymbol.nil, "global");
- im_global = im_table[tag];
+ im_table[mdb.tag] = new MInputMethod (mdb.tag);
}
// Constructor
}
}
+ private Xex.Variable get_global_var (Xex.Symbol name)
+ {
+ if (im_global == null || this != im_global)
+ {
+ tag = new MDatabase.Tag (Minput_method, MSymbol.t, MSymbol.nil,
+ "global");
+ im_global = im_table[tag];
+ if (! im_global.Open ())
+ throw new Exception ("Failed to load global");
+ }
+ return im_global.domain.GetVar (name, false);
+ }
+
private void parse_variables (MPlist plist)
{
var_names = new Xex.Symbol[plist.Count];
var_names[i] = name;
p = p.next;
string desc = (string) parse_description (p);
- Xex.Variable vari
- = im_global != null ? im_global.domain.GetVar (name, false) : null;
+ Xex.Variable vari = get_global_var (name);
if (vari != null)
domain.Defvar (vari);
if (desc != null)
for (int i = 0; i < node_list.Count; i++)
{
Xex.Symbol name = node_list[i].Attributes[0].Value;
- Xex.Variable vari = im_global.domain.GetVar (name, false);
-
+ Xex.Variable vari = get_global_var (name);
if (vari != null)
domain.Defvar (vari);
else
private MText produced;
private bool active;
private MText status;
- private bool status_changed;
internal MText preedit;
- private bool preedit_changed;
internal int cursor_pos;
- private bool cursor_pos_changed;
private Candidates candidates;
private MPlist candidate_group;
private int candidate_index;
private int candidate_from, candidate_to;
private bool candidate_show;
- private bool candidate_changed;
private Stack<MInputMethod.State> states;
internal MInputMethod.KeySeq keys;
internal Xex.Domain domain;
+ [FlagsAttribute]
+ public enum ChangedStatus
+ {
+ None = 0x00,
+ StateTitle = 0x01,
+ Preedit = 0x02,
+ CursorPos = 0x04,
+ CandidateList = 0x08,
+ CandidateIndex = 0x10,
+ CandidateShow = 0x20,
+ }
+
+ private static ChangedStatus CandidateAll = (ChangedStatus.CandidateList
+ | ChangedStatus.CandidateIndex
+ | ChangedStatus.CandidateShow);
+ private ChangedStatus changed;
+
+ public ChangedStatus Changed { get { return changed; } }
+
public MInputContext (MInputMethod im)
{
this.im = im;
preedit_replace (cursor_pos, cursor_pos, arg.Intval);
else
preedit_replace (cursor_pos, cursor_pos, new MText (arg.Strval));
- preedit_changed = true;
- cursor_pos_changed = true;
+ changed |= ChangedStatus.Preedit | ChangedStatus.CursorPos;
}
private class Candidates
{
ic.preedit.PopProp (0, ic.preedit.Length, MInputMethod.Mcandidates);
ic.candidates = null;
- ic.preedit_changed = true;
- ic.cursor_pos_changed = true;
- ic.candidate_changed = true;
+ ic.changed |= (ChangedStatus.Preedit | ChangedStatus.CursorPos
+ | CandidateAll);
}
// Fill the array "group" by candidates stating from INDEX.
preedit.PushProp (candidate_from, candidate_to,
MInputMethod.Mcandidates, this);
cursor_pos = candidate_from;
- preedit_changed = true;
- cursor_pos_changed = true;
- candidate_changed = true;
+ changed |= (ChangedStatus.Preedit | ChangedStatus.CursorPos
+ | CandidateAll);
}
internal void insert_candidates (Xex.Term arg)
preedit_replace (pos, cursor_pos, null);
else
preedit_replace (cursor_pos, pos, null);
- preedit_changed = true;
- cursor_pos_changed = true;
+ changed |= ChangedStatus.Preedit | ChangedStatus.CursorPos;
}
internal void show ()
{
candidate_show = true;
- candidate_changed = true;
+ changed |= ChangedStatus.CandidateShow;
}
internal void hide ()
{
candidate_show = false;
- candidate_changed = true;
+ changed |= ChangedStatus.CandidateShow;
}
internal void move (int pos)
if (pos != cursor_pos)
{
cursor_pos = pos;
- preedit_changed = true;
+ changed |= ChangedStatus.Preedit;
}
}
{
produced.Cat (preedit);
preedit.Del ();
- preedit_changed = true;
+ changed |= ChangedStatus.Preedit;
}
internal void shift (MSymbol sym)
status = state.title;
if (status == null)
status = im.title;
- status_changed = true;
+ changed |= ChangedStatus.StateTitle;
Xex on_entry
= (Xex) state.branches.Get (MSymbol.t);
if (on_entry != null)
internal void HandleKey ()
{
- MInputMethod.State state = states.Peek ();
+ }
-
+ public bool Toggle ()
+ {
+ active = ! active;
+ return active;
}
}
}