void _Insert(string s) { Debug.Assert(InsertInControl == Panels.Editor.ZActiveDoc); if (!CodeInfo.GetDocumentAndFindToken(out var cd, out var token)) { return; } if (true != token.IsInString(cd.pos, cd.code, out var si)) { return; } var code = cd.code; var pos = cd.pos; var sci = cd.sci; int from = si.textSpan.Start, to = si.textSpan.End; switch (s) { case "text": _AddArg(", \"!\b\""); return; case "html": _AddArg(", \"%\b\""); return; case "sleepMs": _AddArg(", 100"); return; case "keyCode": _AddArg(", KKey.Left"); return; case "scanCode": _AddArg(", new KKeyScan(1, false)"); return; case "action": _AddArg(", new Action(() => { mouse.rightClick(); })"); return; } void _AddArg(string s) { int stringEnd = si.stringNode.Span.End; if (to == stringEnd) { s = "\"" + s; } sci.zGoToPos(true, stringEnd); InsertCode.TextSimplyInControl(sci, s); } bool addArg = code[from] is '!' or '%' || code[from..pos].Contains('^'); if (s.Length == 2 && s[0] != '#' && !s[0].IsAsciiAlpha()) { s = s[0] == '\\' ? "|" : s[..1]; //eg 2@ or /? or \|
protected override void OnLoad(EventArgs e) { for (int i = 0; i < 2; i++) { var c = i == 0 ? this.Control1 : this.Control2; c.ZTags.AddStyleTag(".r", new SciTags.UserDefinedStyle { textColor = 0xf08080 }); //red regex c.ZTags.AddLinkTag("+p", o => CurrentTopic = o); //link to a local info topic c.ZTags.SetLinkStyle(new SciTags.UserDefinedStyle { textColor = 0x0080FF, underline = false }); //remove underline from links c.Call(Sci.SCI_SETWRAPSTARTINDENT, 4); } this.Control2.ZTags.AddStyleTag(".h", new SciTags.UserDefinedStyle { backColor = 0xC0E0C0, bold = true, eolFilled = true }); //topic header this.Control2.ZTags.AddLinkTag("+a", o => InsertCode.TextSimplyInControl(InsertInControl, o)); //link that inserts a regex token _SetTocText(); CurrentTopic = "help"; }