Commit 6d2c6ad5 authored by vysheng's avatar vysheng

fixed interface. Small changes.

parent feac5066
...@@ -224,17 +224,13 @@ int complete_string_list (char **list, int index, const char *text, int len, cha ...@@ -224,17 +224,13 @@ int complete_string_list (char **list, int index, const char *text, int len, cha
char *command_generator (const char *text, int state) { char *command_generator (const char *text, int state) {
static int len, index, mode; static int len, index, mode;
char c = 0;
if (!state) { if (!state) {
len = strlen (text); len = strlen (text);
index = -1; index = -1;
rl_line_buffer[rl_point] = '\0'; /* the effect should be such c = rl_line_buffer[rl_point];
* that the cursor position rl_line_buffer[rl_point] = 0;
* is at the end of line for
* the auto completion regex
* above (note the $ at end)
*/
mode = get_complete_mode (); mode = get_complete_mode ();
} else { } else {
if (index == -1) { return 0; } if (index == -1) { return 0; }
...@@ -246,19 +242,26 @@ char *command_generator (const char *text, int state) { ...@@ -246,19 +242,26 @@ char *command_generator (const char *text, int state) {
switch (mode & 7) { switch (mode & 7) {
case 0: case 0:
index = complete_string_list (commands, index, text, len, &R); index = complete_string_list (commands, index, text, len, &R);
if (c) { rl_line_buffer[rl_point] = c; }
return R; return R;
case 1: case 1:
index = complete_user_list (index, text, len, &R); index = complete_user_list (index, text, len, &R);
if (c) { rl_line_buffer[rl_point] = c; }
return R; return R;
case 2: case 2:
index = complete_user_chat_list (index, text, len, &R); index = complete_user_chat_list (index, text, len, &R);
if (c) { rl_line_buffer[rl_point] = c; }
return R; return R;
case 3: case 3:
return rl_filename_completion_function(text,state); R = rl_filename_completion_function(text,state);
if (c) { rl_line_buffer[rl_point] = c; }
return R;
case 4: case 4:
index = complete_chat_list (index, text, len, &R); index = complete_chat_list (index, text, len, &R);
if (c) { rl_line_buffer[rl_point] = c; }
return R; return R;
default: default:
if (c) { rl_line_buffer[rl_point] = c; }
return 0; return 0;
} }
} }
...@@ -268,6 +271,7 @@ char **complete_text (char *text, int start UU, int end UU) { ...@@ -268,6 +271,7 @@ char **complete_text (char *text, int start UU, int end UU) {
} }
void interpreter (char *line UU) { void interpreter (char *line UU) {
if (!line) { return; }
if (line && *line) { if (line && *line) {
add_history (line); add_history (line);
} }
......
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