]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/stc/scintilla/src/Editor.h
4ff334767a19b67c454d80f2de85e4f0364b7819
1 // Scintilla source code edit control
2 // Editor.h - defines the main editor class
3 // Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
4 // The License.txt file describes the conditions under which this software may be distributed.
23 enum {tickSize
= 100};
31 // Drawing is only performed for maxLineLength characters on each line.
32 enum {maxLineLength
= 4000};
34 char chars
[maxLineLength
];
35 char styles
[maxLineLength
];
36 char indicators
[maxLineLength
];
37 int positions
[maxLineLength
];
40 class Editor
: public DocWatcher
{
41 protected: // ScintillaBase subclass needs access to much of Editor
43 // On GTK+, Scintilla is a container widget holding two scroll bars and a drawing area
44 // whereas on Windows there is just one window with both scroll bars turned on.
45 // Therefore, on GTK+ the following are separate windows but only one window on Windows.
46 Window wMain
; // The Scintilla parent window
47 Window wDraw
; // The text drawing area
49 // Style resources may be expensive to allocate so are cached between uses.
50 // When a style attribute is changed, this cache is flushed.
58 // In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to
59 // the screen. This avoids flashing but is about 30% slower.
62 int xOffset
; // Horizontal scrolled amount in pixels
63 int xCaretMargin
; // Ensure this many pixels visible on both sides of caret
66 Surface pixmapSelMargin
;
67 Surface pixmapSelPattern
;
68 // Intellimouse support - currently only implemented for Windows
69 unsigned int ucWheelScrollLines
;
70 short cWheelDelta
; //wheel delta from roll
78 unsigned int lastClickTime
;
79 enum { selChar
, selWord
, selLine
} selectionType
;
88 int originalAnchorPos
;
101 enum { notPainting
, painting
, paintAbandoned
} paintState
;
103 bool paintingAllText
;
109 bool dragIsRectangle
;
110 enum { selStream
, selRectangle
, selRectangleFixed
} selType
;
130 virtual void Initialise() = 0;
131 virtual void Finalise();
133 void InvalidateStyleData();
134 void InvalidateStyleRedraw();
135 virtual void RefreshColourPalette(Palette
&pal
, bool want
);
136 void RefreshStyleData();
139 PRectangle
GetClientRectangle();
140 PRectangle
GetTextRectangle();
145 Point
LocationFromPosition(unsigned int pos
);
146 int XFromPosition(unsigned int pos
);
147 int PositionFromLocation(Point pt
);
148 int PositionFromLineX(int line
, int x
);
149 int LineFromLocation(Point pt
);
150 void SetTopLine(int topLineNew
);
152 void RedrawRect(PRectangle rc
);
154 void RedrawSelMargin();
155 PRectangle
RectangleFromRange(int start
, int end
);
156 void InvalidateRange(int start
, int end
);
158 int CurrentPosition();
159 bool SelectionEmpty();
160 int SelectionStart(int line
=-1);
161 int SelectionEnd(int line
=-1);
162 void SetSelection(int currentPos_
, int anchor_
);
163 void SetSelection(int currentPos_
);
164 void SetEmptySelection(int currentPos_
);
165 int MovePositionTo(int newPos
, bool extend
= false);
166 int MovePositionSoVisible(int pos
, int moveDir
);
167 void SetLastXChosen();
169 void ScrollTo(int line
);
170 virtual void ScrollText(int linesToMove
);
171 void HorizontalScrollTo(int xPos
);
172 void EnsureCaretVisible(bool useMargin
=true);
173 void ShowCaretAtCurrentPosition();
175 void InvalidateCaret();
177 void PaintSelMargin(Surface
*surface
, PRectangle
&rc
);
178 void LayoutLine(int line
, Surface
*surface
, ViewStyle
&vstyle
, LineLayout
&ll
);
179 void DrawLine(Surface
*surface
, ViewStyle
&vsDraw
, int line
, int xStart
,
180 PRectangle rcLine
, LineLayout
&ll
);
181 void Paint(Surface
*surfaceWindow
, PRectangle rcArea
);
182 long FormatRange(bool draw
, FORMATRANGE
*pfr
);
184 virtual void SetVerticalScrollPos() = 0;
185 virtual void SetHorizontalScrollPos() = 0;
186 virtual bool ModifyScrollBars(int nMax
, int nPage
) = 0;
187 void SetScrollBarsTo(PRectangle rsClient
);
188 void SetScrollBars();
190 virtual void AddChar(char ch
);
191 void ClearSelection();
194 void PasteRectangular(int pos
, const char *ptr
, int len
);
195 virtual void Copy() = 0;
196 virtual void Paste() = 0;
203 virtual void ClaimSelection() = 0;
205 virtual void NotifyChange() = 0;
206 virtual void NotifyFocus(bool focus
);
207 virtual void NotifyParent(SCNotification scn
) = 0;
208 virtual void NotifyStyleNeeded(int endStyleNeeded
);
209 void NotifyChar(char ch
);
210 void NotifySavePoint(bool isSavePoint
);
211 void NotifyModifyAttempt();
212 virtual void NotifyDoubleClick(Point pt
, bool shift
);
213 void NotifyUpdateUI();
214 bool NotifyMarginClick(Point pt
, bool shift
, bool ctrl
, bool alt
);
215 void NotifyNeedShown(int pos
, int len
);
217 void NotifyModifyAttempt(Document
*document
, void *userData
);
218 void NotifySavePoint(Document
*document
, void *userData
, bool atSavePoint
);
219 void NotifyModified(Document
*document
, DocModification mh
, void *userData
);
220 void NotifyDeleted(Document
*document
, void *userData
);
223 void NotifyMacroRecord(UINT iMessage
, WPARAM wParam
, LPARAM lParam
);
226 void PageMove(int direction
, bool extend
=false);
227 virtual int KeyCommand(UINT iMessage
);
228 virtual int KeyDefault(int /* key */, int /*modifiers*/);
229 int KeyDown(int key
, bool shift
, bool ctrl
, bool alt
);
231 bool GetWhitespaceVisible();
232 void SetWhitespaceVisible(bool view
);
234 void Indent(bool forwards
);
236 long FindText(UINT iMessage
,WPARAM wParam
,LPARAM lParam
);
238 long SearchText(UINT iMessage
,WPARAM wParam
,LPARAM lParam
);
239 void GoToLine(int lineNo
);
241 char *CopyRange(int start
, int end
);
242 int SelectionRangeLength();
243 char *CopySelectionRange();
244 void CopySelectionIntoDrag();
245 void SetDragPosition(int newPos
);
246 virtual void StartDrag();
247 void DropAt(int position
, const char *value
, bool moving
, bool rectangular
);
248 // PositionInSelection returns 0 if position in selection, -1 if position before selection, and 1 if after.
249 // Before means either before any line of selection or before selection on its line, with a similar meaning to after
250 int PositionInSelection(int pos
);
251 bool PointInSelection(Point pt
);
252 bool PointInSelMargin(Point pt
);
253 virtual void ButtonDown(Point pt
, unsigned int curTime
, bool shift
, bool ctrl
, bool alt
);
254 void ButtonMove(Point pt
);
255 void ButtonUp(Point pt
, unsigned int curTime
, bool ctrl
);
258 virtual void SetTicking(bool on
) = 0;
259 virtual void SetMouseCapture(bool on
) = 0;
260 virtual bool HaveMouseCapture() = 0;
262 void CheckForChangeOutsidePaint(Range r
);
263 int BraceMatch(int position
, int maxReStyle
);
264 void SetBraceHighlight(Position pos0
, Position pos1
, int matchStyle
);
266 void SetDocPointer(Document
*document
);
268 void Expand(int &line
, bool doExpand
);
269 void ToggleContraction(int line
);
270 void EnsureLineVisible(int line
);
272 virtual LRESULT
DefWndProc(UINT iMessage
, WPARAM wParam
, LPARAM lParam
) = 0;
275 // Public so scintilla_send_message can use it
276 virtual LRESULT
WndProc(UINT iMessage
, WPARAM wParam
, LPARAM lParam
);
277 // Public so scintilla_set_id can use it