Re: mutt/2019: menu_context itches
On 2005-11-03 18:45:03 +0100, Oswald Buddenhagen wrote:
> now, 1) if the index has fewer lines than menu_context and the
> number of lines is odd/even (pick one :), menu_context seems to
> have no effect at all (the cursor should be just kept in the
> middle, like it is in the other case). 2) when the index is long
> enough, the cursor can still have an initial position outside
> menu_context; this also happens after resizing the terminal.
> this leads either to scrolling in the wrong direction or to a
> jump recenter, depending on the terminal size (i think).
Mhhh... Basically, if menu_context grows too large, we want
menu_scroll behavior regardless of whether or not that option is
set.
I seem to be unable to reproduce the problems that we've seen with
the attached patch against current CVS, but I might still overlook
some corner case.
--
Thomas Roessler · Personal soap box at <http://log.does-not-exist.org/>.
diff -u -r3.23 menu.c
--- menu.c 1 Nov 2005 08:42:00 -0000 3.23
+++ menu.c 17 Nov 2005 17:19:29 -0000
@@ -379,36 +379,27 @@
if (!option (OPTMENUMOVEOFF) && menu->max <= menu->pagelen) /* less entries
than lines */
{
- if (menu->top != 0) {
+ if (menu->top != 0)
+ {
menu->top = 0;
set_option (OPTNEEDREDRAW);
}
}
else
{
- /*
- * If c = menu->pagelen / 2 and menu->pagelen is even, then (obviously):
- *
- * menu->top + menu->pagelen - c == menu->top + c
- *
- * In that case, having an "else if" below leads to what has become known
as the
- * indicator break dance effect. Instead of special-casing, we just
forget the
- * "else".
- */
-
- if (menu->current < menu->top + c) /* indicator above top threshold */
+ if (option (OPTMENUSCROLL) || (menu->pagelen <= 0) || c <= MenuContext)
{
- if (option (OPTMENUSCROLL) || (menu->pagelen <= 0))
+ if (menu->current < menu->top + c)
menu->top = menu->current - c;
- else
- menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 -
menu->current) / (menu->pagelen - c)) - c;
+ if (menu->current >= menu->top + menu->pagelen - c)
+ menu->top = menu->current - menu->pagelen + c + 1;
}
- if (menu->current >= menu->top + menu->pagelen - c) /* indicator below
bottom threshold */
+ else
{
- if (option (OPTMENUSCROLL) || (menu->pagelen <= 0))
- menu->top = menu->current - menu->pagelen + c + 1;
- else
- menu->top += (menu->pagelen - c) * ((menu->current - menu->top) /
(menu->pagelen - c)) - c;
+ if (menu->current < menu->top + c)
+ menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 -
menu->current) / (menu->pagelen - c)) - c;
+ else if (menu->current >= menu->top + menu->pagelen - c)
+ menu->top += (menu->pagelen - c) * ((menu->current - menu->top) /
(menu->pagelen - c)) - c;
}
}