X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FTermlib%2FEditor.hh;h=d2d091c8bbf594bd24ab434b51b7d244edcda249;hb=0461eef93912cb9d454d726b4a7b4ccf50ed31bd;hp=e5cb475cdc75745ea4358adc7144b74bc265fa25;hpb=27d5a4aaebd8abb6c6bb842af3c170063b206f0f;p=senf.git diff --git a/Utils/Termlib/Editor.hh b/Utils/Termlib/Editor.hh index e5cb475..d2d091c 100644 --- a/Utils/Termlib/Editor.hh +++ b/Utils/Termlib/Editor.hh @@ -28,6 +28,8 @@ // Custom includes #include +#include +#include #include #include #include "AbstractTerminal.hh" @@ -52,13 +54,19 @@ namespace term { void newline(); ///< Move to beginning of a new, empty line void toColumn(unsigned c); ///< Move cursor to column \p c void put(char ch); ///< Write \p ch at current column - void put(std::string const & text); + void put(std::string const & text); ///< Write \a text starting at current column void clearLine(); ///< Clear current line and move cursor to first column void setBold(); ///< Set bold char display void setNormal(); ///< Set normal char display + void maybeClrScr(); ///< Clear screen if possible + + void toLine(unsigned l); ///< Move to relative display line \a l + void reset(); ///< Reset display area to single line unsigned currentColumn() const; ///< Return number of current column - unsigned width(); + unsigned currentLine() const; ///< Return number of current relative line + unsigned width(); ///< Return current screen width + unsigned height(); ///< Return current screen height protected: virtual bool cb_init(); @@ -82,6 +90,8 @@ namespace term { ClockService::clock_type keyTimeout_; scheduler::TimerEvent timer_; unsigned column_; + unsigned displayHeight_; + unsigned line_; }; class LineEditor @@ -94,6 +104,8 @@ namespace term { typedef boost::function KeyBinding; typedef boost::function AcceptCallback; + static unsigned const MAX_HISTORY_SIZE = 1024u; + /////////////////////////////////////////////////////////////////////////// LineEditor(AbstractTerminal & terminal, AcceptCallback cb); @@ -120,6 +132,16 @@ namespace term { void insert(char ch); void insert(std::string const & text); + // History + void pushHistory(std::string const & text); + void prevHistory(); + void nextHistory(); + + // Aux Display + void auxDisplay(int line, std::string const & text); + unsigned maxAuxDisplayHeight(); + void clearAuxDisplay(); + // Get information std::string const & text(); unsigned point(); @@ -136,6 +158,7 @@ namespace term { virtual void v_keyReceived(keycode_t key); typedef std::map KeyMap; + typedef std::vector History; bool enabled_; bool redisplayNeeded_; @@ -148,6 +171,8 @@ namespace term { keycode_t lastKey_; AcceptCallback callback_; KeyMap bindings_; + History history_; + unsigned historyPoint_; }; namespace bindings { @@ -162,6 +187,12 @@ namespace bindings { void endOfLine (LineEditor & editor); void deleteToEndOfLine (LineEditor & editor); void restartEdit (LineEditor & editor); + void prevHistory (LineEditor & editor); + void nextHistory (LineEditor & editor); + void clearScreen (LineEditor & editor); + + typedef boost::function &)> Completer; + void complete (LineEditor & editor, Completer completer); }