{
public class MInputMethod
{
+ internal static MExpression.Domain domain = new MExpression.Domain (null);
+
private static MSymbol Minput_method = MSymbol.Of ("input-method");
private static MSymbol Mdescription = MSymbol.Of ("description");
private static MSymbol Mvariable = MSymbol.Of ("variable");
private static Dictionary<MDatabase.Tag, MInputMethod> im_table
= new Dictionary<MDatabase.Tag, MInputMethod> ();
- private static MExpression.FunctionTable global_table
- = new MExpression.FunctionTable ();
-
public readonly MSymbol language;
public readonly MSymbol name;
public readonly MSymbol subname;
- internal MExpression.FunctionTable local_table
- = new MExpression.FunctionTable (global_table);
internal MDatabase mdb;
internal MText description;
internal MText title;
static MInputMethod ()
{
- MExpression.Defun (global_table, "insert",
- new MExpression.Evaluator (insert),
- 1, 1, typeof (MExpression));
- MExpression.Defun (global_table, "candidates",
- new MExpression.Evaluator (insert_candidates),
- 1, 1, typeof (object));
- MExpression.Defun (global_table, "delete",
- new MExpression.Evaluator (delete),
- 1, 1, typeof (object));
- MExpression.Defun (global_table, "select",
- new MExpression.Evaluator (select),
- 1, 1, typeof (object));
- MExpression.Defun (global_table, "show",
- new MExpression.Evaluator (show),
- 0, 0);
- MExpression.Defun (global_table, "hide",
- new MExpression.Evaluator (hide),
- 0, 0);
- MExpression.Defun (global_table, "move",
- new MExpression.Evaluator (move),
- 1, 1, typeof (object));
- MExpression.Defun (global_table, "mark",
- new MExpression.Evaluator (mark),
- 1, 1, typeof (MSymbol));
- MExpression.Defun (global_table, "pushback",
- new MExpression.Evaluator (pushback),
- 1, 1, typeof (object));
- MExpression.Defun (global_table, "pop",
- new MExpression.Evaluator (pop),
- 0, 0);
- MExpression.Defun (global_table, "undo",
- new MExpression.Evaluator (undo),
- 0, 1, typeof (object));
- MExpression.Defun (global_table, "commit",
- new MExpression.Evaluator (commit),
- 0, 0);
- MExpression.Defun (global_table, "unhandle",
- new MExpression.Evaluator (unhandle),
- 0, 0);
- MExpression.Defun (global_table, "shift",
- new MExpression.Evaluator (shift),
- 1, 1, typeof (MSymbol));
- MExpression.Defun (global_table, "call",
- new MExpression.Evaluator (call),
- 2, -1, typeof (MSymbol), typeof (MSymbol),
- typeof (object));
+ domain.Defun ("insert", new MExpression.Evaluator (insert), 1, 1);
+ domain.Defun ("candidates", new MExpression.Evaluator (insert_candidates),
+ 1, 1);
+ domain.Defun ("delete", new MExpression.Evaluator (delete), 1, 1);
+ domain.Defun ("select", new MExpression.Evaluator (select), 1, 1);
+ domain.Defun ("show", new MExpression.Evaluator (show), 0, 0);
+ domain.Defun ("hide", new MExpression.Evaluator (hide), 0, 0);
+ domain.Defun ("move", new MExpression.Evaluator (move), 1, 1);
+ domain.Defun ("mark", new MExpression.Evaluator (mark), 1, 1);
+ domain.Defun ("pushback", new MExpression.Evaluator (pushback), 1, 1);
+ domain.Defun ("pop", new MExpression.Evaluator (pop), 0, 0);
+ domain.Defun ("undo", new MExpression.Evaluator (undo), 0, 1);
+ domain.Defun ("commit", new MExpression.Evaluator (commit), 0, 0);
+ domain.Defun ("unhandle", new MExpression.Evaluator (unhandle), 0, 0);
+ domain.Defun ("shift", new MExpression.Evaluator (shift), 1, 1);
+ domain.Defun ("call", new MExpression.Evaluator (call), 2, -1);
}
private MInputMethod (MDatabase.Tag tag)
if (target_type == Mmacro)
{
if (target_name == MSymbol.nil)
- im.local_table.Copy (local_table);
+ im.domain.Copy (local_table);
else
im.local_table.Copy (target_name, local_table);
}
adjust_markers (ic, from, to, mt);
}
- private static object insert (object[] args, MPlist bindings,
- object context)
+ private static object insert (MExpression[] args,
+ MExpression.Domain domain)
{
- MInputContext ic = (MInputContext) context;
- object arg = ((MExpression) args[0]).Eval (bindings, ic);
+ MInputContext ic = (MInputContext) domain.context;
+ object arg = args[0].val;
if (arg is int)
preedit_replace (ic, ic.cursor_pos, ic.cursor_pos, (int) arg);
}
}
- private static object insert_candidates (object[] args, MPlist bindings,
- object context)
+ private static object insert_candidates (MExpression[] args,
+ MExpression.Domain domain)
{
- MInputContext ic = (MInputContext) context;
+ MInputContext ic = (MInputContext) domain.context;
MPlist list = (MPlist) args[0];
int column = 0;
- MPlist slot = (MPlist) bindings.Find (Mcandidates_group_size);
- if (slot != null)
- column = slot.Integer;
+ if (domain.IsBound (Mcandidates_group_size))
+ {
+ object val = domain.GetValue (Mcandidates_group_size);
+ if (val is int)
+ column = (int) val;
+ }
Candidates candidates = new Candidates (list, column);
candidates.Update (ic);
return 1;
}
- private static object select (object[] args, MPlist bindings,
- object context)
+ private static object select (MExpression[] args,
+ MExpression.Domain domain)
{
- MInputContext ic = (MInputContext) context;
- object arg = args[0];
+ MInputContext ic = (MInputContext) domain.context;
+ object arg = args[0].val;
if (ic.candidates == null)
return 0;
return 0;
}
- private static object delete (object[] args, MPlist bindings,
- object context) { return 1; }
- private static object show (object[] args, MPlist bindings,
- object context) { return 1; }
- private static object hide (object[] args, MPlist bindings,
- object context) { return 1; }
- private static object move (object[] args, MPlist bindings,
- object context) { return 1; }
- private static object mark (object[] args, MPlist bindings,
- object context) { return 1; }
- private static object pushback (object[] args, MPlist bindings,
- object context) { return 1; }
- private static object pop (object[] args, MPlist bindings,
- object context) { return 1; }
- private static object undo (object[] args, MPlist bindings,
- object context) { return 1; }
- private static object commit (object[] args, MPlist bindings,
- object context) { return 1; }
- private static object unhandle (object[] args, MPlist bindings,
- object context) { return 1; }
- private static object shift (object[] args, MPlist bindings,
- object context) { return 1; }
- private static object call (object[] args, MPlist bindings,
- object context) { return 1; }
+ private static object delete (MExpression[] args, MExpression.Domain domain)
+ {
+ return 1;
+ }
+
+ private static object show (MExpression[] args, MExpression.Domain domain)
+ { return 1; }
+ private static object hide (MExpression[] args, MExpression.Domain domain)
+ { return 1; }
+ private static object move (MExpression[] args, MExpression.Domain domain)
+ { return 1; }
+ private static object mark (MExpression[] args, MExpression.Domain domain)
+ { return 1; }
+ private static object pushback (MExpression[] args, MExpression.Domain domain)
+ { return 1; }
+ private static object pop (MExpression[] args, MExpression.Domain domain)
+ { return 1; }
+ private static object undo (MExpression[] args, MExpression.Domain domain)
+ { return 1; }
+ private static object commit (MExpression[] args, MExpression.Domain domain)
+ { return 1; }
+ private static object unhandle (MExpression[] args, MExpression.Domain domain)
+ { return 1; }
+ private static object shift (MExpression[] args, MExpression.Domain domain)
+ { return 1; }
+ private static object call (MExpression[] args, MExpression.Domain domain)
+ { return 1; }
}
public class MInputContext
private MText following_text;
private bool key_unhandled;
+ internal MExpression.Domain domain;
+
+ public MInputContext (MInputMethod im)
+ {
+ this.im = im;
+ domain = new MExpression (this);
+ }
+
internal object GetCandidates (out int column)
{
column = 0;