diff options
author | Michael Vetter <jubalh@iodoru.org> | 2020-02-12 14:24:11 +0100 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2020-02-14 10:17:07 +0100 |
commit | bc571a387d3fa82e1746a7c7c2dc80283879a1ec (patch) | |
tree | 20ab0592fd9b067f9f4ab133bd30cf3d2afc3020 | |
parent | 4ec005e4c3563066e33e0cf7b87dd027489f03bc (diff) | |
download | profani-tty-bc571a387d3fa82e1746a7c7c2dc80283879a1ec.tar.gz |
xep-0308: Add autocompletion of last message for /correct
-rw-r--r-- | src/command/cmd_ac.c | 33 |
1 files changed, 29 insertions, 4 deletions
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; } |