// // // // // $Revision$ // using System; using System.Collections.Generic; using System.Drawing; using ICSharpCode.TextEditor.Undo; namespace ICSharpCode.TextEditor.Document { /// /// This interface represents a container which holds a text sequence and /// all necessary information about it. It is used as the base for a text editor. /// public interface IDocument { ITextEditorProperties TextEditorProperties { get; set; } UndoStack UndoStack { get; } /// /// If true the document can't be altered /// bool ReadOnly { get; set; } /// /// The attached to the instance /// IFormattingStrategy FormattingStrategy { get; set; } /// /// The attached to the instance /// ITextBufferStrategy TextBufferStrategy { get; } /// /// The attached to the instance /// FoldingManager FoldingManager { get; } /// /// The attached to the instance /// IHighlightingStrategy HighlightingStrategy { get; set; } /// /// The attached to the instance /// BookmarkManager BookmarkManager { get; } MarkerStrategy MarkerStrategy { get; } // /// // /// The attached to the instance // /// // SelectionManager SelectionManager { // get; // } #region ILineManager interface /// /// A collection of all line segments /// /// /// The collection should only be used if you're aware /// of the 'last line ends with a delimiter problem'. Otherwise /// the method should be used. /// IList LineSegmentCollection { get; } /// /// The total number of lines in the document. /// int TotalNumberOfLines { get; } /// /// Returns a valid line number for the given offset. /// /// /// A offset which points to a character in the line which /// line number is returned. /// /// /// An int which value is the line number. /// /// If offset points not to a valid position int GetLineNumberForOffset(int offset); /// /// Returns a for the given offset. /// /// /// A offset which points to a character in the line which /// is returned. /// /// /// A object. /// /// If offset points not to a valid position LineSegment GetLineSegmentForOffset(int offset); /// /// Returns a for the given line number. /// This function should be used to get a line instead of getting the /// line using the . /// /// /// The line number which is requested. /// /// /// A object. /// /// If offset points not to a valid position LineSegment GetLineSegment(int lineNumber); /// /// Get the first logical line for a given visible line. /// example : lineNumber == 100 foldings are in the linetracker /// between 0..1 (2 folded, invisible lines) this method returns 102 /// the 'logical' line number /// int GetFirstLogicalLine(int lineNumber); /// /// Get the last logical line for a given visible line. /// example : lineNumber == 100 foldings are in the linetracker /// between 0..1 (2 folded, invisible lines) this method returns 102 /// the 'logical' line number /// int GetLastLogicalLine(int lineNumber); /// /// Get the visible line for a given logical line. /// example : lineNumber == 100 foldings are in the linetracker /// between 0..1 (2 folded, invisible lines) this method returns 98 /// the 'visible' line number /// int GetVisibleLine(int lineNumber); // /// // /// Get the visible column for a given logical line and logical column. // /// // int GetVisibleColumn(int logicalLine, int logicalColumn); /// /// Get the next visible line after lineNumber /// int GetNextVisibleLineAbove(int lineNumber, int lineCount); /// /// Get the next visible line below lineNumber /// int GetNextVisibleLineBelow(int lineNumber, int lineCount); event EventHandler LineLengthChanged; event EventHandler LineCountChanged; event EventHandler LineDeleted; #endregion #region ITextBufferStrategy interface /// /// Get the whole text as string. /// When setting the text using the TextContent property, the undo stack is cleared. /// Set TextContent only for actions such as loading a file; if you want to change the current document /// use the Replace method instead. /// string TextContent { get; set; } /// /// The current length of the sequence of characters that can be edited. /// int TextLength { get; } /// /// Inserts a string of characters into the sequence. /// /// /// offset where to insert the string. /// /// /// text to be inserted. /// void Insert(int offset, string text); /// /// Removes some portion of the sequence. /// /// /// offset of the remove. /// /// /// number of characters to remove. /// void Remove(int offset, int length); /// /// Replace some portion of the sequence. /// /// /// offset. /// /// /// number of characters to replace. /// /// /// text to be replaced with. /// void Replace(int offset, int length, string text); /// /// Returns a specific char of the sequence. /// /// /// Offset of the char to get. /// char GetCharAt(int offset); /// /// Fetches a string of characters contained in the sequence. /// /// /// Offset into the sequence to fetch /// /// /// number of characters to copy. /// string GetText(int offset, int length); #endregion string GetText(ISegment segment); #region ITextModel interface /// /// returns the logical line/column position from an offset /// TextLocation OffsetToPosition(int offset); /// /// returns the offset from a logical line/column position /// int PositionToOffset(TextLocation p); #endregion /// /// A container where all TextAreaUpdate objects get stored /// List UpdateQueue { get; } /// /// Requests an update of the textarea /// void RequestUpdate(TextAreaUpdate update); /// /// Commits all updates in the queue to the textarea (the /// textarea will be painted) /// void CommitUpdate(); /// /// Moves, Resizes, Removes a list of segments on insert/remove/replace events. /// void UpdateSegmentListOnDocumentChange(List list, DocumentEventArgs e) where T : ISegment; /// /// Is fired when CommitUpdate is called /// event EventHandler UpdateCommited; /// /// event DocumentEventHandler DocumentAboutToBeChanged; /// /// event DocumentEventHandler DocumentChanged; event EventHandler TextContentChanged; } }