When using term_handler, you must link against libreadline.so and libncurses.so, i.e., add -lreadline -lncurses to your linker command line.
To use a term_handler, you will typically
term_handler 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 | |
| term_handler (io_event_loop &loop, string prompt=">") | |
| Constructor. | |
| ~term_handler () | |
| 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.
|