diff mcabber/mcabber/hbuf.c @ 1956:f309f343070c

Add command /buffer readmark
author Mikael Berthe <mikael@lilotux.net>
date Mon, 14 Mar 2011 23:16:11 +0100
parents e8cebf5fd36c
children 39021fd6b0e1
line wrap: on
line diff
--- a/mcabber/mcabber/hbuf.c	Mon Mar 14 15:04:00 2011 +0100
+++ b/mcabber/mcabber/hbuf.c	Mon Mar 14 23:16:11 2011 +0100
@@ -428,6 +428,23 @@
   return g_list_nth(hbuf, pc*hlen/100);
 }
 
+//  hbuf_jump_readmark(hbuf)
+// Return a pointer to the line following the readmark
+// or NULL if no mark was found.
+GList *hbuf_jump_readmark(GList *hbuf)
+{
+  hbuf_block *blk;
+
+  hbuf = g_list_last(hbuf);
+  for ( ; hbuf; hbuf = g_list_previous(hbuf)) {
+    blk = (hbuf_block*)(hbuf->data);
+    if (blk->prefix.flags & HBB_PREFIX_READMARK)
+      return g_list_next(hbuf);
+  }
+
+  return NULL;
+}
+
 //  hbuf_dump_to_file(hbuf, filename)
 // Save the buffer to a file.
 void hbuf_dump_to_file(GList *hbuf, const char *filename)
@@ -522,12 +539,12 @@
     blk = (hbuf_block*)(hbuf->data);
     blk->prefix.flags ^= HBB_PREFIX_READMARK;
     // Shift hbuf in order to remove previous flags
-    // (XXX maybe can be optimized out if there's no risk
+    // (maybe it can be optimized out, if there's no risk
     //  we have several marks)
     hbuf = g_list_previous(hbuf);
   }
 
-  // Remove old marks
+  // Remove old mark
   for ( ; hbuf; hbuf = g_list_previous(hbuf)) {
     blk = (hbuf_block*)(hbuf->data);
     if (blk->prefix.flags & HBB_PREFIX_READMARK) {