diff options
author | aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-03-05 23:01:37 +0000 |
---|---|---|
committer | aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-03-05 23:01:37 +0000 |
commit | 4c36ba323582773a87e9d277b0ce8febcf2113fd (patch) | |
tree | 97a1cb91b1c14722266cbc5f5c9b6de8e7b0207c /readline.h | |
parent | bb806047e22f20b96fc4f2e1a8c93bfe16e552d7 (diff) |
monitor: Introduce ReadLineState (Jan Kiszka)
As another step towards decoupled monitor terminals encapsulate the
state of the readline processor in a separate data structure called
ReadLineState and adapt all interfaces appropriately. For now the
monitor continues to instantiate just a single readline state.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6714 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'readline.h')
-rw-r--r-- | readline.h | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/readline.h b/readline.h index c5c10d6e3f..fcf0f3344c 100644 --- a/readline.h +++ b/readline.h @@ -3,18 +3,52 @@ #include "qemu-common.h" +#define READLINE_CMD_BUF_SIZE 4095 +#define READLINE_MAX_CMDS 64 +#define READLINE_MAX_COMPLETIONS 256 + typedef void ReadLineFunc(Monitor *mon, const char *str, void *opaque); +typedef void ReadLineCompletionFunc(const char *cmdline); + +typedef struct ReadLineState { + char cmd_buf[READLINE_CMD_BUF_SIZE + 1]; + int cmd_buf_index; + int cmd_buf_size; + + char last_cmd_buf[READLINE_CMD_BUF_SIZE + 1]; + int last_cmd_buf_index; + int last_cmd_buf_size; + + int esc_state; + int esc_param; -void readline_add_completion(const char *str); -void readline_set_completion_index(int index); -void readline_find_completion(const char *cmdline); + char *history[READLINE_MAX_CMDS]; + int hist_entry; -const char *readline_get_history(unsigned int index); + ReadLineCompletionFunc *completion_finder; + char *completions[READLINE_MAX_COMPLETIONS]; + int nb_completions; + int completion_index; -void readline_handle_byte(int ch); + ReadLineFunc *readline_func; + void *readline_opaque; + int read_password; + char prompt[256]; + Monitor *mon; +} ReadLineState; -void readline_start(const char *prompt, int is_password, +void readline_add_completion(ReadLineState *rs, const char *str); +void readline_set_completion_index(ReadLineState *rs, int completion_index); + +const char *readline_get_history(ReadLineState *rs, unsigned int index); + +void readline_handle_byte(ReadLineState *rs, int ch); + +void readline_start(ReadLineState *rs, const char *prompt, int read_password, ReadLineFunc *readline_func, void *opaque); -void readline_show_prompt(void); +void readline_show_prompt(ReadLineState *rs); + +ReadLineState *readline_init(Monitor *mon, + ReadLineCompletionFunc *completion_finder); #endif /* !READLINE_H */ |