public static bool ReplaceChar(ViBuilderContext ctx) { if (ctx.LastKey.Char != '\0') { ctx.RunAction((ViEditor ed) => ed.Data.Replace(ed.Data.Caret.Offset, 1, ctx.LastKey.Char.ToString())); } else { ctx.SetError("Expecting a character"); } return(true); }
public static bool GoToMark(ViBuilderContext ctx) { char c = ctx.LastKey.Char; if (!char.IsLetterOrDigit (c)) { ctx.SetError ("Invalid Mark"); return true; } ctx.RunAction ((ViEditor ed) => { ViMark mark; if (ed.Marks.TryGetValue (c, out mark)) mark.LoadMark (ed.Data); else ed.Reset ("Unknown Mark"); }); return true; }
static void StartRegisterBuilder(ViBuilderContext ctx, ViBuilder nextBuilder) { if (ctx.Register != '\0') { ctx.SetError("Register already set"); return; } ctx.Builder = (ViBuilderContext x) => { char c = x.LastKey.Char; if (!ViEditor.IsValidRegister(c)) { x.SetError("Invalid register"); return(true); } x.Register = c; x.Builder = nextBuilder; return(true); }; }
public static bool Mark(ViBuilderContext ctx) { char c = ctx.LastKey.Char; if (!char.IsLetterOrDigit(c)) { ctx.SetError("Invalid Mark"); return(true); } ctx.RunAction((ViEditor ed) => { ViMark mark; if (!ed.Marks.TryGetValue(c, out mark)) { ed.Marks [c] = mark = new ViMark(c); } mark.SaveMark(ed.Data); }); return(true); }
public static bool GoToMark(ViBuilderContext ctx) { char c = ctx.LastKey.Char; if (!char.IsLetterOrDigit(c)) { ctx.SetError("Invalid Mark"); return(true); } ctx.RunAction((ViEditor ed) => { ViMark mark; if (ed.Marks.TryGetValue(c, out mark)) { mark.LoadMark(ed.Data); } else { ed.Reset("Unknown Mark"); } }); return(true); }
static void StartRegisterBuilder(ViBuilderContext ctx, ViBuilder nextBuilder) { if (ctx.Register != '\0') { ctx.SetError ("Register already set"); return; } ctx.Builder = (ViBuilderContext x) => { char c = x.LastKey.Char; if (!ViEditor.IsValidRegister (c)) { x.SetError ("Invalid register"); return true; } x.Register = c; x.Builder = nextBuilder; return true; }; }
public static bool ReplaceChar(ViBuilderContext ctx) { if (ctx.LastKey.Char != '\0') ctx.RunAction ((ViEditor ed) => ed.Data.Replace (ed.Data.Caret.Offset, 1, ctx.LastKey.Char.ToString ())); else ctx.SetError ("Expecting a character"); return true; }
public static bool Mark(ViBuilderContext ctx) { char c = ctx.LastKey.Char; if (!char.IsLetterOrDigit (c)) { ctx.SetError ("Invalid Mark"); return true; } ctx.RunAction ((ViEditor ed) => { ViMark mark; if (!ed.Marks.TryGetValue (c, out mark)) ed.Marks [c] = mark = new ViMark (c); mark.SaveMark (ed.Data); }); return true; }