~ubuntu-branches/ubuntu/raring/geany/raring-proposed

« back to all changes in this revision

Viewing changes to scintilla/Editor.h

  • Committer: Bazaar Package Importer
  • Author(s): Damián Viano
  • Date: 2008-05-02 11:37:45 UTC
  • mto: (3.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: james.westby@ubuntu.com-20080502113745-7q62rqhl2ku02ptu
Import upstream version 0.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
#ifndef EDITOR_H
9
9
#define EDITOR_H
10
10
 
 
11
#ifdef SCI_NAMESPACE
 
12
namespace Scintilla {
 
13
#endif
 
14
 
11
15
/**
12
16
 */
13
17
class Caret {
42
46
};
43
47
 
44
48
/**
45
 
 */
46
 
class LineLayout {
47
 
private:
48
 
        friend class LineLayoutCache;
49
 
        int *lineStarts;
50
 
        int lenLineStarts;
51
 
        /// Drawing is only performed for @a maxLineLength characters on each line.
52
 
        int lineNumber;
53
 
        bool inCache;
54
 
public:
55
 
        enum { wrapWidthInfinite = 0x7ffffff };
56
 
        int maxLineLength;
57
 
        int numCharsInLine;
58
 
        enum validLevel { llInvalid, llCheckTextAndStyle, llPositions, llLines } validity;
59
 
        int xHighlightGuide;
60
 
        bool highlightColumn;
61
 
        int selStart;
62
 
        int selEnd;
63
 
        bool containsCaret;
64
 
        int edgeColumn;
65
 
        char *chars;
66
 
        unsigned char *styles;
67
 
        int styleBitsSet;
68
 
        char *indicators;
69
 
        int *positions;
70
 
        char bracePreviousStyles[2];
71
 
 
72
 
        // Hotspot support
73
 
        int hsStart;
74
 
        int hsEnd;
75
 
 
76
 
        // Wrapped line support
77
 
        int widthLine;
78
 
        int lines;
79
 
 
80
 
        LineLayout(int maxLineLength_);
81
 
        virtual ~LineLayout();
82
 
        void Resize(int maxLineLength_);
83
 
        void Free();
84
 
        void Invalidate(validLevel validity_);
85
 
        int LineStart(int line) {
86
 
                if (line <= 0) {
87
 
                        return 0;
88
 
                } else if ((line >= lines) || !lineStarts) {
89
 
                        return numCharsInLine;
90
 
                } else {
91
 
                        return lineStarts[line];
92
 
                }
93
 
        }
94
 
        void SetLineStart(int line, int start);
95
 
        void SetBracesHighlight(Range rangeLine, Position braces[],
96
 
                char bracesMatchStyle, int xHighlight);
97
 
        void RestoreBracesHighlight(Range rangeLine, Position braces[]);
98
 
};
99
 
 
100
 
/**
101
 
 */
102
 
class LineLayoutCache {
103
 
        int level;
104
 
        int length;
105
 
        int size;
106
 
        LineLayout **cache;
107
 
        bool allInvalidated;
108
 
        int styleClock;
109
 
        int useCount;
110
 
        void Allocate(int length_);
111
 
        void AllocateForLevel(int linesOnScreen, int linesInDoc);
112
 
public:
113
 
        LineLayoutCache();
114
 
        virtual ~LineLayoutCache();
115
 
        void Deallocate();
116
 
        enum {
117
 
                llcNone=SC_CACHE_NONE,
118
 
                llcCaret=SC_CACHE_CARET,
119
 
                llcPage=SC_CACHE_PAGE,
120
 
                llcDocument=SC_CACHE_DOCUMENT
121
 
        };
122
 
        void Invalidate(LineLayout::validLevel validity_);
123
 
        void SetLevel(int level_);
124
 
        int GetLevel() { return level; }
125
 
        LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
126
 
                int linesOnScreen, int linesInDoc);
127
 
        void Dispose(LineLayout *ll);
128
 
};
129
 
 
130
 
/**
131
49
 * Hold a piece of text selected for copying or dragging.
132
50
 * The text is expected to hold a terminating '\0' and this is counted in len.
133
51
 */
136
54
        char *s;
137
55
        int len;
138
56
        bool rectangular;
 
57
        bool lineCopy;
139
58
        int codePage;
140
59
        int characterSet;
141
 
        SelectionText() : s(0), len(0), rectangular(false), codePage(0), characterSet(0) {}
 
60
        SelectionText() : s(0), len(0), rectangular(false), lineCopy(false), codePage(0), characterSet(0) {}
142
61
        ~SelectionText() {
143
62
                Free();
144
63
        }
145
64
        void Free() {
146
 
                Set(0, 0, 0, 0, false);
 
65
                Set(0, 0, 0, 0, false, false);
147
66
        }
148
 
        void Set(char *s_, int len_, int codePage_, int characterSet_, bool rectangular_) {
 
67
        void Set(char *s_, int len_, int codePage_, int characterSet_, bool rectangular_, bool lineCopy_) {
149
68
                delete []s;
150
69
                s = s_;
151
70
                if (s)
155
74
                codePage = codePage_;
156
75
                characterSet = characterSet_;
157
76
                rectangular = rectangular_;
 
77
                lineCopy = lineCopy_;
158
78
        }
159
 
        void Copy(const char *s_, int len_, int codePage_, int characterSet_, bool rectangular_) {
 
79
        void Copy(const char *s_, int len_, int codePage_, int characterSet_, bool rectangular_, bool lineCopy_) {
160
80
                delete []s;
161
81
                s = new char[len_];
162
82
                if (s) {
170
90
                codePage = codePage_;
171
91
                characterSet = characterSet_;
172
92
                rectangular = rectangular_;
 
93
                lineCopy = lineCopy_;
173
94
        }
174
95
        void Copy(const SelectionText &other) {
175
 
                Copy(other.s, other.len, other.codePage, other.characterSet, other.rectangular);
 
96
                Copy(other.s, other.len, other.codePage, other.characterSet, other.rectangular, other.lineCopy);
176
97
        }
177
98
};
178
99
 
218
139
        int xCaretMargin;       ///< Ensure this many pixels visible on both sides of caret
219
140
        bool horizontalScrollBarVisible;
220
141
        int scrollWidth;
 
142
        bool trackLineWidth;
 
143
        int lineWidthMaxSeen;
221
144
        bool verticalScrollBarVisible;
222
145
        bool endAtLastLine;
223
146
        bool caretSticky;
229
152
        Surface *pixmapIndentGuideHighlight;
230
153
 
231
154
        LineLayoutCache llc;
 
155
        PositionCache posCache;
232
156
 
233
157
        KeyMap kmap;
234
158
 
246
170
        bool dwelling;
247
171
        enum { selChar, selWord, selLine } selectionType;
248
172
        Point ptMouseLast;
249
 
        bool inDragDrop;
 
173
        enum { ddNone, ddInitial, ddDragging } inDragDrop;
250
174
        bool dropWentOutside;
251
175
        int posDrag;
252
176
        int posDrop;
355
279
        int SelectionStart();
356
280
        int SelectionEnd();
357
281
        void SetRectangularRange();
358
 
        void InvalidateSelection(int currentPos_, int anchor_);
 
282
        void InvalidateSelection(int currentPos_, int anchor_, bool invalidateWholeSelection);
359
283
        void SetSelection(int currentPos_, int anchor_);
360
284
        void SetSelection(int currentPos_);
361
285
        void SetEmptySelection(int currentPos_);
378
302
        virtual void UpdateSystemCaret();
379
303
 
380
304
        void NeedWrapping(int docLineStart = 0, int docLineEnd = wrapLineLarge);
 
305
        bool WrapOneLine(Surface *surface, int lineToWrap);
381
306
        bool WrapLines(bool fullWrap, int priorityWrapLineStart);
382
307
        void LinesJoin();
383
308
        void LinesSplit(int pixelWidth);
395
320
                int line, int lineEnd, int xStart, int subLine, int subLineStart,
396
321
                bool overrideBackground, ColourAllocated background,
397
322
                bool drawWrapMark, ColourAllocated wrapColour);
 
323
        void DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
 
324
                PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under);
398
325
        void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
399
326
                PRectangle rcLine, LineLayout *ll, int subLine=0);
 
327
        void DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, int xStart, int offset, int posCaret, PRectangle rcCaret);
400
328
        void RefreshPixMaps(Surface *surfaceWindow);
401
329
        void Paint(Surface *surfaceWindow, PRectangle rcArea);
402
330
        long FormatRange(bool draw, RangeToFormat *pfr);
413
341
        virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
414
342
        void ClearSelection();
415
343
        void ClearAll();
416
 
        void ClearDocumentStyle();
 
344
        void ClearDocumentStyle();
417
345
        void Cut();
418
346
        void PasteRectangular(int pos, const char *ptr, int len);
419
347
        virtual void Copy() = 0;
 
348
        virtual void CopyAllowLine();
420
349
        virtual bool CanPaste();
421
350
        virtual void Paste() = 0;
422
351
        void Clear();
436
365
        void NotifyMove(int position);
437
366
        void NotifySavePoint(bool isSavePoint);
438
367
        void NotifyModifyAttempt();
439
 
        virtual void NotifyDoubleClick(Point pt, bool shift);
 
368
        virtual void NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt);
440
369
        void NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt);
441
370
        void NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt);
442
371
        void NotifyUpdateUI();
443
372
        void NotifyPainted();
 
373
        void NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt);
444
374
        bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt);
445
375
        void NotifyNeedShown(int pos, int len);
446
376
        void NotifyDwelling(Point pt, bool state);
480
410
 
481
411
        virtual void CopyToClipboard(const SelectionText &selectedText) = 0;
482
412
        char *CopyRange(int start, int end);
483
 
        void CopySelectionFromRange(SelectionText *ss, int start, int end);
484
 
        void CopySelectionRange(SelectionText *ss);
 
413
        void CopySelectionFromRange(SelectionText *ss, bool allowLineCopy, int start, int end);
 
414
        void CopySelectionRange(SelectionText *ss, bool allowLineCopy=false);
485
415
        void CopyRangeToClipboard(int start, int end);
486
416
        void CopyText(int length, const char *text);
487
417
        void SetDragPosition(int newPos);
488
418
        virtual void DisplayCursor(Window::Cursor c);
 
419
        virtual bool DragThreshold(Point ptStart, Point ptNow);
489
420
        virtual void StartDrag();
490
421
        void DropAt(int position, const char *value, bool moving, bool rectangular);
491
422
        /** PositionInSelection returns 0 if position in selection, -1 if position before selection, and 1 if after.
527
458
        int CodePage() const;
528
459
        virtual bool ValidCodePage(int /* codePage */) const { return true; }
529
460
        int WrapCount(int line);
 
461
        void AddStyledText(char *buffer, int appendLength);
530
462
 
531
463
        virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
 
464
        void StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
 
465
        sptr_t StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
 
466
 
 
467
        static const char *StringFromEOLMode(int eolMode);
532
468
 
533
469
public:
534
470
        // Public so the COM thunks can access it.
579
515
        }
580
516
};
581
517
 
 
518
#ifdef SCI_NAMESPACE
 
519
}
 
520
#endif
 
521
 
582
522
#endif