2009-04-24 23:35:41 +00:00
|
|
|
// Scintilla source code edit control
|
|
|
|
/** @file Document.h
|
|
|
|
** Text document that handles notifications, DBCS, styling, words and end of line.
|
|
|
|
**/
|
2011-07-17 22:30:49 +00:00
|
|
|
// Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org>
|
2009-04-24 23:35:41 +00:00
|
|
|
// The License.txt file describes the conditions under which this software may be distributed.
|
|
|
|
|
|
|
|
#ifndef DOCUMENT_H
|
|
|
|
#define DOCUMENT_H
|
|
|
|
|
|
|
|
#ifdef SCI_NAMESPACE
|
|
|
|
namespace Scintilla {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A Position is a position within a document between two characters or at the beginning or end.
|
|
|
|
* Sometimes used as a character index where it identifies the character after the position.
|
|
|
|
*/
|
|
|
|
typedef int Position;
|
|
|
|
const Position invalidPosition = -1;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The range class represents a range of text in a document.
|
|
|
|
* The two values are not sorted as one end may be more significant than the other
|
|
|
|
* as is the case for the selection where the end position is the position of the caret.
|
|
|
|
* If either position is invalidPosition then the range is invalid and most operations will fail.
|
|
|
|
*/
|
|
|
|
class Range {
|
|
|
|
public:
|
|
|
|
Position start;
|
|
|
|
Position end;
|
|
|
|
|
|
|
|
Range(Position pos=0) :
|
|
|
|
start(pos), end(pos) {
|
2010-07-12 22:19:51 +00:00
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
Range(Position start_, Position end_) :
|
|
|
|
start(start_), end(end_) {
|
2010-07-12 22:19:51 +00:00
|
|
|
}
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
bool Valid() const {
|
|
|
|
return (start != invalidPosition) && (end != invalidPosition);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Is the position within the range?
|
|
|
|
bool Contains(Position pos) const {
|
|
|
|
if (start < end) {
|
|
|
|
return (pos >= start && pos <= end);
|
|
|
|
} else {
|
|
|
|
return (pos <= start && pos >= end);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Is the character after pos within the range?
|
|
|
|
bool ContainsCharacter(Position pos) const {
|
|
|
|
if (start < end) {
|
|
|
|
return (pos >= start && pos < end);
|
|
|
|
} else {
|
|
|
|
return (pos < start && pos >= end);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Contains(Range other) const {
|
|
|
|
return Contains(other.start) && Contains(other.end);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Overlaps(Range other) const {
|
|
|
|
return
|
|
|
|
Contains(other.start) ||
|
|
|
|
Contains(other.end) ||
|
|
|
|
other.Contains(start) ||
|
|
|
|
other.Contains(end);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class DocWatcher;
|
|
|
|
class DocModification;
|
2009-04-25 23:38:15 +00:00
|
|
|
class Document;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface class for regular expression searching
|
|
|
|
*/
|
|
|
|
class RegexSearchBase {
|
|
|
|
public:
|
2010-07-12 22:19:51 +00:00
|
|
|
virtual ~RegexSearchBase() {}
|
2009-04-25 23:38:15 +00:00
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
virtual long FindText(Document *doc, int minPos, int maxPos, const char *s,
|
2009-04-25 23:38:15 +00:00
|
|
|
bool caseSensitive, bool word, bool wordStart, int flags, int *length) = 0;
|
|
|
|
|
|
|
|
///@return String with the substitutions, must remain valid until the next call or destruction
|
2010-07-12 22:19:51 +00:00
|
|
|
virtual const char *SubstituteByPosition(Document *doc, const char *text, int *length) = 0;
|
2009-04-25 23:38:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Factory function for RegexSearchBase
|
2010-07-12 22:19:51 +00:00
|
|
|
extern RegexSearchBase *CreateRegexSearch(CharClassify *charClassTable);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2009-06-24 19:09:31 +00:00
|
|
|
struct StyledText {
|
|
|
|
size_t length;
|
|
|
|
const char *text;
|
|
|
|
bool multipleStyles;
|
|
|
|
size_t style;
|
|
|
|
const unsigned char *styles;
|
2010-07-12 22:19:51 +00:00
|
|
|
StyledText(size_t length_, const char *text_, bool multipleStyles_, int style_, const unsigned char *styles_) :
|
2009-06-24 19:09:31 +00:00
|
|
|
length(length_), text(text_), multipleStyles(multipleStyles_), style(style_), styles(styles_) {
|
|
|
|
}
|
|
|
|
// Return number of bytes from start to before '\n' or end of text.
|
|
|
|
// Return 1 when start is outside text
|
|
|
|
size_t LineLength(size_t start) const {
|
|
|
|
size_t cur = start;
|
|
|
|
while ((cur < length) && (text[cur] != '\n'))
|
|
|
|
cur++;
|
|
|
|
return cur-start;
|
|
|
|
}
|
|
|
|
size_t StyleAt(size_t i) const {
|
|
|
|
return multipleStyles ? styles[i] : style;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-07-17 22:30:49 +00:00
|
|
|
class HighlightDelimiter {
|
|
|
|
public:
|
|
|
|
HighlightDelimiter() {
|
|
|
|
beginFoldBlock = -1;
|
|
|
|
endFoldBlock = -1;
|
|
|
|
beginMarginCorrectlyDrawnZone = -1;
|
|
|
|
endMarginCorrectlyDrawnZone = -1;
|
|
|
|
isEnabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NeedsDrawing(int line) {
|
|
|
|
return isEnabled && (line <= beginMarginCorrectlyDrawnZone || endMarginCorrectlyDrawnZone <= line);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isCurrentBlockHighlight(int line) {
|
|
|
|
return isEnabled && beginFoldBlock != -1 && beginFoldBlock <= line && line <= endFoldBlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isHeadBlockFold(int line) {
|
|
|
|
return beginFoldBlock == line && line < endFoldBlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isBodyBlockFold(int line) {
|
|
|
|
return beginFoldBlock != -1 && beginFoldBlock < line && line < endFoldBlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isTailBlockFold(int line) {
|
|
|
|
return beginFoldBlock != -1 && beginFoldBlock < line && line == endFoldBlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
// beginFoldBlock : Begin of current fold block.
|
|
|
|
// endStartBlock : End of current fold block.
|
|
|
|
// beginMarginCorrectlyDrawnZone : Begin of zone where margin is correctly drawn.
|
|
|
|
// endMarginCorrectlyDrawnZone : End of zone where margin is correctly drawn.
|
|
|
|
int beginFoldBlock;
|
|
|
|
int endFoldBlock;
|
|
|
|
int beginMarginCorrectlyDrawnZone;
|
|
|
|
int endMarginCorrectlyDrawnZone;
|
|
|
|
bool isEnabled;
|
|
|
|
};
|
|
|
|
|
2010-07-12 22:19:51 +00:00
|
|
|
class CaseFolder {
|
|
|
|
public:
|
|
|
|
virtual ~CaseFolder() {
|
|
|
|
}
|
|
|
|
virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CaseFolderTable : public CaseFolder {
|
|
|
|
protected:
|
|
|
|
char mapping[256];
|
|
|
|
public:
|
|
|
|
CaseFolderTable();
|
|
|
|
virtual ~CaseFolderTable();
|
|
|
|
virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed);
|
|
|
|
void SetTranslation(char ch, char chTranslation);
|
|
|
|
void StandardASCII();
|
|
|
|
};
|
|
|
|
|
2010-08-21 23:59:56 +00:00
|
|
|
class Document;
|
|
|
|
|
|
|
|
class LexInterface {
|
|
|
|
protected:
|
|
|
|
Document *pdoc;
|
|
|
|
ILexer *instance;
|
|
|
|
bool performingStyle; ///< Prevent reentrance
|
|
|
|
public:
|
|
|
|
LexInterface(Document *pdoc_) : pdoc(pdoc_), instance(0), performingStyle(false) {
|
|
|
|
}
|
|
|
|
virtual ~LexInterface() {
|
|
|
|
}
|
|
|
|
void Colourise(int start, int end);
|
|
|
|
bool UseContainerLexing() const {
|
|
|
|
return instance == 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
/**
|
|
|
|
*/
|
2010-08-21 23:59:56 +00:00
|
|
|
class Document : PerLine, public IDocument {
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** Used to pair watcher pointer with user data. */
|
|
|
|
class WatcherWithUserData {
|
|
|
|
public:
|
|
|
|
DocWatcher *watcher;
|
|
|
|
void *userData;
|
|
|
|
WatcherWithUserData() {
|
|
|
|
watcher = 0;
|
|
|
|
userData = 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
enum charClassification { ccSpace, ccNewLine, ccWord, ccPunctuation };
|
|
|
|
private:
|
|
|
|
int refCount;
|
|
|
|
CellBuffer cb;
|
|
|
|
CharClassify charClass;
|
|
|
|
char stylingMask;
|
|
|
|
int endStyled;
|
|
|
|
int styleClock;
|
|
|
|
int enteredModification;
|
|
|
|
int enteredStyling;
|
|
|
|
int enteredReadOnlyCount;
|
|
|
|
|
|
|
|
WatcherWithUserData *watchers;
|
|
|
|
int lenWatchers;
|
|
|
|
|
2009-06-24 19:09:31 +00:00
|
|
|
// ldSize is not real data - it is for dimensions and loops
|
2010-07-12 22:19:51 +00:00
|
|
|
enum lineData { ldMarkers, ldLevels, ldState, ldMargin, ldAnnotation, ldSize };
|
2009-06-24 19:09:31 +00:00
|
|
|
PerLine *perLineData[ldSize];
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
bool matchesValid;
|
2010-07-12 22:19:51 +00:00
|
|
|
RegexSearchBase *regex;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
public:
|
2010-08-21 23:59:56 +00:00
|
|
|
|
|
|
|
LexInterface *pli;
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
int stylingBits;
|
|
|
|
int stylingBitsMask;
|
|
|
|
|
|
|
|
int eolMode;
|
|
|
|
/// Can also be SC_CP_UTF8 to enable UTF-8 mode
|
|
|
|
int dbcsCodePage;
|
|
|
|
int tabInChars;
|
|
|
|
int indentInChars;
|
|
|
|
int actualIndentInChars;
|
|
|
|
bool useTabs;
|
|
|
|
bool tabIndents;
|
|
|
|
bool backspaceUnindents;
|
|
|
|
|
|
|
|
DecorationList decorations;
|
|
|
|
|
|
|
|
Document();
|
|
|
|
virtual ~Document();
|
|
|
|
|
|
|
|
int AddRef();
|
|
|
|
int Release();
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
virtual void Init();
|
2009-06-24 19:09:31 +00:00
|
|
|
virtual void InsertLine(int line);
|
|
|
|
virtual void RemoveLine(int line);
|
|
|
|
|
2010-08-21 23:59:56 +00:00
|
|
|
int SCI_METHOD Version() const {
|
|
|
|
return dvOriginal;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCI_METHOD SetErrorStatus(int status);
|
|
|
|
|
|
|
|
int SCI_METHOD LineFromPosition(int pos) const;
|
2009-04-24 23:35:41 +00:00
|
|
|
int ClampPositionIntoDocument(int pos);
|
|
|
|
bool IsCrLf(int pos);
|
|
|
|
int LenChar(int pos);
|
2011-03-22 00:16:49 +00:00
|
|
|
bool InGoodUTF8(int pos, int &start, int &end) const;
|
2009-04-24 23:35:41 +00:00
|
|
|
int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true);
|
2011-03-22 00:16:49 +00:00
|
|
|
int NextPosition(int pos, int moveDir) const;
|
2010-09-05 22:56:27 +00:00
|
|
|
bool NextCharacter(int &pos, int moveDir); // Returns true if pos changed
|
2010-08-21 23:59:56 +00:00
|
|
|
int SCI_METHOD CodePage() const;
|
|
|
|
bool SCI_METHOD IsDBCSLeadByte(char ch) const;
|
2011-07-17 22:30:49 +00:00
|
|
|
int SafeSegment(const char *text, int length, int lengthSegment);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
// Gateways to modifying document
|
|
|
|
void ModifiedAt(int pos);
|
|
|
|
void CheckReadOnly();
|
|
|
|
bool DeleteChars(int pos, int len);
|
|
|
|
bool InsertString(int position, const char *s, int insertLength);
|
|
|
|
int Undo();
|
|
|
|
int Redo();
|
|
|
|
bool CanUndo() { return cb.CanUndo(); }
|
|
|
|
bool CanRedo() { return cb.CanRedo(); }
|
|
|
|
void DeleteUndoHistory() { cb.DeleteUndoHistory(); }
|
|
|
|
bool SetUndoCollection(bool collectUndo) {
|
|
|
|
return cb.SetUndoCollection(collectUndo);
|
|
|
|
}
|
|
|
|
bool IsCollectingUndo() { return cb.IsCollectingUndo(); }
|
|
|
|
void BeginUndoAction() { cb.BeginUndoAction(); }
|
|
|
|
void EndUndoAction() { cb.EndUndoAction(); }
|
2009-06-24 19:09:31 +00:00
|
|
|
void AddUndoAction(int token, bool mayCoalesce) { cb.AddUndoAction(token, mayCoalesce); }
|
2009-04-24 23:35:41 +00:00
|
|
|
void SetSavePoint();
|
|
|
|
bool IsSavePoint() { return cb.IsSavePoint(); }
|
2010-09-05 22:56:27 +00:00
|
|
|
const char * SCI_METHOD BufferPointer() { return cb.BufferPointer(); }
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2010-09-05 22:56:27 +00:00
|
|
|
int SCI_METHOD GetLineIndentation(int line);
|
2009-04-24 23:35:41 +00:00
|
|
|
void SetLineIndentation(int line, int indent);
|
|
|
|
int GetLineIndentPosition(int line) const;
|
|
|
|
int GetColumn(int position);
|
|
|
|
int FindColumn(int line, int column);
|
|
|
|
void Indent(bool forwards, int lineBottom, int lineTop);
|
|
|
|
static char *TransformLineEnds(int *pLenOut, const char *s, size_t len, int eolMode);
|
|
|
|
void ConvertLineEnds(int eolModeSet);
|
|
|
|
void SetReadOnly(bool set) { cb.SetReadOnly(set); }
|
|
|
|
bool IsReadOnly() { return cb.IsReadOnly(); }
|
|
|
|
|
|
|
|
bool InsertChar(int pos, char ch);
|
|
|
|
bool InsertCString(int position, const char *s);
|
|
|
|
void ChangeChar(int pos, char ch);
|
|
|
|
void DelChar(int pos);
|
|
|
|
void DelCharBack(int pos);
|
|
|
|
|
|
|
|
char CharAt(int position) { return cb.CharAt(position); }
|
2010-08-21 23:59:56 +00:00
|
|
|
void SCI_METHOD GetCharRange(char *buffer, int position, int lengthRetrieve) const {
|
2009-04-24 23:35:41 +00:00
|
|
|
cb.GetCharRange(buffer, position, lengthRetrieve);
|
|
|
|
}
|
2010-08-21 23:59:56 +00:00
|
|
|
char SCI_METHOD StyleAt(int position) const { return cb.StyleAt(position); }
|
2011-03-22 00:16:49 +00:00
|
|
|
void GetStyleRange(unsigned char *buffer, int position, int lengthRetrieve) const {
|
|
|
|
cb.GetStyleRange(buffer, position, lengthRetrieve);
|
|
|
|
}
|
2009-06-24 19:09:31 +00:00
|
|
|
int GetMark(int line);
|
2009-04-24 23:35:41 +00:00
|
|
|
int AddMark(int line, int markerNum);
|
|
|
|
void AddMarkSet(int line, int valueSet);
|
|
|
|
void DeleteMark(int line, int markerNum);
|
|
|
|
void DeleteMarkFromHandle(int markerHandle);
|
|
|
|
void DeleteAllMarks(int markerNum);
|
2009-06-24 19:09:31 +00:00
|
|
|
int LineFromHandle(int markerHandle);
|
2010-08-21 23:59:56 +00:00
|
|
|
int SCI_METHOD LineStart(int line) const;
|
2009-04-24 23:35:41 +00:00
|
|
|
int LineEnd(int line) const;
|
2009-08-23 02:24:48 +00:00
|
|
|
int LineEndPosition(int position) const;
|
|
|
|
bool IsLineEndPosition(int position) const;
|
|
|
|
int VCHomePosition(int position) const;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2010-08-21 23:59:56 +00:00
|
|
|
int SCI_METHOD SetLevel(int line, int level);
|
|
|
|
int SCI_METHOD GetLevel(int line) const;
|
2009-06-24 19:09:31 +00:00
|
|
|
void ClearLevels();
|
2009-04-24 23:35:41 +00:00
|
|
|
int GetLastChild(int lineParent, int level=-1);
|
|
|
|
int GetFoldParent(int line);
|
2011-07-17 22:30:49 +00:00
|
|
|
void GetHighlightDelimiters(HighlightDelimiter &hDelimiter, int line, int topLine, int bottomLine);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
void Indent(bool forwards);
|
|
|
|
int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false);
|
|
|
|
int NextWordStart(int pos, int delta);
|
|
|
|
int NextWordEnd(int pos, int delta);
|
2010-08-21 23:59:56 +00:00
|
|
|
int SCI_METHOD Length() const { return cb.Length(); }
|
2009-04-24 23:35:41 +00:00
|
|
|
void Allocate(int newSize) { cb.Allocate(newSize); }
|
2010-07-12 22:19:51 +00:00
|
|
|
size_t ExtractChar(int pos, char *bytes);
|
|
|
|
bool MatchesWordOptions(bool word, bool wordStart, int pos, int length);
|
|
|
|
long FindText(int minPos, int maxPos, const char *search, bool caseSensitive, bool word,
|
|
|
|
bool wordStart, bool regExp, int flags, int *length, CaseFolder *pcf);
|
2009-04-24 23:35:41 +00:00
|
|
|
const char *SubstituteByPosition(const char *text, int *length);
|
|
|
|
int LinesTotal() const;
|
|
|
|
|
|
|
|
void ChangeCase(Range r, bool makeUpperCase);
|
|
|
|
|
|
|
|
void SetDefaultCharClasses(bool includeWordClass);
|
|
|
|
void SetCharClasses(const unsigned char *chars, CharClassify::cc newCharClass);
|
|
|
|
void SetStylingBits(int bits);
|
2010-08-21 23:59:56 +00:00
|
|
|
void SCI_METHOD StartStyling(int position, char mask);
|
|
|
|
bool SCI_METHOD SetStyleFor(int length, char style);
|
|
|
|
bool SCI_METHOD SetStyles(int length, const char *styles);
|
2009-04-24 23:35:41 +00:00
|
|
|
int GetEndStyled() { return endStyled; }
|
|
|
|
void EnsureStyledTo(int pos);
|
2010-08-21 23:59:56 +00:00
|
|
|
void LexerChanged();
|
2009-04-24 23:35:41 +00:00
|
|
|
int GetStyleClock() { return styleClock; }
|
|
|
|
void IncrementStyleClock();
|
2010-08-21 23:59:56 +00:00
|
|
|
void SCI_METHOD DecorationSetCurrentIndicator(int indicator) {
|
|
|
|
decorations.SetCurrentIndicator(indicator);
|
|
|
|
}
|
|
|
|
void SCI_METHOD DecorationFillRange(int position, int value, int fillLength);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2010-08-21 23:59:56 +00:00
|
|
|
int SCI_METHOD SetLineState(int line, int state);
|
|
|
|
int SCI_METHOD GetLineState(int line) const;
|
2009-06-24 19:09:31 +00:00
|
|
|
int GetMaxLineState();
|
2010-08-21 23:59:56 +00:00
|
|
|
void SCI_METHOD ChangeLexerState(int start, int end);
|
2009-06-24 19:09:31 +00:00
|
|
|
|
|
|
|
StyledText MarginStyledText(int line);
|
|
|
|
void MarginSetStyle(int line, int style);
|
|
|
|
void MarginSetStyles(int line, const unsigned char *styles);
|
|
|
|
void MarginSetText(int line, const char *text);
|
|
|
|
int MarginLength(int line) const;
|
|
|
|
void MarginClearAll();
|
|
|
|
|
|
|
|
bool AnnotationAny() const;
|
|
|
|
StyledText AnnotationStyledText(int line);
|
|
|
|
void AnnotationSetText(int line, const char *text);
|
|
|
|
void AnnotationSetStyle(int line, int style);
|
|
|
|
void AnnotationSetStyles(int line, const unsigned char *styles);
|
|
|
|
int AnnotationLength(int line) const;
|
|
|
|
int AnnotationLines(int line) const;
|
|
|
|
void AnnotationClearAll();
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
bool AddWatcher(DocWatcher *watcher, void *userData);
|
|
|
|
bool RemoveWatcher(DocWatcher *watcher, void *userData);
|
|
|
|
const WatcherWithUserData *GetWatchers() const { return watchers; }
|
|
|
|
int GetLenWatchers() const { return lenWatchers; }
|
|
|
|
|
2011-03-22 00:16:49 +00:00
|
|
|
CharClassify::cc WordCharClass(unsigned char ch);
|
2009-04-24 23:35:41 +00:00
|
|
|
bool IsWordPartSeparator(char ch);
|
|
|
|
int WordPartLeft(int pos);
|
|
|
|
int WordPartRight(int pos);
|
|
|
|
int ExtendStyleRange(int pos, int delta, bool singleLine = false);
|
|
|
|
bool IsWhiteLine(int line) const;
|
|
|
|
int ParaUp(int pos);
|
|
|
|
int ParaDown(int pos);
|
|
|
|
int IndentSize() { return actualIndentInChars; }
|
|
|
|
int BraceMatch(int position, int maxReStyle);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool IsWordStartAt(int pos);
|
|
|
|
bool IsWordEndAt(int pos);
|
|
|
|
bool IsWordAt(int start, int end);
|
|
|
|
|
|
|
|
void NotifyModifyAttempt();
|
|
|
|
void NotifySavePoint(bool atSavePoint);
|
|
|
|
void NotifyModified(DocModification mh);
|
|
|
|
};
|
|
|
|
|
2009-08-23 02:24:48 +00:00
|
|
|
class UndoGroup {
|
|
|
|
Document *pdoc;
|
|
|
|
bool groupNeeded;
|
|
|
|
public:
|
2010-07-12 22:19:51 +00:00
|
|
|
UndoGroup(Document *pdoc_, bool groupNeeded_=true) :
|
2009-08-23 02:24:48 +00:00
|
|
|
pdoc(pdoc_), groupNeeded(groupNeeded_) {
|
|
|
|
if (groupNeeded) {
|
|
|
|
pdoc->BeginUndoAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
~UndoGroup() {
|
|
|
|
if (groupNeeded) {
|
|
|
|
pdoc->EndUndoAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool Needed() const {
|
|
|
|
return groupNeeded;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
/**
|
|
|
|
* To optimise processing of document modifications by DocWatchers, a hint is passed indicating the
|
|
|
|
* scope of the change.
|
|
|
|
* If the DocWatcher is a document view then this can be used to optimise screen updating.
|
|
|
|
*/
|
|
|
|
class DocModification {
|
|
|
|
public:
|
|
|
|
int modificationType;
|
|
|
|
int position;
|
|
|
|
int length;
|
|
|
|
int linesAdded; /**< Negative if lines deleted. */
|
|
|
|
const char *text; /**< Only valid for changes to text, not for changes to style. */
|
|
|
|
int line;
|
|
|
|
int foldLevelNow;
|
|
|
|
int foldLevelPrev;
|
2009-06-24 19:09:31 +00:00
|
|
|
int annotationLinesAdded;
|
|
|
|
int token;
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
DocModification(int modificationType_, int position_=0, int length_=0,
|
|
|
|
int linesAdded_=0, const char *text_=0, int line_=0) :
|
|
|
|
modificationType(modificationType_),
|
|
|
|
position(position_),
|
|
|
|
length(length_),
|
|
|
|
linesAdded(linesAdded_),
|
|
|
|
text(text_),
|
|
|
|
line(line_),
|
|
|
|
foldLevelNow(0),
|
2009-06-24 19:09:31 +00:00
|
|
|
foldLevelPrev(0),
|
|
|
|
annotationLinesAdded(0),
|
|
|
|
token(0) {}
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
DocModification(int modificationType_, const Action &act, int linesAdded_=0) :
|
|
|
|
modificationType(modificationType_),
|
|
|
|
position(act.position),
|
|
|
|
length(act.lenData),
|
|
|
|
linesAdded(linesAdded_),
|
|
|
|
text(act.data),
|
|
|
|
line(0),
|
|
|
|
foldLevelNow(0),
|
2009-06-24 19:09:31 +00:00
|
|
|
foldLevelPrev(0),
|
|
|
|
annotationLinesAdded(0),
|
|
|
|
token(0) {}
|
2009-04-24 23:35:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A class that wants to receive notifications from a Document must be derived from DocWatcher
|
|
|
|
* and implement the notification methods. It can then be added to the watcher list with AddWatcher.
|
|
|
|
*/
|
|
|
|
class DocWatcher {
|
|
|
|
public:
|
|
|
|
virtual ~DocWatcher() {}
|
|
|
|
|
|
|
|
virtual void NotifyModifyAttempt(Document *doc, void *userData) = 0;
|
|
|
|
virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0;
|
|
|
|
virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0;
|
|
|
|
virtual void NotifyDeleted(Document *doc, void *userData) = 0;
|
|
|
|
virtual void NotifyStyleNeeded(Document *doc, void *userData, int endPos) = 0;
|
2010-08-21 23:59:56 +00:00
|
|
|
virtual void NotifyLexerChanged(Document *doc, void *userData) = 0;
|
|
|
|
virtual void NotifyErrorOccurred(Document *doc, void *userData, int status) = 0;
|
2009-04-24 23:35:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef SCI_NAMESPACE
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|