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

This commit is contained in:
Vysheng 2013-11-30 22:52:13 +04:00
parent ef8de029a5
commit b1b4cd8b21

View File

@ -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;