about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config/theme.c2
-rw-r--r--src/config/theme.h1
-rw-r--r--src/ui/console.c1
-rw-r--r--src/ui/mucwin.c33
4 files changed, 36 insertions, 1 deletions
diff --git a/src/config/theme.c b/src/config/theme.c
index c8e466d5..414bf2b4 100644
--- a/src/config/theme.c
+++ b/src/config/theme.c
@@ -107,6 +107,7 @@ theme_init(const char *const theme_name)
     g_hash_table_insert(defaults, strdup("receipt.sent"),            strdup("red"));
     g_hash_table_insert(defaults, strdup("roominfo"),                strdup("yellow"));
     g_hash_table_insert(defaults, strdup("roommention"),             strdup("yellow"));
+    g_hash_table_insert(defaults, strdup("roommention.term"),        strdup("yellow"));
     g_hash_table_insert(defaults, strdup("roomtrigger"),             strdup("yellow"));
     g_hash_table_insert(defaults, strdup("online"),                  strdup("green"));
     g_hash_table_insert(defaults, strdup("offline"),                 strdup("red"));
@@ -751,6 +752,7 @@ theme_attrs(theme_item_t attrs)
     case THEME_RECEIPT_SENT:            _theme_prep_fgnd("receipt.sent",            lookup_str, &bold); break;
     case THEME_ROOMINFO:                _theme_prep_fgnd("roominfo",                lookup_str, &bold); break;
     case THEME_ROOMMENTION:             _theme_prep_fgnd("roommention",             lookup_str, &bold); break;
+    case THEME_ROOMMENTION_TERM:        _theme_prep_fgnd("roommention.term",        lookup_str, &bold); break;
     case THEME_ROOMTRIGGER:             _theme_prep_fgnd("roomtrigger",             lookup_str, &bold); break;
     case THEME_ONLINE:                  _theme_prep_fgnd("online",                  lookup_str, &bold); break;
     case THEME_OFFLINE:                 _theme_prep_fgnd("offline",                 lookup_str, &bold); break;
diff --git a/src/config/theme.h b/src/config/theme.h
index 4ec74510..a90fa360 100644
--- a/src/config/theme.h
+++ b/src/config/theme.h
@@ -70,6 +70,7 @@ typedef enum {
     THEME_THEM,
     THEME_ROOMINFO,
     THEME_ROOMMENTION,
+    THEME_ROOMMENTION_TERM,
     THEME_ROOMTRIGGER,
     THEME_ONLINE,
     THEME_OFFLINE,
diff --git a/src/ui/console.c b/src/ui/console.c
index 8d8542a4..00957aae 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -2215,6 +2215,7 @@ cons_theme_properties(void)
 
     _cons_theme_prop(THEME_ROOMINFO, "roominfo");
     _cons_theme_prop(THEME_ROOMMENTION, "roommention");
+    _cons_theme_prop(THEME_ROOMMENTION_TERM, "roommention.term");
     _cons_theme_prop(THEME_ROOMTRIGGER, "roomtrigger");
 
     _cons_theme_prop(THEME_ROSTER_HEADER, "roster.header");
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c
index a24daa59..3d7263f3 100644
--- a/src/ui/mucwin.c
+++ b/src/ui/mucwin.c
@@ -355,6 +355,36 @@ mucwin_history(ProfMucWin *mucwin, const char *const nick, GDateTime *timestamp,
     g_string_free(line, TRUE);
 }
 
+static void
+_mucwin_print_mention(ProfWin *window, const char *const message, const char *const my_nick)
+{
+    char *mynick_lower = g_utf8_strdown(my_nick, -1);
+    char *message_lower = g_utf8_strdown(message, -1);
+    char message_section[strlen(message) + 1];
+
+    int i = 0;
+    while(!g_str_has_prefix(&message_lower[i], mynick_lower) && i < strlen(message)) {
+        message_section[i] = message[i];
+        i++;
+    }
+    message_section[i] = '\0';
+
+    char *mention_section = strndup(&message[i], strlen(my_nick));
+    int used = strlen(message_section) + strlen(mention_section);
+
+    win_print(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMMENTION, "", message_section);
+    if (strlen(message) > used) {
+        win_print(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMMENTION_TERM, "", mention_section);
+        _mucwin_print_mention(window, &message[used], my_nick);
+    } else {
+        win_print(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMMENTION_TERM, "", mention_section);
+    }
+
+    free(mention_section);
+    g_free(mynick_lower);
+    g_free(message_lower);
+}
+
 void
 mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const message, gboolean mention,
     gboolean trigger_found)
@@ -366,7 +396,8 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes
 
     if (g_strcmp0(nick, my_nick) != 0) {
         if (mention) {
-            win_print(window, '-', 0, NULL, NO_ME, THEME_ROOMMENTION, nick, message);
+            win_print(window, '-', 0, NULL, NO_ME | NO_EOL, THEME_ROOMMENTION, nick, "");
+            _mucwin_print_mention(window, message, my_nick);
         } else if (trigger_found) {
             win_print(window, '-', 0, NULL, NO_ME, THEME_ROOMTRIGGER, nick, message);
         } else {
title='Blame the previous revision' href='/akkartik/mu/blame/subx/053new_segment.subx?h=main&id=66aa96ecc74140e0f2f920deb47c12a7f6f6e515'>^
71eb22a5 ^
7a583220 ^
33352536 ^

cdfb2dbf ^
33352536 ^

c98d4b1c ^
33352536 ^
686a52bd ^
f75f333f ^
33352536 ^
7dac9ade ^
33352536 ^


71eb22a5 ^
33352536 ^
71eb22a5 ^
33352536 ^

cf02c20b ^
cdfb2dbf ^
33352536 ^

7a583220 ^
33352536 ^

6030d7e2 ^
871d2227 ^

e5cbbea4 ^
871d2227 ^
f1eade72 ^
6030d7e2 ^
9b16f190 ^
686a52bd ^
6030d7e2 ^
9b16f190 ^
6030d7e2 ^
9b16f190 ^
6030d7e2 ^
9b16f190 ^
6030d7e2 ^
9b16f190 ^
6030d7e2 ^
9b16f190 ^
871d2227 ^
ee9a9237 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88