~ubuntu-branches/ubuntu/natty/geany/natty

« back to all changes in this revision

Viewing changes to scintilla/Document.h

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2010-08-07 03:23:12 UTC
  • mfrom: (1.4.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20100807032312-ot70ac9d50cn79we
Tags: upstream-0.19
ImportĀ upstreamĀ versionĀ 0.19

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
        Range(Position pos=0) :
34
34
                start(pos), end(pos) {
35
 
        };
 
35
        }
36
36
        Range(Position start_, Position end_) :
37
37
                start(start_), end(end_) {
38
 
        };
 
38
        }
39
39
 
40
40
        bool Valid() const {
41
41
                return (start != invalidPosition) && (end != invalidPosition);
81
81
 */
82
82
class RegexSearchBase {
83
83
public:
84
 
        virtual ~RegexSearchBase(){}
 
84
        virtual ~RegexSearchBase() {}
85
85
 
86
 
        virtual long FindText(Document* doc, int minPos, int maxPos, const char *s,
 
86
        virtual long FindText(Document *doc, int minPos, int maxPos, const char *s,
87
87
                        bool caseSensitive, bool word, bool wordStart, int flags, int *length) = 0;
88
88
 
89
89
        ///@return String with the substitutions, must remain valid until the next call or destruction
90
 
        virtual const char *SubstituteByPosition(Document* doc, const char *text, int *length) = 0;
 
90
        virtual const char *SubstituteByPosition(Document *doc, const char *text, int *length) = 0;
91
91
};
92
92
 
93
93
/// Factory function for RegexSearchBase
94
 
extern RegexSearchBase* CreateRegexSearch(CharClassify *charClassTable);
 
94
extern RegexSearchBase *CreateRegexSearch(CharClassify *charClassTable);
95
95
 
96
96
struct StyledText {
97
97
        size_t length;
99
99
        bool multipleStyles;
100
100
        size_t style;
101
101
        const unsigned char *styles;
102
 
        StyledText(     size_t length_, const char *text_, bool multipleStyles_, int style_, const unsigned char *styles_) : 
 
102
        StyledText(size_t length_, const char *text_, bool multipleStyles_, int style_, const unsigned char *styles_) :
103
103
                length(length_), text(text_), multipleStyles(multipleStyles_), style(style_), styles(styles_) {
104
104
        }
105
105
        // Return number of bytes from start to before '\n' or end of text.
115
115
        }
116
116
};
117
117
 
 
118
class CaseFolder {
 
119
public:
 
120
        virtual ~CaseFolder() {
 
121
        }
 
122
        virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) = 0;
 
123
};
 
124
 
 
125
class CaseFolderTable : public CaseFolder {
 
126
protected:
 
127
        char mapping[256];
 
128
public:
 
129
        CaseFolderTable();
 
130
        virtual ~CaseFolderTable();
 
131
        virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed);
 
132
        void SetTranslation(char ch, char chTranslation);
 
133
        void StandardASCII();
 
134
};
 
135
 
118
136
/**
119
137
 */
120
138
class Document : PerLine {
147
165
        int lenWatchers;
148
166
 
149
167
        // ldSize is not real data - it is for dimensions and loops
150
 
        enum lineData { ldMarkers, ldLevels, ldState, ldMargin, ldAnnotation, ldSize }; 
 
168
        enum lineData { ldMarkers, ldLevels, ldState, ldMargin, ldAnnotation, ldSize };
151
169
        PerLine *perLineData[ldSize];
152
170
 
153
171
        bool matchesValid;
154
 
        RegexSearchBase* regex;
 
172
        RegexSearchBase *regex;
155
173
 
156
174
public:
157
175
        int stylingBits;
225
243
        void DelCharBack(int pos);
226
244
 
227
245
        char CharAt(int position) { return cb.CharAt(position); }
228
 
        void GetCharRange(char *buffer, int position, int lengthRetrieve) {
 
246
        void GetCharRange(char *buffer, int position, int lengthRetrieve) const {
229
247
                cb.GetCharRange(buffer, position, lengthRetrieve);
230
248
        }
231
 
        char StyleAt(int position) { return cb.StyleAt(position); }
 
249
        char StyleAt(int position) const { return cb.StyleAt(position); }
232
250
        int GetMark(int line);
233
251
        int AddMark(int line, int markerNum);
234
252
        void AddMarkSet(int line, int valueSet);
239
257
        int LineStart(int line) const;
240
258
        int LineEnd(int line) const;
241
259
        int LineEndPosition(int position) const;
 
260
        bool IsLineEndPosition(int position) const;
242
261
        int VCHomePosition(int position) const;
243
262
 
244
263
        int SetLevel(int line, int level);
245
 
        int GetLevel(int line);
 
264
        int GetLevel(int line) const;
246
265
        void ClearLevels();
247
266
        int GetLastChild(int lineParent, int level=-1);
248
267
        int GetFoldParent(int line);
253
272
        int NextWordEnd(int pos, int delta);
254
273
        int Length() const { return cb.Length(); }
255
274
        void Allocate(int newSize) { cb.Allocate(newSize); }
256
 
        long FindText(int minPos, int maxPos, const char *s,
257
 
                bool caseSensitive, bool word, bool wordStart, bool regExp, int flags, int *length);
258
 
        long FindText(int iMessage, unsigned long wParam, long lParam);
 
275
        size_t ExtractChar(int pos, char *bytes);
 
276
        bool MatchesWordOptions(bool word, bool wordStart, int pos, int length);
 
277
        long FindText(int minPos, int maxPos, const char *search, bool caseSensitive, bool word,
 
278
                bool wordStart, bool regExp, int flags, int *length, CaseFolder *pcf);
259
279
        const char *SubstituteByPosition(const char *text, int *length);
260
280
        int LinesTotal() const;
261
281
 
274
294
        void DecorationFillRange(int position, int value, int fillLength);
275
295
 
276
296
        int SetLineState(int line, int state);
277
 
        int GetLineState(int line);
 
297
        int GetLineState(int line) const;
278
298
        int GetMaxLineState();
279
299
 
280
300
        StyledText MarginStyledText(int line);
319
339
        void NotifyModified(DocModification mh);
320
340
};
321
341
 
 
342
class UndoGroup {
 
343
        Document *pdoc;
 
344
        bool groupNeeded;
 
345
public:
 
346
        UndoGroup(Document *pdoc_, bool groupNeeded_=true) :
 
347
                pdoc(pdoc_), groupNeeded(groupNeeded_) {
 
348
                if (groupNeeded) {
 
349
                        pdoc->BeginUndoAction();
 
350
                }
 
351
        }
 
352
        ~UndoGroup() {
 
353
                if (groupNeeded) {
 
354
                        pdoc->EndUndoAction();
 
355
                }
 
356
        }
 
357
        bool Needed() const {
 
358
                return groupNeeded;
 
359
        }
 
360
};
 
361
 
 
362
 
322
363
/**
323
364
 * To optimise processing of document modifications by DocWatchers, a hint is passed indicating the
324
365
 * scope of the change.