]>
git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/CellBuffer.h
1 // Scintilla source code edit control
2 // CellBuffer.h - manages the text of the document
3 // Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
4 // The License.txt file describes the conditions under which this software may be distributed.
9 // This holds the marker identifier and the marker type to display.
10 // MarkerHandleNumbers are members of lists.
11 struct MarkerHandleNumber
{
14 MarkerHandleNumber
*next
;
17 // A marker handle set contains any number of MarkerHandleNumbers
18 class MarkerHandleSet
{
19 MarkerHandleNumber
*root
;
24 int NumberFromHandle(int handle
);
25 int MarkValue(); // Bit set of marker numbers
26 bool Contains(int handle
);
27 bool InsertHandle(int handle
, int markerNum
);
28 void RemoveHandle(int handle
);
29 void RemoveNumber(int markerNum
);
30 void CombineWith(MarkerHandleSet
*other
);
33 // Each line stores the starting position of the first character of the line in the cell buffer
34 // and potentially a marker handle set. Often a line will not have any attached markers.
37 MarkerHandleSet
*handleSet
;
38 LineData() : startPosition(0), handleSet(0) {
42 // The line vector contains information about each of the lines in a cell buffer.
45 enum { growSize
= 4000 };
52 // Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big.
59 void Expand(int sizeNew
);
60 void ExpandLevels(int sizeNew
=-1);
62 void InsertValue(int pos
, int value
);
63 void SetValue(int pos
, int value
);
65 int LineFromPosition(int pos
);
67 int AddMark(int line
, int marker
);
68 void MergeMarkers(int pos
);
69 void DeleteMark(int line
, int markerNum
);
70 void DeleteMarkFromHandle(int markerHandle
);
71 int LineFromHandle(int markerHandle
);
74 // Actions are used to store all the information required to perform one undo/redo step.
75 enum actionType
{ insertAction
, removeAction
, startAction
};
87 void Create(actionType at_
, int position_
=0, char *data_
=0, int lenData_
=0, bool mayCoalesce_
=true);
89 void Grab(Action
*source
);
97 int undoSequenceDepth
;
100 void EnsureUndoRoom();
106 void AppendAction(actionType at
, int position
, char *data
, int length
);
108 void BeginUndoAction();
109 void EndUndoAction();
110 void DropUndoSequence();
111 void DeleteUndoHistory();
113 // The save point is a marker in the undo stack where the container has stated that
114 // the buffer was saved. Undo and redo can move over the save point.
116 bool IsSavePoint() const;
118 // To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
119 // called that many times. Similarly for redo.
120 bool CanUndo() const;
122 const Action
&GetUndoStep() const;
123 void CompletedUndoStep();
124 bool CanRedo() const;
126 const Action
&GetRedoStep() const;
127 void CompletedRedoStep();
130 // Holder for an expandable array of characters that supports undo and line markers
131 // Based on article "Data Structures in a Bit-Mapped Text Editor"
132 // by Wilfred J. Hansen, Byte January 1987, page 183
150 void GapTo(int position
);
151 void RoomFor(int insertionLength
);
153 inline char ByteAt(int position
);
154 void SetByteAt(int position
, char ch
);
158 CellBuffer(int initialLength
= 4000);
161 // Retrieving positions outside the range of the buffer works and returns 0
162 char CharAt(int position
);
163 void GetCharRange(char *buffer
, int position
, int lengthRetrieve
);
164 char StyleAt(int position
);
169 int LineStart(int line
);
170 int LineFromPosition(int pos
) { return lv
.LineFromPosition(pos
); }
171 const char *InsertString(int position
, char *s
, int insertLength
);
172 void InsertCharStyle(int position
, char ch
, char style
);
174 // Setting styles for positions outside the range of the buffer is safe and has no effect.
175 // True is returned if the style of a character changed.
176 bool SetStyleAt(int position
, char style
, char mask
='\377');
177 bool SetStyleFor(int position
, int length
, char style
, char mask
);
179 const char *DeleteChars(int position
, int deleteLength
);
182 void SetReadOnly(bool set
);
184 // The save point is a marker in the undo stack where the container has stated that
185 // the buffer was saved. Undo and redo can move over the save point.
189 // Line marker functions
190 int AddMark(int line
, int markerNum
);
191 void DeleteMark(int line
, int markerNum
);
192 void DeleteMarkFromHandle(int markerHandle
);
193 int GetMark(int line
);
194 void DeleteAllMarks(int markerNum
);
195 int LineFromHandle(int markerHandle
);
198 void BasicInsertString(int position
, char *s
, int insertLength
);
199 void BasicDeleteChars(int position
, int deleteLength
);
201 bool SetUndoCollection(bool collectUndo
);
202 bool IsCollectingUndo();
203 void BeginUndoAction();
204 void EndUndoAction();
205 void DeleteUndoHistory();
207 // To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
208 // called that many times. Similarly for redo.
211 const Action
&GetUndoStep() const;
212 void PerformUndoStep();
215 const Action
&GetRedoStep() const;
216 void PerformRedoStep();
218 int SetLineState(int line
, int state
);
219 int GetLineState(int line
);
220 int GetMaxLineState();
222 int SetLevel(int line
, int level
);
223 int GetLevel(int line
);