comparison mcabber/src/hooks.c @ 1204:e802ec0c02d2

Basic support for nick highlighting in MUC rooms (the whole line is colored)
author Mikael Berthe <mikael@lilotux.net>
date Sat, 28 Apr 2007 21:52:57 +0200
parents ef40688d87bd
children 2de8f8ba1f34
comparison
equal deleted inserted replaced
1203:c96fef31ff96 1204:e802ec0c02d2
28 #include "roster.h" 28 #include "roster.h"
29 #include "histolog.h" 29 #include "histolog.h"
30 #include "hbuf.h" 30 #include "hbuf.h"
31 #include "settings.h" 31 #include "settings.h"
32 #include "utils.h" 32 #include "utils.h"
33 #include "utf8.h"
33 34
34 static char *extcmd; 35 static char *extcmd;
35 36
36 static const char *COMMAND_ME = "/me "; 37 static const char *COMMAND_ME = "/me ";
37 38
110 if (!strncmp(msg, COMMAND_ME, strlen(COMMAND_ME))) { 111 if (!strncmp(msg, COMMAND_ME, strlen(COMMAND_ME))) {
111 g_free(mmsg); 112 g_free(mmsg);
112 wmsg = mmsg = g_strdup_printf("PRIV#*%s %s", resname, msg+4); 113 wmsg = mmsg = g_strdup_printf("PRIV#*%s %s", resname, msg+4);
113 } 114 }
114 } 115 }
116 message_flags |= HBB_PREFIX_HLIGHT;
115 } else { 117 } else {
116 // This is a regular chatroom message. 118 // This is a regular chatroom message.
117 // Let's see if we are the message sender, in which case we'll
118 // highlight it.
119 const char *nick = buddy_getnickname(roster_usr->data); 119 const char *nick = buddy_getnickname(roster_usr->data);
120 if (resname && nick && !strcmp(resname, nick)) 120
121 message_flags |= HBB_PREFIX_HLIGHT; 121 if (nick) {
122 // Let's see if we are the message sender, in which case we'll
123 // highlight it.
124 if (resname && !strcmp(resname, nick)) {
125 message_flags |= HBB_PREFIX_HLIGHT_OUT;
126 } else {
127 // We're not the sender. Can we see our nick?
128 if (startswith(msg, nick, TRUE)) {
129 // The message starts with our nick. Let's check it's not
130 // followed immediately by an alphnumeric character.
131 if (!iswalnum(get_char(msg+strlen(nick))))
132 message_flags |= HBB_PREFIX_HLIGHT;
133 }
134 // We could do a more global check...
135 }
136 }
122 } 137 }
123 } 138 }
124 139
125 if (type && !strcmp(type, "error")) { 140 if (type && !strcmp(type, "error")) {
126 message_flags = HBB_PREFIX_ERR | HBB_PREFIX_IN; 141 message_flags = HBB_PREFIX_ERR | HBB_PREFIX_IN;