diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 3482e1bc..f901f117 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -308,7 +308,7 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, if (request_receipt && id) { win_print_with_receipt((ProfWin*)chatwin, enc_char, "me", message, id); } else { - win_printf((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", "%s", message); + win_print_outgoing((ProfWin*)chatwin, enc_char, "%s", message); } } diff --git a/src/ui/privwin.c b/src/ui/privwin.c index 54c54564..e7fca112 100644 --- a/src/ui/privwin.c +++ b/src/ui/privwin.c @@ -93,7 +93,7 @@ privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message) { assert(privwin != NULL); - win_printf((ProfWin*)privwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", "%s", message); + win_print_outgoing((ProfWin*)privwin, '-', "%s", message); } void diff --git a/src/ui/window.c b/src/ui/window.c index f0243578..2175ad6c 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1008,6 +1008,26 @@ win_print_incoming_message(ProfWin *window, GDateTime *timestamp, } } +void +win_print_outgoing(ProfWin *window, const char ch, const char *const message, ...) +{ + GDateTime *timestamp = g_date_time_new_now_local(); + + va_list arg; + va_start(arg, message); + GString *fmt_msg = g_string_new(NULL); + g_string_vprintf(fmt_msg, message, arg); + + buffer_push(window->layout->buffer, ch, 0, timestamp, 0, THEME_TEXT_ME, "me", fmt_msg->str, NULL); + + _win_print(window, ch, 0, timestamp, 0, THEME_TEXT_ME, "me", fmt_msg->str, NULL); + inp_nonblocking(TRUE); + g_date_time_unref(timestamp); + + g_string_free(fmt_msg, TRUE); + va_end(arg); +} + void win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char *const from, const char *const message, ...) diff --git a/src/ui/window.h b/src/ui/window.h index ee53b1de..4c1b31a6 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -59,6 +59,8 @@ void win_show_status_string(ProfWin *window, const char *const from, const char *const show, const char *const status, GDateTime *last_activity, const char *const pre, const char *const default_show); + +void win_print_outgoing(ProfWin *window, const char ch, const char *const message, ...); void win_print_incoming_message(ProfWin *window, GDateTime *timestamp, const char *const from, const char *const message, prof_enc_t enc_mode);