class LineEdit : public TextCtrl
A widget used to edit a line of a document one at a time.
virtual void HighlightLine(int line, Vector<Highlight>& h, int pos)
This method can be overridden to add syntax highlighting to the LineEdit. It is called once for each line painted on the screen. line is the line index (first line is 0), h represents character cells in the line; client code should change this array to achieve the highlighting, pos is the index of character from the beginning of text. h initially contains one more space character than is the count of characters in the line; this additional character can be used to set the appearance of the rest of line after the last character. You also add more characters to the h. Default implementation is empty.
virtual void NewScrollPos()
Called when scrollbar gets new position. Default implementation is empty.
Size GetFontSize() const
Returns the size of font character cell (LineEdit expects monospace glyphs - the width of character is constant).
int GetGPos(int ln, int cl) const
Returns "graphical" position of ln line and cl column. This takes into account any tabulator characters in the line.
int GetMousePos(Point p) const
Get the the offset of character placed at p.
Point GetColumnLine(int pos) const
Returns the line and column for the character at pos accounting for any tabulators. Column is x member of resulting Point, line is y.
int GetColumnLinePos(Point pos) const
Returns the position for given column and line pos. Does account for tabulators.
Point GetIndexLine(int pos) const
Returns the line and index of character in the line for the given pos. Does not account for tabulators.
int GetIndexLinePos(Point pos) const
Returns the position for given column and line pos. Does not account for tabulators.
void SetRectSelection(int l, int h)
Sets rectangular selection.
void SetRectSelection(const Rect& rect)
Same as SetRectSelection(GetGPos(rect.top, rect.left), GetGPos(rect.bottom, rect.right));
Rect GetRectSelection() const
Returns rectangular selection (as "graphical").
bool GetRectSelection(const Rect& rect, int line, int& l, int &h)
Returns lower and upper limits l h of characters of line that are in rectangular selection rect. Returns false when line is not in selection.
Scrolls the text single line up.
Scrolls the text single line down.
Scrolls the text one page up.
Scrolls the text one page down.
Scrolls the text to the begin.
Scrolls the text to the end.
Rect GetLineScreenRect(int line) const
Gets the absolute screen rectangle position of line.
Scrolls the text to place the line with cursor is first in the view.
void TopCursor(int lines = 0)
Scrolls the text to place the line with cursor placed lines from the top.
Scrolls the text to place the line with cursor at the center of the view.
void MoveUpDown(int n, bool sel = false)
Moves the cursor n lines up (n is negative) or down. If sel is true, selects characters between starting and ending cursor position.
void MoveLeft(bool sel = false)
void MoveRight(bool sel = false)
void MoveUp(bool sel = false)
void MoveDown(bool sel = false)
void MovePageUp(bool sel = false)
void MovePageDown(bool sel = false)
void MoveHome(bool sel = false)
void MoveEnd(bool sel = false)
void MoveTextBegin(bool sel = false)
void MoveTextEnd(bool sel = false)
Moves the cursor in specified direction (Home/End are beginning/end of line). If sel is true, selects characters between starting and ending cursor position.
bool InsertChar(dword key, int count = 1, bool canoverwrite = false)
Inserts count characters key at cursor position. If canoverwrite is true, overwrite mode (as set by user pressing Insert key) can be used.
Deletes character at cursor position.
If character is not first in the text, deletes it and moves cursor one position back.
Deletes a line with cursor (if it is not the only line in the text).
Stores a line to clipboard and calls DeleteLine.
void PasteColumn(const WString& text)
Pastes lines of text into actual graphical column of text.
PasteColumn with clipboard text.
Sorts lines based on rectangular selection.
Point GetScrollPos() const
Returns the actual scroll position.
Returns the current view size in character cells.
void SetScrollPos(Point p)
Sets the scroll position of view, e.g. to the value obtained by GetScrollPos.
EditPos GetEditPos() const
Returns the edit position in the text to be restored later. Edit position comprises cursor and scrollbar positions.
void SetEditPos(const LineEdit::EditPos& pos)
Sets the edit position obtained by calling GetEditPos. If cursor is not in the view after restoring, view is scrolled so that it is by calling ScrollIntoCursor.
void SetEditPosSb(const LineEdit::EditPos& pos)
Sets the edit position obtained by calling GetEditPos. Unlike SetEditPos, no scrolls are performed to get cursor into the view.
Performs minimal scroll to get the cursor into the view. "Minimal" means that if cursor is "before" the view, view is scrolled to move cursor to the first line, if it is "after", it is moved to the last line.
Point GetCaretPoint() const
Returns the current caret position.
Sets the text empty.
void OverWriteMode(bool o = true)
bool IsOverWriteMode() const
In OverWriteMode mode, input characters replace the content instead of being inserted.
void RefreshChars(bool (*predicate)(int c))
Calls predicate for all characters in current view and when it returns true refreshes (schedules for repainting) character cell. It is useful for advanced code editors (e.g. refreshing color of braces in TheIDE editor).
LineEdit& TabSize(int n)
Sets the tabulator size.
int GetTabSize() const
Returns current tabulator size.
LineEdit& BorderColumn(int col, Color c = SColorFace())
Displays a border column of width col and color c.
int GetBorderColumn() const
Return border column position.
LineEdit& SetFont(Font f)
Sets the font. HighlightLine can replace this font, however, the size of character cell is determined by this font (note that CJK ideograms are two character cells wide). Font should be monospaced. Returns *this. Default font is Courier(16).
Font GetFont() const
Returns the font.
LineEdit& NoHorzScrollbar(bool b = true)
In this mode horizontal scrollbar is never shown. Default is off.
bool IsNoHorzScrollbar() const
Returns status of NoHrozScrollbar.
LineEdit& ShowTabs(bool st = true)
In this mode widget displays tabulators with faint graphics. Default is off.
bool IsShowTabs() const
Returns status of ShowTabs..
LineEdit& ShowSpaces(bool ss = true)
In this mode widget displays spaces with faint dots. Default is off.
bool IsShowSpaces() const
Returns status of ShowSpaces.
LineEdit& ShowLineEndings(bool sl = true)
In this mode widget displays line endings with faint dots. Default is off.
bool IsShowLineEndings() const
Returns status of ShowLineEndings.
LineEdit& WarnWhiteSpace(bool b = true)
In this mode widget shows whitespaces that seem to be misplaced, like tabs after spaces or if line ends with spaces. Default is off.
bool IsWantWhiteSpace() const
Returns status of WarnWhiteSpace.
LineEdit& WithCutLine(bool b)
In this mode widget calls CutLine when user presses Ctrl+Y or Ctrl+L. Default is on.
Switches WithCutLine off.
bool IsWithCutLine() const
Returns status of WithCutLine.
LineEdit& SetFilter(int (*f)(int c))
Sets the filter of characters processed. Filter function can alter characters before they are inserted into the text. If filter function returns zero, character is rejected.
struct Highlight : public Moveable<Highlight>
This structure defines syntax highlighting properties of single character cell.
bool operator==(const Highlight& h) const