//public event EventHandler<DocumentEventArgs> DocumentEventHandler;

        //public event EventHandler<LineLengthChangeEventArgs> LineLengthChanged
        //{
        //    add { LineManager.LineLengthChanged += value; }
        //    remove { LineManager.LineLengthChanged -= value; }
        //}

        //public event EventHandler<LineCountChangeEventArgs> LineCountChanged
        //{
        //    add { LineManager.LineCountChanged += value; }
        //    remove { LineManager.LineCountChanged -= value; }
        //}

        //public event EventHandler<LineEventArgs> LineDeleted
        //{
        //    add { LineManager.LineDeleted += value; }
        //    remove { LineManager.LineDeleted -= value; }
        //}
        #endregion

        #region Lifecycle
        public Document()
        {
            TextBuffer         = new TextBuffer();
            FormattingStrategy = new DefaultFormattingStrategy();
            LineManager        = new LineManager(this, null);
            FoldingManager     = new FoldingManager(this, LineManager);
            MarkerStrategy     = new MarkerStrategy(this);
            BookmarkManager    = new BookmarkManager(this, LineManager);
        }
		/// <summary>
		/// Creates a new instance of <see cref="BookmarkManager"/>
		/// </summary>
		internal BookmarkManager(IDocument document, LineManager lineTracker)
		{
			this.document = document;
			lineTracker.LineDeleted += delegate(object sender, LineEventArgs e) {
				for (int i = 0; i < bookmark.Count; i++) {
					Bookmark b = bookmark[i];
					if (b.Line == e.LineSegment) {
						bookmark.RemoveAt(i--);
						OnRemoved(new BookmarkEventArgs(b));
					}
				}
			};
		}
Beispiel #3
0
 /// <summary>
 /// Creates a new instance of <see cref="BookmarkManager"/>
 /// </summary>
 internal BookmarkManager(IDocument document, LineManager lineTracker)
 {
     this.document            = document;
     lineTracker.LineDeleted += delegate(object sender, LineEventArgs e) {
         for (int i = 0; i < bookmark.Count; i++)
         {
             Bookmark b = bookmark[i];
             if (b.Line == e.LineSegment)
             {
                 bookmark.RemoveAt(i--);
                 OnRemoved(new BookmarkEventArgs(b));
             }
         }
     };
 }
        public void Remove(int offset, int length)
        {
            if (!ReadOnly)
            {
                DocumentAboutToBeChanged?.Invoke(this, new DocumentEventArgs()
                {
                    Document = this, Offset = offset, Length = length
                });
                UndoStack.Push(new UndoableDelete(this, offset, GetText(offset, length)));

                TextBuffer.Remove(offset, length);
                LineManager.Remove(offset, length);

                DocumentChanged?.Invoke(this, new DocumentEventArgs()
                {
                    Document = this, Offset = offset, Length = length
                });
            }
        }
        public void Replace(int offset, int length, string text)
        {
            if (!ReadOnly)
            {
                DocumentAboutToBeChanged?.Invoke(this, new DocumentEventArgs()
                {
                    Document = this, Offset = offset, Length = length, Text = text
                });
                UndoStack.Push(new UndoableReplace(this, offset, GetText(offset, length), text));

                TextBuffer.Replace(offset, length, text);
                LineManager.Replace(offset, length, text);

                DocumentChanged?.Invoke(this, new DocumentEventArgs()
                {
                    Document = this, Offset = offset, Length = length, Text = text
                });
            }
        }
        public void Insert(int offset, string text)
        {
            if (!ReadOnly)
            {
                DocumentAboutToBeChanged?.Invoke(this, new DocumentEventArgs()
                {
                    Document = this, Offset = offset, Length = -1, Text = text
                });

                TextBuffer.Insert(offset, text);
                LineManager.Insert(offset, text);

                UndoStack.Push(new UndoableInsert(this, offset, text));

                DocumentChanged?.Invoke(this, new DocumentEventArgs()
                {
                    Document = this, Offset = offset, Length = -1, Text = text
                });
            }
        }
Beispiel #7
0
 internal FoldingManager(IDocument document, LineManager lineTracker)
 {
     this.document             = document;
     document.DocumentChanged += new DocumentEventHandler(DocumentChanged);
     //			lineTracker.LineCountChanged  += new LineManagerEventHandler(LineManagerLineCountChanged);
     //			lineTracker.LineLengthChanged += new LineLengthEventHandler(LineManagerLineLengthChanged);
     //			foldMarker.Add(new FoldMarker(0, 5, 3, 5));
     //
     //			foldMarker.Add(new FoldMarker(5, 5, 10, 3));
     //			foldMarker.Add(new FoldMarker(6, 0, 8, 2));
     //
     //			FoldMarker fm1 = new FoldMarker(10, 4, 10, 7);
     //			FoldMarker fm2 = new FoldMarker(10, 10, 10, 14);
     //
     //			fm1.IsFolded = true;
     //			fm2.IsFolded = true;
     //
     //			foldMarker.Add(fm1);
     //			foldMarker.Add(fm2);
     //			foldMarker.Sort();
 }
Beispiel #8
0
 /// <summary>
 /// Creates a new instance of <see cref="BookmarkManager"/>
 /// </summary>
 internal BookmarkManager(IDocument document, LineManager lineTracker)
 {
     this.document = document;
 }
 public int GetNextVisibleLineBelow(int lineNumber, int lineCount)
 {
     return(LineManager.GetNextVisibleLineBelow(lineNumber, lineCount));
 }
 public int GetVisibleLine(int lineNumber)
 {
     return(LineManager.GetVisibleLine(lineNumber));
 }
 public int GetLastLogicalLine(int lineNumber)
 {
     return(LineManager.GetLastLogicalLine(lineNumber));
 }
 public LineSegment GetLineSegment(int line)
 {
     return(LineManager.GetLineSegment(line));
 }
 public LineSegment GetLineSegmentForOffset(int offset)
 {
     return(LineManager.GetLineSegmentForOffset(offset));
 }
 public int GetLineNumberForOffset(int offset)
 {
     return(LineManager.GetLineNumberForOffset(offset));
 }
		/// <summary>
		/// Creates a new instance of <see cref="CustomLineManager"/>
		/// </summary>
		internal CustomLineManager(LineManager lineTracker)
		{
			lineTracker.LineCountChanged += MoveIndices;
		}
 /// <summary>
 /// Creates a new instance of <see cref="BookmarkManager"/>
 /// </summary>
 internal BookmarkManager(Document document, LineManager lineTracker)
 {
     Document = document;
 }
 internal FoldingManager(IDocument document, LineManager lineTracker)
 {
     this.document             = document;
     document.DocumentChanged += new DocumentEventHandler(this.DocumentChanged);
 }
 /// <summary>
 /// Creates a new instance of <see cref="CustomLineManager"/>
 /// </summary>
 internal CustomLineManager(LineManager lineTracker)
 {
     lineTracker.LineCountChanged += MoveIndices;
 }