diff mcabber/src/hbuf.c @ 189:4f3975f1b852

[/trunk] Changeset 201 by mikael * Add hbuf_previous_persistent(). Now we should not jump to the buffer's bottom when increasing the screen width.
author mikael
date Fri, 06 May 2005 14:34:51 +0000
parents b5aa2b9c425a
children c289e3c39c48
line wrap: on
line diff
--- a/mcabber/src/hbuf.c	Fri May 06 09:58:44 2005 +0000
+++ b/mcabber/src/hbuf.c	Fri May 06 14:34:51 2005 +0000
@@ -217,6 +217,26 @@
   }
 }
 
+//  hbuf_previous_persistent()
+// Returns the previous persistent block (line).  If the given line is
+// persistent, then it is returned.
+// This function is used for example when resizing a buffer.  If the top of the
+// screen is on a non-persistent block, then a screen resize could destroy this
+// line...
+GList *hbuf_previous_persistent(GList *l_line)
+{
+  hbuf_block *hbuf_b_elt;
+
+  while (l_line) {
+    hbuf_b_elt = (hbuf_block*)l_line->data;
+    if (hbuf_b_elt->flags & HBB_FLAG_PERSISTENT)
+      return l_line;
+    l_line = g_list_previous(l_line);
+  }
+
+  return NULL;
+}
+
 //  hbuf_get_lines(hbuf, n, where)  FIXME bad comments XXX
 // Returns an array of 2*n pointers (for n prefixes + n lines from hbuf)
 // (prefix line 1, line 1, prefix line 2, line 2, etc.)