72
80
class DocModification;
84
* Interface class for regular expression searching
86
class RegexSearchBase {
88
virtual ~RegexSearchBase(){}
90
virtual long FindText(Document* doc, int minPos, int maxPos, const char *s,
91
bool caseSensitive, bool word, bool wordStart, int flags, int *length) = 0;
93
///@return String with the substitutions, must remain valid until the next call or destruction
94
virtual const char *SubstituteByPosition(Document* doc, const char *text, int *length) = 0;
97
/// Factory function for RegexSearchBase
98
extern RegexSearchBase* CreateRegexSearch(CharClassify *charClassTable);
105
const unsigned char *styles;
106
StyledText( size_t length_, const char *text_, bool multipleStyles_, int style_, const unsigned char *styles_) :
107
length(length_), text(text_), multipleStyles(multipleStyles_), style(style_), styles(styles_) {
109
// Return number of bytes from start to before '\n' or end of text.
110
// Return 1 when start is outside text
111
size_t LineLength(size_t start) const {
113
while ((cur < length) && (text[cur] != '\n'))
117
size_t StyleAt(size_t i) const {
118
return multipleStyles ? styles[i] : style;
124
class Document : PerLine {
80
127
/** Used to pair watcher pointer with user data. */
122
172
bool backspaceUnindents;
174
DecorationList decorations;
125
177
virtual ~Document();
130
int LineFromPosition(int pos);
183
virtual void InsertLine(int line);
184
virtual void RemoveLine(int line);
186
int LineFromPosition(int pos) const;
131
187
int ClampPositionIntoDocument(int pos);
132
188
bool IsCrLf(int pos);
133
189
int LenChar(int pos);
190
bool InGoodUTF8(int pos, int &start, int &end);
134
191
int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true);
136
193
// Gateways to modifying document
137
194
void ModifiedAt(int pos);
195
void CheckReadOnly();
138
196
bool DeleteChars(int pos, int len);
139
bool InsertStyledString(int position, char *s, int insertLength);
197
bool InsertString(int position, const char *s, int insertLength);
142
200
bool CanUndo() { return cb.CanUndo(); }
143
201
bool CanRedo() { return cb.CanRedo(); }
144
void DeleteUndoHistory() { cb.DeleteUndoHistory(); }
202
/* CHANGEBAR begin */
203
void DeleteUndoHistory(bool collectChangeHistory=false) { cb.DeleteUndoHistory(collectChangeHistory); }
145
205
bool SetUndoCollection(bool collectUndo) {
146
206
return cb.SetUndoCollection(collectUndo);
148
208
bool IsCollectingUndo() { return cb.IsCollectingUndo(); }
209
/* CHANGEBAR begin */
210
void DeleteChangeCollection() { cb.DeleteChangeCollection(); }
211
bool SetChangeCollection(bool collectChange) {
212
return cb.SetChangeCollection(collectChange);
149
215
void BeginUndoAction() { cb.BeginUndoAction(); }
150
216
void EndUndoAction() { cb.EndUndoAction(); }
217
void AddUndoAction(int token, bool mayCoalesce) { cb.AddUndoAction(token, mayCoalesce); }
151
218
void SetSavePoint();
152
219
bool IsSavePoint() { return cb.IsSavePoint(); }
220
const char *BufferPointer() { return cb.BufferPointer(); }
154
222
int GetLineIndentation(int line);
155
223
void SetLineIndentation(int line, int indent);
156
int GetLineIndentPosition(int line);
224
int GetLineIndentPosition(int line) const;
157
225
int GetColumn(int position);
158
226
int FindColumn(int line, int column);
159
227
void Indent(bool forwards, int lineBottom, int lineTop);
174
241
cb.GetCharRange(buffer, position, lengthRetrieve);
176
243
char StyleAt(int position) { return cb.StyleAt(position); }
177
int GetMark(int line) { return cb.GetMark(line); }
244
int GetMark(int line);
178
245
int AddMark(int line, int markerNum);
179
246
void AddMarkSet(int line, int valueSet);
180
247
void DeleteMark(int line, int markerNum);
181
248
void DeleteMarkFromHandle(int markerHandle);
182
249
void DeleteAllMarks(int markerNum);
183
int LineFromHandle(int markerHandle) { return cb.LineFromHandle(markerHandle); }
184
int LineStart(int line);
185
int LineEnd(int line);
186
int LineEndPosition(int position);
187
int VCHomePosition(int position);
250
int LineFromHandle(int markerHandle);
251
int LineStart(int line) const;
252
int LineEnd(int line) const;
253
int LineEndPosition(int position) const;
254
bool IsLineEndPosition(int position) const;
255
int VCHomePosition(int position) const;
189
257
int SetLevel(int line, int level);
190
int GetLevel(int line) { return cb.GetLevel(line); }
191
void ClearLevels() { cb.ClearLevels(); }
258
int GetLevel(int line);
192
260
int GetLastChild(int lineParent, int level=-1);
193
261
int GetFoldParent(int line);
262
/* CHANGEBAR begin */
263
int GetChanged(int line) { return cb.GetChanged(line); }
195
266
void Indent(bool forwards);
196
267
int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false);
197
268
int NextWordStart(int pos, int delta);
198
269
int NextWordEnd(int pos, int delta);
199
int Length() { return cb.Length(); }
200
void Allocate(int newSize) { cb.Allocate(newSize*2); }
270
int Length() const { return cb.Length(); }
271
void Allocate(int newSize) { cb.Allocate(newSize); }
201
272
long FindText(int minPos, int maxPos, const char *s,
202
bool caseSensitive, bool word, bool wordStart, bool regExp, bool posix, int *length);
273
bool caseSensitive, bool word, bool wordStart, bool regExp, int flags, int *length);
203
274
long FindText(int iMessage, unsigned long wParam, long lParam);
204
275
const char *SubstituteByPosition(const char *text, int *length);
276
int LinesTotal() const;
207
278
void ChangeCase(Range r, bool makeUpperCase);
209
280
void SetDefaultCharClasses(bool includeWordClass);
210
void SetCharClasses(const unsigned char *chars, charClassification newCharClass);
281
void SetCharClasses(const unsigned char *chars, CharClassify::cc newCharClass);
211
282
void SetStylingBits(int bits);
212
283
void StartStyling(int position, char mask);
213
284
bool SetStyleFor(int length, char style);
214
bool SetStyles(int length, char *styles);
285
bool SetStyles(int length, const char *styles);
215
286
int GetEndStyled() { return endStyled; }
216
bool EnsureStyledTo(int pos);
287
void EnsureStyledTo(int pos);
217
288
int GetStyleClock() { return styleClock; }
218
289
void IncrementStyleClock();
220
int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
221
int GetLineState(int line) { return cb.GetLineState(line); }
222
int GetMaxLineState() { return cb.GetMaxLineState(); }
290
void DecorationFillRange(int position, int value, int fillLength);
292
int SetLineState(int line, int state);
293
int GetLineState(int line);
294
int GetMaxLineState();
296
StyledText MarginStyledText(int line);
297
void MarginSetStyle(int line, int style);
298
void MarginSetStyles(int line, const unsigned char *styles);
299
void MarginSetText(int line, const char *text);
300
int MarginLength(int line) const;
301
void MarginClearAll();
303
bool AnnotationAny() const;
304
StyledText AnnotationStyledText(int line);
305
void AnnotationSetText(int line, const char *text);
306
void AnnotationSetStyle(int line, int style);
307
void AnnotationSetStyles(int line, const unsigned char *styles);
308
int AnnotationLength(int line) const;
309
int AnnotationLines(int line) const;
310
void AnnotationClearAll();
224
312
bool AddWatcher(DocWatcher *watcher, void *userData);
225
313
bool RemoveWatcher(DocWatcher *watcher, void *userData);