mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Tab completion code simplification
Factor out common code for Tab and Shift-Tab in a separate function. No functional change.
This commit is contained in:
parent
7301c99676
commit
3b40da854d
@ -588,7 +588,7 @@ _inp_rl_win_close_handler(int count, int key)
|
||||
}
|
||||
|
||||
static int
|
||||
_inp_rl_tab_handler(int count, int key)
|
||||
_inp_rl_tab_com_handler(int count, int key, gboolean previous)
|
||||
{
|
||||
if (rl_point != rl_end || !rl_line_buffer) {
|
||||
return 0;
|
||||
@ -596,7 +596,7 @@ _inp_rl_tab_handler(int count, int key)
|
||||
|
||||
if (strncmp(rl_line_buffer, "/", 1) == 0) {
|
||||
ProfWin* window = wins_get_current();
|
||||
char* result = cmd_ac_complete(window, rl_line_buffer, FALSE);
|
||||
char* result = cmd_ac_complete(window, rl_line_buffer, previous);
|
||||
if (result) {
|
||||
rl_replace_line(result, 1);
|
||||
rl_point = rl_end;
|
||||
@ -607,7 +607,7 @@ _inp_rl_tab_handler(int count, int key)
|
||||
|
||||
if (strncmp(rl_line_buffer, ">", 1) == 0) {
|
||||
ProfWin* window = wins_get_current();
|
||||
char* result = win_quote_autocomplete(window, rl_line_buffer, FALSE);
|
||||
char* result = win_quote_autocomplete(window, rl_line_buffer, previous);
|
||||
if (result) {
|
||||
rl_replace_line(result, 1);
|
||||
rl_point = rl_end;
|
||||
@ -618,7 +618,7 @@ _inp_rl_tab_handler(int count, int key)
|
||||
|
||||
ProfWin* current = wins_get_current();
|
||||
if (current->type == WIN_MUC) {
|
||||
char* result = muc_autocomplete(current, rl_line_buffer, FALSE);
|
||||
char* result = muc_autocomplete(current, rl_line_buffer, previous);
|
||||
if (result) {
|
||||
rl_replace_line(result, 1);
|
||||
rl_point = rl_end;
|
||||
@ -629,46 +629,16 @@ _inp_rl_tab_handler(int count, int key)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_inp_rl_tab_handler(int count, int key)
|
||||
{
|
||||
return _inp_rl_tab_com_handler(count, key, FALSE);
|
||||
}
|
||||
|
||||
static int
|
||||
_inp_rl_shift_tab_handler(int count, int key)
|
||||
{
|
||||
if (rl_point != rl_end || !rl_line_buffer) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
free(result);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (strncmp(rl_line_buffer, ">", 1) == 0) {
|
||||
ProfWin* window = wins_get_current();
|
||||
char* result = win_quote_autocomplete(window, rl_line_buffer, TRUE);
|
||||
if (result) {
|
||||
rl_replace_line(result, 1);
|
||||
rl_point = rl_end;
|
||||
free(result);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
ProfWin* current = wins_get_current();
|
||||
if (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);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return _inp_rl_tab_com_handler(count, key, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user