From bc571a387d3fa82e1746a7c7c2dc80283879a1ec Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Wed, 12 Feb 2020 14:24:11 +0100 Subject: xep-0308: Add autocompletion of last message for /correct --- src/command/cmd_ac.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'src/command/cmd_ac.c') diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 17629d87..386e8939 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -3742,8 +3742,33 @@ _correction_autocomplete(ProfWin *window, const char *const input, gboolean prev static char* _correct_autocomplete(ProfWin *window, const char *const input, gboolean previous) { - char *result = NULL; - - //TODO: get last message - return result; + char *last_message = NULL; + switch(window->type) { + case WIN_CHAT: + { + ProfChatWin *chatwin = (ProfChatWin*)window; + assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); + last_message = chatwin->last_message; + break; + } + case WIN_MUC: + { + ProfMucWin *mucwin = (ProfMucWin*)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + last_message = mucwin->last_message; + } + default: + break; + } + + if (last_message == NULL) { + return NULL; + } + + GString *result_str = g_string_new("/correct "); + g_string_append(result_str, last_message); + char *result = result_str->str; + g_string_free(result_str, FALSE); + + return result; } -- cgit 1.4.1-2-gfad0