mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-20 17:36:22 +00:00
Add quote autocompletion for previous messages
Fixes https://github.com/profanity-im/profanity/issues/1649 Type `>` then press tab or shift tab to autocomplete previous messages, then type your reply and send message. Newlines are replaced with newline followed by `> `. A newline is added at the end so that the user can immediately type a message without manually adding a new line.
This commit is contained in:
@@ -558,6 +558,10 @@ _inp_rl_getc(FILE* stream)
|
||||
if (_inp_edited(ch)) {
|
||||
ProfWin* window = wins_get_current();
|
||||
cmd_ac_reset(window);
|
||||
|
||||
if ((window->type == WIN_CHAT || window->type == WIN_MUC || window->type == WIN_PRIVATE) && window->quotes_ac != NULL) {
|
||||
autocomplete_reset(window->quotes_ac);
|
||||
}
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
@@ -597,6 +601,17 @@ _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);
|
||||
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, FALSE);
|
||||
@@ -607,7 +622,6 @@ _inp_rl_tab_handler(int count, int key)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -629,6 +643,17 @@ _inp_rl_shift_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, 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);
|
||||
|
||||
Reference in New Issue
Block a user