diff 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
line wrap: on
line diff
--- a/mcabber/src/hooks.c	Sat Apr 28 12:16:45 2007 +0200
+++ b/mcabber/src/hooks.c	Sat Apr 28 21:52:57 2007 +0200
@@ -30,6 +30,7 @@
 #include "hbuf.h"
 #include "settings.h"
 #include "utils.h"
+#include "utf8.h"
 
 static char *extcmd;
 
@@ -112,13 +113,27 @@
           wmsg = mmsg = g_strdup_printf("PRIV#*%s %s", resname, msg+4);
         }
       }
+      message_flags |= HBB_PREFIX_HLIGHT;
     } else {
       // This is a regular chatroom message.
-      // Let's see if we are the message sender, in which case we'll
-      // highlight it.
       const char *nick = buddy_getnickname(roster_usr->data);
-      if (resname && nick && !strcmp(resname, nick))
-        message_flags |= HBB_PREFIX_HLIGHT;
+
+      if (nick) {
+        // Let's see if we are the message sender, in which case we'll
+        // highlight it.
+        if (resname && !strcmp(resname, nick)) {
+          message_flags |= HBB_PREFIX_HLIGHT_OUT;
+        } else {
+          // We're not the sender.  Can we see our nick?
+          if (startswith(msg, nick, TRUE)) {
+            // The message starts with our nick.  Let's check it's not
+            // followed immediately by an alphnumeric character.
+            if (!iswalnum(get_char(msg+strlen(nick))))
+              message_flags |= HBB_PREFIX_HLIGHT;
+          }
+          // We could do a more global check...
+        }
+      }
     }
   }