bool IsCodeCoverageTextMarkerMatch(TextMarker marker) { if (marker is CodeCoverageTextMarker) { return true; } return false; }
protected override TextMarker CreateMarker() { LineSegment lineSeg = Anchor.Line; TextMarker marker = new TextMarker(lineSeg.Offset, lineSeg.Length, TextMarkerType.SolidBlock, defaultColor, Color.White); Document.MarkerStrategy.AddMarker(marker); return marker; }
protected override TextMarker CreateMarker() { LineSegment lineSeg = Document.GetLineSegment(startLine - 1); TextMarker marker = new TextMarker(lineSeg.Offset + startColumn - 1, Math.Max(endColumn - startColumn, 1), TextMarkerType.SolidBlock, Color.Yellow, Color.Blue); Document.MarkerStrategy.InsertMarker(0, marker); return marker; }
public void SetUp() { document = new DocumentFactory().CreateDocument(); document.TextContent = "0123456789"; marker = new TextMarker(3, 3, TextMarkerType.Underlined); document.MarkerStrategy.AddMarker(marker); }
public void Validate(String doc,TextArea textArea) { this.textArea = textArea; textArea.Document.MarkerStrategy.RemoveAll(p => true); XmlReaderSettings settings = new XmlReaderSettings(); settings.CloseInput = true; settings.ValidationEventHandler += new ValidationEventHandler(settings_ValidationEventHandler); // Your callback... settings.ValidationType = ValidationType.Schema; settings.Schemas.Add(schemaset); settings.ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings | XmlSchemaValidationFlags.ProcessIdentityConstraints | XmlSchemaValidationFlags.ProcessInlineSchema | XmlSchemaValidationFlags.ProcessSchemaLocation; // Wrap document in an XmlNodeReader and run validation on top of that try { using (XmlReader validatingReader = XmlReader.Create(new StringReader(doc), settings)) { while (validatingReader.Read()) { /* just loop through document */ } } } catch (XmlException e) { var offset = textArea.Document.PositionToOffset(new TextLocation(e.LinePosition, e.LineNumber)); var mk = new TextMarker(offset, 5, TextMarkerType.WaveLine, Color.DarkBlue ); mk.ToolTip = e.Message; textArea.Document.MarkerStrategy.AddMarker(mk); } }
protected override TextMarker CreateMarker() { LineSegment lineSeg = Anchor.Line; TextMarker marker = new TextMarker(lineSeg.Offset, lineSeg.Length, TextMarkerType.SolidBlock, Color.FromArgb(180, 38, 38), Color.White); return marker; }
public void BreakPoint(int start, int end, int lineStart, int colStart, int lineEnd, int colEnd) { var offset = start; var length = (end - start); var marker = new TextMarker(offset, length, TextMarkerType.SolidBlock, Color.Yellow); txtDebug.Document.MarkerStrategy.AddMarker(marker); }
void FTextEditorControl_ActiveTextAreaControl_SelectionManager_SelectionChanged(object sender, EventArgs e) { var textAreaControl = ActiveTextAreaControl; var textArea = textAreaControl.TextArea; var doc = Document; // Clear previous selection markers foreach (var marker in FSelectionMarkers) { var location = doc.OffsetToPosition(marker.Offset); doc.MarkerStrategy.RemoveMarker(marker); doc.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToLineEnd, location)); } doc.CommitUpdate(); FSelectionMarkers.Clear(); var selectionManager = textAreaControl.SelectionManager; foreach (var selection in selectionManager.SelectionCollection) { // Ignore selection spanning over multiple lines. if (selection.StartPosition.Line != selection.EndPosition.Line) { continue; } var selectedText = selection.SelectedText.Trim(); // Ignore empty strings if (selectedText == string.Empty) { continue; } for (int lineNumber = 0; lineNumber < doc.TotalNumberOfLines; lineNumber++) { var lineSegment = doc.GetLineSegment(lineNumber); // Highlight text which matches the selection foreach (var word in lineSegment.Words) { var text = word.Word; var start = text.IndexOf(selectedText); if (start >= 0) { var offset = lineSegment.Offset + word.Offset + start; var location = doc.OffsetToPosition(offset); var marker = new SD.TextMarker(offset, selectedText.Length, SD.TextMarkerType.SolidBlock, Color.LightGray); FSelectionMarkers.Add(marker); doc.MarkerStrategy.AddMarker(marker); doc.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToLineEnd, location)); } } } } doc.CommitUpdate(); }
protected void OnValidate(object _, ValidationEventArgs vae) { var offset = textArea.Document.PositionToOffset(new TextLocation(vae.Exception.LinePosition-1,vae.Exception.LineNumber-1)); var mk = new TextMarker(offset, GetWordLen(offset), TextMarkerType.WaveLine, vae.Severity == XmlSeverityType.Error ? Color.DarkBlue : Color.Green); mk.ToolTip = vae.Message; textArea.Document.MarkerStrategy.AddMarker(mk); }
protected override TextMarker CreateMarker() { if (LineNumber >= Document.TotalNumberOfLines) LineNumber = Document.TotalNumberOfLines - 1; LineSegment lineSeg = Document.GetLineSegment(LineNumber); TextMarker marker = new TextMarker(lineSeg.Offset, lineSeg.Length, TextMarkerType.SolidBlock, Color.Red, Color.White); Document.MarkerStrategy.AddMarker(marker); return marker; }
/// <summary> /// Initializes a new instance of the TextEditorTextContent class. /// This TextEditorTextContent instance will be linked with a /// TextEditorControl. /// </summary> /// <param name="textBox">The TextEditorControl to link with.</param> public TextEditorTextContext(TextEditorControl textBox) { TextBox = textBox; SubscribeToTextBox(); remoteMarker = new TextMarker(0, 0, TextMarkerType.SolidBlock, System.Drawing.Color.Yellow); // TODO: implement insert / delete }
public NiTextMarker(NiTextLines owner, TextMarker marker) { if (owner == null) throw new ArgumentNullException("owner"); if (marker == null) throw new ArgumentNullException("marker"); _owner = owner; _marker = marker; }
protected virtual void Clear() { if (readOnlyMarker != null) this.Document.MarkerStrategy.RemoveMarker(readOnlyMarker); this.Document.Remove(0, this.Document.TextLength); this.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea)); this.Document.CommitUpdate(); readOnlyMarker = null; promptStartOffset = 0; promptEndOffset = 0; }
/// <summary> /// Makes the current control content read-only (but still allows appending more content at the end). /// </summary> protected void MakeReadOnly() { if (this.Document.TextLength == 0) return; this.ActiveTextAreaControl.Caret.Position = this.Document.OffsetToPosition(this.Document.TextLength); if (readOnlyMarker == null) { readOnlyMarker = new TextMarker(0, this.Document.TextLength, TextMarkerType.Invisible) { IsReadOnly = true }; this.Document.MarkerStrategy.AddMarker(readOnlyMarker); } readOnlyMarker.Offset = 0; readOnlyMarker.Length = this.Document.TextLength; this.Document.UndoStack.ClearAll(); // prevent user from undoing the prompt insertion }
/// <summary> /// Removes the marker. /// </summary> public void RemoveMarker() { if (Document != null && _marker != null) { Document.MarkerStrategy.RemoveMarker(_marker); int from = GetLineNumberForOffset(Document, _marker.Offset); int to = GetLineNumberForOffset(Document, _marker.Offset + _marker.Length); Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.LinesBetween, from, to)); Document.CommitUpdate(); } _marker = null; }
void MouseMoveCB(object sender, System.Windows.Forms.MouseEventArgs e) { try { var doc = Document; if (FUnderlineMarker != null) { doc.MarkerStrategy.RemoveMarker(FUnderlineMarker); doc.MarkerStrategy.RemoveMarker(FHighlightMarker); var lastMarkerLocation = doc.OffsetToPosition(FUnderlineMarker.Offset); doc.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToLineEnd, lastMarkerLocation)); doc.CommitUpdate(); FUnderlineMarker = null; FHighlightMarker = null; FLink = Link.Empty; } if (Control.ModifierKeys == Keys.Control) { var location = GetTextLocationAtMousePosition(e.Location); if (!location.IsEmpty) { FLink = FLinkDataProvider.GetLink(doc, location); if (!FLink.IsEmpty) { var hoverRegion = FLink.HoverRegion; int offset = doc.PositionToOffset(hoverRegion.ToTextLocation()); int length = hoverRegion.EndColumn - hoverRegion.BeginColumn; FUnderlineMarker = new SD.TextMarker(offset, length, SD.TextMarkerType.Underlined, Document.HighlightingStrategy.GetColorFor("Link").Color); doc.MarkerStrategy.AddMarker(FUnderlineMarker); FHighlightMarker = new SD.TextMarker(offset, length, SD.TextMarkerType.SolidBlock, Document.HighlightingStrategy.GetColorFor("Default").BackgroundColor, Document.HighlightingStrategy.GetColorFor("Link").Color); doc.MarkerStrategy.AddMarker(FHighlightMarker); doc.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToLineEnd, doc.OffsetToPosition(offset))); doc.CommitUpdate(); } } } } catch (Exception) { // Ignore } }
void AddErrorMarker(List <SD.TextMarker> errorMarkers, int column, int line, Color color) { column = Math.Max(column, 0); line = Math.Max(line, 0); var doc = Document; var location = new TextLocation(column, line); var offset = doc.PositionToOffset(location); var segment = doc.GetLineSegment(location.Line); var length = segment.Length - offset + segment.Offset; var marker = new SD.TextMarker(offset, length, SD.TextMarkerType.WaveLine, color); doc.MarkerStrategy.AddMarker(marker); doc.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, segment.LineNumber)); errorMarkers.Add(marker); }
public void SetMarker(Context context) { editor.Document.MarkerStrategy.RemoveAll(m => m != null); if (Context.CurrentStatement != null) { statusBarLabel.Text = Context.CurrentStatement.ToString().Split('\n')[0].Trim(); txtOutput.Text = debugStartContext.RootContext.Interpreter.Output; LineSegment seg = editor.Document.GetLineSegment(Context.CurrentStatement.LineNumber); TextMarker marker = new TextMarker(seg.Offset + Context.CurrentStatement.ColumnNumber, seg.Length - Context.CurrentStatement.ColumnNumber, TextMarkerType.SolidBlock, Color.Yellow); editor.Document.MarkerStrategy.AddMarker(marker); editor.ActiveTextAreaControl.Caret.Position = editor.Document.OffsetToPosition(seg.Offset); tree.Nodes.Clear(); while (context.parent != null) { foreach (object key in context.Variables.Keys) addNode(null, key.ToString(), context.Variables[key]); context = context.parent; } Application.DoEvents(); this.Refresh(); } }
public void evaluate() { var reader = new SchemeReader(); var evaluator = new SchemeEvaluator(); //var ast = reader.parseString( ActiveEditor.Text ); var ast = reader.parseStringWithPos( ActiveEditor.Text, ActiveEditor.Name ); List<SchemeObject> res; try { res = evaluator.evaluate(ast); } catch (SchemeException e) { var document = codeWindow.Document; var marker = new TextMarker(e.offset, e.length, TextMarkerType.SolidBlock); document.MarkerStrategy.AddMarker(marker); var update = new TextAreaUpdate(TextAreaUpdateType.WholeTextArea); document.RequestUpdate(update); document.CommitUpdate(); int length = resultWindow.Text.Length; resultWindow.AppendText(e.Message); resultWindow.Select(length, (resultWindow.Text.Length - length)); resultWindow.SelectionColor = Color.Red; return; } // resultWindow. foreach( SchemeObject obj in res ) { resultWindow.AppendText( obj.ToString() + "\n" ); } }
void DrawMarker(Graphics g, TextMarker marker, RectangleF drawingRect) { // draw markers later so they can overdraw the following text markersToDraw.Add(new MarkerToDraw(marker, drawingRect)); }
public MarkerToDraw(TextMarker marker, RectangleF drawingRect) { this.marker = marker; this.drawingRect = drawingRect; }
public void UnderlineParseError(int startPosition, int length) { var marker = new TextMarker(startPosition, length, TextMarkerType.WaveLine, Color.Red); textBoxSource.Document.MarkerStrategy.AddMarker(marker); textBoxSource.Refresh(); }
void SetMarker() { RemoveMarker(); if (Document != null) { TextMarker marker = CreateMarker(); // Perform editor update Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, LineNumber)); Document.CommitUpdate(); oldMarker = marker; } oldDocument = Document; }
public void ClearScanRegion() { if (_region != null) { _document.MarkerStrategy.RemoveMarker(_region); _region = null; } }
private void btnHighlightAll_Click(object sender, EventArgs e) { if (!_highlightGroups.ContainsKey(_editor)) _highlightGroups[_editor] = new HighlightGroup(_editor); HighlightGroup group = _highlightGroups[_editor]; if (string.IsNullOrEmpty(LookFor)) // Clear highlights group.ClearMarkers(); else { _search.LookFor = txtLookFor.Text; _search.MatchCase = chkMatchCase.Checked; _search.MatchWholeWordOnly = chkMatchWholeWord.Checked; bool looped = false; int offset = 0, count = 0; for(;;) { TextRange range = _search.FindNext(offset, false, out looped); if (range == null || looped) break; offset = range.Offset + range.Length; count++; var m = new TextMarker(range.Offset, range.Length, TextMarkerType.SolidBlock, Color.Yellow, Color.Black); group.AddMarker(m); } if (count == 0) MessageBox.Show("Search text not found."); else Close(); } }
private void CodeValidated(object sender, EventArgs e) { IDocument docDocument = ActiveTextAreaControl.TextArea.Document; docDocument.MarkerStrategy.RemoveAll(x => { return (x.TextMarkerType == TextMarkerType.WaveLine); }); foreach (LanguageError errError in ViewModel.Errors) { LineSegment lsgLine = docDocument.GetLineSegment(errError.Line); TextWord twdWord = lsgLine.GetWord(errError.Column); Int32 intWordOffest = docDocument.PositionToOffset(new TextLocation(errError.Column, errError.Line)); TextMarker tmkError = new TextMarker(intWordOffest, (twdWord == null) ? 1 : twdWord.Length, TextMarkerType.WaveLine); tmkError.ToolTip = errError.Message; docDocument.MarkerStrategy.AddMarker(tmkError); } ActiveTextAreaControl.TextArea.Invalidate(); }
public void AddMarker(TextMarker item) { markersTable.Clear(); textMarker.Add(item); }
public void InsertMarker(int index, TextMarker item) { markersTable.Clear(); textMarker.Insert(index, item); }
public void RemoveMarker() { if (oldDocument != null) { int from = SafeGetLineNumberForOffset(oldDocument, oldMarker.Offset); int to = SafeGetLineNumberForOffset(oldDocument, oldMarker.Offset + oldMarker.Length); oldDocument.MarkerStrategy.RemoveMarker(oldMarker); oldDocument.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.LinesBetween, from, to)); oldDocument.CommitUpdate(); } oldDocument = null; oldMarker = null; }
private void btnSerch_Click(object sender, EventArgs e) { var _editor = txtSchemaXML; if (!_highlightGroups.ContainsKey(_editor)) _highlightGroups[_editor] = new HighlightGroup(_editor); HighlightGroup group = _highlightGroups[_editor]; group.ClearMarkers(); TextEditorSearcher _search = new TextEditorSearcher(); _search.LookFor = txtLookFor.Text; _search.MatchCase = false; _search.MatchWholeWordOnly = false; _search.Document = _editor.Document; bool looped = false; int offset = 0, count = 0; for (; ; ) { TextRange range = _search.FindNext(offset, false, out looped); if (range == null || looped) break; offset = range.Offset + range.Length; count++; TextMarker m = new TextMarker(range.Offset, range.Length, TextMarkerType.SolidBlock, Color.Yellow, Color.Black); group.AddMarker(m); } if (count == 0) MessageBox.Show("没有找到你要查找的内容", "提示"); Folding(); }
static bool IsXPathNodeTextMarkerMatch(TextMarker marker) { return marker is XPathNodeTextMarker; }
private void AddBranchMarker(IDocument document, int offset, int length, bool exTarget=false) { TextMarker marker ; if (exTarget) { marker = new TextMarker(offset, length, TextMarkerType.SolidBlock, Color.Firebrick, Color.White); } else { marker = new TextMarker(offset, length, TextMarkerType.SolidBlock, Color.Gold); } document.MarkerStrategy.AddMarker(marker); _branchMarkers.Add(marker); }
public void AddMarker(TextMarker marker) { _markers.Add(marker); _document.MarkerStrategy.AddMarker(marker); }
private void MarkRegisterUsage(string word, IDocument document, TextArea text) { if (_formatter == null) return; var hadRegisterMarks = _registerMarkers.Count > 0; if (hadRegisterMarks) { foreach(var m in _registerMarkers) document.MarkerStrategy.RemoveMarker(m); } if (word == null || !Regex.IsMatch(word, "^[rp][0-9]+$")) { if (hadRegisterMarks) text.Refresh(); return; } foreach (var line in document.LineSegmentCollection) foreach (var w in line.Words) { if (w.Word != word) continue; var marker = new TextMarker(line.Offset + w.Offset, w.Length, TextMarkerType.SolidBlock, Color.LightSalmon); document.MarkerStrategy.AddMarker(marker); _registerMarkers.Add(marker); } if (_registerMarkers.Count > 0 || hadRegisterMarks) { text.Refresh(); } }
/// <summary>Sets the region to search. The region is updated /// automatically as the document changes.</summary> public void SetScanRegion(int offset, int length) { var bkgColor = _document.HighlightingStrategy.GetColorFor("Default").BackgroundColor; _region = new TextMarker(offset, length, TextMarkerType.SolidBlock, bkgColor.HalfMix(Color.FromArgb(160,160,160))); _document.MarkerStrategy.AddMarker(_region); }
public void RemoveMarker(TextMarker item) { markersTable.Clear(); textMarker.Remove(item); }