Provide editor support terminal functionality. More...

#include <senf/Utils/Termlib/Editor.hh>

Inheritance diagram for senf::term::BaseEditor:

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...
 

Detailed Description

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.

Definition at line 51 of file Editor.hh.

Member Typedef Documentation

◆ keycode_t

Constructor & Destructor Documentation

◆ BaseEditor()

senf::term::BaseEditor::BaseEditor ( AbstractTerminal terminal)
explicit

Definition at line 28 of file Editor.cc.

Member Function Documentation

◆ cb_init()

bool senf::term::BaseEditor::cb_init ( )
protectedvirtual

Called when terminal is initialized.

Implements senf::term::AbstractTerminal::Callbacks.

Definition at line 190 of file Editor.cc.

◆ cb_windowSizeChanged()

void senf::term::BaseEditor::cb_windowSizeChanged ( )
protectedvirtual

Called whenever the terminal window size changes.

Implements senf::term::AbstractTerminal::Callbacks.

Definition at line 218 of file Editor.cc.

◆ clearLine()

void senf::term::BaseEditor::clearLine ( )

Clear current line and move cursor to first column.

Definition at line 98 of file Editor.cc.

◆ currentColumn()

unsigned senf::term::BaseEditor::currentColumn ( ) const

Return number of current column.

Definition at line 178 of file Editor.cc.

◆ currentLine()

unsigned senf::term::BaseEditor::currentLine ( ) const

Return number of current relative line.

Definition at line 184 of file Editor.cc.

◆ height()

unsigned senf::term::BaseEditor::height ( ) const

Return current screen height.

Definition at line 252 of file Editor.cc.

◆ maybeClrScr()

void senf::term::BaseEditor::maybeClrScr ( )

Clear screen if possible.

Definition at line 119 of file Editor.cc.

◆ newline()

void senf::term::BaseEditor::newline ( )

Move to beginning of a new, empty line.

Definition at line 38 of file Editor.cc.

◆ put() [1/2]

void senf::term::BaseEditor::put ( char  ch)

Write ch at current column.

Definition at line 78 of file Editor.cc.

◆ put() [2/2]

void senf::term::BaseEditor::put ( std::string const &  text)

Write text starting at current column.

Definition at line 86 of file Editor.cc.

◆ reset()

void senf::term::BaseEditor::reset ( )

Reset display area to single line.

Definition at line 168 of file Editor.cc.

◆ setBold()

void senf::term::BaseEditor::setBold ( )

Set bold char display.

Definition at line 105 of file Editor.cc.

◆ setNormal()

void senf::term::BaseEditor::setNormal ( )

Set normal char display.

Definition at line 112 of file Editor.cc.

◆ toColumn()

void senf::term::BaseEditor::toColumn ( unsigned  c)

Move cursor to column c.

Definition at line 46 of file Editor.cc.

◆ toLine()

void senf::term::BaseEditor::toLine ( unsigned  l)

Move to relative display line l.

Definition at line 125 of file Editor.cc.

◆ v_keyReceived()

virtual void senf::term::BaseEditor::v_keyReceived ( keycode_t  key)
protectedpure virtual

Called whenever a key is received.

◆ width()

unsigned senf::term::BaseEditor::width ( ) const

Return current screen width.

Definition at line 246 of file Editor.cc.

Member Data Documentation

◆ DEFAULT_KEY_TIMEOUT_MS

unsigned const senf::term::BaseEditor::DEFAULT_KEY_TIMEOUT_MS = 500u
static

Definition at line 57 of file Editor.hh.


The documentation for this class was generated from the following files: