#ifndef READLINE_H
#define READLINE_H
#include "cutils.h"
typedef struct ReadlineState ReadlineState;
typedef void ReadLineFunc(void *opaque, const char *str);
typedef int ReadLineGetColor(int *plen, const char *buf, int pos, int buf_len);
struct ReadlineState {
int term_cmd_buf_index;
int term_cmd_buf_len;
uint32_t utf8_val;
uint8_t term_cmd_updated;
uint8_t utf8_state;
uint8_t term_esc_state;
int term_esc_param;
int term_esc_param1;
int term_esc_param2;
int term_cursor_x;
int term_cursor_pos;
int term_hist_entry;
int term_history_size;
uint8_t term_is_password;
const char *term_prompt;
int term_width;
int term_cmd_buf_size;
int term_kill_buf_len;
uint8_t *term_cmd_buf;
uint8_t *term_kill_buf;
int term_history_buf_size;
char *term_history;
ReadLineGetColor *get_color;
};
#define COLOR_NONE 0
#define COLOR_BLACK 1
#define COLOR_RED 2
#define COLOR_GREEN 3
#define COLOR_YELLOW 4
#define COLOR_BLUE 5
#define COLOR_MAGENTA 6
#define COLOR_CYAN 7
#define COLOR_WHITE 8
#define COLOR_GRAY 9
#define COLOR_BRIGHT_RED 10
#define COLOR_BRIGHT_GREEN 11
#define COLOR_BRIGHT_YELLOW 12
#define COLOR_BRIGHT_BLUE 13
#define COLOR_BRIGHT_MAGENTA 14
#define COLOR_BRIGHT_CYAN 15
#define COLOR_BRIGHT_WHITE 16
extern const char *term_colors[17];
void add_completion(const char *str);
#define READLINE_RET_EXIT (-1)
#define READLINE_RET_NOT_HANDLED 0
#define READLINE_RET_HANDLED 1
#define READLINE_RET_ACCEPTED 2
int readline_handle_byte(ReadlineState *s, int c);
void readline_start(ReadlineState *s, const char *prompt, int is_password);
void readline_find_completion(const char *cmdline);
void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
void term_flush(void);
#endif