about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-02-26 12:02:32 +0100
committerMichael Vetter <jubalh@iodoru.org>2019-02-26 12:02:32 +0100
commitd0a1cae8e838ec9c6c1c3b8ee41225c247c12880 (patch)
treecd98ce666d67333b419cec894939524a84a913d0 /src
parent681e5de523178ce78965e37fa0665cd69f30ed72 (diff)
downloadprofani-tty-d0a1cae8e838ec9c6c1c3b8ee41225c247c12880.tar.gz
Fix /me display when highlighting user in MUCs
Fixes https://github.com/boothj5/profanity/issues/950
Closes https://github.com/boothj5/profanity/pull/992
Diffstat (limited to 'src')
-rw-r--r--src/ui/mucwin.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c
index fc13a9b1..0f9f4f2b 100644
--- a/src/ui/mucwin.c
+++ b/src/ui/mucwin.c
@@ -361,7 +361,7 @@ mucwin_history(ProfMucWin *mucwin, const char *const nick, GDateTime *timestamp,
 }
 
 static void
-_mucwin_print_mention(ProfWin *window, const char *const message, const char *const nick, GSList *mentions)
+_mucwin_print_mention(ProfWin *window, const char *const message, const char *const from, const char *const mynick, GSList *mentions, const char *const ch)
 {
     int last_pos = 0;
     int pos = 0;
@@ -370,13 +370,20 @@ _mucwin_print_mention(ProfWin *window, const char *const message, const char *co
         pos = GPOINTER_TO_INT(curr->data);
 
         char *before_str = g_strndup(message + last_pos, pos - last_pos);
-        win_append_highlight(window, THEME_ROOMMENTION, "%s", before_str);
+        if (strncmp(before_str, "/me ", 4) == 0) {
+            win_print_them(window, THEME_ROOMMENTION, *ch, "");
+            win_append_highlight(window, THEME_ROOMMENTION, "*%s ", from);
+            win_append_highlight(window, THEME_ROOMMENTION, "%s", before_str + 4);
+        } else {
+            win_print_them(window, THEME_ROOMMENTION, *ch, from);
+            win_append_highlight(window, THEME_ROOMMENTION, "%s", before_str);
+        }
         g_free(before_str);
-        char *nick_str = g_strndup(message + pos, strlen(nick));
-        win_append_highlight(window, THEME_ROOMMENTION_TERM, "%s", nick_str);
-        g_free(nick_str);
+        char *mynick_str = g_strndup(message + pos, strlen(mynick));
+        win_append_highlight(window, THEME_ROOMMENTION_TERM, "%s", mynick_str);
+        g_free(mynick_str);
 
-        last_pos = pos + strlen(nick);
+        last_pos = pos + strlen(mynick);
 
         curr = g_slist_next(curr);
     }
@@ -485,8 +492,7 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes
 
     if (g_strcmp0(nick, mynick) != 0) {
         if (g_slist_length(mentions) > 0) {
-            win_print_them(window, THEME_ROOMMENTION, ch, nick);
-            _mucwin_print_mention(window, message, mynick, mentions);
+            _mucwin_print_mention(window, message, nick, mynick, mentions, &ch);
         } else if (triggers) {
             win_print_them(window, THEME_ROOMTRIGGER, ch, nick);
             _mucwin_print_triggers(window, message, triggers);