~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/sdk/wxscintilla/src/scintilla/src/Document.h

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
#ifndef DOCUMENT_H
9
9
#define DOCUMENT_H
10
10
 
 
11
/* C::B begin */
 
12
#include "Decoration.h"
 
13
/* C::B end */
 
14
 
 
15
#ifdef SCI_NAMESPACE
 
16
namespace Scintilla {
 
17
#endif
 
18
 
11
19
/**
12
20
 * A Position is a position within a document between two characters or at the beginning or end.
13
21
 * Sometimes used as a character index where it identifies the character after the position.
70
78
 
71
79
class DocWatcher;
72
80
class DocModification;
73
 
class RESearch;
74
 
 
75
 
/**
76
 
 */
77
 
class Document {
 
81
class Document;
 
82
 
 
83
/**
 
84
 * Interface class for regular expression searching
 
85
 */
 
86
class RegexSearchBase {
 
87
public:
 
88
        virtual ~RegexSearchBase(){}
 
89
 
 
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;
 
92
 
 
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;
 
95
};
 
96
 
 
97
/// Factory function for RegexSearchBase
 
98
extern RegexSearchBase* CreateRegexSearch(CharClassify *charClassTable);
 
99
 
 
100
struct StyledText {
 
101
        size_t length;
 
102
        const char *text;
 
103
        bool multipleStyles;
 
104
        size_t style;
 
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_) {
 
108
        }
 
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 {
 
112
                size_t cur = start;
 
113
                while ((cur < length) && (text[cur] != '\n'))
 
114
                        cur++;
 
115
                return cur-start;
 
116
        }
 
117
        size_t StyleAt(size_t i) const {
 
118
                return multipleStyles ? styles[i] : style;
 
119
        }
 
120
};
 
121
 
 
122
/**
 
123
 */
 
124
class Document : PerLine {
78
125
 
79
126
public:
80
127
        /** Used to pair watcher pointer with user data. */
89
136
        };
90
137
 
91
138
        enum charClassification { ccSpace, ccNewLine, ccWord, ccPunctuation };
92
 
 
93
139
private:
94
140
        int refCount;
95
141
        CellBuffer cb;
96
 
        charClassification charClass[256];
 
142
        CharClassify charClass;
97
143
        char stylingMask;
98
144
        int endStyled;
99
145
        int styleClock;
100
 
        int enteredCount;
 
146
        int enteredModification;
 
147
        int enteredStyling;
101
148
        int enteredReadOnlyCount;
102
149
 
103
150
        WatcherWithUserData *watchers;
104
151
        int lenWatchers;
105
152
 
 
153
        // ldSize is not real data - it is for dimensions and loops
 
154
        enum lineData { ldMarkers, ldLevels, ldState, ldMargin, ldAnnotation, ldSize }; 
 
155
        PerLine *perLineData[ldSize];
 
156
 
106
157
        bool matchesValid;
107
 
        RESearch *pre;
108
 
        char *substituted;
 
158
        RegexSearchBase* regex;
109
159
 
110
160
public:
111
161
        int stylingBits;
121
171
        bool tabIndents;
122
172
        bool backspaceUnindents;
123
173
 
 
174
        DecorationList decorations;
 
175
 
124
176
        Document();
125
177
        virtual ~Document();
126
178
 
127
179
        int AddRef();
128
180
        int Release();
129
181
 
130
 
        int LineFromPosition(int pos);
 
182
        virtual void Init();
 
183
        virtual void InsertLine(int line);
 
184
        virtual void RemoveLine(int line);
 
185
 
 
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);
135
192
 
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);
140
198
        int Undo();
141
199
        int Redo();
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); } 
 
204
/* CHANGEBAR end */
145
205
        bool SetUndoCollection(bool collectUndo) {
146
206
                return cb.SetUndoCollection(collectUndo);
147
207
        }
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);
 
213
        }
 
214
/* CHANGEBAR end */
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(); }
153
221
 
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);
163
231
        bool IsReadOnly() { return cb.IsReadOnly(); }
164
232
 
165
233
        bool InsertChar(int pos, char ch);
166
 
        bool InsertString(int position, const char *s);
167
 
        bool InsertString(int position, const char *s, size_t insertLength);
 
234
        bool InsertCString(int position, const char *s);
168
235
        void ChangeChar(int pos, char ch);
169
236
        void DelChar(int pos);
170
237
        void DelCharBack(int pos);
174
241
                cb.GetCharRange(buffer, position, lengthRetrieve);
175
242
        }
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;
188
256
 
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);
 
259
        void ClearLevels();
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); } 
 
264
/* CHANGEBAR end */
194
265
 
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);
205
 
        int LinesTotal();
 
276
        int LinesTotal() const;
206
277
 
207
278
        void ChangeCase(Range r, bool makeUpperCase);
208
279
 
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();
219
 
 
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);
 
291
 
 
292
        int SetLineState(int line, int state);
 
293
        int GetLineState(int line);
 
294
        int GetMaxLineState();
 
295
 
 
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();
 
302
 
 
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();
223
311
 
224
312
        bool AddWatcher(DocWatcher *watcher, void *userData);
225
313
        bool RemoveWatcher(DocWatcher *watcher, void *userData);
230
318
        int WordPartLeft(int pos);
231
319
        int WordPartRight(int pos);
232
320
        int ExtendStyleRange(int pos, int delta, bool singleLine = false);
233
 
        bool IsWhiteLine(int line);
 
321
        bool IsWhiteLine(int line) const;
234
322
        int ParaUp(int pos);
235
323
        int ParaDown(int pos);
236
324
        int IndentSize() { return actualIndentInChars; }
237
325
        int BraceMatch(int position, int maxReStyle);
238
326
 
239
327
private:
240
 
        void CheckReadOnly();
241
 
 
242
 
        charClassification WordCharClass(unsigned char ch);
 
328
        CharClassify::cc WordCharClass(unsigned char ch);
243
329
        bool IsWordStartAt(int pos);
244
330
        bool IsWordEndAt(int pos);
245
331
        bool IsWordAt(int start, int end);
249
335
        void NotifyModified(DocModification mh);
250
336
};
251
337
 
 
338
class UndoGroup {
 
339
        Document *pdoc;
 
340
        bool groupNeeded;
 
341
public:
 
342
        UndoGroup(Document *pdoc_, bool groupNeeded_=true) : 
 
343
                pdoc(pdoc_), groupNeeded(groupNeeded_) {
 
344
                if (groupNeeded) {
 
345
                        pdoc->BeginUndoAction();
 
346
                }
 
347
        }
 
348
        ~UndoGroup() {
 
349
                if (groupNeeded) {
 
350
                        pdoc->EndUndoAction();
 
351
                }
 
352
        }
 
353
        bool Needed() const {
 
354
                return groupNeeded;
 
355
        }
 
356
};
 
357
 
 
358
 
252
359
/**
253
360
 * To optimise processing of document modifications by DocWatchers, a hint is passed indicating the
254
361
 * scope of the change.
264
371
        int line;
265
372
        int foldLevelNow;
266
373
        int foldLevelPrev;
 
374
        int annotationLinesAdded;
 
375
        int token;
267
376
 
268
377
        DocModification(int modificationType_, int position_=0, int length_=0,
269
378
                int linesAdded_=0, const char *text_=0, int line_=0) :
274
383
                text(text_),
275
384
                line(line_),
276
385
                foldLevelNow(0),
277
 
                foldLevelPrev(0) {}
 
386
                foldLevelPrev(0),
 
387
                annotationLinesAdded(0),
 
388
                token(0) {}
278
389
 
279
390
        DocModification(int modificationType_, const Action &act, int linesAdded_=0) :
280
391
                modificationType(modificationType_),
284
395
                text(act.data),
285
396
                line(0),
286
397
                foldLevelNow(0),
287
 
                foldLevelPrev(0) {}
 
398
                foldLevelPrev(0),
 
399
                annotationLinesAdded(0),
 
400
                token(0) {}
288
401
};
289
402
 
290
403
/**
302
415
        virtual void NotifyStyleNeeded(Document *doc, void *userData, int endPos) = 0;
303
416
};
304
417
 
 
418
#ifdef SCI_NAMESPACE
 
419
}
 
420
#endif
 
421
 
305
422
#endif