Provide editor support terminal functionality. More...
#include <senf/Utils/Termlib/Editor.hh>
Public Types | |
typedef KeyParser::keycode_t | keycode_t |
Public Member Functions | |
BaseEditor (AbstractTerminal &terminal) | |
void | newline () |
Move to beginning of a new, empty line. More... | |
void | toColumn (unsigned c) |
Move cursor to column c . More... | |
void | put (char ch) |
Write ch at current column. More... | |
void | put (std::string const &text) |
Write text starting at current column. More... | |
void | clearLine () |
Clear current line and move cursor to first column. More... | |
void | setBold () |
Set bold char display. More... | |
void | setNormal () |
Set normal char display. More... | |
void | maybeClrScr () |
Clear screen if possible. More... | |
void | toLine (unsigned l) |
Move to relative display line l. More... | |
void | reset () |
Reset display area to single line. More... | |
unsigned | currentColumn () const |
Return number of current column. More... | |
unsigned | currentLine () const |
Return number of current relative line. More... | |
unsigned | width () const |
Return current screen width. More... | |
unsigned | height () const |
Return current screen height. More... | |
Public Member Functions inherited from senf::term::AbstractTerminal::Callbacks | |
virtual | ~Callbacks () |
Static Public Attributes | |
static unsigned const | DEFAULT_KEY_TIMEOUT_MS = 500u |
Protected Member Functions | |
virtual bool | cb_init () |
Called when terminal is initialized. More... | |
virtual void | cb_windowSizeChanged () |
Called whenever the terminal window size changes. More... | |
virtual void | v_keyReceived (keycode_t key)=0 |
Called whenever a key is received. More... | |
Provide editor support terminal functionality.
This base class utilizes an arbitrary AbstractTerminal and provides terminfo based terminal navigation and key parsing.
All navigation is relative to the current line. The display area can then be extended downwards up to a maximum of height() lines. Resetting this extended display area will return to a one line area containing only the top line.
All navigation is restricted to a width() x height() area. The last column may not be written to since auto-margin terminals will move the cursor to the next line when writing to that column.
This base class calls v_keyReceived() which must be defined in a derived class whenever a key is fully parsed.
|
explicit |
|
protectedvirtual |
Called when terminal is initialized.
Implements senf::term::AbstractTerminal::Callbacks.
|
protectedvirtual |
Called whenever the terminal window size changes.
Implements senf::term::AbstractTerminal::Callbacks.
void senf::term::BaseEditor::clearLine | ( | ) |
unsigned senf::term::BaseEditor::currentColumn | ( | ) | const |
unsigned senf::term::BaseEditor::currentLine | ( | ) | const |
unsigned senf::term::BaseEditor::height | ( | ) | const |
void senf::term::BaseEditor::maybeClrScr | ( | ) |
void senf::term::BaseEditor::newline | ( | ) |
void senf::term::BaseEditor::put | ( | char | ch | ) |
void senf::term::BaseEditor::put | ( | std::string const & | text | ) |
void senf::term::BaseEditor::reset | ( | ) |
void senf::term::BaseEditor::setBold | ( | ) |
void senf::term::BaseEditor::setNormal | ( | ) |
void senf::term::BaseEditor::toColumn | ( | unsigned | c | ) |
void senf::term::BaseEditor::toLine | ( | unsigned | l | ) |
|
protectedpure virtual |
Called whenever a key is received.
unsigned senf::term::BaseEditor::width | ( | ) | const |
|
static |