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