Allow previous autocompletion with shift tab
This commit is contained in:
@@ -96,6 +96,7 @@ static void _inp_rl_addfuncs(void);
|
||||
static int _inp_rl_getc(FILE *stream);
|
||||
static void _inp_rl_linehandler(char *line);
|
||||
static int _inp_rl_tab_handler(int count, int key);
|
||||
static int _inp_rl_shift_tab_handler(int count, int key);
|
||||
static int _inp_rl_win_clear_handler(int count, int key);
|
||||
static int _inp_rl_win_1_handler(int count, int key);
|
||||
static int _inp_rl_win_2_handler(int count, int key);
|
||||
@@ -421,6 +422,7 @@ _inp_rl_startup_hook(void)
|
||||
rl_bind_keyseq("\\eOs", _inp_rl_win_pagedown_handler);
|
||||
|
||||
rl_bind_key('\t', _inp_rl_tab_handler);
|
||||
rl_bind_keyseq("\\e[Z", _inp_rl_shift_tab_handler);
|
||||
|
||||
// unbind unwanted mappings
|
||||
rl_bind_keyseq("\\e=", NULL);
|
||||
@@ -449,10 +451,27 @@ _inp_rl_linehandler(char *line)
|
||||
inp_line = line;
|
||||
}
|
||||
|
||||
static gboolean shift_tab = FALSE;
|
||||
|
||||
static int
|
||||
_inp_rl_getc(FILE *stream)
|
||||
{
|
||||
int ch = rl_getc(stream);
|
||||
|
||||
// 27, 91, 90 = Shift tab
|
||||
if (ch == 27) {
|
||||
shift_tab = TRUE;
|
||||
return ch;
|
||||
}
|
||||
if (shift_tab && ch == 91) {
|
||||
return ch;
|
||||
}
|
||||
if (shift_tab && ch == 90) {
|
||||
return ch;
|
||||
}
|
||||
|
||||
shift_tab = FALSE;
|
||||
|
||||
if (_inp_printable(ch)) {
|
||||
ProfWin *window = wins_get_current();
|
||||
cmd_ac_reset(window);
|
||||
@@ -477,7 +496,7 @@ _inp_rl_tab_handler(int count, int key)
|
||||
|
||||
ProfWin *current = wins_get_current();
|
||||
if ((strncmp(rl_line_buffer, "/", 1) != 0) && (current->type == WIN_MUC)) {
|
||||
char *result = muc_autocomplete(current, rl_line_buffer);
|
||||
char *result = muc_autocomplete(current, rl_line_buffer, FALSE);
|
||||
if (result) {
|
||||
rl_replace_line(result, 1);
|
||||
rl_point = rl_end;
|
||||
@@ -485,7 +504,35 @@ _inp_rl_tab_handler(int count, int key)
|
||||
}
|
||||
} else if (strncmp(rl_line_buffer, "/", 1) == 0) {
|
||||
ProfWin *window = wins_get_current();
|
||||
char *result = cmd_ac_complete(window, rl_line_buffer);
|
||||
char *result = cmd_ac_complete(window, rl_line_buffer, FALSE);
|
||||
if (result) {
|
||||
rl_replace_line(result, 1);
|
||||
rl_point = rl_end;
|
||||
free(result);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_inp_rl_shift_tab_handler(int count, int key)
|
||||
{
|
||||
if (rl_point != rl_end || !rl_line_buffer) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ProfWin *current = wins_get_current();
|
||||
if ((strncmp(rl_line_buffer, "/", 1) != 0) && (current->type == WIN_MUC)) {
|
||||
char *result = muc_autocomplete(current, rl_line_buffer, TRUE);
|
||||
if (result) {
|
||||
rl_replace_line(result, 1);
|
||||
rl_point = rl_end;
|
||||
free(result);
|
||||
}
|
||||
} else if (strncmp(rl_line_buffer, "/", 1) == 0) {
|
||||
ProfWin *window = wins_get_current();
|
||||
char *result = cmd_ac_complete(window, rl_line_buffer, TRUE);
|
||||
if (result) {
|
||||
rl_replace_line(result, 1);
|
||||
rl_point = rl_end;
|
||||
|
||||
Reference in New Issue
Block a user