PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/IDE/ICSharpCode.TextEditor/Document/IDocument.cs

https://bitbucket.org/AdamMil/boaold
C# | 309 lines | 86 code | 38 blank | 185 comment | 0 complexity | 721c1e06f521f46db32761ea2da4b1fc MD5 | raw file
Possible License(s): GPL-2.0
  1. // <file>
  2. // <copyright see="prj:///doc/copyright.txt"/>
  3. // <license see="prj:///doc/license.txt"/>
  4. // <owner name="Mike KrĂźger" email="mike@icsharpcode.net"/>
  5. // <version value="$version"/>
  6. // </file>
  7. using System;
  8. using System.Collections;
  9. using System.Drawing;
  10. using ICSharpCode.TextEditor.Undo;
  11. namespace ICSharpCode.TextEditor.Document
  12. {
  13. /// <summary>
  14. /// This interface represents a container which holds a text sequence and
  15. /// all necessary information about it. It is used as the base for a text editor.
  16. /// </summary>
  17. public interface IDocument
  18. {
  19. ITextEditorProperties TextEditorProperties {
  20. get;
  21. set;
  22. }
  23. UndoStack UndoStack {
  24. get;
  25. }
  26. /// <value>
  27. /// If true the document can't be altered
  28. /// </value>
  29. bool ReadOnly {
  30. get;
  31. set;
  32. }
  33. /// <summary>
  34. /// The <see cref="IFormattingStrategy"/> attached to the <see cref="IDocument"/> instance
  35. /// </summary>
  36. IFormattingStrategy FormattingStrategy {
  37. get;
  38. set;
  39. }
  40. /// <summary>
  41. /// The <see cref="ITextBufferStrategy"/> attached to the <see cref="IDocument"/> instance
  42. /// </summary>
  43. ITextBufferStrategy TextBufferStrategy {
  44. get;
  45. }
  46. /// <summary>
  47. /// The <see cref="FoldingManager"/> attached to the <see cref="IDocument"/> instance
  48. /// </summary>
  49. FoldingManager FoldingManager {
  50. get;
  51. }
  52. /// <summary>
  53. /// The <see cref="IHighlightingStrategy"/> attached to the <see cref="IDocument"/> instance
  54. /// </summary>
  55. IHighlightingStrategy HighlightingStrategy {
  56. get;
  57. set;
  58. }
  59. /// <summary>
  60. /// The <see cref="IBookMarkManager"/> attached to the <see cref="IDocument"/> instance
  61. /// </summary>
  62. IBookMarkManager BookmarkManager {
  63. get;
  64. }
  65. MarkerStrategy MarkerStrategy {
  66. get;
  67. }
  68. // /// <summary>
  69. // /// The <see cref="SelectionManager"/> attached to the <see cref="IDocument"/> instance
  70. // /// </summary>
  71. // SelectionManager SelectionManager {
  72. // get;
  73. // }
  74. #region ILineManager interface
  75. /// <value>
  76. /// A collection of all line segments
  77. /// </value>
  78. /// <remarks>
  79. /// The collection should only be used if you're aware
  80. /// of the 'last line ends with a delimiter problem'. Otherwise
  81. /// the <see cref="GetLineSegment"/> method should be used.
  82. /// </remarks>
  83. ArrayList LineSegmentCollection {
  84. get;
  85. }
  86. /// <value>
  87. /// The total number of lines, this may be != ArrayList.Count
  88. /// if the last line ends with a delimiter.
  89. /// </value>
  90. int TotalNumberOfLines {
  91. get;
  92. }
  93. /// <remarks>
  94. /// Returns a valid line number for the given offset.
  95. /// </remarks>
  96. /// <param name="offset">
  97. /// A offset which points to a character in the line which
  98. /// line number is returned.
  99. /// </param>
  100. /// <returns>
  101. /// An int which value is the line number.
  102. /// </returns>
  103. /// <exception cref="System.ArgumentException">If offset points not to a valid position</exception>
  104. int GetLineNumberForOffset(int offset);
  105. /// <remarks>
  106. /// Returns a <see cref="LineSegment"/> for the given offset.
  107. /// </remarks>
  108. /// <param name="offset">
  109. /// A offset which points to a character in the line which
  110. /// is returned.
  111. /// </param>
  112. /// <returns>
  113. /// A <see cref="LineSegment"/> object.
  114. /// </returns>
  115. /// <exception cref="System.ArgumentException">If offset points not to a valid position</exception>
  116. LineSegment GetLineSegmentForOffset(int offset);
  117. /// <remarks>
  118. /// Returns a <see cref="LineSegment"/> for the given line number.
  119. /// This function should be used to get a line instead of getting the
  120. /// line using the <see cref="ArrayList"/>.
  121. /// </remarks>
  122. /// <param name="lineNumber">
  123. /// The line number which is requested.
  124. /// </param>
  125. /// <returns>
  126. /// A <see cref="LineSegment"/> object.
  127. /// </returns>
  128. /// <exception cref="System.ArgumentException">If offset points not to a valid position</exception>
  129. LineSegment GetLineSegment(int lineNumber);
  130. /// <remarks>
  131. /// Get the first logical line for a given visible line.
  132. /// example : lineNumber == 100 foldings are in the linetracker
  133. /// between 0..1 (2 folded, invisible lines) this method returns 102
  134. /// the 'logical' line number
  135. /// </remarks>
  136. int GetFirstLogicalLine(int lineNumber);
  137. /// <remarks>
  138. /// Get the last logical line for a given visible line.
  139. /// example : lineNumber == 100 foldings are in the linetracker
  140. /// between 0..1 (2 folded, invisible lines) this method returns 102
  141. /// the 'logical' line number
  142. /// </remarks>
  143. int GetLastLogicalLine(int lineNumber);
  144. /// <remarks>
  145. /// Get the visible line for a given logical line.
  146. /// example : lineNumber == 100 foldings are in the linetracker
  147. /// between 0..1 (2 folded, invisible lines) this method returns 98
  148. /// the 'visible' line number
  149. /// </remarks>
  150. int GetVisibleLine(int lineNumber);
  151. // /// <remarks>
  152. // /// Get the visible column for a given logical line and logical column.
  153. // /// </remarks>
  154. // int GetVisibleColumn(int logicalLine, int logicalColumn);
  155. /// <remarks>
  156. /// Get the next visible line after lineNumber
  157. /// </remarks>
  158. int GetNextVisibleLineAbove(int lineNumber, int lineCount);
  159. /// <remarks>
  160. /// Get the next visible line below lineNumber
  161. /// </remarks>
  162. int GetNextVisibleLineBelow(int lineNumber, int lineCount);
  163. #endregion
  164. #region ITextBufferStrategy interface
  165. /// <value>
  166. /// Get the whole text as string
  167. /// </value>
  168. string TextContent {
  169. get;
  170. set;
  171. }
  172. /// <value>
  173. /// The current length of the sequence of characters that can be edited.
  174. /// </value>
  175. int TextLength {
  176. get;
  177. }
  178. /// <summary>
  179. /// Inserts a string of characters into the sequence.
  180. /// </summary>
  181. /// <param name="offset">
  182. /// offset where to insert the string.
  183. /// </param>
  184. /// <param name="text">
  185. /// text to be inserted.
  186. /// </param>
  187. void Insert(int offset, string text);
  188. /// <summary>
  189. /// Removes some portion of the sequence.
  190. /// </summary>
  191. /// <param name="offset">
  192. /// offset of the remove.
  193. /// </param>
  194. /// <param name="length">
  195. /// number of characters to remove.
  196. /// </param>
  197. void Remove(int offset, int length);
  198. /// <summary>
  199. /// Replace some portion of the sequence.
  200. /// </summary>
  201. /// <param name="offset">
  202. /// offset.
  203. /// </param>
  204. /// <param name="length">
  205. /// number of characters to replace.
  206. /// </param>
  207. /// <param name="text">
  208. /// text to be replaced with.
  209. /// </param>
  210. void Replace(int offset, int length, string text);
  211. /// <summary>
  212. /// Returns a specific char of the sequence.
  213. /// </summary>
  214. /// <param name="offset">
  215. /// Offset of the char to get.
  216. /// </param>
  217. char GetCharAt(int offset);
  218. /// <summary>
  219. /// Fetches a string of characters contained in the sequence.
  220. /// </summary>
  221. /// <param name="offset">
  222. /// Offset into the sequence to fetch
  223. /// </param>
  224. /// <param name="length">
  225. /// number of characters to copy.
  226. /// </param>
  227. string GetText(int offset, int length);
  228. #endregion
  229. string GetText(ISegment segment);
  230. #region ITextModel interface
  231. /// <summary>
  232. /// returns the logical line/column position from an offset
  233. /// </summary>
  234. Point OffsetToPosition(int offset);
  235. /// <summary>
  236. /// returns the offset from a logical line/column position
  237. /// </summary>
  238. int PositionToOffset(Point p);
  239. #endregion
  240. /// <value>
  241. /// A container where all TextAreaUpdate objects get stored
  242. /// </value>
  243. ArrayList UpdateQueue {
  244. get;
  245. }
  246. /// <remarks>
  247. /// Requests an update of the textarea
  248. /// </remarks>
  249. void RequestUpdate(TextAreaUpdate update);
  250. /// <remarks>
  251. /// Commits all updates in the queue to the textarea (the
  252. /// textarea will be painted)
  253. /// </remarks>
  254. void CommitUpdate();
  255. /// <summary>
  256. /// Moves, Resizes, Removes a list of segments on insert/remove/replace events.
  257. /// </summary>
  258. void UpdateSegmentListOnDocumentChange(ArrayList list, DocumentEventArgs e);
  259. /// <summary>
  260. /// Is fired when CommitUpdate is called
  261. /// </summary>
  262. event EventHandler UpdateCommited;
  263. /// <summary>
  264. /// </summary>
  265. event DocumentEventHandler DocumentAboutToBeChanged;
  266. /// <summary>
  267. /// </summary>
  268. event DocumentEventHandler DocumentChanged;
  269. event EventHandler TextContentChanged;
  270. }
  271. }