internal DocumentLine(TextDocument document) { #if DEBUG Debug.Assert(document != null); this.document = document; #endif }
public HeightTree(TextDocument document, double defaultLineHeight) { this.document = document; weakLineTracker = WeakLineTracker.Register(document, this); this.DefaultLineHeight = defaultLineHeight; RebuildDocument(); }
public TextView(Control parent, TextDocument textDocument) : base(parent) { Dock = Pos.Fill; TextLayer = new TextLayer(this, textDocument); CarretLayer = new CarretLayer(this); }
/// <summary> /// Deregisters the weak line tracker. /// </summary> public void Deregister() { if (textDocument != null) { textDocument.LineTrackers.Remove(this); textDocument = null; } }
public LineManager(DocumentLineTree documentLineTree, TextDocument document) { this.document = document; this.documentLineTree = documentLineTree; UpdateListOfLineTrackers(); Rebuild(); }
/// <summary> /// Registers the <paramref name="targetTracker"/> as line tracker for the <paramref name="textDocument"/>. /// A weak reference to the target tracker will be used, and the WeakLineTracker will deregister itself /// when the target tracker is garbage collected. /// </summary> public static WeakLineTracker Register(TextDocument textDocument, ILineTracker targetTracker) { if (textDocument == null) throw new ArgumentNullException("textDocument"); if (targetTracker == null) throw new ArgumentNullException("targetTracker"); WeakLineTracker wlt = new WeakLineTracker(textDocument, targetTracker); textDocument.LineTrackers.Add(wlt); return wlt; }
public void OnLoad(Flood.Remoting.ServiceManager serviceManager) { var paneManager = serviceManager.GetGlobalService<IPaneManager>(); var textDocument = new TextDocument(); var textView = new TextView(null, textDocument); var pane = new Pane { Title = "CodeEdit", Control = textView }; paneManager.AddPane(pane); }
/// <summary> /// Creates a new DocumentHighlighter instance. /// </summary> public DocumentHighlighter(TextDocument document, HighlightingRuleSet baseRuleSet) { if (document == null) throw new ArgumentNullException("document"); if (baseRuleSet == null) throw new ArgumentNullException("baseRuleSet"); this.document = document; this.baseRuleSet = baseRuleSet; WeakLineTracker.Register(document, this); InvalidateHighlighting(); }
public TextLayer(TextView parent, TextDocument textDocument) : base(parent) { Document = textDocument; elementGenerators = new ObserveAddRemoveCollection<VisualLineElementGenerator>(ElementGenerator_Added, ElementGenerator_Removed); lineTransformers = new ObserveAddRemoveCollection<IVisualLineTransformer>(LineTransformer_Added, LineTransformer_Removed); heightTree = new HeightTree(textDocument, 16); //TODO Skin.DefaultFont.Size lines = new Dictionary<DocumentLine, VisualLine>(); GlobalTextRunProperties = new TextRunProperties { Foreground = Color.Black}; lineTransformers = new ObserveAddRemoveCollection<IVisualLineTransformer>(LineTransformer_Added,LineTransformer_Removed); HighlightingDefinition = HighlightingManager.DefaultHighlightingManager.Instance.GetDefinition("C#"); var colorizer = new HighlightingColorizer(highlightingDefinition.MainRuleSet); lineTransformers.Add(colorizer); weakLineTracker = WeakLineTracker.Register(textDocument, this); RebuildDocument(); }
void OnDocumentChanged(TextDocument oldValue, TextDocument newValue) { if (DocumentChanged != null) DocumentChanged(this, EventArgs.Empty); }
internal TextAnchor(TextDocument document) { this.document = document; }
public TextAnchorTree(TextDocument document) { this.document = document; }
/// <summary> /// Creates the IHighlighter instance for the specified text document. /// </summary> protected virtual IHighlighter CreateHighlighter(TextLayer textLayer, TextDocument document) { return new TextLayerDocumentHighlighter(this, textLayer, ruleSet); }
public static ISegment GetTrailingWhitespace(TextDocument document, DocumentLine documentLine) { if (documentLine == null) throw new ArgumentNullException("documentLine"); ISegment segment = GetWhitespaceBefore(document, documentLine.EndOffset); // If the whole line consists of whitespace, we consider all of it as leading whitespace, // so return an empty segment as trailing whitespace. if (segment.Offset == documentLine.Offset) return new SimpleSegment(documentLine.EndOffset, 0); else return segment; }
public static ISegment GetLeadingWhitespace(TextDocument document, DocumentLine documentLine) { if (documentLine == null) throw new ArgumentNullException("documentLine"); return GetWhitespaceAfter(document, documentLine.Offset); }
internal void Push(TextDocument document, DocumentChangeEventArgs e) { if (state == StatePlayback) throw new InvalidOperationException("Document changes during undo/redo operations are not allowed."); if (state == StatePlaybackModifyDocument) state = StatePlayback; // allow only 1 change per expected modification else Push(new DocumentChangeOperation(document, e)); }
private WeakLineTracker(TextDocument textDocument, ILineTracker targetTracker) { this.textDocument = textDocument; this.targetObject = new WeakReference(targetTracker); }
public DocumentChangeOperation(TextDocument document, DocumentChangeEventArgs change) { this.document = document; this.change = change; }
/// <summary> /// Gets the newline sequence used in the document at the specified line. /// </summary> public static string GetNewLineFromDocument(TextDocument document, int lineNumber) { DocumentLine line = document.GetLineByNumber(lineNumber); if (line.DelimiterLength == 0) { // at the end of the document, there's no line delimiter, so use the delimiter // from the previous line line = line.PreviousLine; if (line == null) return Environment.NewLine; } return document.GetText(line.Offset + line.Length, line.DelimiterLength); }
internal void RegisterAffectedDocument(TextDocument document) { if (affectedDocuments == null) affectedDocuments = new List<TextDocument>(); if (!affectedDocuments.Contains(document)) { affectedDocuments.Add(document); document.BeginUpdate(); } }
/// <summary> /// Creates a change tracking checkpoint for the specified document. /// This method is thread-safe. /// If you need a ChangeTrackingCheckpoint that's consistent with a snapshot of the document, /// use <see cref="TextDocument.CreateSnapshot(out ChangeTrackingCheckpoint)"/>. /// </summary> public static ChangeTrackingCheckpoint Create(TextDocument document) { if (document == null) throw new ArgumentNullException("document"); return document.CreateChangeTrackingCheckpoint(); }