changeset 220:8dfdc6f1778e

[/trunk] Changeset 232 by mikael * Fix a bug when displaying a multi-line message in a /clear-ed window * Always make sure the last msg is displayed in the buffer window (fix another problem with the /clear command...)
author mikael
date Sat, 04 Jun 2005 11:44:55 +0000
parents 8b6adc3f1acc
children 73f6ce668ba8
files mcabber/src/TODO mcabber/src/screen.c
diffstat 2 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/TODO	Tue May 31 16:56:49 2005 +0000
+++ b/mcabber/src/TODO	Sat Jun 04 11:44:55 2005 +0000
@@ -1,8 +1,6 @@
 
 BUGS:
 
-* /clear : does not scroll again when typing until bottom after issuing a
-  /clear command...
 * We should display a warning when we can't write (any more) logs
   (bad dir, no space left...)
 * Colors are misnamed
--- a/mcabber/src/screen.c	Tue May 31 16:56:49 2005 +0000
+++ b/mcabber/src/screen.c	Sat Jun 04 11:44:55 2005 +0000
@@ -391,12 +391,27 @@
     win_entry = scr_CreateBuddyPanel(winId, dont_show);
   }
 
+  // The message must be displayed -> update top pointer
+  if (win_entry->cleared)
+    win_entry->top = g_list_last(win_entry->hbuf);
+
   hbuf_add_line(&win_entry->hbuf, text, timestamp, prefix_flags,
                 maxX - ROSTER_WIDTH - PREFIX_WIDTH);
 
   if (win_entry->cleared) {
-    win_entry->cleared = 0; // The message must be displayed
-    win_entry->top = g_list_last(win_entry->hbuf);
+    win_entry->cleared = FALSE;
+    if (g_list_next(win_entry->top))
+      win_entry->top = g_list_next(win_entry->top);
+  }
+
+  // Make sure the last line appears in the window; update top if necessary
+  if (win_entry->top) {
+    int dist;
+    GList *first = g_list_first(win_entry->hbuf);
+    dist = g_list_position(first, g_list_last(win_entry->hbuf)) -
+           g_list_position(first, win_entry->top);
+    if (dist >= CHAT_WIN_HEIGHT)
+      win_entry->top = NULL;
   }
 
   if (!dont_show) {