Ejemplo n.º 1
0
 internal DocumentLine(TextDocument document)
 {
     #if DEBUG
     Debug.Assert(document != null);
     this.document = document;
     #endif
 }
Ejemplo n.º 2
0
 public HeightTree(TextDocument document, double defaultLineHeight)
 {
     this.document = document;
     weakLineTracker = WeakLineTracker.Register(document, this);
     this.DefaultLineHeight = defaultLineHeight;
     RebuildDocument();
 }
Ejemplo n.º 3
0
 public TextView(Control parent, TextDocument textDocument)
     : base(parent)
 {
     Dock = Pos.Fill;
     TextLayer = new TextLayer(this, textDocument);
     CarretLayer = new CarretLayer(this);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Deregisters the weak line tracker.
 /// </summary>
 public void Deregister()
 {
     if (textDocument != null) {
         textDocument.LineTrackers.Remove(this);
         textDocument = null;
     }
 }
Ejemplo n.º 5
0
        public LineManager(DocumentLineTree documentLineTree, TextDocument document)
        {
            this.document = document;
            this.documentLineTree = documentLineTree;
            UpdateListOfLineTrackers();

            Rebuild();
        }
Ejemplo n.º 6
0
 /// <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;
 }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
 /// <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();
 }
Ejemplo n.º 9
0
        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();
        }
Ejemplo n.º 10
0
 void OnDocumentChanged(TextDocument oldValue, TextDocument newValue)
 {
     if (DocumentChanged != null)
         DocumentChanged(this, EventArgs.Empty);
 }
Ejemplo n.º 11
0
 internal TextAnchor(TextDocument document)
 {
     this.document = document;
 }
Ejemplo n.º 12
0
 public TextAnchorTree(TextDocument document)
 {
     this.document = document;
 }
Ejemplo n.º 13
0
 /// <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);
 }
Ejemplo n.º 14
0
 internal TextAnchor(TextDocument document)
 {
     this.document = document;
 }
Ejemplo n.º 15
0
 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;
 }
Ejemplo n.º 16
0
 public static ISegment GetLeadingWhitespace(TextDocument document, DocumentLine documentLine)
 {
     if (documentLine == null)
         throw new ArgumentNullException("documentLine");
     return GetWhitespaceAfter(document, documentLine.Offset);
 }
Ejemplo n.º 17
0
 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));
 }
Ejemplo n.º 18
0
 private WeakLineTracker(TextDocument textDocument, ILineTracker targetTracker)
 {
     this.textDocument = textDocument;
     this.targetObject = new WeakReference(targetTracker);
 }
Ejemplo n.º 19
0
 public DocumentChangeOperation(TextDocument document, DocumentChangeEventArgs change)
 {
     this.document = document;
     this.change = change;
 }
Ejemplo n.º 20
0
 /// <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);
 }
Ejemplo n.º 21
0
 internal void RegisterAffectedDocument(TextDocument document)
 {
     if (affectedDocuments == null)
         affectedDocuments = new List<TextDocument>();
     if (!affectedDocuments.Contains(document)) {
         affectedDocuments.Add(document);
         document.BeginUpdate();
     }
 }
Ejemplo n.º 22
0
 /// <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();
 }