From b1b4cd8b2199f184cd0538a352961bee87238d90 Mon Sep 17 00:00:00 2001 From: Vysheng Date: Sat, 30 Nov 2013 22:52:13 +0400 Subject: [PATCH] interface: added auto-completion for modifiers (only [offline] for now) --- interface.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/interface.c b/interface.c index 6460ba0..c8a1519 100644 --- a/interface.c +++ b/interface.c @@ -43,7 +43,7 @@ #include "mtproto-common.h" -#define ALLOW_MULT 1 +//#define ALLOW_MULT 1 char *default_prompt = "> "; int unread_messages; @@ -247,6 +247,11 @@ void update_prompt (void) { print_end (); } +char *modifiers[] = { + "[offline]", + 0 +}; + char *commands[] = { "help", "msg", @@ -339,6 +344,8 @@ int commands_flags[] = { 07, }; + + int get_complete_mode (void) { line_ptr = rl_line_buffer; int l = 0; @@ -348,6 +355,9 @@ int get_complete_mode (void) { r = next_token (&l); if (!r) { return 0; } } + if (*r == '[' && !r[l]) { + return 6; + } if (!*line_ptr) { return 0; } char **command = commands; @@ -485,6 +495,10 @@ char *command_generator (const char *text, int state) { index = complete_encr_chat_list (index, text, len, &R); if (c) { rl_line_buffer[rl_point] = c; } return R; + case 6: + index = complete_string_list (modifiers, index, text, len, &R); + if (c) { rl_line_buffer[rl_point] = c; } + return R; default: if (c) { rl_line_buffer[rl_point] = c; } return 0;