geany  1.38
About: Geany is a text editor (using GTK2) with basic features of an integrated development environment (syntax highlighting, code folding, symbol name auto-completion, ...). F: office T: editor programming GTK+ IDE
  Fossies Dox: geany-1.38.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Document.h
Go to the documentation of this file.
1// Scintilla source code edit control
2/** @file Document.h
3 ** Text document that handles notifications, DBCS, styling, words and end of line.
4 **/
5// Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org>
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
11namespace Scintilla {
12
13class DocWatcher;
14class DocModification;
15class Document;
16class LineMarkers;
17class LineLevels;
18class LineState;
19class LineAnnotation;
20
22
23/**
24 * The range class represents a range of text in a document.
25 * The two values are not sorted as one end may be more significant than the other
26 * as is the case for the selection where the end position is the position of the caret.
27 * If either position is invalidPosition then the range is invalid and most operations will fail.
28 */
29class Range {
30public:
33
34 explicit Range(Sci::Position pos=0) noexcept :
35 start(pos), end(pos) {
36 }
37 Range(Sci::Position start_, Sci::Position end_) noexcept :
38 start(start_), end(end_) {
39 }
40
41 bool operator==(const Range &other) const noexcept {
42 return (start == other.start) && (end == other.end);
43 }
44
45 bool Valid() const noexcept {
47 }
48
49 Sci::Position First() const noexcept {
50 return (start <= end) ? start : end;
51 }
52
53 Sci::Position Last() const noexcept {
54 return (start > end) ? start : end;
55 }
56
57 // Is the position within the range?
58 bool Contains(Sci::Position pos) const noexcept {
59 if (start < end) {
60 return (pos >= start && pos <= end);
61 } else {
62 return (pos <= start && pos >= end);
63 }
64 }
65
66 // Is the character after pos within the range?
67 bool ContainsCharacter(Sci::Position pos) const noexcept {
68 if (start < end) {
69 return (pos >= start && pos < end);
70 } else {
71 return (pos < start && pos >= end);
72 }
73 }
74
75 bool Contains(Range other) const noexcept {
76 return Contains(other.start) && Contains(other.end);
77 }
78
79 bool Overlaps(Range other) const noexcept {
80 return
81 Contains(other.start) ||
82 Contains(other.end) ||
83 other.Contains(start) ||
84 other.Contains(end);
85 }
86};
87
88/**
89 * Interface class for regular expression searching
90 */
92public:
93 virtual ~RegexSearchBase() {}
94
95 virtual Sci::Position FindText(Document *doc, Sci::Position minPos, Sci::Position maxPos, const char *s,
96 bool caseSensitive, bool word, bool wordStart, int flags, Sci::Position *length) = 0;
97
98 ///@return String with the substitutions, must remain valid until the next call or destruction
99 virtual const char *SubstituteByPosition(Document *doc, const char *text, Sci::Position *length) = 0;
100};
101
102/// Factory function for RegexSearchBase
103extern RegexSearchBase *CreateRegexSearch(CharClassify *charClassTable);
104
106 size_t length;
107 const char *text;
109 size_t style;
110 const unsigned char *styles;
111 StyledText(size_t length_, const char *text_, bool multipleStyles_, int style_, const unsigned char *styles_) noexcept :
112 length(length_), text(text_), multipleStyles(multipleStyles_), style(style_), styles(styles_) {
113 }
114 // Return number of bytes from start to before '\n' or end of text.
115 // Return 1 when start is outside text
116 size_t LineLength(size_t start) const noexcept {
117 size_t cur = start;
118 while ((cur < length) && (text[cur] != '\n'))
119 cur++;
120 return cur-start;
121 }
122 size_t StyleAt(size_t i) const noexcept {
123 return multipleStyles ? styles[i] : style;
124 }
125};
126
128public:
129 HighlightDelimiter() noexcept : isEnabled(false) {
130 Clear();
131 }
132
133 void Clear() noexcept {
134 beginFoldBlock = -1;
135 endFoldBlock = -1;
138 }
139
140 bool NeedsDrawing(Sci::Line line) const noexcept {
141 return isEnabled && (line <= firstChangeableLineBefore || line >= firstChangeableLineAfter);
142 }
143
144 bool IsFoldBlockHighlighted(Sci::Line line) const noexcept {
145 return isEnabled && beginFoldBlock != -1 && beginFoldBlock <= line && line <= endFoldBlock;
146 }
147
148 bool IsHeadOfFoldBlock(Sci::Line line) const noexcept {
149 return beginFoldBlock == line && line < endFoldBlock;
150 }
151
152 bool IsBodyOfFoldBlock(Sci::Line line) const noexcept {
153 return beginFoldBlock != -1 && beginFoldBlock < line && line < endFoldBlock;
154 }
155
156 bool IsTailOfFoldBlock(Sci::Line line) const noexcept {
157 return beginFoldBlock != -1 && beginFoldBlock < line && line == endFoldBlock;
158 }
159
160 Sci::Line beginFoldBlock; // Begin of current fold block
161 Sci::Line endFoldBlock; // End of current fold block
162 Sci::Line firstChangeableLineBefore; // First line that triggers repaint before starting line that determined current fold block
163 Sci::Line firstChangeableLineAfter; // First line that triggers repaint after starting line that determined current fold block
165};
166
167constexpr int LevelNumber(int level) noexcept {
168 return level & SC_FOLDLEVELNUMBERMASK;
169}
170
172protected:
175 bool performingStyle; ///< Prevent reentrance
176public:
177 explicit LexInterface(Document *pdoc_) noexcept : pdoc(pdoc_), instance(nullptr), performingStyle(false) {
178 }
179 virtual ~LexInterface() {
180 }
181 void Colourise(Sci::Position start, Sci::Position end);
182 virtual int LineEndTypesSupported();
183 bool UseContainerLexing() const noexcept {
184 return instance == nullptr;
185 }
186};
187
188struct RegexError : public std::runtime_error {
189 RegexError() : std::runtime_error("regex failure") {}
190};
191
192/**
193 * The ActionDuration class stores the average time taken for some action such as styling or
194 * wrapping a line. It is used to decide how many repetitions of that action can be performed
195 * on idle to maximize efficiency without affecting application responsiveness.
196 * The duration changes if the time for the action changes. For example, if a simple lexer is
197 * changed to a complex lexer. Changes are damped and clamped to avoid short periods of easy
198 * or difficult processing moving the value too far leading to inefficiency or poor user
199 * experience.
200 */
201
203 double duration;
204 const double minDuration;
205 const double maxDuration;
206public:
207 ActionDuration(double duration_, double minDuration_, double maxDuration_) noexcept;
208 void AddSample(size_t numberActions, double durationOfActions) noexcept;
209 double Duration() const noexcept;
210};
211
212/**
213 */
215
216public:
217 /** Used to pair watcher pointer with user data. */
220 void *userData;
221 WatcherWithUserData(DocWatcher *watcher_=nullptr, void *userData_=nullptr) noexcept :
222 watcher(watcher_), userData(userData_) {
223 }
224 bool operator==(const WatcherWithUserData &other) const noexcept {
225 return (watcher == other.watcher) && (userData == other.userData);
226 }
227 };
228
229private:
234 std::unique_ptr<CaseFolder> pcf;
240
242 std::string insertion;
243
244 std::vector<WatcherWithUserData> watchers;
245
246 // ldSize is not real data - it is for dimensions and loops
247 enum lineData { ldMarkers, ldLevels, ldState, ldMargin, ldAnnotation, ldEOLAnnotation, ldSize };
248 std::unique_ptr<PerLine> perLineData[ldSize];
249 LineMarkers *Markers() const noexcept;
250 LineLevels *Levels() const noexcept;
251 LineState *States() const noexcept;
252 LineAnnotation *Margins() const noexcept;
253 LineAnnotation *Annotations() const noexcept;
254 LineAnnotation *EOLAnnotations() const noexcept;
255
256 bool matchesValid;
257 std::unique_ptr<RegexSearchBase> regex;
258 std::unique_ptr<LexInterface> pli;
259
260public:
261
263 unsigned int character;
264 unsigned int widthBytes;
265 CharacterExtracted(unsigned int character_, unsigned int widthBytes_) noexcept :
266 character(character_), widthBytes(widthBytes_) {
267 }
268 // For DBCS characters turn 2 bytes into an int
269 static CharacterExtracted DBCS(unsigned char lead, unsigned char trail) noexcept {
270 return CharacterExtracted((lead << 8) | trail, 2);
271 }
272 };
273
275 /// Can also be SC_CP_UTF8 to enable UTF-8 mode
285
286 std::unique_ptr<IDecorationList> decorations;
287
288 Document(int options);
289 // Deleted so Document objects can not be copied.
290 Document(const Document &) = delete;
291 Document(Document &&) = delete;
292 void operator=(const Document &) = delete;
294 ~Document() override;
295
296 int AddRef();
297 int SCI_METHOD Release() override;
298
299 // From PerLine
300 void Init() override;
301 void InsertLine(Sci::Line line) override;
302 void InsertLines(Sci::Line line, Sci::Line lines) override;
303 void RemoveLine(Sci::Line line) override;
304
305 int LineEndTypesSupported() const;
306 bool SetDBCSCodePage(int dbcsCodePage_);
307 int GetLineEndTypesAllowed() const noexcept { return cb.GetLineEndTypes(); }
308 bool SetLineEndTypesAllowed(int lineEndBitSet_);
309 int GetLineEndTypesActive() const noexcept { return cb.GetLineEndTypes(); }
310
311 int SCI_METHOD Version() const override {
312 return dvLineEnd;
313 }
314
315 void SCI_METHOD SetErrorStatus(int status) override;
316
317 Sci_Position SCI_METHOD LineFromPosition(Sci_Position pos) const override;
318 Sci::Line SciLineFromPosition(Sci::Position pos) const noexcept; // Avoids casting LineFromPosition
319 Sci::Position ClampPositionIntoDocument(Sci::Position pos) const noexcept;
320 bool ContainsLineEnd(const char *s, Sci::Position length) const noexcept { return cb.ContainsLineEnd(s, length); }
321 bool IsCrLf(Sci::Position pos) const noexcept;
322 int LenChar(Sci::Position pos) const noexcept;
323 bool InGoodUTF8(Sci::Position pos, Sci::Position &start, Sci::Position &end) const noexcept;
324 Sci::Position MovePositionOutsideChar(Sci::Position pos, Sci::Position moveDir, bool checkLineEnd=true) const noexcept;
325 Sci::Position NextPosition(Sci::Position pos, int moveDir) const noexcept;
326 bool NextCharacter(Sci::Position &pos, int moveDir) const noexcept; // Returns true if pos changed
327 Document::CharacterExtracted CharacterAfter(Sci::Position position) const noexcept;
328 Document::CharacterExtracted CharacterBefore(Sci::Position position) const noexcept;
329 Sci_Position SCI_METHOD GetRelativePosition(Sci_Position positionStart, Sci_Position characterOffset) const override;
330 Sci::Position GetRelativePositionUTF16(Sci::Position positionStart, Sci::Position characterOffset) const noexcept;
331 int SCI_METHOD GetCharacterAndWidth(Sci_Position position, Sci_Position *pWidth) const override;
332 int SCI_METHOD CodePage() const override;
333 bool SCI_METHOD IsDBCSLeadByte(char ch) const override;
334 bool IsDBCSLeadByteNoExcept(char ch) const noexcept;
335 bool IsDBCSLeadByteInvalid(char ch) const noexcept;
336 bool IsDBCSTrailByteInvalid(char ch) const noexcept;
337 int DBCSDrawBytes(const char *text, int len) const noexcept;
338 int SafeSegment(const char *text, int length, int lengthSegment) const noexcept;
339 EncodingFamily CodePageFamily() const noexcept;
340
341 // Gateways to modifying document
342 void ModifiedAt(Sci::Position pos) noexcept;
343 void CheckReadOnly();
344 bool DeleteChars(Sci::Position pos, Sci::Position len);
345 Sci::Position InsertString(Sci::Position position, const char *s, Sci::Position insertLength);
346 void ChangeInsertion(const char *s, Sci::Position length);
347 int SCI_METHOD AddData(const char *data, Sci_Position length) override;
348 void * SCI_METHOD ConvertToDocument() override;
349 Sci::Position Undo();
350 Sci::Position Redo();
351 bool CanUndo() const noexcept { return cb.CanUndo(); }
352 bool CanRedo() const noexcept { return cb.CanRedo(); }
354 bool SetUndoCollection(bool collectUndo) {
355 return cb.SetUndoCollection(collectUndo);
356 }
357 bool IsCollectingUndo() const noexcept { return cb.IsCollectingUndo(); }
360 void AddUndoAction(Sci::Position token, bool mayCoalesce) { cb.AddUndoAction(token, mayCoalesce); }
361 void SetSavePoint();
362 bool IsSavePoint() const noexcept { return cb.IsSavePoint(); }
363
366 void TentativeUndo();
367 bool TentativeActive() const noexcept { return cb.TentativeActive(); }
368
369 const char * SCI_METHOD BufferPointer() override { return cb.BufferPointer(); }
370 const char *RangePointer(Sci::Position position, Sci::Position rangeLength) noexcept { return cb.RangePointer(position, rangeLength); }
371 Sci::Position GapPosition() const noexcept { return cb.GapPosition(); }
372
373 int SCI_METHOD GetLineIndentation(Sci_Position line) override;
374 Sci::Position SetLineIndentation(Sci::Line line, Sci::Position indent);
375 Sci::Position GetLineIndentPosition(Sci::Line line) const;
377 Sci::Position CountCharacters(Sci::Position startPos, Sci::Position endPos) const noexcept;
378 Sci::Position CountUTF16(Sci::Position startPos, Sci::Position endPos) const noexcept;
379 Sci::Position FindColumn(Sci::Line line, Sci::Position column);
380 void Indent(bool forwards, Sci::Line lineBottom, Sci::Line lineTop);
381 static std::string TransformLineEnds(const char *s, size_t len, int eolModeWanted);
382 void ConvertLineEnds(int eolModeSet);
383 void SetReadOnly(bool set) { cb.SetReadOnly(set); }
384 bool IsReadOnly() const noexcept { return cb.IsReadOnly(); }
385 bool IsLarge() const noexcept { return cb.IsLarge(); }
386 int Options() const noexcept;
387
388 void DelChar(Sci::Position pos);
389 void DelCharBack(Sci::Position pos);
390
391 char CharAt(Sci::Position position) const noexcept { return cb.CharAt(position); }
392 void SCI_METHOD GetCharRange(char *buffer, Sci_Position position, Sci_Position lengthRetrieve) const override {
393 cb.GetCharRange(buffer, position, lengthRetrieve);
394 }
395 char SCI_METHOD StyleAt(Sci_Position position) const override { return cb.StyleAt(position); }
396 int StyleIndexAt(Sci_Position position) const noexcept { return static_cast<unsigned char>(cb.StyleAt(position)); }
397 void GetStyleRange(unsigned char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const {
398 cb.GetStyleRange(buffer, position, lengthRetrieve);
399 }
400 int GetMark(Sci::Line line) const noexcept;
401 Sci::Line MarkerNext(Sci::Line lineStart, int mask) const noexcept;
402 int AddMark(Sci::Line line, int markerNum);
403 void AddMarkSet(Sci::Line line, int valueSet);
404 void DeleteMark(Sci::Line line, int markerNum);
405 void DeleteMarkFromHandle(int markerHandle);
406 void DeleteAllMarks(int markerNum);
407 Sci::Line LineFromHandle(int markerHandle) const noexcept;
408 int MarkerNumberFromLine(Sci::Line line, int which) const noexcept;
409 int MarkerHandleFromLine(Sci::Line line, int which) const noexcept;
411 bool IsLineStartPosition(Sci::Position position) const;
413 Sci::Position LineEndPosition(Sci::Position position) const;
414 bool IsLineEndPosition(Sci::Position position) const;
415 bool IsPositionInLineEnd(Sci::Position position) const;
416 Sci::Position VCHomePosition(Sci::Position position) const;
417 Sci::Position IndexLineStart(Sci::Line line, int lineCharacterIndex) const noexcept;
418 Sci::Line LineFromPositionIndex(Sci::Position pos, int lineCharacterIndex) const noexcept;
419
420 int SCI_METHOD SetLevel(Sci_Position line, int level) override;
421 int SCI_METHOD GetLevel(Sci_Position line) const override;
422 void ClearLevels();
423 Sci::Line GetLastChild(Sci::Line lineParent, int level=-1, Sci::Line lastLine=-1);
424 Sci::Line GetFoldParent(Sci::Line line) const;
425 void GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, Sci::Line line, Sci::Line lastLine);
426
427 Sci::Position ExtendWordSelect(Sci::Position pos, int delta, bool onlyWordCharacters=false) const;
428 Sci::Position NextWordStart(Sci::Position pos, int delta) const;
429 Sci::Position NextWordEnd(Sci::Position pos, int delta) const;
430 Sci_Position SCI_METHOD Length() const override { return cb.Length(); }
431 Sci::Position LengthNoExcept() const noexcept { return cb.Length(); }
432 void Allocate(Sci::Position newSize) { cb.Allocate(newSize); }
433
434 CharacterExtracted ExtractCharacter(Sci::Position position) const noexcept;
435
436 bool IsWordStartAt(Sci::Position pos) const;
437 bool IsWordEndAt(Sci::Position pos) const;
438 bool IsWordAt(Sci::Position start, Sci::Position end) const;
439
440 bool MatchesWordOptions(bool word, bool wordStart, Sci::Position pos, Sci::Position length) const;
441 bool HasCaseFolder() const noexcept;
442 void SetCaseFolder(CaseFolder *pcf_) noexcept;
443 Sci::Position FindText(Sci::Position minPos, Sci::Position maxPos, const char *search, int flags, Sci::Position *length);
444 const char *SubstituteByPosition(const char *text, Sci::Position *length);
445 int LineCharacterIndex() const noexcept;
446 void AllocateLineCharacterIndex(int lineCharacterIndex);
447 void ReleaseLineCharacterIndex(int lineCharacterIndex);
448 Sci::Line LinesTotal() const noexcept;
449
450 void SetDefaultCharClasses(bool includeWordClass);
451 void SetCharClasses(const unsigned char *chars, CharClassify::cc newCharClass);
452 int GetCharsOfClass(CharClassify::cc characterClass, unsigned char *buffer) const;
453 void SetCharacterCategoryOptimization(int countCharacters);
454 int CharacterCategoryOptimization() const noexcept;
455 void SCI_METHOD StartStyling(Sci_Position position, char mask) override;
456 bool SCI_METHOD SetStyleFor(Sci_Position length, char style) override;
457 bool SCI_METHOD SetStyles(Sci_Position length, const char *styles) override;
458 Sci::Position GetEndStyled() const noexcept { return endStyled; }
459 void EnsureStyledTo(Sci::Position pos);
460 void StyleToAdjustingLineDuration(Sci::Position pos);
461 void LexerChanged();
462 int GetStyleClock() const noexcept { return styleClock; }
463 void IncrementStyleClock() noexcept;
464 void SCI_METHOD DecorationSetCurrentIndicator(int indicator) override;
465 void SCI_METHOD DecorationFillRange(Sci_Position position, int value, Sci_Position fillLength) override;
466 LexInterface *GetLexInterface() const noexcept;
467 void SetLexInterface(std::unique_ptr<LexInterface> pLexInterface) noexcept;
468
469 int SCI_METHOD SetLineState(Sci_Position line, int state) override;
470 int SCI_METHOD GetLineState(Sci_Position line) const override;
471 Sci::Line GetMaxLineState() const noexcept;
472 void SCI_METHOD ChangeLexerState(Sci_Position start, Sci_Position end) override;
473
474 StyledText MarginStyledText(Sci::Line line) const noexcept;
475 void MarginSetStyle(Sci::Line line, int style);
476 void MarginSetStyles(Sci::Line line, const unsigned char *styles);
477 void MarginSetText(Sci::Line line, const char *text);
478 void MarginClearAll();
479
480 StyledText AnnotationStyledText(Sci::Line line) const noexcept;
481 void AnnotationSetText(Sci::Line line, const char *text);
482 void AnnotationSetStyle(Sci::Line line, int style);
483 void AnnotationSetStyles(Sci::Line line, const unsigned char *styles);
484 int AnnotationLines(Sci::Line line) const noexcept;
485 void AnnotationClearAll();
486
487 StyledText EOLAnnotationStyledText(Sci::Line line) const noexcept;
488 void EOLAnnotationSetStyle(Sci::Line line, int style);
489 void EOLAnnotationSetText(Sci::Line line, const char *text);
490 void EOLAnnotationClearAll();
491
492 bool AddWatcher(DocWatcher *watcher, void *userData);
493 bool RemoveWatcher(DocWatcher *watcher, void *userData);
494
495 CharClassify::cc WordCharacterClass(unsigned int ch) const;
496 bool IsWordPartSeparator(unsigned int ch) const;
497 Sci::Position WordPartLeft(Sci::Position pos) const;
498 Sci::Position WordPartRight(Sci::Position pos) const;
499 Sci::Position ExtendStyleRange(Sci::Position pos, int delta, bool singleLine) noexcept;
500 bool IsWhiteLine(Sci::Line line) const;
501 Sci::Position ParaUp(Sci::Position pos) const;
502 Sci::Position ParaDown(Sci::Position pos) const;
503 int IndentSize() const noexcept { return actualIndentInChars; }
504 Sci::Position BraceMatch(Sci::Position position, Sci::Position maxReStyle, Sci::Position startPos, bool useStartPos) noexcept;
505
506private:
507 void NotifyModifyAttempt();
508 void NotifySavePoint(bool atSavePoint);
509 void NotifyModified(DocModification mh);
510};
511
515public:
516 UndoGroup(Document *pdoc_, bool groupNeeded_=true) :
517 pdoc(pdoc_), groupNeeded(groupNeeded_) {
518 if (groupNeeded) {
519 pdoc->BeginUndoAction();
520 }
521 }
522 // Deleted so UndoGroup objects can not be copied.
523 UndoGroup(const UndoGroup &) = delete;
524 UndoGroup(UndoGroup &&) = delete;
525 void operator=(const UndoGroup &) = delete;
528 if (groupNeeded) {
529 pdoc->EndUndoAction();
530 }
531 }
532 bool Needed() const noexcept {
533 return groupNeeded;
534 }
535};
536
537
538/**
539 * To optimise processing of document modifications by DocWatchers, a hint is passed indicating the
540 * scope of the change.
541 * If the DocWatcher is a document view then this can be used to optimise screen updating.
542 */
544public:
548 Sci::Line linesAdded; /**< Negative if lines deleted. */
549 const char *text; /**< Only valid for changes to text, not for changes to style. */
555
556 DocModification(int modificationType_, Sci::Position position_=0, Sci::Position length_=0,
557 Sci::Line linesAdded_=0, const char *text_=nullptr, Sci::Line line_=0) noexcept :
558 modificationType(modificationType_),
559 position(position_),
560 length(length_),
561 linesAdded(linesAdded_),
562 text(text_),
563 line(line_),
564 foldLevelNow(0),
565 foldLevelPrev(0),
566 annotationLinesAdded(0),
567 token(0) {}
568
569 DocModification(int modificationType_, const Action &act, Sci::Line linesAdded_=0) noexcept :
570 modificationType(modificationType_),
571 position(act.position),
572 length(act.lenData),
573 linesAdded(linesAdded_),
574 text(act.data.get()),
575 line(0),
576 foldLevelNow(0),
577 foldLevelPrev(0),
578 annotationLinesAdded(0),
579 token(0) {}
580};
581
582/**
583 * A class that wants to receive notifications from a Document must be derived from DocWatcher
584 * and implement the notification methods. It can then be added to the watcher list with AddWatcher.
585 */
587public:
588 virtual ~DocWatcher() {}
589
590 virtual void NotifyModifyAttempt(Document *doc, void *userData) = 0;
591 virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0;
592 virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0;
593 virtual void NotifyDeleted(Document *doc, void *userData) noexcept = 0;
594 virtual void NotifyStyleNeeded(Document *doc, void *userData, Sci::Position endPos) = 0;
595 virtual void NotifyLexerChanged(Document *doc, void *userData) = 0;
596 virtual void NotifyErrorOccurred(Document *doc, void *userData, int status) = 0;
597};
598
599}
600
601#endif
static Sci_Position LineEnd(Sci_Position line, Accessor &styler)
Definition: LexAbaqus.cxx:302
static Sci_Position LineStart(Sci_Position line, Accessor &styler)
Definition: LexAbaqus.cxx:315
#define SCI_METHOD
Definition: Sci_Position.h:26
ptrdiff_t Sci_Position
Definition: Sci_Position.h:15
#define SC_FOLDLEVELNUMBERMASK
Definition: Scintilla.h:497
The ActionDuration class stores the average time taken for some action such as styling or wrapping a ...
Definition: Document.h:202
void AddSample(size_t numberActions, double durationOfActions) noexcept
Definition: Document.cxx:94
double Duration() const noexcept
Definition: Document.cxx:108
ActionDuration(double duration_, double minDuration_, double maxDuration_) noexcept
Definition: Document.cxx:90
const double minDuration
Definition: Document.h:204
const double maxDuration
Definition: Document.h:205
Actions are used to store all the information required to perform one undo/redo step.
Definition: CellBuffer.h:33
Holder for an expandable array of characters that supports undo and line markers.
Definition: CellBuffer.h:110
bool IsSavePoint() const noexcept
Definition: CellBuffer.cxx:813
void Allocate(Sci::Position newSize)
Definition: CellBuffer.cxx:709
bool IsLarge() const noexcept
Definition: CellBuffer.cxx:801
bool SetUndoCollection(bool collectUndo)
bool IsCollectingUndo() const noexcept
bool ContainsLineEnd(const char *s, Sci::Position length) const noexcept
Definition: CellBuffer.cxx:729
int GetLineEndTypes() const noexcept
Definition: CellBuffer.h:157
void SetReadOnly(bool set) noexcept
Definition: CellBuffer.cxx:797
void GetStyleRange(unsigned char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const
Definition: CellBuffer.cxx:609
void GetCharRange(char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const
Definition: CellBuffer.cxx:590
char CharAt(Sci::Position position) const noexcept
Retrieving positions outside the range of the buffer works and returns 0.
Definition: CellBuffer.cxx:582
bool IsReadOnly() const noexcept
Definition: CellBuffer.cxx:793
const char * RangePointer(Sci::Position position, Sci::Position rangeLength) noexcept
Definition: CellBuffer.cxx:632
const char * BufferPointer()
Definition: CellBuffer.cxx:628
bool CanUndo() const noexcept
To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is called that...
bool TentativeActive() const noexcept
Definition: CellBuffer.cxx:829
Sci::Position Length() const noexcept
Definition: CellBuffer.cxx:705
Sci::Position GapPosition() const noexcept
Definition: CellBuffer.cxx:636
void AddUndoAction(Sci::Position token, bool mayCoalesce)
bool CanRedo() const noexcept
char StyleAt(Sci::Position position) const noexcept
Definition: CellBuffer.cxx:605
To optimise processing of document modifications by DocWatchers, a hint is passed indicating the scop...
Definition: Document.h:543
DocModification(int modificationType_, Sci::Position position_=0, Sci::Position length_=0, Sci::Line linesAdded_=0, const char *text_=nullptr, Sci::Line line_=0) noexcept
Definition: Document.h:556
Sci::Line annotationLinesAdded
Definition: Document.h:553
Sci::Line linesAdded
Negative if lines deleted.
Definition: Document.h:548
DocModification(int modificationType_, const Action &act, Sci::Line linesAdded_=0) noexcept
Definition: Document.h:569
Sci::Position position
Definition: Document.h:546
const char * text
Only valid for changes to text, not for changes to style.
Definition: Document.h:549
Sci::Position length
Definition: Document.h:547
A class that wants to receive notifications from a Document must be derived from DocWatcher and imple...
Definition: Document.h:586
virtual void NotifyStyleNeeded(Document *doc, void *userData, Sci::Position endPos)=0
virtual void NotifyLexerChanged(Document *doc, void *userData)=0
virtual void NotifyErrorOccurred(Document *doc, void *userData, int status)=0
virtual void NotifyModified(Document *doc, DocModification mh, void *userData)=0
virtual ~DocWatcher()
Definition: Document.h:588
virtual void NotifyModifyAttempt(Document *doc, void *userData)=0
virtual void NotifyDeleted(Document *doc, void *userData) noexcept=0
virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint)=0
Sci::Position GapPosition() const noexcept
Definition: Document.h:371
char SCI_METHOD StyleAt(Sci_Position position) const override
Definition: Document.h:395
int GetStyleClock() const noexcept
Definition: Document.h:462
void BeginUndoAction()
Definition: Document.h:358
CharacterCategoryMap charMap
Definition: Document.h:233
Sci_Position SCI_METHOD Length() const override
Definition: Document.h:430
int dbcsCodePage
Can also be SC_CP_UTF8 to enable UTF-8 mode.
Definition: Document.h:276
void DeleteUndoHistory()
Definition: Document.h:353
void GetStyleRange(unsigned char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const
Definition: Document.h:397
void EndUndoAction()
Definition: Document.h:359
int StyleIndexAt(Sci_Position position) const noexcept
Definition: Document.h:396
bool SetUndoCollection(bool collectUndo)
Definition: Document.h:354
Sci::Position endStyled
Definition: Document.h:235
std::unique_ptr< IDecorationList > decorations
Definition: Document.h:286
bool IsCollectingUndo() const noexcept
Definition: Document.h:357
bool IsLarge() const noexcept
Definition: Document.h:385
Document(const Document &)=delete
CellBuffer cb
Definition: Document.h:231
Document & operator=(Document &&)=delete
std::vector< WatcherWithUserData > watchers
Definition: Document.h:244
bool TentativeActive() const noexcept
Definition: Document.h:367
bool IsReadOnly() const noexcept
Definition: Document.h:384
Sci::Position LengthNoExcept() const noexcept
Definition: Document.h:431
const char * RangePointer(Sci::Position position, Sci::Position rangeLength) noexcept
Definition: Document.h:370
int GetLineEndTypesActive() const noexcept
Definition: Document.h:309
void Allocate(Sci::Position newSize)
Definition: Document.h:432
ActionDuration durationStyleOneLine
Definition: Document.h:284
bool CanRedo() const noexcept
Definition: Document.h:352
bool ContainsLineEnd(const char *s, Sci::Position length) const noexcept
Definition: Document.h:320
void AddUndoAction(Sci::Position token, bool mayCoalesce)
Definition: Document.h:360
void TentativeStart()
Definition: Document.h:364
const char *SCI_METHOD BufferPointer() override
Definition: Document.h:369
void SCI_METHOD GetCharRange(char *buffer, Sci_Position position, Sci_Position lengthRetrieve) const override
Definition: Document.h:392
void TentativeCommit()
Definition: Document.h:365
std::string insertion
Definition: Document.h:242
void SetReadOnly(bool set)
Definition: Document.h:383
Document(Document &&)=delete
std::unique_ptr< CaseFolder > pcf
Definition: Document.h:234
CharClassify charClass
Definition: Document.h:232
int SCI_METHOD Version() const override
Definition: Document.h:311
bool IsSavePoint() const noexcept
Definition: Document.h:362
int GetLineEndTypesAllowed() const noexcept
Definition: Document.h:307
void operator=(const Document &)=delete
Sci::Line firstChangeableLineBefore
Definition: Document.h:162
bool IsBodyOfFoldBlock(Sci::Line line) const noexcept
Definition: Document.h:152
bool IsHeadOfFoldBlock(Sci::Line line) const noexcept
Definition: Document.h:148
bool IsFoldBlockHighlighted(Sci::Line line) const noexcept
Definition: Document.h:144
Sci::Line firstChangeableLineAfter
Definition: Document.h:163
bool NeedsDrawing(Sci::Line line) const noexcept
Definition: Document.h:140
bool IsTailOfFoldBlock(Sci::Line line) const noexcept
Definition: Document.h:156
virtual ~LexInterface()
Definition: Document.h:179
bool performingStyle
Prevent reentrance.
Definition: Document.h:175
LexInterface(Document *pdoc_) noexcept
Definition: Document.h:177
virtual int LineEndTypesSupported()
Definition: Document.cxx:79
bool UseContainerLexing() const noexcept
Definition: Document.h:183
void Colourise(Sci::Position start, Sci::Position end)
Definition: Document.cxx:51
The range class represents a range of text in a document.
Definition: Document.h:29
Sci::Position end
Definition: Document.h:32
bool Valid() const noexcept
Definition: Document.h:45
bool operator==(const Range &other) const noexcept
Definition: Document.h:41
Sci::Position start
Definition: Document.h:31
bool ContainsCharacter(Sci::Position pos) const noexcept
Definition: Document.h:67
bool Contains(Sci::Position pos) const noexcept
Definition: Document.h:58
Range(Sci::Position start_, Sci::Position end_) noexcept
Definition: Document.h:37
Sci::Position Last() const noexcept
Definition: Document.h:53
Sci::Position First() const noexcept
Definition: Document.h:49
bool Contains(Range other) const noexcept
Definition: Document.h:75
bool Overlaps(Range other) const noexcept
Definition: Document.h:79
Range(Sci::Position pos=0) noexcept
Definition: Document.h:34
Interface class for regular expression searching.
Definition: Document.h:91
virtual ~RegexSearchBase()
Definition: Document.h:93
virtual const char * SubstituteByPosition(Document *doc, const char *text, Sci::Position *length)=0
virtual Sci::Position FindText(Document *doc, Sci::Position minPos, Sci::Position maxPos, const char *s, bool caseSensitive, bool word, bool wordStart, int flags, Sci::Position *length)=0
UndoGroup(UndoGroup &&)=delete
Document * pdoc
Definition: Document.h:513
UndoGroup(Document *pdoc_, bool groupNeeded_=true)
Definition: Document.h:516
void operator=(const UndoGroup &)=delete
UndoGroup(const UndoGroup &)=delete
bool Needed() const noexcept
Definition: Document.h:532
UndoGroup & operator=(UndoGroup &&)=delete
static gchar indent[100]
Definition: editor.c:91
gchar * text
Definition: editor.c:83
gboolean set
Definition: editor.c:84
gint pos
Definition: editor.c:87
vString * line
Definition: geany_cobol.c:133
const gchar * chars[][2]
Definition: htmlchars.c:72
A Position is a position within a document between two characters or at the beginning or end.
Definition: Position.h:17
ptrdiff_t Position
Definition: Position.h:19
const Position invalidPosition
Definition: Position.h:22
ptrdiff_t Line
Definition: Position.h:20
Styling buffer using one element for each run rather than using a filled buffer.
Definition: Converter.h:9
RegexSearchBase * CreateRegexSearch(CharClassify *charClassTable)
Factory function for RegexSearchBase.
Definition: Document.cxx:3308
constexpr int LevelNumber(int level) noexcept
Definition: Document.h:167
EncodingFamily
Definition: Document.h:21
@ dvLineEnd
Definition: ILexer.h:15
gint position[2]
Definition: search.c:120
long lines
Definition: stats.c:32
static CharacterExtracted DBCS(unsigned char lead, unsigned char trail) noexcept
Definition: Document.h:269
CharacterExtracted(unsigned int character_, unsigned int widthBytes_) noexcept
Definition: Document.h:265
Used to pair watcher pointer with user data.
Definition: Document.h:218
WatcherWithUserData(DocWatcher *watcher_=nullptr, void *userData_=nullptr) noexcept
Definition: Document.h:221
bool operator==(const WatcherWithUserData &other) const noexcept
Definition: Document.h:224
StyledText(size_t length_, const char *text_, bool multipleStyles_, int style_, const unsigned char *styles_) noexcept
Definition: Document.h:111
size_t StyleAt(size_t i) const noexcept
Definition: Document.h:122
size_t LineLength(size_t start) const noexcept
Definition: Document.h:116
const unsigned char * styles
Definition: Document.h:110
const char * text
Definition: Document.h:107