# HG changeset patch # User mikael # Date 1115390091 0 # Node ID 4f3975f1b8522b1b5388db55c111f58a3e5c31dd # Parent 7604e3cdbb86ab3984ae2f1531154c86b20f0902 [/trunk] Changeset 201 by mikael * Add hbuf_previous_persistent(). Now we should not jump to the buffer's bottom when increasing the screen width. diff -r 7604e3cdbb86 -r 4f3975f1b852 mcabber/src/TODO --- a/mcabber/src/TODO Fri May 06 09:58:44 2005 +0000 +++ b/mcabber/src/TODO Fri May 06 14:34:51 2005 +0000 @@ -13,10 +13,9 @@ * Key bindings (ex: F5 <-> /group toggle) * Pending message not displayed if buddy outside Contact window, maybe we could show it someway (maybe just a flag?). -* Add a function in hbuf ~previous_persistent(hbuf *top) (to avoid loosing the - top variable on a resize). * Show number of online contacts in folded groups * Buddy buffer in full width (handy for cut'n paste!) +* Emacs key bindings in input line (ctrl-w, ctrl-t) * Commands! :-) - /roster diff -r 7604e3cdbb86 -r 4f3975f1b852 mcabber/src/hbuf.c --- 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.) diff -r 7604e3cdbb86 -r 4f3975f1b852 mcabber/src/hbuf.h --- a/mcabber/src/hbuf.h Fri May 06 09:58:44 2005 +0000 +++ b/mcabber/src/hbuf.h Fri May 06 14:34:51 2005 +0000 @@ -30,6 +30,7 @@ guint prefix_flags, guint width); void hbuf_free(GList **p_hbuf); void hbuf_rebuild(GList **p_hbuf, unsigned int width); +GList *hbuf_previous_persistent(GList *l_line); hbb_line **hbuf_get_lines(GList *hbuf, unsigned int n); diff -r 7604e3cdbb86 -r 4f3975f1b852 mcabber/src/screen.c --- a/mcabber/src/screen.c Fri May 06 09:58:44 2005 +0000 +++ b/mcabber/src/screen.c Fri May 06 14:34:51 2005 +0000 @@ -533,6 +533,7 @@ list_for_each_safe(pos, n, &window_list) { search_entry = window_entry(pos); if (search_entry->win) { + GList *rescue_top; // Resize buddy window (no need to move it) wresize(search_entry->win, lines, cols); werase(search_entry->win); @@ -541,8 +542,11 @@ replace_panel(search_entry->panel, search_entry->win); } // Redo line wrapping + rescue_top = hbuf_previous_persistent(search_entry->top); hbuf_rebuild(&search_entry->hbuf, maxX - ROSTER_WIDTH - PREFIX_WIDTH); + if (g_list_position(g_list_first(search_entry->hbuf), search_entry->top) == -1) + search_entry->top = rescue_top; } }