26 #include <gui/control.h>
27 #include <gui/bitmap.h>
29 #include <util/looper.h>
30 #include <util/message.h>
55 typedef vector<Line> buffer_type;
92 Fold( uint32 s, uint32 e ) {
107 mutable list<Fold> cFoldedSections;
110 uint _TranslateBufferIndex( uint32 nLineIndex )
const;
111 uint _TranslateLineNumber( uint32 nBufferIndex )
const;
112 void _FoldSection( uint32 nStart, uint32 nEnd );
113 void _UnfoldSection( uint32 nStart );
114 uint _LineIsFolded( uint32 nBufferIndex );
115 void _AdjustFoldedSections( uint nStart,
int nLen );
117 os::Control* control;
128 void UpdateBackBuffer();
143 float GetW(uint x, uint y)
const;
144 uint GetChar(
float x, uint line)
const;
150 void UpdateScrollbars();
151 void UpdateWidth(uint);
152 void UpdateAllWidths();
153 void InvalidateLines(
int,
int);
155 void SplitLine(vector<os::String>&,
const os::String&,
const char splitter=
'\n');
160 void Reformat(uint first, uint last);
162 void IndentSelection(
bool unindent);
167 void AddUndoNode(uint mode,
const os::String &str, uint x, uint y);
175 os::Menu* m_pcContextMenu;
176 os::Color32_s sHighlight;
177 os::Color32_s m_sLineNumberFg;
178 os::Color32_s m_sLineNumberBg;
179 os::Color32_s m_sLineBackColor;
186 void SetText(
const os::String &);
188 void GetText(os::String*, uint startx, uint starty, uint endx, uint endy)
const;
189 void GetText(os::String *str,
const os::IPoint &p0,
const os::IPoint &p1)
const{
190 GetText(str, p0.x, p0.y, p1.x, p1.y);
192 void InsertText(
const os::String &, uint x, uint y,
bool addUndo=
true);
193 void InsertText(
const os::String &str,
const os::IPoint &p){
194 InsertText(str, p.x, p.y);
196 void RemoveText(uint startx, uint starty, uint startx, uint starty,
bool addUndo=
true);
197 void RemoveText(
const os::IPoint &p0,
const os::IPoint &p1){
198 RemoveText(p0.x, p0.y, p1.x, p1.y);
200 const os::String& GetLine(uint y)
const {
return buffer[y].text; }
201 void SetLine(
const os::String &, uint y,
bool addUndo=
true);
202 uint GetLineCount()
const{
return buffer.size()-1; }
205 Format* GetFormat()
const{
return format; }
207 void SetTabSize(uint);
208 uint GetTabSize()
const{
return tabSize; }
209 void SetUseTab(
bool b){ useTab=b; }
210 bool GetUseTab(){
return useTab; }
212 void SetCursor(uint x, uint y,
bool select=
false);
213 void SetCursor(
const os::IPoint &p,
bool select=
false){
214 SetCursor(p.x, p.y, select);
216 os::IPoint GetCursor()
const;
219 void MoveLeft(
bool select=
false);
220 void MoveRight(
bool select=
false);
221 void MoveUp(
bool select=
false);
222 void MoveDown(
bool select=
false);
223 void MoveTop(
bool select=
false);
224 void MoveBottom(
bool select=
false);
225 void MovePageUp(
bool select=
false);
226 void MovePageDown(
bool select=
false);
227 void MoveLineStart(
bool select=
false);
228 void MoveLineEnd(
bool select=
false);
229 void MoveWordLeft(
bool select=
false);
230 void MoveWordRight(
bool select=
false);
237 void ScrollPageDown();
239 void SetSelectionStart(uint x, uint y);
240 void SetSelectionStart(
const os::IPoint &p){
241 SetSelectionStart(p.x, p.y);
243 void SetSelectionEnd(uint x, uint y);
244 void SetSelectionEnd(
const os::IPoint &p){
245 SetSelectionEnd(p.x, p.y);
247 void SetSelection(
const os::IPoint &p0,
const os::IPoint &p1){
248 SetSelectionStart(p0.x, p0.y);
249 SetSelectionEnd(p1.x, p1.y);
252 SetSelectionStart(0,0);
253 SetSelectionEnd(buffer.back().text.size(), buffer.size());
255 void ClearSelection();
262 void SetEnable(
bool b);
263 bool GetEnable(){
return enabled; }
264 void SetReadOnly(
bool);
265 bool GetReadOnly() {
return readOnly; }
267 void SetShowLineNumbers(
bool bShowLineNumbers );
268 bool GetShowLineNumbers( ) {
return ( m_nMargin != 0 ); }
273 void SetEventMask( uint32 nMask ) { eventMask = nMask; }
274 uint32 GetEventMask() {
return eventMask; }
276 void SetMaxUndoSize(
int i);
277 int GetMaxUndoSize();
280 bool UndoAvailable();
281 bool RedoAvailable();
284 virtual void Paint(
const os::Rect&);
285 virtual void FrameSized(
const os::Point &);
286 virtual void Activated(
bool);
287 virtual void KeyDown(
const char *,
const char *, uint32);
288 virtual void FontChanged(os::Font *);
289 virtual void MouseDown(
const os::Point &, uint32);
290 virtual void MouseUp(
const os::Point &, uint32, os::Message*);
291 virtual void MouseMove(
const os::Point &,
int, uint32, os::Message*);
292 virtual void WheelMoved(
const os::Point&);
294 void FoldSection( uint nFirst, uint nLast );
296 void SetContextMenu( os::Menu* );
297 os::Menu* GetContextMenu()
299 return m_pcContextMenu;
302 void SetHighlightColor(os::Color32_s sHigh)
307 os::Color32_s GetHighlightColor()
312 void SetLineNumberBgColor(os::Color32_s sColor)
314 m_sLineNumberBg = sColor;
317 os::Color32_s GetLineNumberBgColor()
319 return m_sLineNumberBg;
322 void SetLineNumberFgColor(os::Color32_s sColor)
324 m_sLineNumberFg = sColor;
327 os::Color32_s GetLineNumberFgColor()
329 return m_sLineNumberFg;
332 void SetLineBackColor(os::Color32_s sColor)
334 m_sLineBackColor = sColor;
337 os::Color32_s GetLineBackColor()
339 return m_sLineBackColor;