/// <summary> /// Selects the source source text corresponding to the provided error node. /// </summary> /// <param name="codeEditor">The code editor.</param> /// <param name="node">The error node.</param> /// <exception cref="T:System.ArgumentNullException"><paramref name="codeEditor"/> is <see langword="null"/></exception> public static void SelectSource([NotNull] this FastColoredTextBox codeEditor, ErrorNodeImpl node) { if (codeEditor is null) { throw new ArgumentNullException(nameof(codeEditor)); } if (node == null) { return; } var startingPlace = new Place(node.Symbol.Column, node.Symbol.Line - 1); Place stoppingPlace; if (node.Symbol.StartIndex != -1) { var spot = node.Symbol.GetEndPlace(); stoppingPlace = new Place(spot.Position + 1, spot.Line - 1); } else { stoppingPlace = startingPlace; } codeEditor.Selection = new Range(codeEditor, startingPlace, stoppingPlace); codeEditor.DoCaretVisible(); }
public static void SelectText(string target, FastColoredTextBox editor) { int index = Match(editor.Text, $@"(?<=\n)\({target}\)").Index; //finding the goto destination Range range = editor.GetRange(index + target.Length + 2, index + target.Length + 2); editor.Selection = new Range(editor, range.Start.iLine); editor.DoCaretVisible(); }
public static void SelectText(string target, FastColoredTextBox editor) { int index = Match(editor.Text, $@"(?<=\n)\({target}\)").Index; //finding the goto destination Range range = editor.GetRange(index + target.Length + 2, index + target.Length + 2); editor.Selection = new Range(editor, range.Start.iLine); editor.DoCaretVisible(); }
public static void ScrollToBottom(FastColoredTextBox tb) { if (tb.Lines.Count > 0) { tb.Selection.Start = new Place(tb.Lines.Count, tb.Lines.Count - 1); } else { tb.Selection.Start = new Place(0, 0); } tb.DoCaretVisible(); }
/// <summary> /// Selects the source source text corresponding to the provided token. /// </summary> /// <param name="codeEditor">The code editor.</param> /// <param name="token">The token.</param> /// <exception cref="T:System.ArgumentNullException"><paramref name="codeEditor"/> is <see langword="null"/></exception> public static void SelectSource([NotNull] this FastColoredTextBox codeEditor, IToken token) { if (codeEditor is null) { throw new ArgumentNullException(nameof(codeEditor)); } if (token == null) { return; } var startingPlace = new Place(token.Column, token.Line - 1); var spot = token.GetEndPlace(); var stoppingPlace = new Place(spot.Position + 1, spot.Line - 1); codeEditor.Selection = new Range(codeEditor, startingPlace, stoppingPlace); codeEditor.DoCaretVisible(); }
/// <summary> /// Selects the source source text corresponding to the provided parser rule context. /// </summary> /// <param name="codeEditor">The code editor.</param> /// <param name="context">The parser rule context.</param> /// <exception cref="T:System.ArgumentNullException"><paramref name="codeEditor"/> is <see langword="null"/></exception> public static void SelectSource([NotNull] this FastColoredTextBox codeEditor, ParserRuleContext context) { if (codeEditor is null) { throw new ArgumentNullException(nameof(codeEditor)); } if (context == null) { return; } var startingPlace = new Place(context.Start.Column, context.start.Line - 1); var stopToken = context.Stop ?? context.Start; var spot = stopToken.GetEndPlace(); var stoppingPlace = new Place(spot.Position + 1, spot.Line - 1); codeEditor.Selection = new Range(codeEditor, startingPlace, stoppingPlace); codeEditor.DoCaretVisible(); }
public static void Select(Place placeStart, Place placeEnd, FastColoredTextBox editor) { editor.Selection = new Range(editor, placeStart, placeEnd); editor.DoCaretVisible(); }
public static void Select(Place placeStart, Place placeEnd, FastColoredTextBox editor) { editor.Selection = new Range(editor, placeStart, placeEnd); editor.DoCaretVisible(); }
/// <summary> /// Scrolls the contents of the control to the current caret position. /// </summary> public void ScrollToCaret() { FastColoredTextBox.DoCaretVisible(); }
/// <summary> /// Selects a range of text in the text box. /// </summary> /// <param name="start">The starting position.</param> /// <param name="length">The length of the selection.</param> public void Select(int start, int length) { FastColoredTextBox.SelectionStart = start; FastColoredTextBox.SelectionLength = length; FastColoredTextBox.DoCaretVisible(); }