]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/stc/scintilla/src/CellBuffer.h
2866d548cb808560373c6d7040c495a0ae277020
1 // Scintilla source code edit control
3 ** Manages the text of the document.
5 // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
12 * This holds the marker identifier and the marker type to display.
13 * MarkerHandleNumbers are members of lists.
15 struct MarkerHandleNumber
{
18 MarkerHandleNumber
*next
;
22 * A marker handle set contains any number of MarkerHandleNumbers.
24 class MarkerHandleSet
{
25 MarkerHandleNumber
*root
;
31 int NumberFromHandle(int handle
);
32 int MarkValue(); ///< Bit set of marker numbers.
33 bool Contains(int handle
);
34 bool InsertHandle(int handle
, int markerNum
);
35 void RemoveHandle(int handle
);
36 void RemoveNumber(int markerNum
);
37 void CombineWith(MarkerHandleSet
*other
);
41 * Each line stores the starting position of the first character of the line in the cell buffer
42 * and potentially a marker handle set. Often a line will not have any attached markers.
46 MarkerHandleSet
*handleSet
;
47 LineData() : startPosition(0), handleSet(0) {
52 * The line vector contains information about each of the lines in a cell buffer.
63 /// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big.
70 void Expand(int sizeNew
);
71 void ExpandLevels(int sizeNew
=-1);
73 void InsertValue(int pos
, int value
);
74 void SetValue(int pos
, int value
);
76 int LineFromPosition(int pos
);
78 int AddMark(int line
, int marker
);
79 void MergeMarkers(int pos
);
80 void DeleteMark(int line
, int markerNum
);
81 void DeleteMarkFromHandle(int markerHandle
);
82 int LineFromHandle(int markerHandle
);
85 enum actionType
{ insertAction
, removeAction
, startAction
};
88 * Actions are used to store all the information required to perform one undo/redo step.
100 void Create(actionType at_
, int position_
=0, char *data_
=0, int lenData_
=0, bool mayCoalesce_
=true);
102 void Grab(Action
*source
);
113 int undoSequenceDepth
;
116 void EnsureUndoRoom();
122 void AppendAction(actionType at
, int position
, char *data
, int length
);
124 void BeginUndoAction();
125 void EndUndoAction();
126 void DropUndoSequence();
127 void DeleteUndoHistory();
129 /// The save point is a marker in the undo stack where the container has stated that
130 /// the buffer was saved. Undo and redo can move over the save point.
132 bool IsSavePoint() const;
134 /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
135 /// called that many times. Similarly for redo.
136 bool CanUndo() const;
138 const Action
&GetUndoStep() const;
139 void CompletedUndoStep();
140 bool CanRedo() const;
142 const Action
&GetRedoStep() const;
143 void CompletedRedoStep();
147 * Holder for an expandable array of characters that supports undo and line markers.
148 * Based on article "Data Structures in a Bit-Mapped Text Editor"
149 * by Wilfred J. Hansen, Byte January 1987, page 183.
169 void GapTo(int position
);
170 void RoomFor(int insertionLength
);
172 inline char ByteAt(int position
);
173 void SetByteAt(int position
, char ch
);
177 CellBuffer(int initialLength
= 4000);
180 /// Retrieving positions outside the range of the buffer works and returns 0
181 char CharAt(int position
);
182 void GetCharRange(char *buffer
, int position
, int lengthRetrieve
);
183 char StyleAt(int position
);
188 int LineStart(int line
);
189 int LineFromPosition(int pos
) { return lv
.LineFromPosition(pos
); }
190 const char *InsertString(int position
, char *s
, int insertLength
);
191 void InsertCharStyle(int position
, char ch
, char style
);
193 /// Setting styles for positions outside the range of the buffer is safe and has no effect.
194 /// @return true if the style of a character is changed.
195 bool SetStyleAt(int position
, char style
, char mask
='\377');
196 bool SetStyleFor(int position
, int length
, char style
, char mask
);
198 const char *DeleteChars(int position
, int deleteLength
);
201 void SetReadOnly(bool set
);
203 /// The save point is a marker in the undo stack where the container has stated that
204 /// the buffer was saved. Undo and redo can move over the save point.
208 /// Line marker functions
209 int AddMark(int line
, int markerNum
);
210 void DeleteMark(int line
, int markerNum
);
211 void DeleteMarkFromHandle(int markerHandle
);
212 int GetMark(int line
);
213 void DeleteAllMarks(int markerNum
);
214 int LineFromHandle(int markerHandle
);
216 /// Actions without undo
217 void BasicInsertString(int position
, char *s
, int insertLength
);
218 void BasicDeleteChars(int position
, int deleteLength
);
220 bool SetUndoCollection(bool collectUndo
);
221 bool IsCollectingUndo();
222 void BeginUndoAction();
223 void EndUndoAction();
224 void DeleteUndoHistory();
226 /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
227 /// called that many times. Similarly for redo.
230 const Action
&GetUndoStep() const;
231 void PerformUndoStep();
234 const Action
&GetRedoStep() const;
235 void PerformRedoStep();
237 int SetLineState(int line
, int state
);
238 int GetLineState(int line
);
239 int GetMaxLineState();
241 int SetLevel(int line
, int level
);
242 int GetLevel(int line
);