mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Merge pull request #1664 from paulfertser/tab-completion-cleanup
Tab completion code simplification
This commit is contained in:
commit
ba3d5e8de9
@ -596,7 +596,7 @@ _inp_rl_win_close_handler(int count, int key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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) {
|
if (rl_point != rl_end || !rl_line_buffer) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -604,7 +604,7 @@ _inp_rl_tab_handler(int count, int key)
|
|||||||
|
|
||||||
if (strncmp(rl_line_buffer, "/", 1) == 0) {
|
if (strncmp(rl_line_buffer, "/", 1) == 0) {
|
||||||
ProfWin* window = wins_get_current();
|
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) {
|
if (result) {
|
||||||
rl_replace_line(result, 1);
|
rl_replace_line(result, 1);
|
||||||
rl_point = rl_end;
|
rl_point = rl_end;
|
||||||
@ -615,7 +615,7 @@ _inp_rl_tab_handler(int count, int key)
|
|||||||
|
|
||||||
if (strncmp(rl_line_buffer, ">", 1) == 0) {
|
if (strncmp(rl_line_buffer, ">", 1) == 0) {
|
||||||
ProfWin* window = wins_get_current();
|
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) {
|
if (result) {
|
||||||
rl_replace_line(result, 1);
|
rl_replace_line(result, 1);
|
||||||
rl_point = rl_end;
|
rl_point = rl_end;
|
||||||
@ -626,7 +626,7 @@ _inp_rl_tab_handler(int count, int key)
|
|||||||
|
|
||||||
ProfWin* current = wins_get_current();
|
ProfWin* current = wins_get_current();
|
||||||
if (current->type == WIN_MUC) {
|
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) {
|
if (result) {
|
||||||
rl_replace_line(result, 1);
|
rl_replace_line(result, 1);
|
||||||
rl_point = rl_end;
|
rl_point = rl_end;
|
||||||
@ -637,46 +637,16 @@ _inp_rl_tab_handler(int count, int key)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_inp_rl_tab_handler(int count, int key)
|
||||||
|
{
|
||||||
|
return _inp_rl_tab_com_handler(count, key, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_inp_rl_shift_tab_handler(int count, int key)
|
_inp_rl_shift_tab_handler(int count, int key)
|
||||||
{
|
{
|
||||||
if (rl_point != rl_end || !rl_line_buffer) {
|
return _inp_rl_tab_com_handler(count, key, TRUE);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user