17 #ifndef HH_SENF_Utils_Termlib_Editor_ 18 #define HH_SENF_Utils_Termlib_Editor_ 1 64 void put(std::string
const & text);
75 unsigned width()
const;
89 virtual void cb_charReceived(
char c);
91 void keySequenceTimeout();
95 void write(std::string
const & s);
100 std::string inputBuffer_;
104 unsigned displayHeight_;
213 static unsigned const MAX_HISTORY_SIZE = 1024u;
233 void forceRedisplay();
234 void prompt(std::string
const & text);
241 void gotoChar(
unsigned n);
242 void scrollTo(
unsigned n);
250 void insert(
char ch);
251 void insert(std::string
const & text);
252 void set(std::string
const & text,
unsigned pos = 0u);
263 void pushHistory(std::string
const & text,
bool accept =
false);
273 void auxDisplay(
unsigned line, std::string
const & text);
275 unsigned maxAuxDisplayHeight();
276 void clearAuxDisplay();
283 std::string
const & text();
285 unsigned displayPos();
293 void defineKey(
keycode_t key, KeyBinding binding);
304 typedef std::map<keycode_t, KeyBinding> KeyMap;
305 typedef std::vector<std::string> History;
306 typedef std::vector<std::string> AuxDisplay;
309 bool redisplayNeeded_;
311 unsigned promptWidth_;
315 unsigned displayPos_;
317 AcceptCallback callback_;
320 unsigned historyPoint_;
321 AuxDisplay auxDisplay_;
343 typedef boost::function<void (
LineEditor &,
unsigned & b,
unsigned & e,
344 std::string & prefix, std::vector<std::string> &)>
Completer;
unsigned currentLine() const
Return number of current relative line.
config::time_type clock_type
Provide editor support terminal functionality.
void acceptWithRepeat(LineEditor &editor)
Accept, possibly repeat last history entry.
wchar_t keycode_t
Key code data type.
boost::function< void(LineEditor &, unsigned &b, unsigned &e, std::string &prefix, std::vector< std::string > &)> Completer
unsigned height() const
Return current screen height.
void selfInsertCommand(LineEditor &editor)
Insert key as literal character.
virtual void cb_windowSizeChanged()
Called whenever the terminal window size changes.
void nextHistory(LineEditor &editor)
Move to next history entry.
void clearLine()
Clear current line and move cursor to first column.
Parse key escape sequences.
void restartEdit(LineEditor &editor)
Clear edit buffer and restart edit.
void toLine(unsigned l)
Move to relative display line l.
void backwardChar(LineEditor &editor)
Move one char backwards.
static unsigned const DEFAULT_KEY_TIMEOUT_MS
BaseEditor(AbstractTerminal &terminal)
virtual void v_keyReceived(keycode_t key)=0
Called whenever a key is received.
void accept(LineEditor &editor)
Accept input line.
void complete(LineEditor &editor, Completer completer)
Complete text at cursor.
void deleteToEndOfLine(LineEditor &editor)
Delete from cursor to end of line.
AbstractTerminal callbacks.
void backwardDeleteChar(LineEditor &editor)
Delete char before cursor.
virtual bool cb_init()
Called when terminal is initialized.
void forwardChar(LineEditor &editor)
Move one char forward.
void put(char ch)
Write ch at current column.
boost::function< void(std::string const &)> AcceptCallback
Callback function type.
void prevHistory(LineEditor &editor)
Move to previous history entry.
void setNormal()
Set normal char display.
unsigned currentColumn() const
Return number of current column.
boost::function< void(LineEditor &)> KeyBinding
Type of a key binding function.
void beginningOfLine(LineEditor &editor)
Move to beginning of line.
Single line interactive text editor.
void newline()
Move to beginning of a new, empty line.
void clearScreen(LineEditor &editor)
Clear screen and redisplay editor.
void maybeClrScr()
Clear screen if possible.
void reset()
Reset display area to single line.
KeyParser::keycode_t keycode_t
void deleteChar(LineEditor &editor)
Delete char at cursor.
::phoenix::function< detail::clear > const clear
void setBold()
Set bold char display.
void toColumn(unsigned c)
Move cursor to column c.
unsigned width() const
Return current screen width.
Abstract terminal interface.
void endOfLine(LineEditor &editor)
Move to end of line.