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.
15 // Interface to per-line data that wants to see each line insertion and deletion
19 virtual void Init()=0;
20 virtual void InsertLine(int line
)=0;
21 virtual void RemoveLine(int line
)=0;
25 * The line vector contains information about each of the lines in a cell buffer.
37 void SetPerLine(PerLine
*pl
);
39 void InsertText(int line
, int delta
);
40 void InsertLine(int line
, int position
, bool lineStart
);
41 void SetLineStart(int line
, int position
);
42 void RemoveLine(int line
);
44 return starts
.Partitions();
46 int LineFromPosition(int pos
) const;
47 int LineStart(int line
) const {
48 return starts
.PositionFromPartition(line
);
51 int MarkValue(int line
);
52 int AddMark(int line
, int marker
);
53 void MergeMarkers(int pos
);
54 void DeleteMark(int line
, int markerNum
, bool all
);
55 void DeleteMarkFromHandle(int markerHandle
);
56 int LineFromHandle(int markerHandle
);
59 int SetLevel(int line
, int level
);
60 int GetLevel(int line
);
62 int SetLineState(int line
, int state
);
63 int GetLineState(int line
);
64 int GetMaxLineState();
68 enum actionType
{ insertAction
, removeAction
, startAction
, containerAction
};
71 * Actions are used to store all the information required to perform one undo/redo step.
83 void Create(actionType at_
, int position_
=0, const char *data_
=0, int lenData_
=0, bool mayCoalesce_
=true);
85 void Grab(Action
*source
);
96 int undoSequenceDepth
;
99 void EnsureUndoRoom();
101 // Private so UndoHistory objects can not be copied
102 UndoHistory(const UndoHistory
&);
108 const char *AppendAction(actionType at
, int position
, const char *data
, int length
, bool &startSequence
, bool mayCoalesce
=true);
110 void BeginUndoAction();
111 void EndUndoAction();
112 void DropUndoSequence();
113 void DeleteUndoHistory();
115 /// The save point is a marker in the undo stack where the container has stated that
116 /// the buffer was saved. Undo and redo can move over the save point.
118 bool IsSavePoint() const;
120 /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
121 /// called that many times. Similarly for redo.
122 bool CanUndo() const;
124 const Action
&GetUndoStep() const;
125 void CompletedUndoStep();
126 bool CanRedo() const;
128 const Action
&GetRedoStep() const;
129 void CompletedRedoStep();
133 * Holder for an expandable array of characters that supports undo and line markers.
134 * Based on article "Data Structures in a Bit-Mapped Text Editor"
135 * by Wilfred J. Hansen, Byte January 1987, page 183.
139 SplitVector
<char> substance
;
140 SplitVector
<char> style
;
149 bool UTF8LineEndOverlaps(int position
) const;
150 void ResetLineEnds();
151 /// Actions without undo
152 void BasicInsertString(int position
, const char *s
, int insertLength
);
153 void BasicDeleteChars(int position
, int deleteLength
);
160 /// Retrieving positions outside the range of the buffer works and returns 0
161 char CharAt(int position
) const;
162 void GetCharRange(char *buffer
, int position
, int lengthRetrieve
) const;
163 char StyleAt(int position
) const;
164 void GetStyleRange(unsigned char *buffer
, int position
, int lengthRetrieve
) const;
165 const char *BufferPointer();
166 const char *RangePointer(int position
, int rangeLength
);
167 int GapPosition() const;
170 void Allocate(int newSize
);
171 int GetLineEndTypes() const { return utf8LineEnds
; }
172 void SetLineEndTypes(int utf8LineEnds_
);
173 void SetPerLine(PerLine
*pl
);
175 int LineStart(int line
) const;
176 int LineFromPosition(int pos
) const { return lv
.LineFromPosition(pos
); }
177 void InsertLine(int line
, int position
, bool lineStart
);
178 void RemoveLine(int line
);
179 const char *InsertString(int position
, const char *s
, int insertLength
, bool &startSequence
);
181 /// Setting styles for positions outside the range of the buffer is safe and has no effect.
182 /// @return true if the style of a character is changed.
183 bool SetStyleAt(int position
, char styleValue
, char mask
='\377');
184 bool SetStyleFor(int position
, int length
, char styleValue
, char mask
);
186 const char *DeleteChars(int position
, int deleteLength
, bool &startSequence
);
188 bool IsReadOnly() const;
189 void SetReadOnly(bool set
);
191 /// The save point is a marker in the undo stack where the container has stated that
192 /// the buffer was saved. Undo and redo can move over the save point.
194 bool IsSavePoint() const;
196 bool SetUndoCollection(bool collectUndo
);
197 bool IsCollectingUndo() const;
198 void BeginUndoAction();
199 void EndUndoAction();
200 void AddUndoAction(int token
, bool mayCoalesce
);
201 void DeleteUndoHistory();
203 /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
204 /// called that many times. Similarly for redo.
205 bool CanUndo() const;
207 const Action
&GetUndoStep() const;
208 void PerformUndoStep();
209 bool CanRedo() const;
211 const Action
&GetRedoStep() const;
212 void PerformRedoStep();