From c9310836deb2b8961c0b7f1cc847c527cb84116e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonathan=20Neusch=C3=A4fer?= Date: Wed, 23 May 2012 02:51:24 +0200 Subject: [PATCH] screen_chat: add nick name emulation --- src/screen_chat.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/screen_chat.c b/src/screen_chat.c index b4d3aac..6daca65 100644 --- a/src/screen_chat.c +++ b/src/screen_chat.c @@ -26,6 +26,7 @@ #include "mpdclient.h" #include "i18n.h" #include "charset.h" +#include "options.h" #include #include @@ -138,13 +139,28 @@ screen_chat_update(struct mpdclient *c) } } +static char * +screen_chat_get_prefix(void) +{ + static char *prefix = NULL; + + if (prefix) + return prefix; + + prefix = g_strconcat("<", g_get_user_name(), "> ", NULL); + return prefix; +} + static void screen_chat_send_message(struct mpdclient *c, char *msg) { char *utf8 = locale_to_utf8(msg); - - (void) mpdclient_cmd_send_message(c, chat_channel, utf8); + char *prefix = screen_chat_get_prefix(); + char *full_msg = g_strconcat(prefix, utf8, NULL); g_free(utf8); + + (void) mpdclient_cmd_send_message(c, chat_channel, full_msg); + g_free(full_msg); } static bool -- 2.30.2