]>
Commit | Line | Data |
---|---|---|
9ce192d4 | 1 | // Scintilla source code edit control |
65ec6247 RD |
2 | /** @file Document.h |
3 | ** Text document that handles notifications, DBCS, styling, words and end of line. | |
4 | **/ | |
1dcf666d | 5 | // Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org> |
9ce192d4 RD |
6 | // The License.txt file describes the conditions under which this software may be distributed. |
7 | ||
8 | #ifndef DOCUMENT_H | |
9 | #define DOCUMENT_H | |
10 | ||
7e0c58e9 RD |
11 | #ifdef SCI_NAMESPACE |
12 | namespace Scintilla { | |
13 | #endif | |
14 | ||
65ec6247 RD |
15 | /** |
16 | * A Position is a position within a document between two characters or at the beginning or end. | |
17 | * Sometimes used as a character index where it identifies the character after the position. | |
18 | */ | |
9ce192d4 RD |
19 | typedef int Position; |
20 | const Position invalidPosition = -1; | |
21 | ||
65ec6247 RD |
22 | /** |
23 | * The range class represents a range of text in a document. | |
24 | * The two values are not sorted as one end may be more significant than the other | |
25 | * as is the case for the selection where the end position is the position of the caret. | |
26 | * If either position is invalidPosition then the range is invalid and most operations will fail. | |
27 | */ | |
9ce192d4 RD |
28 | class Range { |
29 | public: | |
30 | Position start; | |
31 | Position end; | |
65ec6247 | 32 | |
9e730a78 | 33 | Range(Position pos=0) : |
9ce192d4 | 34 | start(pos), end(pos) { |
1dcf666d | 35 | } |
9e730a78 | 36 | Range(Position start_, Position end_) : |
9ce192d4 | 37 | start(start_), end(end_) { |
1dcf666d | 38 | } |
65ec6247 | 39 | |
9ce192d4 RD |
40 | bool Valid() const { |
41 | return (start != invalidPosition) && (end != invalidPosition); | |
42 | } | |
65ec6247 | 43 | |
1a2fb4cd | 44 | // Is the position within the range? |
9ce192d4 RD |
45 | bool Contains(Position pos) const { |
46 | if (start < end) { | |
47 | return (pos >= start && pos <= end); | |
48 | } else { | |
49 | return (pos <= start && pos >= end); | |
50 | } | |
51 | } | |
65ec6247 | 52 | |
1a2fb4cd RD |
53 | // Is the character after pos within the range? |
54 | bool ContainsCharacter(Position pos) const { | |
55 | if (start < end) { | |
56 | return (pos >= start && pos < end); | |
57 | } else { | |
58 | return (pos < start && pos >= end); | |
59 | } | |
60 | } | |
61 | ||
9ce192d4 RD |
62 | bool Contains(Range other) const { |
63 | return Contains(other.start) && Contains(other.end); | |
64 | } | |
65ec6247 | 65 | |
9ce192d4 | 66 | bool Overlaps(Range other) const { |
9e730a78 | 67 | return |
9ce192d4 RD |
68 | Contains(other.start) || |
69 | Contains(other.end) || | |
70 | other.Contains(start) || | |
71 | other.Contains(end); | |
72 | } | |
73 | }; | |
74 | ||
75 | class DocWatcher; | |
76 | class DocModification; | |
9e96e16f | 77 | class Document; |
9ce192d4 | 78 | |
65ec6247 | 79 | /** |
9e96e16f | 80 | * Interface class for regular expression searching |
65ec6247 | 81 | */ |
9e96e16f RD |
82 | class RegexSearchBase { |
83 | public: | |
1dcf666d | 84 | virtual ~RegexSearchBase() {} |
9e96e16f | 85 | |
1dcf666d | 86 | virtual long FindText(Document *doc, int minPos, int maxPos, const char *s, |
9e96e16f RD |
87 | bool caseSensitive, bool word, bool wordStart, int flags, int *length) = 0; |
88 | ||
89 | ///@return String with the substitutions, must remain valid until the next call or destruction | |
1dcf666d | 90 | virtual const char *SubstituteByPosition(Document *doc, const char *text, int *length) = 0; |
9e96e16f RD |
91 | }; |
92 | ||
93 | /// Factory function for RegexSearchBase | |
1dcf666d | 94 | extern RegexSearchBase *CreateRegexSearch(CharClassify *charClassTable); |
9e96e16f RD |
95 | |
96 | struct StyledText { | |
97 | size_t length; | |
98 | const char *text; | |
99 | bool multipleStyles; | |
100 | size_t style; | |
101 | const unsigned char *styles; | |
1dcf666d | 102 | StyledText(size_t length_, const char *text_, bool multipleStyles_, int style_, const unsigned char *styles_) : |
9e96e16f RD |
103 | length(length_), text(text_), multipleStyles(multipleStyles_), style(style_), styles(styles_) { |
104 | } | |
105 | // Return number of bytes from start to before '\n' or end of text. | |
106 | // Return 1 when start is outside text | |
107 | size_t LineLength(size_t start) const { | |
108 | size_t cur = start; | |
109 | while ((cur < length) && (text[cur] != '\n')) | |
110 | cur++; | |
111 | return cur-start; | |
112 | } | |
113 | size_t StyleAt(size_t i) const { | |
114 | return multipleStyles ? styles[i] : style; | |
115 | } | |
116 | }; | |
117 | ||
1dcf666d RD |
118 | class HighlightDelimiter { |
119 | public: | |
120 | HighlightDelimiter() : isEnabled(false) { | |
121 | Clear(); | |
122 | } | |
123 | ||
124 | void Clear() { | |
125 | beginFoldBlock = -1; | |
126 | endFoldBlock = -1; | |
127 | firstChangeableLineBefore = -1; | |
128 | firstChangeableLineAfter = -1; | |
129 | } | |
130 | ||
131 | bool NeedsDrawing(int line) { | |
132 | return isEnabled && (line <= firstChangeableLineBefore || line >= firstChangeableLineAfter); | |
133 | } | |
134 | ||
135 | bool IsFoldBlockHighlighted(int line) { | |
136 | return isEnabled && beginFoldBlock != -1 && beginFoldBlock <= line && line <= endFoldBlock; | |
137 | } | |
138 | ||
139 | bool IsHeadOfFoldBlock(int line) { | |
140 | return beginFoldBlock == line && line < endFoldBlock; | |
141 | } | |
142 | ||
143 | bool IsBodyOfFoldBlock(int line) { | |
144 | return beginFoldBlock != -1 && beginFoldBlock < line && line < endFoldBlock; | |
145 | } | |
146 | ||
147 | bool IsTailOfFoldBlock(int line) { | |
148 | return beginFoldBlock != -1 && beginFoldBlock < line && line == endFoldBlock; | |
149 | } | |
150 | ||
151 | int beginFoldBlock; // Begin of current fold block | |
152 | int endFoldBlock; // End of current fold block | |
153 | int firstChangeableLineBefore; // First line that triggers repaint before starting line that determined current fold block | |
154 | int firstChangeableLineAfter; // First line that triggers repaint after starting line that determined current fold block | |
155 | bool isEnabled; | |
156 | }; | |
157 | ||
158 | class CaseFolder { | |
159 | public: | |
160 | virtual ~CaseFolder() { | |
161 | } | |
162 | virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) = 0; | |
163 | }; | |
164 | ||
165 | class CaseFolderTable : public CaseFolder { | |
166 | protected: | |
167 | char mapping[256]; | |
168 | public: | |
169 | CaseFolderTable(); | |
170 | virtual ~CaseFolderTable(); | |
171 | virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed); | |
172 | void SetTranslation(char ch, char chTranslation); | |
173 | void StandardASCII(); | |
174 | }; | |
175 | ||
176 | class Document; | |
177 | ||
178 | class LexInterface { | |
179 | protected: | |
180 | Document *pdoc; | |
181 | ILexer *instance; | |
182 | bool performingStyle; ///< Prevent reentrance | |
183 | public: | |
184 | LexInterface(Document *pdoc_) : pdoc(pdoc_), instance(0), performingStyle(false) { | |
185 | } | |
186 | virtual ~LexInterface() { | |
187 | } | |
188 | void Colourise(int start, int end); | |
189 | bool UseContainerLexing() const { | |
190 | return instance == 0; | |
191 | } | |
192 | }; | |
193 | ||
9e96e16f RD |
194 | /** |
195 | */ | |
1dcf666d | 196 | class Document : PerLine, public IDocument, public ILoader { |
9ce192d4 RD |
197 | |
198 | public: | |
65ec6247 | 199 | /** Used to pair watcher pointer with user data. */ |
9ce192d4 RD |
200 | class WatcherWithUserData { |
201 | public: | |
202 | DocWatcher *watcher; | |
203 | void *userData; | |
204 | WatcherWithUserData() { | |
205 | watcher = 0; | |
206 | userData = 0; | |
207 | } | |
208 | }; | |
591d01be | 209 | |
8e54aaed | 210 | enum charClassification { ccSpace, ccNewLine, ccWord, ccPunctuation }; |
9e730a78 | 211 | private: |
9ce192d4 RD |
212 | int refCount; |
213 | CellBuffer cb; | |
b8193d80 | 214 | CharClassify charClass; |
f6bcfd97 | 215 | char stylingMask; |
9ce192d4 | 216 | int endStyled; |
1a2fb4cd | 217 | int styleClock; |
7e0c58e9 RD |
218 | int enteredModification; |
219 | int enteredStyling; | |
f6bcfd97 | 220 | int enteredReadOnlyCount; |
65ec6247 | 221 | |
9ce192d4 RD |
222 | WatcherWithUserData *watchers; |
223 | int lenWatchers; | |
65ec6247 | 224 | |
9e96e16f | 225 | // ldSize is not real data - it is for dimensions and loops |
1dcf666d | 226 | enum lineData { ldMarkers, ldLevels, ldState, ldMargin, ldAnnotation, ldSize }; |
9e96e16f RD |
227 | PerLine *perLineData[ldSize]; |
228 | ||
65ec6247 | 229 | bool matchesValid; |
1dcf666d | 230 | RegexSearchBase *regex; |
65ec6247 | 231 | |
9ce192d4 | 232 | public: |
1dcf666d RD |
233 | |
234 | LexInterface *pli; | |
235 | ||
9ce192d4 RD |
236 | int stylingBits; |
237 | int stylingBitsMask; | |
65ec6247 | 238 | |
9ce192d4 | 239 | int eolMode; |
65ec6247 | 240 | /// Can also be SC_CP_UTF8 to enable UTF-8 mode |
9ce192d4 RD |
241 | int dbcsCodePage; |
242 | int tabInChars; | |
f6bcfd97 | 243 | int indentInChars; |
591d01be | 244 | int actualIndentInChars; |
f6bcfd97 | 245 | bool useTabs; |
65ec6247 RD |
246 | bool tabIndents; |
247 | bool backspaceUnindents; | |
248 | ||
7e0c58e9 RD |
249 | DecorationList decorations; |
250 | ||
9ce192d4 RD |
251 | Document(); |
252 | virtual ~Document(); | |
65ec6247 | 253 | |
9ce192d4 | 254 | int AddRef(); |
1dcf666d | 255 | int SCI_METHOD Release(); |
65ec6247 | 256 | |
9e96e16f RD |
257 | virtual void Init(); |
258 | virtual void InsertLine(int line); | |
259 | virtual void RemoveLine(int line); | |
260 | ||
1dcf666d RD |
261 | int SCI_METHOD Version() const { |
262 | return dvOriginal; | |
263 | } | |
264 | ||
265 | void SCI_METHOD SetErrorStatus(int status); | |
266 | ||
267 | int SCI_METHOD LineFromPosition(int pos) const; | |
9ce192d4 RD |
268 | int ClampPositionIntoDocument(int pos); |
269 | bool IsCrLf(int pos); | |
f6bcfd97 | 270 | int LenChar(int pos); |
1dcf666d | 271 | bool InGoodUTF8(int pos, int &start, int &end) const; |
9ce192d4 | 272 | int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true); |
1dcf666d RD |
273 | int NextPosition(int pos, int moveDir) const; |
274 | bool NextCharacter(int &pos, int moveDir); // Returns true if pos changed | |
275 | int SCI_METHOD CodePage() const; | |
276 | bool SCI_METHOD IsDBCSLeadByte(char ch) const; | |
277 | int SafeSegment(const char *text, int length, int lengthSegment); | |
9ce192d4 RD |
278 | |
279 | // Gateways to modifying document | |
1e9bafca | 280 | void ModifiedAt(int pos); |
7e0c58e9 | 281 | void CheckReadOnly(); |
a834585d | 282 | bool DeleteChars(int pos, int len); |
7e0c58e9 | 283 | bool InsertString(int position, const char *s, int insertLength); |
1dcf666d RD |
284 | int SCI_METHOD AddData(char *data, int length); |
285 | void * SCI_METHOD ConvertToDocument(); | |
9ce192d4 RD |
286 | int Undo(); |
287 | int Redo(); | |
288 | bool CanUndo() { return cb.CanUndo(); } | |
289 | bool CanRedo() { return cb.CanRedo(); } | |
290 | void DeleteUndoHistory() { cb.DeleteUndoHistory(); } | |
d134f170 | 291 | bool SetUndoCollection(bool collectUndo) { |
9ce192d4 RD |
292 | return cb.SetUndoCollection(collectUndo); |
293 | } | |
d134f170 | 294 | bool IsCollectingUndo() { return cb.IsCollectingUndo(); } |
9ce192d4 RD |
295 | void BeginUndoAction() { cb.BeginUndoAction(); } |
296 | void EndUndoAction() { cb.EndUndoAction(); } | |
9e96e16f | 297 | void AddUndoAction(int token, bool mayCoalesce) { cb.AddUndoAction(token, mayCoalesce); } |
9ce192d4 RD |
298 | void SetSavePoint(); |
299 | bool IsSavePoint() { return cb.IsSavePoint(); } | |
1dcf666d RD |
300 | const char * SCI_METHOD BufferPointer() { return cb.BufferPointer(); } |
301 | const char *RangePointer(int position, int rangeLength) { return cb.RangePointer(position, rangeLength); } | |
302 | int GapPosition() const { return cb.GapPosition(); } | |
f6bcfd97 | 303 | |
1dcf666d | 304 | int SCI_METHOD GetLineIndentation(int line); |
f6bcfd97 | 305 | void SetLineIndentation(int line, int indent); |
7e0c58e9 | 306 | int GetLineIndentPosition(int line) const; |
d134f170 | 307 | int GetColumn(int position); |
1dcf666d | 308 | int CountCharacters(int startPos, int endPos); |
1a2fb4cd | 309 | int FindColumn(int line, int column); |
9ce192d4 | 310 | void Indent(bool forwards, int lineBottom, int lineTop); |
1dcf666d | 311 | static char *TransformLineEnds(int *pLenOut, const char *s, size_t len, int eolModeWanted); |
9ce192d4 RD |
312 | void ConvertLineEnds(int eolModeSet); |
313 | void SetReadOnly(bool set) { cb.SetReadOnly(set); } | |
d134f170 | 314 | bool IsReadOnly() { return cb.IsReadOnly(); } |
9ce192d4 | 315 | |
a834585d | 316 | bool InsertChar(int pos, char ch); |
7e0c58e9 | 317 | bool InsertCString(int position, const char *s); |
f6bcfd97 | 318 | void ChangeChar(int pos, char ch); |
9ce192d4 | 319 | void DelChar(int pos); |
a834585d | 320 | void DelCharBack(int pos); |
9ce192d4 RD |
321 | |
322 | char CharAt(int position) { return cb.CharAt(position); } | |
1dcf666d | 323 | void SCI_METHOD GetCharRange(char *buffer, int position, int lengthRetrieve) const { |
9ce192d4 RD |
324 | cb.GetCharRange(buffer, position, lengthRetrieve); |
325 | } | |
1dcf666d RD |
326 | char SCI_METHOD StyleAt(int position) const { return cb.StyleAt(position); } |
327 | void GetStyleRange(unsigned char *buffer, int position, int lengthRetrieve) const { | |
328 | cb.GetStyleRange(buffer, position, lengthRetrieve); | |
329 | } | |
9e96e16f | 330 | int GetMark(int line); |
1dcf666d | 331 | int MarkerNext(int lineStart, int mask) const; |
f6bcfd97 | 332 | int AddMark(int line, int markerNum); |
1e9bafca | 333 | void AddMarkSet(int line, int valueSet); |
f6bcfd97 BP |
334 | void DeleteMark(int line, int markerNum); |
335 | void DeleteMarkFromHandle(int markerHandle); | |
336 | void DeleteAllMarks(int markerNum); | |
9e96e16f | 337 | int LineFromHandle(int markerHandle); |
1dcf666d | 338 | int SCI_METHOD LineStart(int line) const; |
7e0c58e9 | 339 | int LineEnd(int line) const; |
9e96e16f RD |
340 | int LineEndPosition(int position) const; |
341 | bool IsLineEndPosition(int position) const; | |
342 | int VCHomePosition(int position) const; | |
9ce192d4 | 343 | |
1dcf666d RD |
344 | int SCI_METHOD SetLevel(int line, int level); |
345 | int SCI_METHOD GetLevel(int line) const; | |
9e96e16f | 346 | void ClearLevels(); |
1dcf666d | 347 | int GetLastChild(int lineParent, int level=-1, int lastLine=-1); |
9ce192d4 | 348 | int GetFoldParent(int line); |
1dcf666d | 349 | void GetHighlightDelimiters(HighlightDelimiter &hDelimiter, int line, int lastLine); |
9ce192d4 RD |
350 | |
351 | void Indent(bool forwards); | |
1a2fb4cd | 352 | int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false); |
9ce192d4 | 353 | int NextWordStart(int pos, int delta); |
8e54aaed | 354 | int NextWordEnd(int pos, int delta); |
1dcf666d | 355 | int SCI_METHOD Length() const { return cb.Length(); } |
7e0c58e9 | 356 | void Allocate(int newSize) { cb.Allocate(newSize); } |
1dcf666d RD |
357 | bool MatchesWordOptions(bool word, bool wordStart, int pos, int length); |
358 | long FindText(int minPos, int maxPos, const char *search, bool caseSensitive, bool word, | |
359 | bool wordStart, bool regExp, int flags, int *length, CaseFolder *pcf); | |
65ec6247 | 360 | const char *SubstituteByPosition(const char *text, int *length); |
7e0c58e9 | 361 | int LinesTotal() const; |
65ec6247 | 362 | |
f6bcfd97 | 363 | void ChangeCase(Range r, bool makeUpperCase); |
591d01be RD |
364 | |
365 | void SetDefaultCharClasses(bool includeWordClass); | |
b8193d80 | 366 | void SetCharClasses(const unsigned char *chars, CharClassify::cc newCharClass); |
1dcf666d | 367 | int GetCharsOfClass(CharClassify::cc charClass, unsigned char *buffer); |
9ce192d4 | 368 | void SetStylingBits(int bits); |
1dcf666d RD |
369 | void SCI_METHOD StartStyling(int position, char mask); |
370 | bool SCI_METHOD SetStyleFor(int length, char style); | |
371 | bool SCI_METHOD SetStyles(int length, const char *styles); | |
9ce192d4 | 372 | int GetEndStyled() { return endStyled; } |
7e0c58e9 | 373 | void EnsureStyledTo(int pos); |
1dcf666d | 374 | void LexerChanged(); |
1a2fb4cd | 375 | int GetStyleClock() { return styleClock; } |
591d01be | 376 | void IncrementStyleClock(); |
1dcf666d RD |
377 | void SCI_METHOD DecorationSetCurrentIndicator(int indicator) { |
378 | decorations.SetCurrentIndicator(indicator); | |
379 | } | |
380 | void SCI_METHOD DecorationFillRange(int position, int value, int fillLength); | |
9ce192d4 | 381 | |
1dcf666d RD |
382 | int SCI_METHOD SetLineState(int line, int state); |
383 | int SCI_METHOD GetLineState(int line) const; | |
9e96e16f | 384 | int GetMaxLineState(); |
1dcf666d | 385 | void SCI_METHOD ChangeLexerState(int start, int end); |
9e96e16f RD |
386 | |
387 | StyledText MarginStyledText(int line); | |
388 | void MarginSetStyle(int line, int style); | |
389 | void MarginSetStyles(int line, const unsigned char *styles); | |
390 | void MarginSetText(int line, const char *text); | |
391 | int MarginLength(int line) const; | |
392 | void MarginClearAll(); | |
393 | ||
394 | bool AnnotationAny() const; | |
395 | StyledText AnnotationStyledText(int line); | |
396 | void AnnotationSetText(int line, const char *text); | |
397 | void AnnotationSetStyle(int line, int style); | |
398 | void AnnotationSetStyles(int line, const unsigned char *styles); | |
399 | int AnnotationLength(int line) const; | |
400 | int AnnotationLines(int line) const; | |
401 | void AnnotationClearAll(); | |
65ec6247 | 402 | |
9ce192d4 RD |
403 | bool AddWatcher(DocWatcher *watcher, void *userData); |
404 | bool RemoveWatcher(DocWatcher *watcher, void *userData); | |
405 | const WatcherWithUserData *GetWatchers() const { return watchers; } | |
406 | int GetLenWatchers() const { return lenWatchers; } | |
65ec6247 | 407 | |
1dcf666d | 408 | CharClassify::cc WordCharClass(unsigned char ch); |
65ec6247 RD |
409 | bool IsWordPartSeparator(char ch); |
410 | int WordPartLeft(int pos); | |
411 | int WordPartRight(int pos); | |
8e54aaed | 412 | int ExtendStyleRange(int pos, int delta, bool singleLine = false); |
7e0c58e9 | 413 | bool IsWhiteLine(int line) const; |
9e730a78 RD |
414 | int ParaUp(int pos); |
415 | int ParaDown(int pos); | |
591d01be | 416 | int IndentSize() { return actualIndentInChars; } |
1e9bafca | 417 | int BraceMatch(int position, int maxReStyle); |
65ec6247 | 418 | |
9ce192d4 | 419 | private: |
d134f170 RD |
420 | bool IsWordStartAt(int pos); |
421 | bool IsWordEndAt(int pos); | |
9ce192d4 | 422 | bool IsWordAt(int start, int end); |
65ec6247 | 423 | |
9ce192d4 RD |
424 | void NotifyModifyAttempt(); |
425 | void NotifySavePoint(bool atSavePoint); | |
426 | void NotifyModified(DocModification mh); | |
427 | }; | |
428 | ||
9e96e16f RD |
429 | class UndoGroup { |
430 | Document *pdoc; | |
431 | bool groupNeeded; | |
432 | public: | |
1dcf666d | 433 | UndoGroup(Document *pdoc_, bool groupNeeded_=true) : |
9e96e16f RD |
434 | pdoc(pdoc_), groupNeeded(groupNeeded_) { |
435 | if (groupNeeded) { | |
436 | pdoc->BeginUndoAction(); | |
437 | } | |
438 | } | |
439 | ~UndoGroup() { | |
440 | if (groupNeeded) { | |
441 | pdoc->EndUndoAction(); | |
442 | } | |
443 | } | |
444 | bool Needed() const { | |
445 | return groupNeeded; | |
446 | } | |
447 | }; | |
448 | ||
449 | ||
65ec6247 RD |
450 | /** |
451 | * To optimise processing of document modifications by DocWatchers, a hint is passed indicating the | |
452 | * scope of the change. | |
453 | * If the DocWatcher is a document view then this can be used to optimise screen updating. | |
454 | */ | |
9ce192d4 RD |
455 | class DocModification { |
456 | public: | |
457 | int modificationType; | |
458 | int position; | |
459 | int length; | |
65ec6247 RD |
460 | int linesAdded; /**< Negative if lines deleted. */ |
461 | const char *text; /**< Only valid for changes to text, not for changes to style. */ | |
9ce192d4 RD |
462 | int line; |
463 | int foldLevelNow; | |
464 | int foldLevelPrev; | |
9e96e16f RD |
465 | int annotationLinesAdded; |
466 | int token; | |
9ce192d4 | 467 | |
9e730a78 | 468 | DocModification(int modificationType_, int position_=0, int length_=0, |
1e9bafca | 469 | int linesAdded_=0, const char *text_=0, int line_=0) : |
9ce192d4 RD |
470 | modificationType(modificationType_), |
471 | position(position_), | |
472 | length(length_), | |
473 | linesAdded(linesAdded_), | |
474 | text(text_), | |
1e9bafca | 475 | line(line_), |
9ce192d4 | 476 | foldLevelNow(0), |
9e96e16f RD |
477 | foldLevelPrev(0), |
478 | annotationLinesAdded(0), | |
479 | token(0) {} | |
f6bcfd97 | 480 | |
1e9bafca | 481 | DocModification(int modificationType_, const Action &act, int linesAdded_=0) : |
f6bcfd97 | 482 | modificationType(modificationType_), |
1e9bafca | 483 | position(act.position), |
f6bcfd97 BP |
484 | length(act.lenData), |
485 | linesAdded(linesAdded_), | |
486 | text(act.data), | |
487 | line(0), | |
488 | foldLevelNow(0), | |
9e96e16f RD |
489 | foldLevelPrev(0), |
490 | annotationLinesAdded(0), | |
491 | token(0) {} | |
9ce192d4 RD |
492 | }; |
493 | ||
65ec6247 RD |
494 | /** |
495 | * A class that wants to receive notifications from a Document must be derived from DocWatcher | |
496 | * and implement the notification methods. It can then be added to the watcher list with AddWatcher. | |
497 | */ | |
9ce192d4 RD |
498 | class DocWatcher { |
499 | public: | |
500 | virtual ~DocWatcher() {} | |
65ec6247 | 501 | |
9ce192d4 RD |
502 | virtual void NotifyModifyAttempt(Document *doc, void *userData) = 0; |
503 | virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0; | |
504 | virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0; | |
505 | virtual void NotifyDeleted(Document *doc, void *userData) = 0; | |
f6bcfd97 | 506 | virtual void NotifyStyleNeeded(Document *doc, void *userData, int endPos) = 0; |
1dcf666d RD |
507 | virtual void NotifyLexerChanged(Document *doc, void *userData) = 0; |
508 | virtual void NotifyErrorOccurred(Document *doc, void *userData, int status) = 0; | |
9ce192d4 RD |
509 | }; |
510 | ||
7e0c58e9 RD |
511 | #ifdef SCI_NAMESPACE |
512 | } | |
513 | #endif | |
514 | ||
9ce192d4 | 515 | #endif |