private static MSymbol Mstate = "state";
internal static MSymbol Mcandidates = "candidates";
private static MSymbol Minsert = "insert";
+ internal static MSymbol Mselect = "select";
private static MSymbol Mdelete = "delete";
private static MSymbol Mmove = "move";
private static MSymbol Mmark = "mark";
private static MSymbol Mkeyseq = "keyseq";
private static Xex.Symbol Nprogn = "progn";
+ private static Xex.Symbol Ninsert = "insert";
+ private static Xex.Symbol Ninsert_candidates = "insert-candidates";
+ private static Xex.Symbol Nchar_at = "char-at";
+
private static Xex.Term Tnil = new Xex.Term ((Xex.Symbol) "nil");
private static Xex.Term Tcatch_tag = new Xex.Term ((Xex.Symbol) "@mimtag");
public abstract int Position (Context ic);
public abstract void Mark (Context ic);
+ public abstract int CharAt (Context ic);
public static Xex.TermValue parser (Xex.Domain domain, XmlNode node)
{
}
}
+ public class PredefinedPlusMinus : Marker
+ {
+ private int distance;
+
+ public PredefinedPlusMinus (MSymbol name): base (name)
+ {
+ if (! int.TryParse (name.Name.Substring (2), out distance))
+ throw new Exception ("Invalid marker name: " + name);
+ if (distance > 0)
+ distance--;
+ }
+
+ public override int Position (Context ic)
+ {
+ return ic.cursor_pos + distance;
+ }
+ }
+
static internal Dictionary<MSymbol,Predefined> predefined_markers;
static Marker ()
if (predefined_markers.TryGetValue (name, out pred))
return pred;
if (name.Name[0] == '@')
- throw new Exception ("Invalid marker name: " + name);
+ {
+ int pos;
+ if (name.Name.Length >= 3
+ && (name.Name[1] == '-' || name.Name[1] == '+')
+ && int.TryParse (name.Name.Substring (2), out pos)
+ && (pos > 0))
+ return (predefined_markers[name] = new Predefined (name));
+ else
+ throw new Exception ("Invalid marker name: " + name);
+ }
return new Named (name);
}
}
im_domain.DefSubr (Fcommit, "commit", false, 0, 0);
im_domain.DefSubr (Funhandle, "unhandle", false, 0, 0);
im_domain.DefSubr (Fshift, "shift", false, 1, 1);
- im_domain.DefSubr (Fshift_back, "shiftback", false, 0, 0);
+ im_domain.DefSubr (Fshiftback, "shiftback", false, 0, 0);
im_domain.DefSubr (Fchar_at, "char-at", false, 1, 1);
im_domain.DefSubr (Fkey_count, "key-count", false, 1, 1);
im_domain.DefSubr (Fsurrounding_flag, "surrounding-text-flag",
else
throw new Exception ("Invalid candidates: " + pl);
}
-
+ return new Xex.Term (domain, Ninsert_candidates, args);
}
else
throw new Exception ("Invalid arg to insert: " + plist);
args[0] = new Xex.Term (Selector.Get (plist.Symbol));
else
args[0] = new Xex.Term (domain, (Xex.Symbol) plist.Symbol.Name);
- return new Xex.Term (domain, Nselect, args);
+ return new Xex.Term (domain, (Xex.Symbol) Mselect.Name, args);
}
private Xex.Term parse_funcall_with_marker (MPlist plist, MSymbol func)
{
Xex.Term[] args = new Xex.Term[1];
- if (plist.IsInteger && func != Nmark)
+ if (plist.IsInteger && func != Mmark)
args[0] = new Xex.Term (plist.Integer);
else if (plist.IsSymbol)
args[0] = new Xex.Term (Marker.Get (plist.Symbol));
private Xex.Term parse_char_at (MSymbol name)
{
Xex.Term[] args = new Xex.Term[1];
- args[0] = Maker.Get (name);
+ args[0] = new Xex.Term (Marker.Get (name));
return new Xex.Term (domain, Nchar_at, args);
}
return args[0];
}
- private static Xex.Term Fshift_back (Xex.Domain domain, Xex.Variable vari,
+ private static Xex.Term Fshiftback (Xex.Domain domain, Xex.Variable vari,
Xex.Term[] args)
{
((Context) domain.context).shift_back ();