Update Scintilla to v3.4.1
[TortoiseGit.git] / ext / scintilla / src / Editor.h
blob7579b3f53139d72a1c9951cbe394cbcb9a8a8eab
1 // Scintilla source code edit control
2 /** @file Editor.h
3 ** Defines the main editor class.
4 **/
5 // Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
8 #ifndef EDITOR_H
9 #define EDITOR_H
11 #ifdef SCI_NAMESPACE
12 namespace Scintilla {
13 #endif
15 /**
17 class Caret {
18 public:
19 bool active;
20 bool on;
21 int period;
23 Caret();
26 /**
28 class Timer {
29 public:
30 bool ticking;
31 int ticksToWait;
32 enum {tickSize = 100};
33 TickerID tickerID;
35 Timer();
38 /**
40 class Idler {
41 public:
42 bool state;
43 IdlerID idlerID;
45 Idler();
48 /**
49 * When platform has a way to generate an event before painting,
50 * accumulate needed styling range and other work items in
51 * WorkNeeded to avoid unnecessary work inside paint handler
53 class WorkNeeded {
54 public:
55 enum workItems {
56 workNone=0,
57 workStyle=1,
58 workUpdateUI=2
60 bool active;
61 enum workItems items;
62 Position upTo;
64 WorkNeeded() : active(false), items(workNone), upTo(0) {}
65 void Reset() {
66 active = false;
67 items = workNone;
68 upTo = 0;
70 void Need(workItems items_, Position pos) {
71 if ((items_ & workStyle) && (upTo < pos))
72 upTo = pos;
73 items = static_cast<workItems>(items | items_);
77 /**
78 * Hold a piece of text selected for copying or dragging, along with encoding and selection format information.
80 class SelectionText {
81 std::string s;
82 public:
83 bool rectangular;
84 bool lineCopy;
85 int codePage;
86 int characterSet;
87 SelectionText() : rectangular(false), lineCopy(false), codePage(0), characterSet(0) {}
88 ~SelectionText() {
90 void Clear() {
91 s.clear();
92 rectangular = false;
93 lineCopy = false;
94 codePage = 0;
95 characterSet = 0;
97 void Copy(const std::string &s_, int codePage_, int characterSet_, bool rectangular_, bool lineCopy_) {
98 s = s_;
99 codePage = codePage_;
100 characterSet = characterSet_;
101 rectangular = rectangular_;
102 lineCopy = lineCopy_;
103 FixSelectionForClipboard();
105 void Copy(const SelectionText &other) {
106 Copy(other.s, other.codePage, other.characterSet, other.rectangular, other.lineCopy);
108 const char *Data() const {
109 return s.c_str();
111 size_t Length() const {
112 return s.length();
114 size_t LengthWithTerminator() const {
115 return s.length() + 1;
117 bool Empty() const {
118 return s.empty();
120 private:
121 void FixSelectionForClipboard() {
122 // To avoid truncating the contents of the clipboard when pasted where the
123 // clipboard contains NUL characters, replace NUL characters by spaces.
124 std::replace(s.begin(), s.end(), '\0', ' ');
128 struct WrapPending {
129 // The range of lines that need to be wrapped
130 enum { lineLarge = 0x7ffffff };
131 int start; // When there are wraps pending, will be in document range
132 int end; // May be lineLarge to indicate all of document after start
133 WrapPending() {
134 start = lineLarge;
135 end = lineLarge;
137 void Reset() {
138 start = lineLarge;
139 end = lineLarge;
141 void Wrapped(int line) {
142 if (start == line)
143 start++;
145 bool NeedsWrap() const {
146 return start < end;
148 bool AddRange(int lineStart, int lineEnd) {
149 const bool neededWrap = NeedsWrap();
150 bool changed = false;
151 if (start > lineStart) {
152 start = lineStart;
153 changed = true;
155 if ((end < lineEnd) || !neededWrap) {
156 end = lineEnd;
157 changed = true;
159 return changed;
163 struct PrintParameters {
164 int magnification;
165 int colourMode;
166 WrapMode wrapState;
167 PrintParameters();
172 class Editor : public DocWatcher {
173 // Private so Editor objects can not be copied
174 Editor(const Editor &);
175 Editor &operator=(const Editor &);
177 protected: // ScintillaBase subclass needs access to much of Editor
179 /** On GTK+, Scintilla is a container widget holding two scroll bars
180 * whereas on Windows there is just one window with both scroll bars turned on. */
181 Window wMain; ///< The Scintilla parent window
182 Window wMargin; ///< May be separate when using a scroll view for wMain
184 /** Style resources may be expensive to allocate so are cached between uses.
185 * When a style attribute is changed, this cache is flushed. */
186 bool stylesValid;
187 ViewStyle vs;
188 int technology;
189 Point sizeRGBAImage;
190 float scaleRGBAImage;
192 PrintParameters printParameters;
194 int cursorMode;
196 // Highlight current folding block
197 HighlightDelimiter highlightDelimiter;
199 bool hasFocus;
200 bool hideSelection;
201 bool inOverstrike;
202 bool drawOverstrikeCaret;
203 bool mouseDownCaptures;
205 /** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to
206 * the screen. This avoids flashing but is about 30% slower. */
207 bool bufferedDraw;
208 /** In twoPhaseDraw mode, drawing is performed in two phases, first the background
209 * and then the foreground. This avoids chopping off characters that overlap the next run. */
210 bool twoPhaseDraw;
212 int xOffset; ///< Horizontal scrolled amount in pixels
213 int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret
214 bool horizontalScrollBarVisible;
215 int scrollWidth;
216 bool trackLineWidth;
217 int lineWidthMaxSeen;
218 bool verticalScrollBarVisible;
219 bool endAtLastLine;
220 int caretSticky;
221 int marginOptions;
222 bool mouseSelectionRectangularSwitch;
223 bool multipleSelection;
224 bool additionalSelectionTyping;
225 int multiPasteMode;
226 bool additionalCaretsBlink;
227 bool additionalCaretsVisible;
229 int virtualSpaceOptions;
231 Surface *pixmapLine;
232 Surface *pixmapSelMargin;
233 Surface *pixmapSelPattern;
234 Surface *pixmapSelPatternOffset1;
235 Surface *pixmapIndentGuide;
236 Surface *pixmapIndentGuideHighlight;
238 LineLayoutCache llc;
239 PositionCache posCache;
240 SpecialRepresentations reprs;
242 KeyMap kmap;
244 Caret caret;
245 Timer timer;
246 Timer autoScrollTimer;
247 enum { autoScrollDelay = 200 };
249 Idler idler;
251 Point lastClick;
252 unsigned int lastClickTime;
253 int dwellDelay;
254 int ticksToDwell;
255 bool dwelling;
256 enum { selChar, selWord, selSubLine, selWholeLine } selectionType;
257 Point ptMouseLast;
258 enum { ddNone, ddInitial, ddDragging } inDragDrop;
259 bool dropWentOutside;
260 SelectionPosition posDrag;
261 SelectionPosition posDrop;
262 int hotSpotClickPos;
263 int lastXChosen;
264 int lineAnchorPos;
265 int originalAnchorPos;
266 int wordSelectAnchorStartPos;
267 int wordSelectAnchorEndPos;
268 int wordSelectInitialCaretPos;
269 int targetStart;
270 int targetEnd;
271 int searchFlags;
272 int topLine;
273 int posTopLine;
274 int lengthForEncode;
276 int needUpdateUI;
277 Position braces[2];
278 int bracesMatchStyle;
279 int highlightGuideColumn;
281 enum { notPainting, painting, paintAbandoned } paintState;
282 bool paintAbandonedByStyling;
283 PRectangle rcPaint;
284 bool paintingAllText;
285 bool willRedrawAll;
286 WorkNeeded workNeeded;
288 int modEventMask;
290 SelectionText drag;
291 Selection sel;
292 bool primarySelection;
294 int caretXPolicy;
295 int caretXSlop; ///< Ensure this many pixels visible on both sides of caret
297 int caretYPolicy;
298 int caretYSlop; ///< Ensure this many lines visible on both sides of caret
300 int visiblePolicy;
301 int visibleSlop;
303 int searchAnchor;
305 bool recordingMacro;
307 int foldFlags;
308 int foldAutomatic;
309 ContractionState cs;
311 // Hotspot support
312 int hsStart;
313 int hsEnd;
315 // Wrapping support
316 int wrapWidth;
317 WrapPending wrapPending;
319 bool convertPastes;
321 Document *pdoc;
323 Editor();
324 virtual ~Editor();
325 virtual void Initialise() = 0;
326 virtual void Finalise();
328 void InvalidateStyleData();
329 void InvalidateStyleRedraw();
330 void RefreshStyleData();
331 void SetRepresentations();
332 void DropGraphics(bool freeObjects);
333 void AllocateGraphics();
335 // The top left visible point in main window coordinates. Will be 0,0 except for
336 // scroll views where it will be equivalent to the current scroll position.
337 virtual Point GetVisibleOriginInMain();
338 Point DocumentPointFromView(Point ptView); // Convert a point from view space to document
339 int TopLineOfMain() const; // Return the line at Main's y coordinate 0
340 virtual PRectangle GetClientRectangle();
341 virtual PRectangle GetClientDrawingRectangle();
342 PRectangle GetTextRectangle();
344 int LinesOnScreen();
345 int LinesToScroll();
346 int MaxScrollPos();
347 SelectionPosition ClampPositionIntoDocument(SelectionPosition sp) const;
348 Point LocationFromPosition(SelectionPosition pos);
349 Point LocationFromPosition(int pos);
350 int XFromPosition(int pos);
351 int XFromPosition(SelectionPosition sp);
352 SelectionPosition SPositionFromLocation(Point pt, bool canReturnInvalid=false, bool charPosition=false, bool virtualSpace=true);
353 int PositionFromLocation(Point pt, bool canReturnInvalid=false, bool charPosition=false);
354 SelectionPosition SPositionFromLineX(int lineDoc, int x);
355 int PositionFromLineX(int line, int x);
356 int LineFromLocation(Point pt) const;
357 void SetTopLine(int topLineNew);
359 bool AbandonPaint();
360 virtual void RedrawRect(PRectangle rc);
361 virtual void DiscardOverdraw();
362 virtual void Redraw();
363 void RedrawSelMargin(int line=-1, bool allAfter=false);
364 PRectangle RectangleFromRange(int start, int end);
365 void InvalidateRange(int start, int end);
367 bool UserVirtualSpace() const {
368 return ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0);
370 int CurrentPosition() const;
371 bool SelectionEmpty() const;
372 SelectionPosition SelectionStart();
373 SelectionPosition SelectionEnd();
374 void SetRectangularRange();
375 void ThinRectangularRange();
376 void InvalidateSelection(SelectionRange newMain, bool invalidateWholeSelection=false);
377 void SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_);
378 void SetSelection(int currentPos_, int anchor_);
379 void SetSelection(SelectionPosition currentPos_);
380 void SetSelection(int currentPos_);
381 void SetEmptySelection(SelectionPosition currentPos_);
382 void SetEmptySelection(int currentPos_);
383 bool RangeContainsProtected(int start, int end) const;
384 bool SelectionContainsProtected();
385 int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true) const;
386 SelectionPosition MovePositionOutsideChar(SelectionPosition pos, int moveDir, bool checkLineEnd=true) const;
387 int MovePositionTo(SelectionPosition newPos, Selection::selTypes sel=Selection::noSel, bool ensureVisible=true);
388 int MovePositionTo(int newPos, Selection::selTypes sel=Selection::noSel, bool ensureVisible=true);
389 SelectionPosition MovePositionSoVisible(SelectionPosition pos, int moveDir);
390 SelectionPosition MovePositionSoVisible(int pos, int moveDir);
391 Point PointMainCaret();
392 void SetLastXChosen();
394 void ScrollTo(int line, bool moveThumb=true);
395 virtual void ScrollText(int linesToMove);
396 void HorizontalScrollTo(int xPos);
397 void VerticalCentreCaret();
398 void MoveSelectedLines(int lineDelta);
399 void MoveSelectedLinesUp();
400 void MoveSelectedLinesDown();
401 void MoveCaretInsideView(bool ensureVisible=true);
402 int DisplayFromPosition(int pos);
404 struct XYScrollPosition {
405 int xOffset;
406 int topLine;
407 XYScrollPosition(int xOffset_, int topLine_) : xOffset(xOffset_), topLine(topLine_) {}
408 bool operator==(const XYScrollPosition &other) const {
409 return (xOffset == other.xOffset) && (topLine == other.topLine);
412 enum XYScrollOptions {
413 xysUseMargin=0x1,
414 xysVertical=0x2,
415 xysHorizontal=0x4,
416 xysDefault=xysUseMargin|xysVertical|xysHorizontal};
417 XYScrollPosition XYScrollToMakeVisible(const SelectionRange &range, const XYScrollOptions options);
418 void SetXYScroll(XYScrollPosition newXY);
419 void EnsureCaretVisible(bool useMargin=true, bool vert=true, bool horiz=true);
420 void ScrollRange(SelectionRange range);
421 void ShowCaretAtCurrentPosition();
422 void DropCaret();
423 void InvalidateCaret();
424 virtual void UpdateSystemCaret();
426 bool Wrapping() const;
427 void NeedWrapping(int docLineStart=0, int docLineEnd=WrapPending::lineLarge);
428 bool WrapOneLine(Surface *surface, int lineToWrap);
429 enum wrapScope {wsAll, wsVisible, wsIdle};
430 bool WrapLines(enum wrapScope ws);
431 void LinesJoin();
432 void LinesSplit(int pixelWidth);
434 int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault) const;
435 void PaintSelMargin(Surface *surface, PRectangle &rc);
436 LineLayout *RetrieveLineLayout(int lineNumber);
437 void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll,
438 int width=LineLayout::wrapWidthInfinite);
439 ColourDesired SelectionBackground(ViewStyle &vsDraw, bool main) const;
440 ColourDesired TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourDesired background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) const;
441 void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight);
442 static void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourDesired wrapColour);
443 void DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll,
444 int line, int lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart,
445 bool overrideBackground, ColourDesired background,
446 bool drawWrapMark, ColourDesired wrapColour);
447 static void DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, ViewStyle &vsDraw,
448 int xStart, PRectangle rcLine, LineLayout *ll, int subLine);
449 void DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
450 PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under);
451 void DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
452 PRectangle rcLine, LineLayout *ll, int subLine);
453 void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
454 PRectangle rcLine, LineLayout *ll, int subLine);
455 void DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine,
456 int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour);
457 void DrawCarets(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
458 PRectangle rcLine, LineLayout *ll, int subLine);
459 void RefreshPixMaps(Surface *surfaceWindow);
460 void Paint(Surface *surfaceWindow, PRectangle rcArea);
461 long FormatRange(bool draw, Sci_RangeToFormat *pfr);
462 int TextWidth(int style, const char *text);
464 virtual void SetVerticalScrollPos() = 0;
465 virtual void SetHorizontalScrollPos() = 0;
466 virtual bool ModifyScrollBars(int nMax, int nPage) = 0;
467 virtual void ReconfigureScrollBars();
468 void SetScrollBars();
469 void ChangeSize();
471 void FilterSelections();
472 int InsertSpace(int position, unsigned int spaces);
473 void AddChar(char ch);
474 virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
475 void InsertPaste(SelectionPosition selStart, const char *text, int len);
476 void ClearSelection(bool retainMultipleSelections=false);
477 void ClearAll();
478 void ClearDocumentStyle();
479 void Cut();
480 void PasteRectangular(SelectionPosition pos, const char *ptr, int len);
481 virtual void Copy() = 0;
482 virtual void CopyAllowLine();
483 virtual bool CanPaste();
484 virtual void Paste() = 0;
485 void Clear();
486 void SelectAll();
487 void Undo();
488 void Redo();
489 void DelChar();
490 void DelCharBack(bool allowLineStartDeletion);
491 virtual void ClaimSelection() = 0;
493 static int ModifierFlags(bool shift, bool ctrl, bool alt, bool meta=false);
494 virtual void NotifyChange() = 0;
495 virtual void NotifyFocus(bool focus);
496 virtual void SetCtrlID(int identifier);
497 virtual int GetCtrlID() { return ctrlID; }
498 virtual void NotifyParent(SCNotification scn) = 0;
499 virtual void NotifyStyleToNeeded(int endStyleNeeded);
500 void NotifyChar(int ch);
501 void NotifySavePoint(bool isSavePoint);
502 void NotifyModifyAttempt();
503 virtual void NotifyDoubleClick(Point pt, int modifiers);
504 virtual void NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt);
505 void NotifyHotSpotClicked(int position, int modifiers);
506 void NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt);
507 void NotifyHotSpotDoubleClicked(int position, int modifiers);
508 void NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt);
509 void NotifyHotSpotReleaseClick(int position, int modifiers);
510 void NotifyHotSpotReleaseClick(int position, bool shift, bool ctrl, bool alt);
511 bool NotifyUpdateUI();
512 void NotifyPainted();
513 void NotifyIndicatorClick(bool click, int position, int modifiers);
514 void NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt);
515 bool NotifyMarginClick(Point pt, int modifiers);
516 bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt);
517 void NotifyNeedShown(int pos, int len);
518 void NotifyDwelling(Point pt, bool state);
519 void NotifyZoom();
521 void NotifyModifyAttempt(Document *document, void *userData);
522 void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
523 void CheckModificationForWrap(DocModification mh);
524 void NotifyModified(Document *document, DocModification mh, void *userData);
525 void NotifyDeleted(Document *document, void *userData);
526 void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
527 void NotifyLexerChanged(Document *doc, void *userData);
528 void NotifyErrorOccurred(Document *doc, void *userData, int status);
529 void NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
531 void ContainerNeedsUpdate(int flags);
532 void PageMove(int direction, Selection::selTypes sel=Selection::noSel, bool stuttered = false);
533 enum { cmSame, cmUpper, cmLower };
534 virtual std::string CaseMapString(const std::string &s, int caseMapping);
535 void ChangeCaseOfSelection(int caseMapping);
536 void LineTranspose();
537 void Duplicate(bool forLine);
538 virtual void CancelModes();
539 void NewLine();
540 void CursorUpOrDown(int direction, Selection::selTypes sel=Selection::noSel);
541 void ParaUpOrDown(int direction, Selection::selTypes sel=Selection::noSel);
542 int StartEndDisplayLine(int pos, bool start);
543 virtual int KeyCommand(unsigned int iMessage);
544 virtual int KeyDefault(int /* key */, int /*modifiers*/);
545 int KeyDownWithModifiers(int key, int modifiers, bool *consumed);
546 int KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed=0);
548 void Indent(bool forwards);
550 virtual CaseFolder *CaseFolderForEncoding();
551 long FindText(uptr_t wParam, sptr_t lParam);
552 void SearchAnchor();
553 long SearchText(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
554 long SearchInTarget(const char *text, int length);
555 void GoToLine(int lineNo);
557 virtual void CopyToClipboard(const SelectionText &selectedText) = 0;
558 std::string RangeText(int start, int end) const;
559 void CopySelectionRange(SelectionText *ss, bool allowLineCopy=false);
560 void CopyRangeToClipboard(int start, int end);
561 void CopyText(int length, const char *text);
562 void SetDragPosition(SelectionPosition newPos);
563 virtual void DisplayCursor(Window::Cursor c);
564 virtual bool DragThreshold(Point ptStart, Point ptNow);
565 virtual void StartDrag();
566 void DropAt(SelectionPosition position, const char *value, size_t lengthValue, bool moving, bool rectangular);
567 void DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular);
568 /** PositionInSelection returns true if position in selection. */
569 bool PositionInSelection(int pos);
570 bool PointInSelection(Point pt);
571 bool PointInSelMargin(Point pt);
572 Window::Cursor GetMarginCursor(Point pt) const;
573 void TrimAndSetSelection(int currentPos_, int anchor_);
574 void LineSelection(int lineCurrentPos_, int lineAnchorPos_, bool wholeLine);
575 void WordSelection(int pos);
576 void DwellEnd(bool mouseMoved);
577 void MouseLeave();
578 virtual void ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers);
579 virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
580 void ButtonMoveWithModifiers(Point pt, int modifiers);
581 void ButtonMove(Point pt);
582 void ButtonUp(Point pt, unsigned int curTime, bool ctrl);
584 void Tick();
585 bool Idle();
586 virtual void SetTicking(bool on) = 0;
587 virtual bool SetIdle(bool) { return false; }
588 virtual void SetMouseCapture(bool on) = 0;
589 virtual bool HaveMouseCapture() = 0;
590 void SetFocusState(bool focusState);
592 int PositionAfterArea(PRectangle rcArea) const;
593 void StyleToPositionInView(Position pos);
594 virtual void IdleWork();
595 virtual void QueueIdleWork(WorkNeeded::workItems items, int upTo=0);
597 virtual bool PaintContains(PRectangle rc);
598 bool PaintContainsMargin();
599 void CheckForChangeOutsidePaint(Range r);
600 void SetBraceHighlight(Position pos0, Position pos1, int matchStyle);
602 void SetAnnotationHeights(int start, int end);
603 virtual void SetDocPointer(Document *document);
605 void SetAnnotationVisible(int visible);
607 int ExpandLine(int line);
608 void SetFoldExpanded(int lineDoc, bool expanded);
609 void FoldLine(int line, int action);
610 void FoldExpand(int line, int action, int level);
611 int ContractedFoldNext(int lineStart) const;
612 void EnsureLineVisible(int lineDoc, bool enforcePolicy);
613 void FoldChanged(int line, int levelNow, int levelPrev);
614 void NeedShown(int pos, int len);
615 void FoldAll(int action);
617 int GetTag(char *tagValue, int tagNumber);
618 int ReplaceTarget(bool replacePatterns, const char *text, int length=-1);
620 bool PositionIsHotspot(int position) const;
621 bool PointIsHotspot(Point pt);
622 void SetHotSpotRange(Point *pt);
623 void GetHotSpotRange(int &hsStart, int &hsEnd) const;
625 int CodePage() const;
626 virtual bool ValidCodePage(int /* codePage */) const { return true; }
627 int WrapCount(int line);
628 void AddStyledText(char *buffer, int appendLength);
630 virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
631 void StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
632 sptr_t StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
634 static const char *StringFromEOLMode(int eolMode);
636 static sptr_t StringResult(sptr_t lParam, const char *val);
637 static sptr_t BytesResult(sptr_t lParam, const unsigned char *val, size_t len);
639 public:
640 // Public so the COM thunks can access it.
641 bool IsUnicodeMode() const;
642 // Public so scintilla_send_message can use it.
643 virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
644 // Public so scintilla_set_id can use it.
645 int ctrlID;
646 // Public so COM methods for drag and drop can set it.
647 int errorStatus;
648 friend class AutoSurface;
649 friend class SelectionLineIterator;
653 * A smart pointer class to ensure Surfaces are set up and deleted correctly.
655 class AutoSurface {
656 private:
657 Surface *surf;
658 public:
659 AutoSurface(Editor *ed, int technology = -1) : surf(0) {
660 if (ed->wMain.GetID()) {
661 surf = Surface::Allocate(technology != -1 ? technology : ed->technology);
662 if (surf) {
663 surf->Init(ed->wMain.GetID());
664 surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage());
665 surf->SetDBCSMode(ed->CodePage());
669 AutoSurface(SurfaceID sid, Editor *ed, int technology = -1) : surf(0) {
670 if (ed->wMain.GetID()) {
671 surf = Surface::Allocate(technology != -1 ? technology : ed->technology);
672 if (surf) {
673 surf->Init(sid, ed->wMain.GetID());
674 surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage());
675 surf->SetDBCSMode(ed->CodePage());
679 ~AutoSurface() {
680 delete surf;
682 Surface *operator->() const {
683 return surf;
685 operator Surface *() const {
686 return surf;
690 #ifdef SCI_NAMESPACE
692 #endif
694 #endif