Skip to content

Commit

Permalink
Move declaration and definition of win_get_last_sent_message to the c…
Browse files Browse the repository at this point in the history
…orrect place
  • Loading branch information
MarcoPolo-PasTonMolo committed Oct 22, 2021
1 parent 6b0f15a commit da3a6d8
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 32 deletions.
32 changes: 2 additions & 30 deletions src/command/cmd_ac.c
Expand Up @@ -49,6 +49,7 @@
#include "command/cmd_funcs.h"
#include "tools/parser.h"
#include "plugins/plugins.h"
#include "ui/ui.h"
#include "ui/win_types.h"
#include "ui/window_list.h"
#include "xmpp/muc.h"
Expand Down Expand Up @@ -4032,42 +4033,13 @@ static char*
_correct_autocomplete(ProfWin* window, const char* const input, gboolean previous)
{
GString* result_str = g_string_new("/correct ");
g_string_append(result_str, _get_last_message(window));
g_string_append(result_str, win_get_last_sent_message(window));
char* result = result_str->str;
g_string_free(result_str, FALSE);

return result;
}

char*
_get_last_message(ProfWin* window)
{
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;
}

return last_message;
}

static char*
_software_autocomplete(ProfWin* window, const char* const input, gboolean previous)
{
Expand Down
1 change: 0 additions & 1 deletion src/command/cmd_ac.h
Expand Up @@ -59,6 +59,5 @@ void cmd_ac_add_form_fields(DataForm* form);
void cmd_ac_remove_form_fields(DataForm* form);

char* cmd_ac_complete_filepath(const char* const input, char* const startstr, gboolean previous);
char* _get_last_message(ProfWin* window);

#endif
2 changes: 1 addition & 1 deletion src/command/cmd_funcs.c
Expand Up @@ -9569,7 +9569,7 @@ cmd_correct_editor(ProfWin* window, const char* const command, gchar** args)
return TRUE;
}

gchar* initial_message = _get_last_message(window);
gchar* initial_message = win_get_last_sent_message(window);

gchar* message = NULL;
if (_get_message_from_editor(initial_message, &message)) {
Expand Down
1 change: 1 addition & 0 deletions src/ui/ui.h
Expand Up @@ -398,6 +398,7 @@ void win_command_exec_error(ProfWin* window, const char* const command, const ch
void win_handle_command_list(ProfWin* window, GSList* cmds);
void win_handle_command_exec_status(ProfWin* window, const char* const type, const char* const value);
void win_handle_command_exec_result_note(ProfWin* window, const char* const type, const char* const value);
char* win_get_last_sent_message(ProfWin* window);

// desktop notifications
void notifier_initialise(void);
Expand Down
29 changes: 29 additions & 0 deletions src/ui/window.c
Expand Up @@ -398,6 +398,35 @@ win_get_tab_identifier(ProfWin* window)
}
}

char*
win_get_last_sent_message(ProfWin* window)
{
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;
}

return last_message;
}

char*
win_to_string(ProfWin* window)
{
Expand Down

0 comments on commit da3a6d8

Please sign in to comment.