// Scintilla source code edit control /** @file Editor.h ** Defines the main editor class. **/ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef EDITOR_H #define EDITOR_H /** */ class Caret { public: bool active; bool on; int period; Caret(); }; /** */ class Timer { public: bool ticking; int ticksToWait; enum {tickSize = 100}; TickerID tickerID; Timer(); }; /** */ class Idler { public: bool state; IdlerID idlerID; Idler(); }; /** */ class LineLayout { private: friend class LineLayoutCache; int *lineStarts; int lenLineStarts; /// Drawing is only performed for @a maxLineLength characters on each line. int lineNumber; bool inCache; public: enum { wrapWidthInfinite = 0x7ffffff }; int maxLineLength; int numCharsInLine; enum validLevel { llInvalid, llCheckTextAndStyle, llPositions, llLines } validity; int xHighlightGuide; bool highlightColumn; int selStart; int selEnd; bool containsCaret; int edgeColumn; char *chars; unsigned char *styles; int styleBitsSet; char *indicators; int *positions; char bracePreviousStyles[2]; // Hotspot support int hsStart; int hsEnd; // Wrapped line support int widthLine; int lines; LineLayout(int maxLineLength_); virtual ~LineLayout(); void Resize(int maxLineLength_); void Free(); void Invalidate(validLevel validity_); int LineStart(int line) { if (line <= 0) { return 0; } else if ((line >= lines) || !lineStarts) { return numCharsInLine; } else { return lineStarts[line]; } } void SetLineStart(int line, int start); void SetBracesHighlight(Range rangeLine, Position braces[], char bracesMatchStyle, int xHighlight); void RestoreBracesHighlight(Range rangeLine, Position braces[]); }; /** */ class LineLayoutCache { int level; int length; int size; LineLayout **cache; bool allInvalidated; int styleClock; int useCount; void Allocate(int length_); void AllocateForLevel(int linesOnScreen, int linesInDoc); public: LineLayoutCache(); virtual ~LineLayoutCache(); void Deallocate(); enum { llcNone=SC_CACHE_NONE, llcCaret=SC_CACHE_CARET, llcPage=SC_CACHE_PAGE, llcDocument=SC_CACHE_DOCUMENT }; void Invalidate(LineLayout::validLevel validity_); void SetLevel(int level_); int GetLevel() { return level; } LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_, int linesOnScreen, int linesInDoc); void Dispose(LineLayout *ll); }; /** * Hold a piece of text selected for copying or dragging. * The text is expected to hold a terminating '\0' and this is counted in len. */ class SelectionText { public: char *s; int len; bool rectangular; int codePage; int characterSet; SelectionText() : s(0), len(0), rectangular(false), codePage(0), characterSet(0) {} ~SelectionText() { Free(); } void Free() { Set(0, 0, 0, 0, false); } void Set(char *s_, int len_, int codePage_, int characterSet_, bool rectangular_) { delete []s; s = s_; if (s) len = len_; else len = 0; codePage = codePage_; characterSet = characterSet_; rectangular = rectangular_; } void Copy(const char *s_, int len_, int codePage_, int characterSet_, bool rectangular_) { delete []s; s = new char[len_]; if (s) { len = len_; for (int i = 0; i < len_; i++) { s[i] = s_[i]; } } else { len = 0; } codePage = codePage_; characterSet = characterSet_; rectangular = rectangular_; } void Copy(const SelectionText &other) { Copy(other.s, other.len, other.codePage, other.characterSet, other.rectangular); } }; /** */ class Editor : public DocWatcher { // Private so Editor objects can not be copied Editor(const Editor &) : DocWatcher() {} Editor &operator=(const Editor &) { return *this; } protected: // ScintillaBase subclass needs access to much of Editor /** On GTK+, Scintilla is a container widget holding two scroll bars * whereas on Windows there is just one window with both scroll bars turned on. */ Window wMain; ///< The Scintilla parent window /** Style resources may be expensive to allocate so are cached between uses. * When a style attribute is changed, this cache is flushed. */ bool stylesValid; ViewStyle vs; Palette palette; int printMagnification; int printColourMode; int printWrapState; int cursorMode; int controlCharSymbol; bool hasFocus; bool hideSelection; bool inOverstrike; int errorStatus; bool mouseDownCaptures; /** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to * the screen. This avoids flashing but is about 30% slower. */ bool bufferedDraw; /** In twoPhaseDraw mode, drawing is performed in two phases, first the background * and then the foreground. This avoids chopping off characters that overlap the next run. */ bool twoPhaseDraw; int xOffset; ///< Horizontal scrolled amount in pixels int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret bool horizontalScrollBarVisible; int scrollWidth; bool verticalScrollBarVisible; bool endAtLastLine; bool caretSticky; Surface *pixmapLine; Surface *pixmapSelMargin; Surface *pixmapSelPattern; Surface *pixmapIndentGuide; Surface *pixmapIndentGuideHighlight; LineLayoutCache llc; KeyMap kmap; Caret caret; Timer timer; Timer autoScrollTimer; enum { autoScrollDelay = 200 }; Idler idler; Point lastClick; unsigned int lastClickTime; int dwellDelay; int ticksToDwell; bool dwelling; enum { selChar, selWord, selLine } selectionType; Point ptMouseLast; bool inDragDrop; bool dropWentOutside; int posDrag; int posDrop; int lastXChosen; int lineAnchor; int originalAnchorPos; int currentPos; int anchor; int targetStart; int targetEnd; int searchFlags; int topLine; int posTopLine; int lengthForEncode; bool needUpdateUI; Position braces[2]; int bracesMatchStyle; int highlightGuideColumn; int theEdge; enum { notPainting, painting, paintAbandoned } paintState; PRectangle rcPaint; bool paintingAllText; int modEventMask; SelectionText drag; enum selTypes { noSel, selStream, selRectangle, selLines }; selTypes selType; bool moveExtendsSelection; int xStartSelect; ///< x position of start of rectangular selection int xEndSelect; ///< x position of end of rectangular selection bool primarySelection; int caretXPolicy; int caretXSlop; ///< Ensure this many pixels visible on both sides of caret int caretYPolicy; int caretYSlop; ///< Ensure this many lines visible on both sides of caret int visiblePolicy; int visibleSlop; int searchAnchor; bool recordingMacro; int foldFlags; ContractionState cs; // Hotspot support int hsStart; int hsEnd; // Wrapping support enum { eWrapNone, eWrapWord, eWrapChar } wrapState; bool backgroundWrapEnabled; int wrapWidth; int docLineLastWrapped; int docLastLineToWrap; int wrapVisualFlags; int wrapVisualFlagsLocation; int wrapVisualStartIndent; int actualWrapVisualStartIndent; bool convertPastes; Document *pdoc; Editor(); virtual ~Editor(); virtual void Initialise() = 0; virtual void Finalise(); void InvalidateStyleData(); void InvalidateStyleRedraw(); virtual void RefreshColourPalette(Palette &pal, bool want); void RefreshStyleData(); void DropGraphics(); virtual PRectangle GetClientRectangle(); PRectangle GetTextRectangle(); int LinesOnScreen(); int LinesToScroll(); int MaxScrollPos(); Point LocationFromPosition(int pos); int XFromPosition(int pos); int PositionFromLocation(Point pt); int PositionFromLocationClose(Point pt); int PositionFromLineX(int line, int x); int LineFromLocation(Point pt); void SetTopLine(int topLineNew); bool AbandonPaint(); void RedrawRect(PRectangle rc); void Redraw(); void RedrawSelMargin(int line=-1); PRectangle RectangleFromRange(int start, int end); void InvalidateRange(int start, int end); int CurrentPosition(); bool SelectionEmpty(); int SelectionStart(); int SelectionEnd(); void SetRectangularRange(); void InvalidateSelection(int currentPos_, int anchor_); void SetSelection(int currentPos_, int anchor_); void SetSelection(int currentPos_); void HTTP/1.1 200 OK Connection: keep-alive Connection: keep-alive Content-Disposition: inline; filename="Editor.h" Content-Disposition: inline; filename="Editor.h" Content-Length: 16525 Content-Length: 16525 Content-Security-Policy: default-src 'none' Content-Security-Policy: default-src 'none' Content-Type: text/plain; charset=UTF-8 Content-Type: text/plain; charset=UTF-8 Date: Fri, 12 Dec 2025 23:25:44 UTC ETag: "9243d3a2f42cf433ade40a24c2b170208b0c975d" ETag: "9243d3a2f42cf433ade40a24c2b170208b0c975d" Expires: Mon, 10 Dec 2035 23:25:44 GMT Expires: Mon, 10 Dec 2035 23:25:45 GMT Last-Modified: Fri, 12 Dec 2025 23:25:44 GMT Last-Modified: Fri, 12 Dec 2025 23:25:45 GMT Server: OpenBSD httpd Server: OpenBSD httpd X-Content-Type-Options: nosniff X-Content-Type-Options: nosniff // Scintilla source code edit control /** @file Editor.h ** Defines the main editor class. **/ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef EDITOR_H #define EDITOR_H /** */ class Caret { public: bool active; bool on; int period; Caret(); }; /** */ class Timer { public: bool ticking; int ticksToWait; enum {tickSize = 100}; TickerID tickerID; Timer(); }; /** */ class Idler { public: bool state; IdlerID idlerID; Idler(); }; /** */ class LineLayout { private: friend class LineLayoutCache; int *lineStarts; int lenLineStarts; /// Drawing is only performed for @a maxLineLength characters on each line. int lineNumber; bool inCache; public: enum { wrapWidthInfinite = 0x7ffffff }; int maxLineLength; int numCharsInLine; enum validLevel { llInvalid, llCheckTextAndStyle, llPositions, llLines } validity; int xHighlightGuide; bool highlightColumn; int selStart; int selEnd; bool containsCaret; int edgeColumn; char *chars; unsigned char *styles; int styleBitsSet; char *indicators; int *positions; char bracePreviousStyles[2]; // Hotspot support int hsStart; int hsEnd; // Wrapped line support int widthLine; int lines; LineLayout(int maxLineLength_); virtual ~LineLayout(); void Resize(int maxLineLength_); void Free(); void Invalidate(validLevel validity_); int LineStart(int line) { if (line <= 0) { return 0; } else if ((line >= lines) || !lineStarts) { return numCharsInLine; } else { return lineStarts[line]; } } void SetLineStart(int line, int start); void SetBracesHighlight(Range rangeLine, Position braces[], char bracesMatchStyle, int xHighlight); void RestoreBracesHighlight(Range rangeLine, Position braces[]); }; /** */ class LineLayoutCache { int level; int length; int size; LineLayout **cache; bool allInvalidated; int styleClock; int useCount; void Allocate(int length_); void AllocateForLevel(int linesOnScreen, int linesInDoc); public: LineLayoutCache(); virtual ~LineLayoutCache(); void Deallocate(); enum { llcNone=SC_CACHE_NONE, llcCaret=SC_CACHE_CARET, llcPage=SC_CACHE_PAGE, llcDocument=SC_CACHE_DOCUMENT }; void Invalidate(LineLayout::validLevel validity_); void SetLevel(int level_); int GetLevel() { return level; } LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_, int linesOnScreen, int linesInDoc); void Dispose(LineLayout *ll); }; /** * Hold a piece of text selected for copying or dragging. * The text is expected to hold a terminating '\0' and this is counted in len. */ class SelectionText { public: char *s; int len; bool rectangular; int codePage; int characterSet; SelectionText() : s(0), len(0), rectangular(false), codePage(0), characterSet(0) {} ~SelectionText() { Free(); } void Free() { Set(0, 0, 0, 0, false); } void Set(char *s_, int len_, int codePage_, int characterSet_, bool rectangular_) { delete []s; s = s_; if (s) len = len_; else len = 0; codePage = codePage_; characterSet = characterSet_; rectangular = rectangular_; } void Copy(const char *s_, int len_, int codePage_, int characterSet_, bool rectangular_) { delete []s; s = new char[len_]; if (s) { len = len_; for (int i = 0; i < len_; i++) { s[i] = s_[i]; } } else { len = 0; } codePage = codePage_; characterSet = characterSet_; rectangular = rectangular_; } void Copy(const SelectionText &other) { Copy(other.s, other.len, other.codePage, other.characterSet, other.rectangular); } }; /** */ class Editor : public DocWatcher { // Private so Editor objects can not be copied Editor(const Editor &) : DocWatcher() {} Editor &operator=(const Editor &) { return *this; } protected: // ScintillaBase subclass needs access to much of Editor /** On GTK+, Scintilla is a container widget holding two scroll bars * whereas on Windows there is just one window with both scroll bars turned on. */ Window wMain; ///< The Scintilla parent window /** Style resources may be expensive to allocate so are cached between uses. * When a style attribute is changed, this cache is flushed. */ bool stylesValid; ViewStyle vs; Palette palette; int printMagnification; int printColourMode; int printWrapState; int cursorMode; int controlCharSymbol; bool hasFocus; bool hideSelection; bool inOverstrike; int errorStatus; bool mouseDownCaptures; /** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to * the screen. This avoids flashing but is about 30% slower. */ bool bufferedDraw; /** In twoPhaseDraw mode, drawing is performed in two phases, first the background * and then the foreground. This avoids chopping off characters that overlap the next run. */ bool twoPhaseDraw; int xOffset; ///< Horizontal scrolled amount in pixels int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret bool horizontalScrollBarVisible; int scrollWidth; bool verticalScrollBarVisible; bool endAtLastLine; bool caretSticky; Surface *pixmapLine; Surface *pixmapSelMargin; Surface *pixmapSelPattern; Surface *pixmapIndentGuide; Surface *pixmapIndentGuideHighlight; LineLayoutCache llc; KeyMap kmap; Caret caret; Timer timer; Timer autoScrollTimer; enum { autoScrollDelay = 200 }; Idler idler; Point lastClick; unsigned int lastClickTime; int dwellDelay; int ticksToDwell; bool dwelling; enum { selChar, selWord, selLine } selectionType; Point ptMouseLast; bool inDragDrop; bool dropWentOutside; int posDrag; int posDrop; int lastXChosen; int lineAnchor; int originalAnchorPos; int currentPos; int anchor; int targetStart; int targetEnd; int searchFlags; int topLine; int posTopLine; int lengthForEncode; bool needUpdateUI; Position braces[2]; int bracesMatchStyle; int highlightGuideColumn; int theEdge; enum { notPainting, painting, paintAbandoned } paintState; PRectangle rcPaint; bool paintingAllText; int modEventMask; SelectionText drag; enum selTypes { noSel, selStream, selRectangle, selLines }; selTypes selType; bool moveExtendsSelection; int xStartSelect; ///< x position of start of rectangular selection int xEndSelect; ///< x position of end of rectangular selection bool primarySelection; int caretXPolicy; int caretXSlop; ///< Ensure this many pixels visible on both sides of caret int caretYPolicy; int caretYSlop; ///< Ensure this many lines visible on both sides of caret int visiblePolicy; int visibleSlop; int searchAnchor; bool recordingMacro; int foldFlags; ContractionState cs; // Hotspot support int hsStart; int hsEnd; // Wrapping support enum { eWrapNone, eWrapWord, eWrapChar } wrapState; bool backgroundWrapEnabled; int wrapWidth; int docLineLastWrapped; int docLastLineToWrap; int wrapVisualFlags; int wrapVisualFlagsLocation; int wrapVisualStartIndent; int actualWrapVisualStartIndent; bool convertPastes; Document *pdoc; Editor(); virtual ~Editor(); virtual void Initialise() = 0; virtual void Finalise(); void InvalidateStyleData(); void InvalidateStyleRedraw(); virtual void RefreshColourPalette(Palette &pal, bool want); void RefreshStyleData(); void DropGraphics(); virtual PRectangle GetClientRectangle(); PRectangle GetTextRectangle(); int LinesOnScreen(); int LinesToScroll(); int MaxScrollPos(); Point LocationFromPosition(int pos); int XFromPosition(int pos