Commit b1b4cd8b authored by Vysheng's avatar Vysheng

interface: added auto-completion for modifiers (only [offline] for now)

parent ef8de029
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#include "mtproto-common.h" #include "mtproto-common.h"
#define ALLOW_MULT 1 //#define ALLOW_MULT 1
char *default_prompt = "> "; char *default_prompt = "> ";
int unread_messages; int unread_messages;
...@@ -247,6 +247,11 @@ void update_prompt (void) { ...@@ -247,6 +247,11 @@ void update_prompt (void) {
print_end (); print_end ();
} }
char *modifiers[] = {
"[offline]",
0
};
char *commands[] = { char *commands[] = {
"help", "help",
"msg", "msg",
...@@ -339,6 +344,8 @@ int commands_flags[] = { ...@@ -339,6 +344,8 @@ int commands_flags[] = {
07, 07,
}; };
int get_complete_mode (void) { int get_complete_mode (void) {
line_ptr = rl_line_buffer; line_ptr = rl_line_buffer;
int l = 0; int l = 0;
...@@ -348,6 +355,9 @@ int get_complete_mode (void) { ...@@ -348,6 +355,9 @@ int get_complete_mode (void) {
r = next_token (&l); r = next_token (&l);
if (!r) { return 0; } if (!r) { return 0; }
} }
if (*r == '[' && !r[l]) {
return 6;
}
if (!*line_ptr) { return 0; } if (!*line_ptr) { return 0; }
char **command = commands; char **command = commands;
...@@ -485,6 +495,10 @@ char *command_generator (const char *text, int state) { ...@@ -485,6 +495,10 @@ char *command_generator (const char *text, int state) {
index = complete_encr_chat_list (index, text, len, &R); index = complete_encr_chat_list (index, text, len, &R);
if (c) { rl_line_buffer[rl_point] = c; } if (c) { rl_line_buffer[rl_point] = c; }
return R; return R;
case 6:
index = complete_string_list (modifiers, index, text, len, &R);
if (c) { rl_line_buffer[rl_point] = c; }
return R;
default: default:
if (c) { rl_line_buffer[rl_point] = c; } if (c) { rl_line_buffer[rl_point] = c; }
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment