protected override void ColorizeLine(ICSharpCode.AvalonEdit.Document.DocumentLine line) { if (!line.IsDeleted && line.LineNumber == lineNumber) { ChangeLinePart(line.Offset, line.EndOffset, ApplyChanges); } }
public void SetPosition(int line, int position) { textEditor.Select(line, position); ICSharpCode.AvalonEdit.Document.DocumentLine doc_line = textEditor.TextArea.Document.GetLineByNumber(line); textEditor.CaretOffset = doc_line.Offset + position; textEditor.ScrollTo(line, position); }
public override void Execute(TextCompletionEngine textCompletionEngine, TextArea textArea) { textArea.GetSelectionBounds(out int startLine, out int endLine); int startOffset = textArea.Document.GetOffset(startLine, 0); textArea.Document.UndoStack.StartUndoGroup(); try { for (int i = startLine; i <= endLine; i++) { ICSharpCode.AvalonEdit.Document.DocumentLine line = textArea.Document.GetLineByNumber(i); string lineText = textArea.Document.GetText(line.Offset, line.Length); if (lineText.StartsWith(Prefix)) { textArea.Document.Remove(line.Offset, Prefix.Length); } } ICSharpCode.AvalonEdit.Document.DocumentLine endDocumentLine = textArea.Document.GetLineByNumber(endLine); textArea.Selection = Selection.Create(textArea, startOffset, endDocumentLine.EndOffset); } finally { textArea.Document.UndoStack.EndUndoGroup(); } }
protected override void ColorizeLine(ICSharpCode.AvalonEdit.Document.DocumentLine line) { if (!line.IsDeleted && line.LineNumber == _lineNumber) { ChangeLinePart(_fromPos, _toPos, ApplyChanges); } }
/// <summary> /// Get current Gherkin language setting by scanning first 5 lines /// </summary> /// <param name="document"></param> /// <returns>language defined in tag or English as default language</returns> public static string CurrentLanguage(ICSharpCode.AvalonEdit.Document.TextDocument document) { var location = new Ast.Location(); ICSharpCode.AvalonEdit.Document.DocumentLine line = document.GetLineByNumber(1); while (line != null) { string line_text = document.GetText(line.Offset, line.TotalLength); Token token = new Token(new GherkinLine(line_text, line.LineNumber), location); try { if (s_TokenMatcher.Match_Language(token) && IsSupported(token.MatchedText)) { return(token.MatchedText); } if (line.LineNumber > 5) { return(DEFAULT_LANGUAGE); } line = line.NextLine; } catch { return(DEFAULT_LANGUAGE); } } return(DEFAULT_LANGUAGE); }
protected override void ColorizeLine(ICSharpCode.AvalonEdit.Document.DocumentLine line) { if (!line.IsDeleted) { if (lines != null) { if (lines.Count > 0) { if (lines.BinarySearch(line.LineNumber) >= 0) { return; } } } string text = editorWindow.textEditor.Document.Text.Substring(line.Offset, line.EndOffset - line.Offset); var testusing = text.Trim(); if (line.obs != null && testusing.StartsWith(" Reference")) //editorWindow.Errors[0].Location.SourceSpan.Start { ChangeLinePart(line.Offset, line.EndOffset, ApplyChanges); } else { SortedSet <int> sc = editorWindow.sc; Dictionary <int, string> dc = editorWindow.dc; if (sc.Count <= 0) { return; } if (testusing.StartsWith("using")) { ChangeLinePart(line.Offset + 5, line.EndOffset, ApplyChangesForUsing); return; } if (testusing.StartsWith("//")) { return; } var matches = Regex.Matches(text, @"\b[a-zA-Z]{2,}\b"); foreach (Match s in matches) { if (sc.Contains(s.Value.GetHashCode())) { ChangeLinePart(line.Offset + s.Index, line.Offset + s.Index + s.Length, ApplyChangesForType); } } } } }
protected override void ColorizeLine(ICSharpCode.AvalonEdit.Document.DocumentLine line) { if (line.LineNumber == LineNum) { ChangeLinePart(line.Offset, line.EndOffset, (element) => { element.TextRunProperties.SetBackgroundBrush(Brushes.Moccasin); }); } }
/// <summary> /// Select the given line in the text view. /// </summary> /// <param name="lineNumber">The line number to select. zero based.</param> public void SelectLine(int lineNumber) { if (lineNumber >= 0 && lineNumber < textEditor.Document.Lines.Count) { ICSharpCode.AvalonEdit.Document.DocumentLine line = textEditor.Document.Lines[lineNumber]; textEditor.Select(line.Offset, line.Length); tabControlContent.SelectedItem = tabItemLogText; textEditor.ScrollToLine(lineNumber); } }
//public KnownLayer Layer => throw new NotImplementedException(); public void Draw(ICSharpCode.AvalonEdit.Rendering.TextView textview, DrawingContext drawingcontext) { if (_editor.Document == null || textview.ActualWidth <= 32) { return; } textview.EnsureVisualLines(); ICSharpCode.AvalonEdit.Document.DocumentLine currentline = _editor.Document.GetLineByOffset(_editor.CaretOffset); foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textview, currentline)) { drawingcontext.DrawRectangle(new SolidColorBrush(System.Windows.Media.Color.FromArgb(25, 255, 255, 255)), null, new System.Windows.Rect(rect.Location, new System.Windows.Size(textview.ActualWidth - 32, rect.Height))); } }
protected override bool ContextIsSatisfied(ExpressionEvaluator evaluator, TextArea textArea) { textArea.GetSelectionBounds(out int startLine, out int endLine); for (int i = startLine; i <= endLine; i++) { ICSharpCode.AvalonEdit.Document.DocumentLine line = textArea.Document.GetLineByNumber(i); string lineText = textArea.Document.GetText(line.Offset, line.Length); if (!string.IsNullOrWhiteSpace(lineText) && !lineText.StartsWith("//")) { return(false); } } return(true); }
protected override void ColorizeLine(ICSharpCode.AvalonEdit.Document.DocumentLine line) { string lineText = CurrentContext.Document.GetText(line); var match = Regex.Match(lineText, "^(.*)>", RegexOptions.Multiline); if (match.Success) { var path = match.Groups[0].Value; path = path.Remove(path.Length - 1); if (Directory.Exists(path)) { ChangeLinePart(line.Offset, line.Offset + path.Length + 1, ApplyChanges); } } }
protected override void ColorizeLine(ICSharpCode.AvalonEdit.Document.DocumentLine line) { if (line.LineNumber - 1 >= _chunkDiff.Changes.Count) { return; } var change = _chunkDiff.Changes[line.LineNumber - 1]; if (!line.IsDeleted && (change.Type == LineChangeType.Add || change.Type == LineChangeType.Delete)) { ChangeLinePart(line.Offset, line.EndOffset, el => { el.TextRunProperties.SetForegroundBrush(Brushes.Black); }); } }
protected override void ColorizeLine(ICSharpCode.AvalonEdit.Document.DocumentLine line) { if (string.IsNullOrWhiteSpace(TextToHighlight)) { return; } int lineStartOffset = line.Offset; string text = CurrentContext.Document.GetText(line); int start = 0; int index; while ((index = text.IndexOf(TextToHighlight, start, StringComparison.CurrentCultureIgnoreCase)) >= 0) { base.ChangeLinePart( lineStartOffset + index, // startOffset lineStartOffset + index + TextToHighlight.Length, // endOffset ApplyChanges); start = index + 1; // search for next occurrence } }
/// <summary> /// Scroll to correct line in the editor. This could be called from a DispatcherTimer. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GotoDefinition_ScrollToLine(object sender = null, EventArgs e = null) { var timer = sender as DispatcherTimer; if (timer != null) { timer.Stop(); } var args = _gotoDefinitionArgs; if (CodeTextEditor != null) { if (args.LineNumber != -1) { ICSharpCode.AvalonEdit.Document.DocumentLine line = CodeTextEditor.Document.GetLineByNumber(args.LineNumber); CodeTextEditor.Select(line.Offset, line.Length); CodeTextEditor.CaretOffset = line.Offset; CodeTextEditor.ScrollToLine(args.LineNumber); CodeTextEditor.Focus(); } } }
public override void IndentLine(ICSharpCode.AvalonEdit.Document.TextDocument document, ICSharpCode.AvalonEdit.Document.DocumentLine line) { if (CodeEditorOptions.Instance.UseSmartIndentation) { base.IndentLine(document, line); } else { new DefaultIndentationStrategy().IndentLine(document, line); } }
protected override void ColorizeLine(ICSharpCode.AvalonEdit.Document.DocumentLine line) { }