changeset 733:c502bfe67c31

Fix highlighting of outgoing multi-line messages
author Mikael Berthe <mikael@lilotux.net>
date Thu, 09 Mar 2006 19:25:31 +0100
parents ab623c2df964
children 1d9f0efcfcee
files mcabber/src/hbuf.c
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/hbuf.c	Thu Mar 09 18:06:02 2006 +0100
+++ b/mcabber/src/hbuf.c	Thu Mar 09 19:25:31 2006 +0100
@@ -250,12 +250,19 @@
   unsigned int i;
   hbuf_block *blk;
   guchar last_persist_prefixflags = 0;
-  GList *last_persist;
+  GList *last_persist;  // last persistent flags
 
+  // To be able to correctly highlight multi-line messages,
+  // we need to look at the last non-null prefix, which should be the first
+  // line of the message.
   last_persist = hbuf_previous_persistent(hbuf);
-  if (last_persist && last_persist != hbuf) {
-    blk = (hbuf_block*)(last_persist->data);
-    last_persist_prefixflags = blk->prefix.flags;
+  while (last_persist) {
+    blk = (hbuf_block*)last_persist->data;
+    if ((blk->flags & HBB_FLAG_PERSISTENT) && blk->prefix.flags) {
+      last_persist_prefixflags = blk->prefix.flags;
+      break;
+    }
+    last_persist = g_list_previous(last_persist);
   }
 
   hbb_line **array = g_new0(hbb_line*, n);
@@ -271,7 +278,7 @@
       (*array_elt)->flags     = blk->prefix.flags;
       (*array_elt)->text      = g_strndup(blk->ptr, maxlen);
 
-      if (blk->flags & HBB_FLAG_PERSISTENT) {
+      if ((blk->flags & HBB_FLAG_PERSISTENT) && blk->prefix.flags) {
         last_persist_prefixflags = blk->prefix.flags;
       } else {
         // Propagate hilighting flag