]>
Commit | Line | Data |
---|---|---|
9ce192d4 | 1 | // Scintilla source code edit control |
65ec6247 RD |
2 | /** @file Editor.h |
3 | ** Defines the main editor class. | |
4 | **/ | |
9e730a78 | 5 | // Copyright 1998-2003 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 | ||
65ec6247 RD |
11 | /** |
12 | */ | |
9ce192d4 RD |
13 | class Caret { |
14 | public: | |
15 | bool active; | |
16 | bool on; | |
17 | int period; | |
1a2fb4cd | 18 | |
9ce192d4 RD |
19 | Caret(); |
20 | }; | |
21 | ||
65ec6247 RD |
22 | /** |
23 | */ | |
9ce192d4 | 24 | class Timer { |
9ce192d4 RD |
25 | public: |
26 | bool ticking; | |
27 | int ticksToWait; | |
28 | enum {tickSize = 100}; | |
1a2fb4cd RD |
29 | TickerID tickerID; |
30 | ||
9ce192d4 RD |
31 | Timer(); |
32 | }; | |
33 | ||
8e54aaed RD |
34 | /** |
35 | */ | |
36 | class Idler { | |
37 | public: | |
38 | bool state; | |
39 | IdlerID idlerID; | |
40 | ||
41 | Idler(); | |
42 | }; | |
43 | ||
65ec6247 RD |
44 | /** |
45 | */ | |
9ce192d4 | 46 | class LineLayout { |
1a2fb4cd RD |
47 | private: |
48 | friend class LineLayoutCache; | |
49 | int *lineStarts; | |
50 | int lenLineStarts; | |
65ec6247 | 51 | /// Drawing is only performed for @a maxLineLength characters on each line. |
1a2fb4cd RD |
52 | int lineNumber; |
53 | bool inCache; | |
54 | public: | |
55 | enum { wrapWidthInfinite = 0x7ffffff }; | |
56 | int maxLineLength; | |
9ce192d4 | 57 | int numCharsInLine; |
a834585d | 58 | enum validLevel { llInvalid, llCheckTextAndStyle, llPositions, llLines } validity; |
d134f170 RD |
59 | int xHighlightGuide; |
60 | bool highlightColumn; | |
61 | int selStart; | |
62 | int selEnd; | |
65ec6247 | 63 | bool containsCaret; |
d134f170 | 64 | int edgeColumn; |
1a2fb4cd | 65 | char *chars; |
591d01be | 66 | unsigned char *styles; |
1a2fb4cd RD |
67 | char *indicators; |
68 | int *positions; | |
69 | char bracePreviousStyles[2]; | |
70 | ||
9e730a78 RD |
71 | // Hotspot support |
72 | int hsStart; | |
73 | int hsEnd; | |
74 | ||
1a2fb4cd RD |
75 | // Wrapped line support |
76 | int widthLine; | |
77 | int lines; | |
78 | ||
79 | LineLayout(int maxLineLength_); | |
80 | virtual ~LineLayout(); | |
81 | void Resize(int maxLineLength_); | |
82 | void Free(); | |
83 | void Invalidate(validLevel validity_); | |
84 | int LineStart(int line) { | |
85 | if (line <= 0) { | |
86 | return 0; | |
87 | } else if ((line >= lines) || !lineStarts) { | |
88 | return numCharsInLine; | |
89 | } else { | |
90 | return lineStarts[line]; | |
91 | } | |
92 | } | |
93 | void SetLineStart(int line, int start); | |
a834585d | 94 | void SetBracesHighlight(Range rangeLine, Position braces[], |
1a2fb4cd RD |
95 | char bracesMatchStyle, int xHighlight); |
96 | void RestoreBracesHighlight(Range rangeLine, Position braces[]); | |
97 | }; | |
98 | ||
99 | /** | |
100 | */ | |
101 | class LineLayoutCache { | |
102 | int level; | |
103 | int length; | |
104 | int size; | |
105 | LineLayout **cache; | |
106 | bool allInvalidated; | |
107 | int styleClock; | |
108 | void Allocate(int length_); | |
109 | void AllocateForLevel(int linesOnScreen, int linesInDoc); | |
110 | public: | |
111 | LineLayoutCache(); | |
112 | virtual ~LineLayoutCache(); | |
113 | void Deallocate(); | |
a834585d RD |
114 | enum { |
115 | llcNone=SC_CACHE_NONE, | |
116 | llcCaret=SC_CACHE_CARET, | |
117 | llcPage=SC_CACHE_PAGE, | |
1a2fb4cd RD |
118 | llcDocument=SC_CACHE_DOCUMENT |
119 | }; | |
120 | void Invalidate(LineLayout::validLevel validity_); | |
121 | void SetLevel(int level_); | |
122 | int GetLevel() { return level; } | |
a834585d | 123 | LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_, |
1a2fb4cd RD |
124 | int linesOnScreen, int linesInDoc); |
125 | void Dispose(LineLayout *ll); | |
9ce192d4 RD |
126 | }; |
127 | ||
8e54aaed RD |
128 | /** |
129 | * Hold a piece of text selected for copying or dragging. | |
a33203cb | 130 | * The text is expected to hold a terminating '\0' and this is counted in len. |
8e54aaed | 131 | */ |
b8b0e402 RD |
132 | class SelectionText { |
133 | public: | |
134 | char *s; | |
135 | int len; | |
136 | bool rectangular; | |
591d01be RD |
137 | int codePage; |
138 | int characterSet; | |
139 | SelectionText() : s(0), len(0), rectangular(false), codePage(0), characterSet(0) {} | |
b8b0e402 | 140 | ~SelectionText() { |
591d01be | 141 | Free(); |
b8b0e402 | 142 | } |
591d01be RD |
143 | void Free() { |
144 | Set(0, 0, 0, 0, false); | |
145 | } | |
146 | void Set(char *s_, int len_, int codePage_, int characterSet_, bool rectangular_) { | |
b8b0e402 RD |
147 | delete []s; |
148 | s = s_; | |
149 | if (s) | |
150 | len = len_; | |
151 | else | |
152 | len = 0; | |
591d01be RD |
153 | codePage = codePage_; |
154 | characterSet = characterSet_; | |
b8b0e402 RD |
155 | rectangular = rectangular_; |
156 | } | |
591d01be | 157 | void Copy(const char *s_, int len_, int codePage_, int characterSet_, bool rectangular_) { |
e14d10b0 RD |
158 | delete []s; |
159 | s = new char[len_]; | |
160 | if (s) { | |
161 | len = len_; | |
162 | for (int i = 0; i < len_; i++) { | |
163 | s[i] = s_[i]; | |
164 | } | |
165 | } else { | |
166 | len = 0; | |
167 | } | |
591d01be RD |
168 | codePage = codePage_; |
169 | characterSet = characterSet_; | |
e14d10b0 RD |
170 | rectangular = rectangular_; |
171 | } | |
591d01be RD |
172 | void Copy(const SelectionText &other) { |
173 | Copy(other.s, other.len, other.codePage, other.characterSet, other.rectangular); | |
174 | } | |
b8b0e402 RD |
175 | }; |
176 | ||
65ec6247 RD |
177 | /** |
178 | */ | |
9ce192d4 | 179 | class Editor : public DocWatcher { |
f6bcfd97 BP |
180 | // Private so Editor objects can not be copied |
181 | Editor(const Editor &) : DocWatcher() {} | |
182 | Editor &operator=(const Editor &) { return *this; } | |
65ec6247 | 183 | |
9ce192d4 RD |
184 | protected: // ScintillaBase subclass needs access to much of Editor |
185 | ||
65ec6247 RD |
186 | /** On GTK+, Scintilla is a container widget holding two scroll bars |
187 | * whereas on Windows there is just one window with both scroll bars turned on. */ | |
188 | Window wMain; ///< The Scintilla parent window | |
9ce192d4 | 189 | |
65ec6247 RD |
190 | /** Style resources may be expensive to allocate so are cached between uses. |
191 | * When a style attribute is changed, this cache is flushed. */ | |
1a2fb4cd | 192 | bool stylesValid; |
9ce192d4 RD |
193 | ViewStyle vs; |
194 | Palette palette; | |
b8b0e402 | 195 | |
d134f170 RD |
196 | int printMagnification; |
197 | int printColourMode; | |
9e730a78 | 198 | int printWrapState; |
65ec6247 | 199 | int cursorMode; |
1a2fb4cd | 200 | int controlCharSymbol; |
65ec6247 RD |
201 | |
202 | bool hasFocus; | |
9ce192d4 RD |
203 | bool hideSelection; |
204 | bool inOverstrike; | |
65ec6247 RD |
205 | int errorStatus; |
206 | bool mouseDownCaptures; | |
1a2fb4cd | 207 | |
65ec6247 RD |
208 | /** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to |
209 | * the screen. This avoids flashing but is about 30% slower. */ | |
9ce192d4 | 210 | bool bufferedDraw; |
9e730a78 RD |
211 | /** In twoPhaseDraw mode, drawing is performed in two phases, first the background |
212 | * and then the foreground. This avoids chopping off characters that overlap the next run. */ | |
213 | bool twoPhaseDraw; | |
9ce192d4 | 214 | |
65ec6247 RD |
215 | int xOffset; ///< Horizontal scrolled amount in pixels |
216 | int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret | |
f6bcfd97 | 217 | bool horizontalScrollBarVisible; |
a834585d | 218 | int scrollWidth; |
9e730a78 | 219 | bool verticalScrollBarVisible; |
a834585d | 220 | bool endAtLastLine; |
1a2fb4cd RD |
221 | |
222 | Surface *pixmapLine; | |
223 | Surface *pixmapSelMargin; | |
224 | Surface *pixmapSelPattern; | |
225 | Surface *pixmapIndentGuide; | |
226 | Surface *pixmapIndentGuideHighlight; | |
227 | ||
228 | LineLayoutCache llc; | |
9ce192d4 RD |
229 | |
230 | KeyMap kmap; | |
231 | ||
232 | Caret caret; | |
233 | Timer timer; | |
65ec6247 RD |
234 | Timer autoScrollTimer; |
235 | enum { autoScrollDelay = 200 }; | |
9ce192d4 | 236 | |
8e54aaed RD |
237 | Idler idler; |
238 | ||
9ce192d4 RD |
239 | Point lastClick; |
240 | unsigned int lastClickTime; | |
65ec6247 RD |
241 | int dwellDelay; |
242 | int ticksToDwell; | |
243 | bool dwelling; | |
9ce192d4 RD |
244 | enum { selChar, selWord, selLine } selectionType; |
245 | Point ptMouseLast; | |
9ce192d4 RD |
246 | bool inDragDrop; |
247 | bool dropWentOutside; | |
248 | int posDrag; | |
249 | int posDrop; | |
250 | int lastXChosen; | |
251 | int lineAnchor; | |
252 | int originalAnchorPos; | |
253 | int currentPos; | |
254 | int anchor; | |
65ec6247 RD |
255 | int targetStart; |
256 | int targetEnd; | |
257 | int searchFlags; | |
9ce192d4 RD |
258 | int topLine; |
259 | int posTopLine; | |
a33203cb | 260 | int lengthForEncode; |
1a2fb4cd | 261 | |
9ce192d4 RD |
262 | bool needUpdateUI; |
263 | Position braces[2]; | |
264 | int bracesMatchStyle; | |
d134f170 | 265 | int highlightGuideColumn; |
1a2fb4cd | 266 | |
9ce192d4 RD |
267 | int theEdge; |
268 | ||
269 | enum { notPainting, painting, paintAbandoned } paintState; | |
270 | PRectangle rcPaint; | |
271 | bool paintingAllText; | |
1a2fb4cd | 272 | |
9ce192d4 | 273 | int modEventMask; |
1a2fb4cd | 274 | |
b8b0e402 | 275 | SelectionText drag; |
8e54aaed RD |
276 | enum selTypes { noSel, selStream, selRectangle, selLines }; |
277 | selTypes selType; | |
278 | bool moveExtendsSelection; | |
279 | int xStartSelect; ///< x position of start of rectangular selection | |
280 | int xEndSelect; ///< x position of end of rectangular selection | |
d134f170 | 281 | bool primarySelection; |
1a2fb4cd | 282 | |
a834585d RD |
283 | int caretXPolicy; |
284 | int caretXSlop; ///< Ensure this many pixels visible on both sides of caret | |
285 | ||
286 | int caretYPolicy; | |
287 | int caretYSlop; ///< Ensure this many lines visible on both sides of caret | |
9ce192d4 | 288 | |
65ec6247 RD |
289 | int visiblePolicy; |
290 | int visibleSlop; | |
1a2fb4cd | 291 | |
9ce192d4 RD |
292 | int searchAnchor; |
293 | ||
b8b0e402 | 294 | bool recordingMacro; |
9ce192d4 RD |
295 | |
296 | int foldFlags; | |
297 | ContractionState cs; | |
298 | ||
9e730a78 RD |
299 | // Hotspot support |
300 | int hsStart; | |
301 | int hsEnd; | |
302 | ||
1a2fb4cd RD |
303 | // Wrapping support |
304 | enum { eWrapNone, eWrapWord } wrapState; | |
8e54aaed | 305 | bool backgroundWrapEnabled; |
1a2fb4cd RD |
306 | int wrapWidth; |
307 | int docLineLastWrapped; | |
8e54aaed | 308 | int docLastLineToWrap; |
591d01be RD |
309 | int wrapVisualFlags; |
310 | int wrapVisualFlagsLocation; | |
311 | int wrapVisualStartIndent; | |
312 | int actualWrapVisualStartIndent; | |
1a2fb4cd | 313 | |
9ce192d4 RD |
314 | Document *pdoc; |
315 | ||
316 | Editor(); | |
317 | virtual ~Editor(); | |
318 | virtual void Initialise() = 0; | |
319 | virtual void Finalise(); | |
320 | ||
321 | void InvalidateStyleData(); | |
322 | void InvalidateStyleRedraw(); | |
323 | virtual void RefreshColourPalette(Palette &pal, bool want); | |
324 | void RefreshStyleData(); | |
325 | void DropGraphics(); | |
326 | ||
65ec6247 | 327 | virtual PRectangle GetClientRectangle(); |
9ce192d4 | 328 | PRectangle GetTextRectangle(); |
1a2fb4cd | 329 | |
9ce192d4 RD |
330 | int LinesOnScreen(); |
331 | int LinesToScroll(); | |
332 | int MaxScrollPos(); | |
65ec6247 RD |
333 | Point LocationFromPosition(int pos); |
334 | int XFromPosition(int pos); | |
9ce192d4 | 335 | int PositionFromLocation(Point pt); |
65ec6247 | 336 | int PositionFromLocationClose(Point pt); |
9ce192d4 RD |
337 | int PositionFromLineX(int line, int x); |
338 | int LineFromLocation(Point pt); | |
339 | void SetTopLine(int topLineNew); | |
1a2fb4cd | 340 | |
a834585d | 341 | bool AbandonPaint(); |
9ce192d4 RD |
342 | void RedrawRect(PRectangle rc); |
343 | void Redraw(); | |
344 | void RedrawSelMargin(); | |
345 | PRectangle RectangleFromRange(int start, int end); | |
346 | void InvalidateRange(int start, int end); | |
1a2fb4cd | 347 | |
9ce192d4 RD |
348 | int CurrentPosition(); |
349 | bool SelectionEmpty(); | |
8e54aaed RD |
350 | int SelectionStart(); |
351 | int SelectionEnd(); | |
352 | void InvalidateSelection(int currentPos_, int anchor_); | |
9ce192d4 RD |
353 | void SetSelection(int currentPos_, int anchor_); |
354 | void SetSelection(int currentPos_); | |
355 | void SetEmptySelection(int currentPos_); | |
9e730a78 | 356 | bool RangeContainsProtected(int start, int end) const; |
8e54aaed | 357 | bool SelectionContainsProtected(); |
d134f170 | 358 | int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true); |
8e54aaed | 359 | int MovePositionTo(int newPos, selTypes sel=noSel, bool ensureVisible=true); |
9ce192d4 RD |
360 | int MovePositionSoVisible(int pos, int moveDir); |
361 | void SetLastXChosen(); | |
362 | ||
9e730a78 | 363 | void ScrollTo(int line, bool moveThumb=true); |
9ce192d4 RD |
364 | virtual void ScrollText(int linesToMove); |
365 | void HorizontalScrollTo(int xPos); | |
f114b858 | 366 | void MoveCaretInsideView(bool ensureVisible=true); |
1a2fb4cd | 367 | int DisplayFromPosition(int pos); |
65ec6247 | 368 | void EnsureCaretVisible(bool useMargin=true, bool vert=true, bool horiz=true); |
9ce192d4 RD |
369 | void ShowCaretAtCurrentPosition(); |
370 | void DropCaret(); | |
371 | void InvalidateCaret(); | |
a33203cb | 372 | virtual void UpdateSystemCaret(); |
9ce192d4 | 373 | |
8e54aaed RD |
374 | void NeedWrapping(int docLineStartWrapping = 0, int docLineEndWrapping = 0x7ffffff); |
375 | bool WrapLines(bool fullWrap, int priorityWrapLineStart); | |
9e730a78 RD |
376 | void LinesJoin(); |
377 | void LinesSplit(int pixelWidth); | |
1a2fb4cd | 378 | |
65ec6247 | 379 | int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault); |
9ce192d4 | 380 | void PaintSelMargin(Surface *surface, PRectangle &rc); |
1a2fb4cd | 381 | LineLayout *RetrieveLineLayout(int lineNumber); |
a834585d | 382 | void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, |
1a2fb4cd | 383 | int width=LineLayout::wrapWidthInfinite); |
9e730a78 RD |
384 | ColourAllocated TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourAllocated background, bool inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll); |
385 | void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight); | |
591d01be | 386 | void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourAllocated wrapColour); |
9e730a78 RD |
387 | void DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll, |
388 | int line, int lineEnd, int xStart, int subLine, int subLineStart, | |
591d01be RD |
389 | bool overrideBackground, ColourAllocated background, |
390 | bool drawWrapMark, ColourAllocated wrapColour); | |
1a2fb4cd RD |
391 | void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart, |
392 | PRectangle rcLine, LineLayout *ll, int subLine=0); | |
9e730a78 | 393 | void RefreshPixMaps(Surface *surfaceWindow); |
9ce192d4 | 394 | void Paint(Surface *surfaceWindow, PRectangle rcArea); |
d134f170 | 395 | long FormatRange(bool draw, RangeToFormat *pfr); |
a834585d | 396 | int TextWidth(int style, const char *text); |
9ce192d4 RD |
397 | |
398 | virtual void SetVerticalScrollPos() = 0; | |
399 | virtual void SetHorizontalScrollPos() = 0; | |
400 | virtual bool ModifyScrollBars(int nMax, int nPage) = 0; | |
f6bcfd97 | 401 | virtual void ReconfigureScrollBars(); |
9ce192d4 | 402 | void SetScrollBars(); |
1a2fb4cd | 403 | void ChangeSize(); |
9ce192d4 | 404 | |
f6bcfd97 | 405 | void AddChar(char ch); |
1a2fb4cd | 406 | virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false); |
9ce192d4 RD |
407 | void ClearSelection(); |
408 | void ClearAll(); | |
d134f170 | 409 | void ClearDocumentStyle(); |
9ce192d4 RD |
410 | void Cut(); |
411 | void PasteRectangular(int pos, const char *ptr, int len); | |
412 | virtual void Copy() = 0; | |
65ec6247 | 413 | virtual bool CanPaste(); |
9ce192d4 RD |
414 | virtual void Paste() = 0; |
415 | void Clear(); | |
416 | void SelectAll(); | |
417 | void Undo(); | |
418 | void Redo(); | |
419 | void DelChar(); | |
1a2fb4cd | 420 | void DelCharBack(bool allowLineStartDeletion); |
9ce192d4 RD |
421 | virtual void ClaimSelection() = 0; |
422 | ||
423 | virtual void NotifyChange() = 0; | |
424 | virtual void NotifyFocus(bool focus); | |
1a2fb4cd | 425 | virtual int GetCtrlID() { return ctrlID; } |
9ce192d4 | 426 | virtual void NotifyParent(SCNotification scn) = 0; |
f6bcfd97 | 427 | virtual void NotifyStyleToNeeded(int endStyleNeeded); |
65ec6247 | 428 | void NotifyChar(int ch); |
d134f170 | 429 | void NotifyMove(int position); |
9ce192d4 RD |
430 | void NotifySavePoint(bool isSavePoint); |
431 | void NotifyModifyAttempt(); | |
432 | virtual void NotifyDoubleClick(Point pt, bool shift); | |
9e730a78 RD |
433 | void NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt); |
434 | void NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt); | |
9ce192d4 | 435 | void NotifyUpdateUI(); |
65ec6247 | 436 | void NotifyPainted(); |
9ce192d4 RD |
437 | bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt); |
438 | void NotifyNeedShown(int pos, int len); | |
65ec6247 | 439 | void NotifyDwelling(Point pt, bool state); |
a834585d | 440 | void NotifyZoom(); |
1a2fb4cd | 441 | |
9ce192d4 RD |
442 | void NotifyModifyAttempt(Document *document, void *userData); |
443 | void NotifySavePoint(Document *document, void *userData, bool atSavePoint); | |
1a2fb4cd | 444 | void CheckModificationForWrap(DocModification mh); |
9ce192d4 RD |
445 | void NotifyModified(Document *document, DocModification mh, void *userData); |
446 | void NotifyDeleted(Document *document, void *userData); | |
f6bcfd97 | 447 | void NotifyStyleNeeded(Document *doc, void *userData, int endPos); |
a834585d | 448 | void NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam); |
9ce192d4 | 449 | |
8e54aaed | 450 | void PageMove(int direction, selTypes sel=noSel, bool stuttered = false); |
f6bcfd97 BP |
451 | void ChangeCaseOfSelection(bool makeUpperCase); |
452 | void LineTranspose(); | |
9e730a78 | 453 | void LineDuplicate(); |
f114b858 | 454 | virtual void CancelModes(); |
a834585d | 455 | void NewLine(); |
8e54aaed | 456 | void CursorUpOrDown(int direction, selTypes sel=noSel); |
f114b858 | 457 | int StartEndDisplayLine(int pos, bool start); |
d134f170 | 458 | virtual int KeyCommand(unsigned int iMessage); |
9ce192d4 | 459 | virtual int KeyDefault(int /* key */, int /*modifiers*/); |
65ec6247 | 460 | int KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed=0); |
9ce192d4 | 461 | |
d134f170 RD |
462 | int GetWhitespaceVisible(); |
463 | void SetWhitespaceVisible(int view); | |
9ce192d4 RD |
464 | |
465 | void Indent(bool forwards); | |
466 | ||
a834585d | 467 | long FindText(uptr_t wParam, sptr_t lParam); |
9ce192d4 | 468 | void SearchAnchor(); |
a834585d | 469 | long SearchText(unsigned int iMessage, uptr_t wParam, sptr_t lParam); |
65ec6247 | 470 | long SearchInTarget(const char *text, int length); |
9ce192d4 RD |
471 | void GoToLine(int lineNo); |
472 | ||
e14d10b0 | 473 | virtual void CopyToClipboard(const SelectionText &selectedText) = 0; |
9ce192d4 | 474 | char *CopyRange(int start, int end); |
e14d10b0 | 475 | void CopySelectionFromRange(SelectionText *ss, int start, int end); |
b8b0e402 | 476 | void CopySelectionRange(SelectionText *ss); |
e14d10b0 RD |
477 | void CopyRangeToClipboard(int start, int end); |
478 | void CopyText(int length, const char *text); | |
9ce192d4 | 479 | void SetDragPosition(int newPos); |
e14d10b0 | 480 | virtual void DisplayCursor(Window::Cursor c); |
9ce192d4 RD |
481 | virtual void StartDrag(); |
482 | void DropAt(int position, const char *value, bool moving, bool rectangular); | |
65ec6247 RD |
483 | /** PositionInSelection returns 0 if position in selection, -1 if position before selection, and 1 if after. |
484 | * Before means either before any line of selection or before selection on its line, with a similar meaning to after. */ | |
9ce192d4 RD |
485 | int PositionInSelection(int pos); |
486 | bool PointInSelection(Point pt); | |
487 | bool PointInSelMargin(Point pt); | |
65ec6247 RD |
488 | void LineSelection(int lineCurrent_, int lineAnchor_); |
489 | void DwellEnd(bool mouseMoved); | |
9ce192d4 RD |
490 | virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt); |
491 | void ButtonMove(Point pt); | |
492 | void ButtonUp(Point pt, unsigned int curTime, bool ctrl); | |
493 | ||
494 | void Tick(); | |
8e54aaed | 495 | bool Idle(); |
9ce192d4 | 496 | virtual void SetTicking(bool on) = 0; |
8e54aaed | 497 | virtual bool SetIdle(bool) { return false; } |
9ce192d4 RD |
498 | virtual void SetMouseCapture(bool on) = 0; |
499 | virtual bool HaveMouseCapture() = 0; | |
65ec6247 | 500 | void SetFocusState(bool focusState); |
9ce192d4 RD |
501 | |
502 | void CheckForChangeOutsidePaint(Range r); | |
503 | int BraceMatch(int position, int maxReStyle); | |
504 | void SetBraceHighlight(Position pos0, Position pos1, int matchStyle); | |
1a2fb4cd | 505 | |
9ce192d4 | 506 | void SetDocPointer(Document *document); |
1a2fb4cd | 507 | |
9ce192d4 RD |
508 | void Expand(int &line, bool doExpand); |
509 | void ToggleContraction(int line); | |
65ec6247 RD |
510 | void EnsureLineVisible(int lineDoc, bool enforcePolicy); |
511 | int ReplaceTarget(bool replacePatterns, const char *text, int length=-1); | |
9ce192d4 | 512 | |
9e730a78 RD |
513 | bool PositionIsHotspot(int position); |
514 | bool PointIsHotspot(Point pt); | |
515 | void SetHotSpotRange(Point *pt); | |
516 | void GetHotSpotRange(int& hsStart, int& hsEnd); | |
517 | ||
518 | int CodePage() const; | |
519 | ||
65ec6247 | 520 | virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0; |
1a2fb4cd | 521 | |
9ce192d4 | 522 | public: |
1a2fb4cd RD |
523 | // Public so the COM thunks can access it. |
524 | bool IsUnicodeMode() const; | |
525 | // Public so scintilla_send_message can use it. | |
65ec6247 | 526 | virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam); |
1a2fb4cd RD |
527 | // Public so scintilla_set_id can use it. |
528 | int ctrlID; | |
9e730a78 | 529 | friend class AutoSurface; |
8e54aaed | 530 | friend class SelectionLineIterator; |
9e730a78 RD |
531 | }; |
532 | ||
533 | /** | |
534 | * A smart pointer class to ensure Surfaces are set up and deleted correctly. | |
535 | */ | |
536 | class AutoSurface { | |
537 | private: | |
538 | Surface *surf; | |
539 | public: | |
540 | AutoSurface(Editor *ed) : surf(0) { | |
541 | if (ed->wMain.GetID()) { | |
542 | surf = Surface::Allocate(); | |
543 | if (surf) { | |
544 | surf->Init(ed->wMain.GetID()); | |
545 | surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage()); | |
546 | surf->SetDBCSMode(ed->CodePage()); | |
547 | } | |
548 | } | |
549 | } | |
550 | AutoSurface(SurfaceID sid, Editor *ed) : surf(0) { | |
551 | if (ed->wMain.GetID()) { | |
552 | surf = Surface::Allocate(); | |
553 | if (surf) { | |
554 | surf->Init(sid, ed->wMain.GetID()); | |
555 | surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage()); | |
556 | surf->SetDBCSMode(ed->CodePage()); | |
557 | } | |
558 | } | |
559 | } | |
560 | ~AutoSurface() { | |
561 | delete surf; | |
562 | } | |
563 | Surface *operator->() const { | |
564 | return surf; | |
565 | } | |
566 | operator Surface *() const { | |
567 | return surf; | |
568 | } | |
9ce192d4 RD |
569 | }; |
570 | ||
571 | #endif |