diff options
Diffstat (limited to 'util/readline.c')
-rw-r--r-- | util/readline.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/util/readline.c b/util/readline.c index 8baec55509..cc1302ac0a 100644 --- a/util/readline.c +++ b/util/readline.c @@ -263,6 +263,12 @@ static void readline_hist_add(ReadLineState *rs, const char *cmdline) void readline_add_completion(ReadLineState *rs, const char *str) { if (rs->nb_completions < READLINE_MAX_COMPLETIONS) { + int i; + for (i = 0; i < rs->nb_completions; i++) { + if (!strcmp(rs->completions[i], str)) { + return; + } + } rs->completions[rs->nb_completions++] = g_strdup(str); } } @@ -345,6 +351,12 @@ static void readline_completion(ReadLineState *rs) } } +static void readline_clear_screen(ReadLineState *rs) +{ + rs->printf_func(rs->opaque, "\033[2J\033[1;1H"); + readline_show_prompt(rs); +} + /* return true if command handled */ void readline_handle_byte(ReadLineState *rs, int ch) { @@ -363,6 +375,9 @@ void readline_handle_byte(ReadLineState *rs, int ch) case 9: readline_completion(rs); break; + case 12: + readline_clear_screen(rs); + break; case 10: case 13: rs->cmd_buf[rs->cmd_buf_size] = '\0'; |