unsigned currentColumn() const; ///< Return number of current column
unsigned currentLine() const; ///< Return number of current relative line
- unsigned width(); ///< Return current screen width
- unsigned height(); ///< Return current screen height
+ unsigned width() const; ///< Return current screen width
+ unsigned height() const; ///< Return current screen height
protected:
virtual bool cb_init(); ///< Called when terminal is initialized
bindings::complete():
\code
- void myCompleter(senf::term::LineEditor & editor, unsigned b, unsigned e,
- std::vector<std::string> & completions)
+ void myCompleter(senf::term::LineEditor & editor, unsigned & b, unsigned & e,
+ std::string & prefix, std::vector<std::string> & completions)
{
// Get text to complete
std::string text (editor.text().substr(b, e-b));
When \c myCompleter is a class member, use senf::membind() and pass this instead of \c
&myCompleter to \c boost::bind() and thus to senf::term::bindings::complete.
+
+ The completion protocol is as follows: When completion is desired, the completer function is
+ called. \a b and \a e are set to 0 and <tt>editor.point()</tt> respectively. \a prefix and
+ \a completions are empty.
+
+ \li the completer may restrict the to-be-completed string to any subrange by changing \a b
+ and \a e accordingly.
+ \li If there is an initial substring which applies to \e all completions but should not be
+ listed in the list of completions, assign this value to \a prefix.
+ \li Add all possible completions to the \a completions vector not including the \a prefix.
+ \li The completion result is taken from the size of the \a completions vector \e only: If
+ this vector is empty, completion failed (even if \a prefix is set), a single entry in \a
+ completions (even if it is the empty string) signals a unique completion.
\section editor_auxarea The aux display area
///////////////////////////////////////////////////////////////////////////
- void prompt(std::string const & text); ///< Set prompt string
- void set(std::string const & text, unsigned pos = 0u);
- ///< Set edit buffer contents
- /**< The edit buffer contents will be replaced by \a
- text. The cursor will be placed at position \a pos
- within this text. */
-
///\name Overall edit control
///\{
void clear(); ///< Clear editor buffer
void redisplay(); ///< Mark the editor buffer for redisplay
void forceRedisplay(); ///< Redisplay the editor buffer \e now
+ void prompt(std::string const & text); ///< Set prompt string
///\}
void deleteChar(unsigned n=1); ///< Delete \a n characters at point
void insert(char ch); ///< Insert \a ch at point
void insert(std::string const & text); ///< Insert \a text at point
+ void set(std::string const & text, unsigned pos = 0u);
+ ///< Set edit buffer contents
+ /**< The edit buffer contents will be replaced by \a
+ text. The cursor will be placed at position \a pos
+ within this text. */
///\}
///\name History
///\{
- void pushHistory(std::string const & text); ///< Add string \a text to history
+ void pushHistory(std::string const & text, bool accept = false);
+ ///< Add string \a text to history
void prevHistory(); ///< Switch to previous history entry
void nextHistory(); ///< Switch to next history entry
///\name Aux Display
///\{
- void auxDisplay(int line, std::string const & text);
+ void auxDisplay(unsigned line, std::string const & text);
///< Display \a text on aux display line \a lilne
unsigned maxAuxDisplayHeight(); ///< Get maximum height of the aux display area
void clearAuxDisplay(); ///< Clear the aux display area
void forwardChar (LineEditor & editor); ///< Move one char forward
void backwardChar (LineEditor & editor); ///< Move one char backwards
void accept (LineEditor & editor); ///< Accept input line
+ void acceptWithRepeat (LineEditor & editor); ///< Accept, possibly repeat last history entry
void backwardDeleteChar (LineEditor & editor); ///< Delete char before cursor
void deleteChar (LineEditor & editor); ///< Delete char at cursor
void beginningOfLine (LineEditor & editor); ///< Move to beginning of line
void nextHistory (LineEditor & editor); ///< Move to next history entry
void clearScreen (LineEditor & editor); ///< Clear screen and redisplay editor
- typedef boost::function<void (LineEditor &, unsigned b, unsigned e, std::vector<std::string> &)> Completer;
+ typedef boost::function<void (LineEditor &, unsigned & b, unsigned & e,
+ std::string & prefix, std::vector<std::string> &)> Completer;
void complete (LineEditor & editor, Completer completer);
///< Complete text at cursor
/**< This function calls \a completer to find the list of
possible completions for the text between \a b and \a e
(as passed to the completer). The completer must add
- all possible completions to the completions vector.
+ all possible completions to the \a completions vector.
\see \ref editor_complete */