2009-03-05 23:01:23 +00:00
|
|
|
#ifndef READLINE_H
|
|
|
|
#define READLINE_H
|
|
|
|
|
2009-03-05 23:01:37 +00:00
|
|
|
#define READLINE_CMD_BUF_SIZE 4095
|
|
|
|
#define READLINE_MAX_CMDS 64
|
|
|
|
#define READLINE_MAX_COMPLETIONS 256
|
|
|
|
|
2014-01-25 17:18:23 +00:00
|
|
|
typedef void GCC_FMT_ATTR(2, 3) ReadLinePrintfFunc(void *opaque,
|
|
|
|
const char *fmt, ...);
|
2013-11-14 10:54:14 +00:00
|
|
|
typedef void ReadLineFlushFunc(void *opaque);
|
|
|
|
typedef void ReadLineFunc(void *opaque, const char *str,
|
|
|
|
void *readline_opaque);
|
|
|
|
typedef void ReadLineCompletionFunc(void *opaque,
|
2013-08-27 12:38:16 +00:00
|
|
|
const char *cmdline);
|
2009-03-05 23:01:37 +00:00
|
|
|
|
|
|
|
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;
|
2009-03-05 23:01:23 +00:00
|
|
|
|
2009-03-05 23:01:37 +00:00
|
|
|
char *history[READLINE_MAX_CMDS];
|
|
|
|
int hist_entry;
|
2009-03-05 23:01:23 +00:00
|
|
|
|
2009-03-05 23:01:37 +00:00
|
|
|
ReadLineCompletionFunc *completion_finder;
|
|
|
|
char *completions[READLINE_MAX_COMPLETIONS];
|
|
|
|
int nb_completions;
|
|
|
|
int completion_index;
|
2009-03-05 23:01:23 +00:00
|
|
|
|
2009-03-05 23:01:37 +00:00
|
|
|
ReadLineFunc *readline_func;
|
|
|
|
void *readline_opaque;
|
|
|
|
int read_password;
|
|
|
|
char prompt[256];
|
2013-11-14 10:54:14 +00:00
|
|
|
|
|
|
|
ReadLinePrintfFunc *printf_func;
|
|
|
|
ReadLineFlushFunc *flush_func;
|
|
|
|
void *opaque;
|
2009-03-05 23:01:37 +00:00
|
|
|
} ReadLineState;
|
2009-03-05 23:01:23 +00:00
|
|
|
|
2009-03-05 23:01:37 +00:00
|
|
|
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,
|
2013-11-14 10:54:14 +00:00
|
|
|
ReadLineFunc *readline_func, void *readline_opaque);
|
2009-03-05 23:01:47 +00:00
|
|
|
void readline_restart(ReadLineState *rs);
|
2009-03-05 23:01:37 +00:00
|
|
|
void readline_show_prompt(ReadLineState *rs);
|
|
|
|
|
2013-11-14 10:54:14 +00:00
|
|
|
ReadLineState *readline_init(ReadLinePrintfFunc *printf_func,
|
|
|
|
ReadLineFlushFunc *flush_func,
|
|
|
|
void *opaque,
|
2009-03-05 23:01:37 +00:00
|
|
|
ReadLineCompletionFunc *completion_finder);
|
2018-01-04 16:05:15 +00:00
|
|
|
void readline_free(ReadLineState *rs);
|
2009-03-05 23:01:23 +00:00
|
|
|
|
2016-06-29 13:29:06 +00:00
|
|
|
#endif /* READLINE_H */
|