]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/stc/scintilla/src/Editor.h
d1281be5a8c98ed794fe5eaddee5362d719b4d6b
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
;
119 int displayPopupMenu
;
132 virtual void Initialise() = 0;
133 virtual void Finalise();
135 void InvalidateStyleData();
136 void InvalidateStyleRedraw();
137 virtual void RefreshColourPalette(Palette
&pal
, bool want
);
138 void RefreshStyleData();
141 PRectangle
GetClientRectangle();
142 PRectangle
GetTextRectangle();
147 Point
LocationFromPosition(unsigned int pos
);
148 int XFromPosition(unsigned int pos
);
149 int PositionFromLocation(Point pt
);
150 int PositionFromLineX(int line
, int x
);
151 int LineFromLocation(Point pt
);
152 void SetTopLine(int topLineNew
);
154 void RedrawRect(PRectangle rc
);
156 void RedrawSelMargin();
157 PRectangle
RectangleFromRange(int start
, int end
);
158 void InvalidateRange(int start
, int end
);
160 int CurrentPosition();
161 bool SelectionEmpty();
162 int SelectionStart(int line
=-1);
163 int SelectionEnd(int line
=-1);
164 void SetSelection(int currentPos_
, int anchor_
);
165 void SetSelection(int currentPos_
);
166 void SetEmptySelection(int currentPos_
);
167 int MovePositionTo(int newPos
, bool extend
= false);
168 int MovePositionSoVisible(int pos
, int moveDir
);
169 void SetLastXChosen();
171 void ScrollTo(int line
);
172 virtual void ScrollText(int linesToMove
);
173 void HorizontalScrollTo(int xPos
);
174 void EnsureCaretVisible(bool useMargin
=true);
175 void ShowCaretAtCurrentPosition();
177 void InvalidateCaret();
179 void PaintSelMargin(Surface
*surface
, PRectangle
&rc
);
180 void LayoutLine(int line
, Surface
*surface
, ViewStyle
&vstyle
, LineLayout
&ll
);
181 void DrawLine(Surface
*surface
, ViewStyle
&vsDraw
, int line
, int xStart
,
182 PRectangle rcLine
, LineLayout
&ll
);
183 void Paint(Surface
*surfaceWindow
, PRectangle rcArea
);
184 long FormatRange(bool draw
, FORMATRANGE
*pfr
);
186 virtual void SetVerticalScrollPos() = 0;
187 virtual void SetHorizontalScrollPos() = 0;
188 virtual bool ModifyScrollBars(int nMax
, int nPage
) = 0;
189 void SetScrollBarsTo(PRectangle rsClient
);
190 void SetScrollBars();
192 virtual void AddChar(char ch
);
193 void ClearSelection();
196 void PasteRectangular(int pos
, const char *ptr
, int len
);
197 virtual void Copy() = 0;
198 virtual void Paste() = 0;
205 virtual void ClaimSelection() = 0;
207 virtual void NotifyChange() = 0;
208 virtual void NotifyFocus(bool focus
);
209 virtual void NotifyParent(SCNotification scn
) = 0;
210 virtual void NotifyStyleNeeded(int endStyleNeeded
);
211 void NotifyChar(char ch
);
212 void NotifySavePoint(bool isSavePoint
);
213 void NotifyModifyAttempt();
214 virtual void NotifyDoubleClick(Point pt
, bool shift
);
215 void NotifyUpdateUI();
216 bool NotifyMarginClick(Point pt
, bool shift
, bool ctrl
, bool alt
);
217 void NotifyNeedShown(int pos
, int len
);
219 void NotifyModifyAttempt(Document
*document
, void *userData
);
220 void NotifySavePoint(Document
*document
, void *userData
, bool atSavePoint
);
221 void NotifyModified(Document
*document
, DocModification mh
, void *userData
);
222 void NotifyDeleted(Document
*document
, void *userData
);
223 void NotifyStyleNeeded(Document
*doc
, void *userData
, int endPos
);
227 void NotifyMacroRecord(UINT iMessage
, WPARAM wParam
, LPARAM lParam
);
230 void PageMove(int direction
, bool extend
=false);
231 void ChangeCaseOfSelection(bool makeUpperCase
);
232 void LineTranspose();
233 virtual int KeyCommand(UINT iMessage
);
234 virtual int KeyDefault(int /* key */, int /*modifiers*/);
235 int KeyDown(int key
, bool shift
, bool ctrl
, bool alt
);
237 bool GetWhitespaceVisible();
238 void SetWhitespaceVisible(bool view
);
240 void Indent(bool forwards
);
242 long FindText(UINT iMessage
,WPARAM wParam
,LPARAM lParam
);
244 long SearchText(UINT iMessage
,WPARAM wParam
,LPARAM lParam
);
245 void GoToLine(int lineNo
);
247 char *CopyRange(int start
, int end
);
248 int SelectionRangeLength();
249 char *CopySelectionRange();
250 void CopySelectionIntoDrag();
251 void SetDragPosition(int newPos
);
252 virtual void StartDrag();
253 void DropAt(int position
, const char *value
, bool moving
, bool rectangular
);
254 // PositionInSelection returns 0 if position in selection, -1 if position before selection, and 1 if after.
255 // Before means either before any line of selection or before selection on its line, with a similar meaning to after
256 int PositionInSelection(int pos
);
257 bool PointInSelection(Point pt
);
258 bool PointInSelMargin(Point pt
);
259 virtual void ButtonDown(Point pt
, unsigned int curTime
, bool shift
, bool ctrl
, bool alt
);
260 void ButtonMove(Point pt
);
261 void ButtonUp(Point pt
, unsigned int curTime
, bool ctrl
);
264 virtual void SetTicking(bool on
) = 0;
265 virtual void SetMouseCapture(bool on
) = 0;
266 virtual bool HaveMouseCapture() = 0;
268 void CheckForChangeOutsidePaint(Range r
);
269 int BraceMatch(int position
, int maxReStyle
);
270 void SetBraceHighlight(Position pos0
, Position pos1
, int matchStyle
);
272 void SetDocPointer(Document
*document
);
274 void Expand(int &line
, bool doExpand
);
275 void ToggleContraction(int line
);
276 void EnsureLineVisible(int line
);
278 virtual LRESULT
DefWndProc(UINT iMessage
, WPARAM wParam
, LPARAM lParam
) = 0;
281 // Public so scintilla_send_message can use it
282 virtual LRESULT
WndProc(UINT iMessage
, WPARAM wParam
, LPARAM lParam
);
283 // Public so scintilla_set_id can use it