diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-09-03 17:45:58 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-09-03 17:45:58 +0100 |
commit | 669cd52f685282289590200daed3fc89466e7206 (patch) | |
tree | 792c26273dd54dab61b5e94693e1895ff9c5440c /contrib/replxx/src/prompt.hxx | |
parent | 8a240656d8378ac20e4c4c3ae61d1a9c33488a20 (diff) | |
download | rspamd-669cd52f685282289590200daed3fc89466e7206.tar.gz rspamd-669cd52f685282289590200daed3fc89466e7206.zip |
[Rework] Replace linenoise with replxx
Source: https://github.com/AmokHuginnsson/replxx
Diffstat (limited to 'contrib/replxx/src/prompt.hxx')
-rw-r--r-- | contrib/replxx/src/prompt.hxx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/contrib/replxx/src/prompt.hxx b/contrib/replxx/src/prompt.hxx new file mode 100644 index 000000000..aabff0ab0 --- /dev/null +++ b/contrib/replxx/src/prompt.hxx @@ -0,0 +1,49 @@ +#ifndef REPLXX_PROMPT_HXX_INCLUDED +#define REPLXX_PROMPT_HXX_INCLUDED 1 + +#include <cstdlib> + +#include "unicodestring.hxx" +#include "io.hxx" + +namespace replxx { + +class Prompt { // a convenience struct for grouping prompt info +public: + UnicodeString _text; // our copy of the prompt text, edited + int _characterCount; // chars in _text + int _byteCount; // bytes in _text + int _extraLines; // extra lines (beyond 1) occupied by prompt + int _indentation; // column offset to end of prompt + int _lastLinePosition; // index into _text where last line begins + int _previousInputLen; // _characterCount of previous input line, for clearing + int _cursorRowOffset; // where the cursor is relative to the start of the prompt + int _previousLen; // help erasing +private: + int _screenColumns; // width of screen in columns [cache] + Terminal& _terminal; +public: + Prompt( Terminal& ); + void set_text( UnicodeString const& textPtr ); + void update_screen_columns( void ); + int screen_columns() const { + return ( _screenColumns ); + } + void write(); +}; + +extern UnicodeString previousSearchText; // remembered across invocations of replxx_input() + +// changing prompt for "(reverse-i-search)`text':" etc. +// +struct DynamicPrompt : public Prompt { + UnicodeString _searchText; // text we are searching for + int _direction; // current search _direction, 1=forward, -1=reverse + + DynamicPrompt( Terminal&, int initialDirection ); + void updateSearchPrompt(void); +}; + +} + +#endif |