]>
git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/CellBuffer.h
4f654a8fd99aec2651734f0dbeccc2e710f9bf76
1 // Scintilla source code edit control
3 ** Manages the text of the document.
5 // Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
16 * This holds the marker identifier and the marker type to display.
17 * MarkerHandleNumbers are members of lists.
19 struct MarkerHandleNumber
{
22 MarkerHandleNumber
*next
;
26 * A marker handle set contains any number of MarkerHandleNumbers.
28 class MarkerHandleSet
{
29 MarkerHandleNumber
*root
;
35 int NumberFromHandle(int handle
) const;
36 int MarkValue() const; ///< Bit set of marker numbers.
37 bool Contains(int handle
) const;
38 bool InsertHandle(int handle
, int markerNum
);
39 void RemoveHandle(int handle
);
40 bool RemoveNumber(int markerNum
);
41 void CombineWith(MarkerHandleSet
*other
);
45 * The line vector contains information about each of the lines in a cell buffer.
50 SplitVector
<MarkerHandleSet
*> markers
;
51 SplitVector
<int> levels
;
52 /// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big.
61 void ExpandLevels(int sizeNew
=-1);
63 int SetLevel(int line
, int level
);
64 int GetLevel(int line
);
66 void InsertText(int line
, int delta
);
67 void InsertLine(int line
, int position
);
68 void SetLineStart(int line
, int position
);
69 void RemoveLine(int line
);
71 return starts
.Partitions();
73 int LineFromPosition(int pos
);
74 int LineStart(int line
) const {
75 return starts
.PositionFromPartition(line
);
78 int MarkValue(int line
);
79 int AddMark(int line
, int marker
);
80 void MergeMarkers(int pos
);
81 void DeleteMark(int line
, int markerNum
, bool all
);
82 void DeleteMarkFromHandle(int markerHandle
);
83 int LineFromHandle(int markerHandle
);
86 enum actionType
{ insertAction
, removeAction
, startAction
};
89 * Actions are used to store all the information required to perform one undo/redo step.
101 void Create(actionType at_
, int position_
=0, char *data_
=0, int lenData_
=0, bool mayCoalesce_
=true);
103 void Grab(Action
*source
);
114 int undoSequenceDepth
;
117 void EnsureUndoRoom();
123 void AppendAction(actionType at
, int position
, char *data
, int length
, bool &startSequence
);
125 void BeginUndoAction();
126 void EndUndoAction();
127 void DropUndoSequence();
128 void DeleteUndoHistory();
130 /// The save point is a marker in the undo stack where the container has stated that
131 /// the buffer was saved. Undo and redo can move over the save point.
133 bool IsSavePoint() const;
135 /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
136 /// called that many times. Similarly for redo.
137 bool CanUndo() const;
139 const Action
&GetUndoStep() const;
140 void CompletedUndoStep();
141 bool CanRedo() const;
143 const Action
&GetRedoStep() const;
144 void CompletedRedoStep();
148 * Holder for an expandable array of characters that supports undo and line markers.
149 * Based on article "Data Structures in a Bit-Mapped Text Editor"
150 * by Wilfred J. Hansen, Byte January 1987, page 183.
154 SplitVector
<char> substance
;
155 SplitVector
<char> style
;
163 SplitVector
<int> lineStates
;
170 /// Retrieving positions outside the range of the buffer works and returns 0
171 char CharAt(int position
) const;
172 void GetCharRange(char *buffer
, int position
, int lengthRetrieve
);
173 char StyleAt(int position
);
176 void Allocate(int newSize
);
178 int LineStart(int line
) const;
179 int LineFromPosition(int pos
) { return lv
.LineFromPosition(pos
); }
180 void InsertLine(int line
, int position
);
181 void RemoveLine(int line
);
182 const char *InsertString(int position
, const char *s
, int insertLength
, bool &startSequence
);
184 /// Setting styles for positions outside the range of the buffer is safe and has no effect.
185 /// @return true if the style of a character is changed.
186 bool SetStyleAt(int position
, char styleValue
, char mask
='\377');
187 bool SetStyleFor(int position
, int length
, char styleValue
, char mask
);
189 const char *DeleteChars(int position
, int deleteLength
, bool &startSequence
);
192 void SetReadOnly(bool set
);
194 /// The save point is a marker in the undo stack where the container has stated that
195 /// the buffer was saved. Undo and redo can move over the save point.
199 /// Line marker functions
200 int AddMark(int line
, int markerNum
);
201 void DeleteMark(int line
, int markerNum
);
202 void DeleteMarkFromHandle(int markerHandle
);
203 int GetMark(int line
);
204 void DeleteAllMarks(int markerNum
);
205 int LineFromHandle(int markerHandle
);
207 /// Actions without undo
208 void BasicInsertString(int position
, const char *s
, int insertLength
);
209 void BasicDeleteChars(int position
, int deleteLength
);
211 bool SetUndoCollection(bool collectUndo
);
212 bool IsCollectingUndo();
213 void BeginUndoAction();
214 void EndUndoAction();
215 void DeleteUndoHistory();
217 /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
218 /// called that many times. Similarly for redo.
221 const Action
&GetUndoStep() const;
222 void PerformUndoStep();
225 const Action
&GetRedoStep() const;
226 void PerformRedoStep();
228 int SetLineState(int line
, int state
);
229 int GetLineState(int line
);
230 int GetMaxLineState();
232 int SetLevel(int line
, int level
);
233 int GetLevel(int line
);