When using TermHandler, you must link against libreadline.so
and libncurses.so
, i.e., add -lreadline -lncurses
to your linker command line.
To use a TermHandler, you will typically
TermHandler
object, writing to it instead of to cout
.
on_eof
to register a handler to be invoked when the input stream ends or the user types the built-in quit
or exit
commands. (The default action is to terminate the event loop.)
add_command
to register handlers for commands that you wish to accept.
Public Methods | |
TermHandler (IOEventLoop &loop, string prompt=">") | |
Constructor. | |
~TermHandler () | |
Destructor. | |
void | on_eof (Callback< void > quit_cb) |
Registers a Callback to be invoked when the input stream ends (e.g., the user types Control-D). | |
template<class CallbackType> void | add_command (string name, unsigned int min_args, unsigned int max_args, CallbackType cb) |
Adds a binding for a command. | |
Static Public Attributes | |
const unsigned int | text_arg = 0x10000 |
const unsigned int | var_args = UINT_MAX |
A flag which may be passed to add_command (as the max_args argument) specifying that any number of arguments greater than or equal to min_args is valid. |
|
Constructor.
|
|
Destructor.
|
|
Adds a binding for a command.
void handler(void);
The first three arguments are passed as arg1, arg2, and arg3; or all arguments are passed as args[0]. If the Callback returns a "bad" Status, it is displayed as an error message on the terminal. |
|
Registers a Callback to be invoked when the input stream ends (e.g., the user types Control-D).
|
|
|
|
A flag which may be passed to add_command (as the max_args argument) specifying that any number of arguments greater than or equal to min_args is valid.
|