~ubuntu-branches/ubuntu/wily/geany/wily

« back to all changes in this revision

Viewing changes to scintilla/src/Editor.h

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2011-12-10 07:43:26 UTC
  • mfrom: (3.3.7 sid)
  • Revision ID: package-import@ubuntu.com-20111210074326-s8yqbew5i20h33tf
Tags: 0.21-1ubuntu1
* Merge from Debian Unstable, remaining changes:
  - debian/patches/20_use_evince_viewer.patch:
     + use evince as viewer for pdf and dvi files
  - debian/patches/20_use_x_terminal_emulator.patch:
     + use x-terminal-emulator as terminal
  - debian/control
     + Add breaks on geany-plugins-common << 0.20
* Also fixes bugs:
  - Filter for MATLAB/Octave files filters everythign (LP: 885505)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Scintilla source code edit control
 
2
/** @file Editor.h
 
3
 ** Defines the main editor class.
 
4
 **/
 
5
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
 
6
// The License.txt file describes the conditions under which this software may be distributed.
 
7
 
 
8
#ifndef EDITOR_H
 
9
#define EDITOR_H
 
10
 
 
11
#ifdef SCI_NAMESPACE
 
12
namespace Scintilla {
 
13
#endif
 
14
 
 
15
/**
 
16
 */
 
17
class Caret {
 
18
public:
 
19
        bool active;
 
20
        bool on;
 
21
        int period;
 
22
 
 
23
        Caret();
 
24
};
 
25
 
 
26
/**
 
27
 */
 
28
class Timer {
 
29
public:
 
30
        bool ticking;
 
31
        int ticksToWait;
 
32
        enum {tickSize = 100};
 
33
        TickerID tickerID;
 
34
 
 
35
        Timer();
 
36
};
 
37
 
 
38
/**
 
39
 */
 
40
class Idler {
 
41
public:
 
42
        bool state;
 
43
        IdlerID idlerID;
 
44
 
 
45
        Idler();
 
46
};
 
47
 
 
48
/**
 
49
 * When platform has a way to generate an event before painting,
 
50
 * accumulate needed styling range in StyleNeeded to avoid unnecessary work.
 
51
 */
 
52
class StyleNeeded {
 
53
public:
 
54
        bool active;
 
55
        Position upTo;
 
56
 
 
57
        StyleNeeded() : active(false), upTo(0) {}
 
58
        void Reset() {
 
59
                active = false;
 
60
                upTo = 0;
 
61
        }
 
62
        void NeedUpTo(Position pos) {
 
63
                if (upTo < pos)
 
64
                        upTo = pos;
 
65
        }
 
66
};
 
67
 
 
68
/**
 
69
 * Hold a piece of text selected for copying or dragging.
 
70
 * The text is expected to hold a terminating '\0' and this is counted in len.
 
71
 */
 
72
class SelectionText {
 
73
public:
 
74
        char *s;
 
75
        int len;
 
76
        bool rectangular;
 
77
        bool lineCopy;
 
78
        int codePage;
 
79
        int characterSet;
 
80
        SelectionText() : s(0), len(0), rectangular(false), lineCopy(false), codePage(0), characterSet(0) {}
 
81
        ~SelectionText() {
 
82
                Free();
 
83
        }
 
84
        void Free() {
 
85
                Set(0, 0, 0, 0, false, false);
 
86
        }
 
87
        void Set(char *s_, int len_, int codePage_, int characterSet_, bool rectangular_, bool lineCopy_) {
 
88
                delete []s;
 
89
                s = s_;
 
90
                if (s)
 
91
                        len = len_;
 
92
                else
 
93
                        len = 0;
 
94
                codePage = codePage_;
 
95
                characterSet = characterSet_;
 
96
                rectangular = rectangular_;
 
97
                lineCopy = lineCopy_;
 
98
        }
 
99
        void Copy(const char *s_, int len_, int codePage_, int characterSet_, bool rectangular_, bool lineCopy_) {
 
100
                delete []s;
 
101
                s = 0;
 
102
                s = new char[len_];
 
103
                len = len_;
 
104
                for (int i = 0; i < len_; i++) {
 
105
                        s[i] = s_[i];
 
106
                }
 
107
                codePage = codePage_;
 
108
                characterSet = characterSet_;
 
109
                rectangular = rectangular_;
 
110
                lineCopy = lineCopy_;
 
111
        }
 
112
        void Copy(const SelectionText &other) {
 
113
                Copy(other.s, other.len, other.codePage, other.characterSet, other.rectangular, other.lineCopy);
 
114
        }
 
115
};
 
116
 
 
117
/**
 
118
 */
 
119
class Editor : public DocWatcher {
 
120
        // Private so Editor objects can not be copied
 
121
        Editor(const Editor &);
 
122
        Editor &operator=(const Editor &);
 
123
 
 
124
protected:      // ScintillaBase subclass needs access to much of Editor
 
125
 
 
126
        /** On GTK+, Scintilla is a container widget holding two scroll bars
 
127
         * whereas on Windows there is just one window with both scroll bars turned on. */
 
128
        Window wMain;   ///< The Scintilla parent window
 
129
 
 
130
        /** Style resources may be expensive to allocate so are cached between uses.
 
131
         * When a style attribute is changed, this cache is flushed. */
 
132
        bool stylesValid;
 
133
        ViewStyle vs;
 
134
        Palette palette;
 
135
 
 
136
        int printMagnification;
 
137
        int printColourMode;
 
138
        int printWrapState;
 
139
        int cursorMode;
 
140
        int controlCharSymbol;
 
141
 
 
142
        bool hasFocus;
 
143
        bool hideSelection;
 
144
        bool inOverstrike;
 
145
        bool mouseDownCaptures;
 
146
 
 
147
        /** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to
 
148
         * the screen. This avoids flashing but is about 30% slower. */
 
149
        bool bufferedDraw;
 
150
        /** In twoPhaseDraw mode, drawing is performed in two phases, first the background
 
151
        * and then the foreground. This avoids chopping off characters that overlap the next run. */
 
152
        bool twoPhaseDraw;
 
153
 
 
154
        int xOffset;            ///< Horizontal scrolled amount in pixels
 
155
        int xCaretMargin;       ///< Ensure this many pixels visible on both sides of caret
 
156
        bool horizontalScrollBarVisible;
 
157
        int scrollWidth;
 
158
        bool trackLineWidth;
 
159
        int lineWidthMaxSeen;
 
160
        bool verticalScrollBarVisible;
 
161
        bool endAtLastLine;
 
162
        int caretSticky;
 
163
        bool multipleSelection;
 
164
        bool additionalSelectionTyping;
 
165
        int multiPasteMode;
 
166
        bool additionalCaretsBlink;
 
167
        bool additionalCaretsVisible;
 
168
 
 
169
        int virtualSpaceOptions;
 
170
 
 
171
        Surface *pixmapLine;
 
172
        Surface *pixmapSelMargin;
 
173
        Surface *pixmapSelPattern;
 
174
        Surface *pixmapIndentGuide;
 
175
        Surface *pixmapIndentGuideHighlight;
 
176
 
 
177
        LineLayoutCache llc;
 
178
        PositionCache posCache;
 
179
 
 
180
        KeyMap kmap;
 
181
 
 
182
        Caret caret;
 
183
        Timer timer;
 
184
        Timer autoScrollTimer;
 
185
        enum { autoScrollDelay = 200 };
 
186
 
 
187
        Idler idler;
 
188
 
 
189
        Point lastClick;
 
190
        unsigned int lastClickTime;
 
191
        int dwellDelay;
 
192
        int ticksToDwell;
 
193
        bool dwelling;
 
194
        enum { selChar, selWord, selLine } selectionType;
 
195
        Point ptMouseLast;
 
196
        enum { ddNone, ddInitial, ddDragging } inDragDrop;
 
197
        bool dropWentOutside;
 
198
        SelectionPosition posDrag;
 
199
        SelectionPosition posDrop;
 
200
        int hotSpotClickPos;
 
201
        int lastXChosen;
 
202
        int lineAnchor;
 
203
        int originalAnchorPos;
 
204
        int wordSelectAnchorStartPos;
 
205
        int wordSelectAnchorEndPos;
 
206
        int wordSelectInitialCaretPos;
 
207
        int targetStart;
 
208
        int targetEnd;
 
209
        int searchFlags;
 
210
        int topLine;
 
211
        int posTopLine;
 
212
        int lengthForEncode;
 
213
 
 
214
        int needUpdateUI;
 
215
        Position braces[2];
 
216
        int bracesMatchStyle;
 
217
        int highlightGuideColumn;
 
218
 
 
219
        int theEdge;
 
220
 
 
221
        enum { notPainting, painting, paintAbandoned } paintState;
 
222
        PRectangle rcPaint;
 
223
        bool paintingAllText;
 
224
        StyleNeeded styleNeeded;
 
225
 
 
226
        int modEventMask;
 
227
 
 
228
        SelectionText drag;
 
229
        Selection sel;
 
230
        bool primarySelection;
 
231
 
 
232
        int caretXPolicy;
 
233
        int caretXSlop; ///< Ensure this many pixels visible on both sides of caret
 
234
 
 
235
        int caretYPolicy;
 
236
        int caretYSlop; ///< Ensure this many lines visible on both sides of caret
 
237
 
 
238
        int visiblePolicy;
 
239
        int visibleSlop;
 
240
 
 
241
        int searchAnchor;
 
242
 
 
243
        bool recordingMacro;
 
244
 
 
245
        int foldFlags;
 
246
        ContractionState cs;
 
247
 
 
248
        // Hotspot support
 
249
        int hsStart;
 
250
        int hsEnd;
 
251
 
 
252
        // Wrapping support
 
253
        enum { eWrapNone, eWrapWord, eWrapChar } wrapState;
 
254
        enum { wrapLineLarge = 0x7ffffff };
 
255
        int wrapWidth;
 
256
        int wrapStart;
 
257
        int wrapEnd;
 
258
        int wrapVisualFlags;
 
259
        int wrapVisualFlagsLocation;
 
260
        int wrapVisualStartIndent;
 
261
        int wrapAddIndent; // This will be added to initial indent of line
 
262
        int wrapIndentMode; // SC_WRAPINDENT_FIXED, _SAME, _INDENT
 
263
 
 
264
        bool convertPastes;
 
265
 
 
266
        Document *pdoc;
 
267
 
 
268
        Editor();
 
269
        virtual ~Editor();
 
270
        virtual void Initialise() = 0;
 
271
        virtual void Finalise();
 
272
 
 
273
        void InvalidateStyleData();
 
274
        void InvalidateStyleRedraw();
 
275
        virtual void RefreshColourPalette(Palette &pal, bool want);
 
276
        void RefreshStyleData();
 
277
        void DropGraphics();
 
278
 
 
279
        virtual PRectangle GetClientRectangle();
 
280
        PRectangle GetTextRectangle();
 
281
 
 
282
        int LinesOnScreen();
 
283
        int LinesToScroll();
 
284
        int MaxScrollPos();
 
285
        SelectionPosition ClampPositionIntoDocument(SelectionPosition sp) const;
 
286
        Point LocationFromPosition(SelectionPosition pos);
 
287
        Point LocationFromPosition(int pos);
 
288
        int XFromPosition(int pos);
 
289
        int XFromPosition(SelectionPosition sp);
 
290
        SelectionPosition SPositionFromLocation(Point pt, bool canReturnInvalid=false, bool charPosition=false, bool virtualSpace=true);
 
291
        int PositionFromLocation(Point pt, bool canReturnInvalid=false, bool charPosition=false);
 
292
        SelectionPosition SPositionFromLineX(int lineDoc, int x);
 
293
        int PositionFromLineX(int line, int x);
 
294
        int LineFromLocation(Point pt);
 
295
        void SetTopLine(int topLineNew);
 
296
 
 
297
        bool AbandonPaint();
 
298
        void RedrawRect(PRectangle rc);
 
299
        void Redraw();
 
300
        void RedrawSelMargin(int line=-1, bool allAfter=false);
 
301
        PRectangle RectangleFromRange(int start, int end);
 
302
        void InvalidateRange(int start, int end);
 
303
 
 
304
        bool UserVirtualSpace() const {
 
305
                return ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0);
 
306
        }
 
307
        int CurrentPosition();
 
308
        bool SelectionEmpty();
 
309
        SelectionPosition SelectionStart();
 
310
        SelectionPosition SelectionEnd();
 
311
        void SetRectangularRange();
 
312
        void ThinRectangularRange();
 
313
        void InvalidateSelection(SelectionRange newMain, bool invalidateWholeSelection=false);
 
314
        void SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_);
 
315
        void SetSelection(int currentPos_, int anchor_);
 
316
        void SetSelection(SelectionPosition currentPos_);
 
317
        void SetSelection(int currentPos_);
 
318
        void SetEmptySelection(SelectionPosition currentPos_);
 
319
        void SetEmptySelection(int currentPos_);
 
320
        bool RangeContainsProtected(int start, int end) const;
 
321
        bool SelectionContainsProtected();
 
322
        int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true) const;
 
323
        SelectionPosition MovePositionOutsideChar(SelectionPosition pos, int moveDir, bool checkLineEnd=true) const;
 
324
        int MovePositionTo(SelectionPosition newPos, Selection::selTypes sel=Selection::noSel, bool ensureVisible=true);
 
325
        int MovePositionTo(int newPos, Selection::selTypes sel=Selection::noSel, bool ensureVisible=true);
 
326
        SelectionPosition MovePositionSoVisible(SelectionPosition pos, int moveDir);
 
327
        SelectionPosition MovePositionSoVisible(int pos, int moveDir);
 
328
        Point PointMainCaret();
 
329
        void SetLastXChosen();
 
330
 
 
331
        void ScrollTo(int line, bool moveThumb=true);
 
332
        virtual void ScrollText(int linesToMove);
 
333
        void HorizontalScrollTo(int xPos);
 
334
        void VerticalCentreCaret();
 
335
        void MoveCaretInsideView(bool ensureVisible=true);
 
336
        int DisplayFromPosition(int pos);
 
337
 
 
338
        struct XYScrollPosition {
 
339
                int xOffset;
 
340
                int topLine;
 
341
                XYScrollPosition(int xOffset_, int topLine_) : xOffset(xOffset_), topLine(topLine_) {}
 
342
        };
 
343
        XYScrollPosition XYScrollToMakeVisible(const bool useMargin, const bool vert, const bool horiz);
 
344
        void SetXYScroll(XYScrollPosition newXY);
 
345
        void EnsureCaretVisible(bool useMargin=true, bool vert=true, bool horiz=true);
 
346
        void ShowCaretAtCurrentPosition();
 
347
        void DropCaret();
 
348
        void InvalidateCaret();
 
349
        virtual void UpdateSystemCaret();
 
350
 
 
351
        void NeedWrapping(int docLineStart = 0, int docLineEnd = wrapLineLarge);
 
352
        bool WrapOneLine(Surface *surface, int lineToWrap);
 
353
        bool WrapLines(bool fullWrap, int priorityWrapLineStart);
 
354
        void LinesJoin();
 
355
        void LinesSplit(int pixelWidth);
 
356
 
 
357
        int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault);
 
358
        void PaintSelMargin(Surface *surface, PRectangle &rc);
 
359
        LineLayout *RetrieveLineLayout(int lineNumber);
 
360
        void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll,
 
361
                int width=LineLayout::wrapWidthInfinite);
 
362
        ColourAllocated SelectionBackground(ViewStyle &vsDraw, bool main);
 
363
        ColourAllocated TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourAllocated background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll);
 
364
        void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight);
 
365
        void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourAllocated wrapColour);
 
366
        void DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll,
 
367
                int line, int lineEnd, int xStart, int subLine, int subLineStart,
 
368
                bool overrideBackground, ColourAllocated background,
 
369
                bool drawWrapMark, ColourAllocated wrapColour);
 
370
        void DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
 
371
                PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under);
 
372
        void DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
 
373
        PRectangle rcLine, LineLayout *ll, int subLine);
 
374
        void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
 
375
                PRectangle rcLine, LineLayout *ll, int subLine);
 
376
        void DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine,
 
377
                int xStart, int offset, int posCaret, PRectangle rcCaret, ColourAllocated caretColour);
 
378
        void DrawCarets(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
 
379
                PRectangle rcLine, LineLayout *ll, int subLine);
 
380
        void RefreshPixMaps(Surface *surfaceWindow);
 
381
        void Paint(Surface *surfaceWindow, PRectangle rcArea);
 
382
        long FormatRange(bool draw, Sci_RangeToFormat *pfr);
 
383
        int TextWidth(int style, const char *text);
 
384
 
 
385
        virtual void SetVerticalScrollPos() = 0;
 
386
        virtual void SetHorizontalScrollPos() = 0;
 
387
        virtual bool ModifyScrollBars(int nMax, int nPage) = 0;
 
388
        virtual void ReconfigureScrollBars();
 
389
        void SetScrollBars();
 
390
        void ChangeSize();
 
391
 
 
392
        void FilterSelections();
 
393
        int InsertSpace(int position, unsigned int spaces);
 
394
        void AddChar(char ch);
 
395
        virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
 
396
        void InsertPaste(SelectionPosition selStart, const char *text, int len);
 
397
        void ClearSelection(bool retainMultipleSelections=false);
 
398
        void ClearAll();
 
399
        void ClearDocumentStyle();
 
400
        void Cut();
 
401
        void PasteRectangular(SelectionPosition pos, const char *ptr, int len);
 
402
        virtual void Copy() = 0;
 
403
        virtual void CopyAllowLine();
 
404
        virtual bool CanPaste();
 
405
        virtual void Paste() = 0;
 
406
        void Clear();
 
407
        void SelectAll();
 
408
        void Undo();
 
409
        void Redo();
 
410
        void DelChar();
 
411
        void DelCharBack(bool allowLineStartDeletion);
 
412
        virtual void ClaimSelection() = 0;
 
413
 
 
414
        virtual void NotifyChange() = 0;
 
415
        virtual void NotifyFocus(bool focus);
 
416
        virtual int GetCtrlID() { return ctrlID; }
 
417
        virtual void NotifyParent(SCNotification scn) = 0;
 
418
        virtual void NotifyStyleToNeeded(int endStyleNeeded);
 
419
        void NotifyChar(int ch);
 
420
        void NotifySavePoint(bool isSavePoint);
 
421
        void NotifyModifyAttempt();
 
422
        virtual void NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt);
 
423
        void NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt);
 
424
        void NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt);
 
425
        void NotifyHotSpotReleaseClick(int position, bool shift, bool ctrl, bool alt);
 
426
        void NotifyUpdateUI();
 
427
        void NotifyPainted();
 
428
        void NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt);
 
429
        bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt);
 
430
        void NotifyNeedShown(int pos, int len);
 
431
        void NotifyDwelling(Point pt, bool state);
 
432
        void NotifyZoom();
 
433
 
 
434
        void NotifyModifyAttempt(Document *document, void *userData);
 
435
        void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
 
436
        void CheckModificationForWrap(DocModification mh);
 
437
        void NotifyModified(Document *document, DocModification mh, void *userData);
 
438
        void NotifyDeleted(Document *document, void *userData);
 
439
        void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
 
440
        void NotifyLexerChanged(Document *doc, void *userData);
 
441
        void NotifyErrorOccurred(Document *doc, void *userData, int status);
 
442
        void NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
 
443
 
 
444
        void ContainerNeedsUpdate(int flags);
 
445
        void PageMove(int direction, Selection::selTypes sel=Selection::noSel, bool stuttered = false);
 
446
        enum { cmSame, cmUpper, cmLower } caseMap;
 
447
        virtual std::string CaseMapString(const std::string &s, int caseMapping);
 
448
        void ChangeCaseOfSelection(int caseMapping);
 
449
        void LineTranspose();
 
450
        void Duplicate(bool forLine);
 
451
        virtual void CancelModes();
 
452
        void NewLine();
 
453
        void CursorUpOrDown(int direction, Selection::selTypes sel=Selection::noSel);
 
454
        void ParaUpOrDown(int direction, Selection::selTypes sel=Selection::noSel);
 
455
        int StartEndDisplayLine(int pos, bool start);
 
456
        virtual int KeyCommand(unsigned int iMessage);
 
457
        virtual int KeyDefault(int /* key */, int /*modifiers*/);
 
458
        int KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed=0);
 
459
 
 
460
        int GetWhitespaceVisible();
 
461
        void SetWhitespaceVisible(int view);
 
462
 
 
463
        void Indent(bool forwards);
 
464
 
 
465
        virtual CaseFolder *CaseFolderForEncoding();
 
466
        long FindText(uptr_t wParam, sptr_t lParam);
 
467
        void SearchAnchor();
 
468
        long SearchText(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
 
469
        long SearchInTarget(const char *text, int length);
 
470
        void GoToLine(int lineNo);
 
471
 
 
472
        virtual void CopyToClipboard(const SelectionText &selectedText) = 0;
 
473
        char *CopyRange(int start, int end);
 
474
        void CopySelectionRange(SelectionText *ss, bool allowLineCopy=false);
 
475
        void CopyRangeToClipboard(int start, int end);
 
476
        void CopyText(int length, const char *text);
 
477
        void SetDragPosition(SelectionPosition newPos);
 
478
        virtual void DisplayCursor(Window::Cursor c);
 
479
        virtual bool DragThreshold(Point ptStart, Point ptNow);
 
480
        virtual void StartDrag();
 
481
        void DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular);
 
482
        /** PositionInSelection returns true if position in selection. */
 
483
        bool PositionInSelection(int pos);
 
484
        bool PointInSelection(Point pt);
 
485
        bool PointInSelMargin(Point pt);
 
486
        Window::Cursor GetMarginCursor(Point pt);
 
487
        void LineSelection(int lineCurrent_, int lineAnchor_);
 
488
        void WordSelection(int pos);
 
489
        void DwellEnd(bool mouseMoved);
 
490
        void MouseLeave();
 
491
        virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
 
492
        void ButtonMove(Point pt);
 
493
        void ButtonUp(Point pt, unsigned int curTime, bool ctrl);
 
494
 
 
495
        void Tick();
 
496
        bool Idle();
 
497
        virtual void SetTicking(bool on) = 0;
 
498
        virtual bool SetIdle(bool) { return false; }
 
499
        virtual void SetMouseCapture(bool on) = 0;
 
500
        virtual bool HaveMouseCapture() = 0;
 
501
        void SetFocusState(bool focusState);
 
502
 
 
503
        int PositionAfterArea(PRectangle rcArea);
 
504
        void StyleToPositionInView(Position pos);
 
505
        void IdleStyling();
 
506
        virtual void QueueStyling(int upTo);
 
507
 
 
508
        virtual bool PaintContains(PRectangle rc);
 
509
        bool PaintContainsMargin();
 
510
        void CheckForChangeOutsidePaint(Range r);
 
511
        void SetBraceHighlight(Position pos0, Position pos1, int matchStyle);
 
512
 
 
513
        void SetAnnotationHeights(int start, int end);
 
514
        void SetDocPointer(Document *document);
 
515
 
 
516
        void SetAnnotationVisible(int visible);
 
517
 
 
518
        void Expand(int &line, bool doExpand);
 
519
        void ToggleContraction(int line);
 
520
        int ContractedFoldNext(int lineStart);
 
521
        void EnsureLineVisible(int lineDoc, bool enforcePolicy);
 
522
        int GetTag(char *tagValue, int tagNumber);
 
523
        int ReplaceTarget(bool replacePatterns, const char *text, int length=-1);
 
524
 
 
525
        bool PositionIsHotspot(int position);
 
526
        bool PointIsHotspot(Point pt);
 
527
        void SetHotSpotRange(Point *pt);
 
528
        void GetHotSpotRange(int &hsStart, int &hsEnd);
 
529
 
 
530
        int CodePage() const;
 
531
        virtual bool ValidCodePage(int /* codePage */) const { return true; }
 
532
        int WrapCount(int line);
 
533
        void AddStyledText(char *buffer, int appendLength);
 
534
 
 
535
        virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
 
536
        void StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
 
537
        sptr_t StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
 
538
 
 
539
        static const char *StringFromEOLMode(int eolMode);
 
540
 
 
541
        static sptr_t StringResult(sptr_t lParam, const char *val);
 
542
 
 
543
public:
 
544
        // Public so the COM thunks can access it.
 
545
        bool IsUnicodeMode() const;
 
546
        // Public so scintilla_send_message can use it.
 
547
        virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
 
548
        // Public so scintilla_set_id can use it.
 
549
        int ctrlID;
 
550
        // Public so COM methods for drag and drop can set it.
 
551
        int errorStatus;
 
552
        friend class AutoSurface;
 
553
        friend class SelectionLineIterator;
 
554
};
 
555
 
 
556
/**
 
557
 * A smart pointer class to ensure Surfaces are set up and deleted correctly.
 
558
 */
 
559
class AutoSurface {
 
560
private:
 
561
        Surface *surf;
 
562
public:
 
563
        AutoSurface(Editor *ed) : surf(0) {
 
564
                if (ed->wMain.GetID()) {
 
565
                        surf = Surface::Allocate();
 
566
                        if (surf) {
 
567
                                surf->Init(ed->wMain.GetID());
 
568
                                surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage());
 
569
                                surf->SetDBCSMode(ed->CodePage());
 
570
                        }
 
571
                }
 
572
        }
 
573
        AutoSurface(SurfaceID sid, Editor *ed) : surf(0) {
 
574
                if (ed->wMain.GetID()) {
 
575
                        surf = Surface::Allocate();
 
576
                        if (surf) {
 
577
                                surf->Init(sid, ed->wMain.GetID());
 
578
                                surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage());
 
579
                                surf->SetDBCSMode(ed->CodePage());
 
580
                        }
 
581
                }
 
582
        }
 
583
        ~AutoSurface() {
 
584
                delete surf;
 
585
        }
 
586
        Surface *operator->() const {
 
587
                return surf;
 
588
        }
 
589
        operator Surface *() const {
 
590
                return surf;
 
591
        }
 
592
};
 
593
 
 
594
#ifdef SCI_NAMESPACE
 
595
}
 
596
#endif
 
597
 
 
598
#endif