/// <summary> /// Handle text insert and delete events. /// </summary> /// <param name="s"></param> /// <param name="e"></param> private void HandleInsertAndDelete(object s, ModificationEventArgs e) { // internal function void HandleModificationEvent(ModificationEventArgs ev) { var first = LineFromPosition(ev.Position); var last = first + ev.LinesAdded; UpdateCodeFolding(Math.Min(first, last), Math.Max(first, last)); } FxLexer.Style(this, e.Position, TextLength); // update line number margins if (e.LinesAdded != 0) { UpdateLineNumbers(); HandleModificationEvent(e); } // update code folding else if (e.Text.LastIndexOfAny(new[] { '{', '}' }) >= 0) { HandleModificationEvent(e); } }
public static void ClassInitialize(TestContext a) { Theme.DarkTheme(); code = File.ReadAllText("../../../UnitTests/data/test.tech"); lexer = new FxLexer("../../../App/resources/keywordsXML.xml"); editor = new CodeEditor(lexer, code); }
/// <summary> /// Handle mouse hover events. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AutoCMouseHover(object sender, EventArgs e) { // check if code hints are enabled if (EnableCodeHints == false) { return; } // convert cursor position to text position var mouse = PointToClient(Cursor.Position); var pos = CharPositionFromPoint(mouse.X, mouse.Y); // select keywords using the current text position // is the style at that position a valid hint style var style = GetStyleAt(pos); if (style > 0) { // is there a word at that position var word = GetWordFromPosition(pos); if (word?.Length > 0) { // get hint for keyword var hint = FxLexer.GetKeywordHint(GetStyleAt(pos), word); if (hint != null) { CallTipShow(WordStartPosition(pos, true), hint); } } } }
/// <summary> /// Show auto complete menu for the specified text position. /// </summary> /// <param name="position">The text position for which /// to show the auto complete menu</param> public void AutoCShow(int position) { var word = GetWordFromPosition(position); var keywords = FxLexer.SelectKeywords(GetStyleAt(position), word); // show auto complete list if (keywords.Count() > 0) { AutoCShow(position - WordStartPosition(position, true), keywords.OrderBy(s => s, StringComparer.CurrentCultureIgnoreCase).Cat("|")); } }
public static void ClassInitialize(TestContext a) { code = File.ReadAllText("../../../App/demos/simple.tech"); lexer = new FxLexer(); editor = new CodeEditor(code); }