<<< Date Index >>>     <<< Thread Index >>>

Re: For 1.5.9: menu_move_off (was: Change in behavior <current-middle>)



On Thu, 24 Mar 2005, Alain Bench wrote:
>     Applying both patches seems to fix above bullet. But still:
> 
>  · Do a <first-entry><next-page> and move cursor down 20 times with
> <next-entry> until you scroll 1 line. Do a <previous-page>, you should
> see 2-35. But you see 14-47.
> 
>  · Do a <first-entry><next-page><next-page>: You see 62-95. Do a
> <first-entry><next-page><next-entry><next-page>: You should also see
> 62-95. But you see 63-96.
> 
>     The destination of <next-page> and <previous-page> is dependent on
> initial cursor position, when it clearly should not. It should only
> depend on initial page position. Same for <half-down> and <half-up>.

Thanks for your testing and detailed information!
Does this patch fix them with no problem?

-- 
tamo
--- menu.c.BAK  2005-03-25 16:56:13.221302376 +0900
+++ menu.c      2005-03-25 16:57:13.978065944 +0900
@@ -386,14 +386,14 @@
     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;
+      menu->top = menu->current - c;
   }
   else if (menu->current < menu->top + c) /* indicator above top threshold */
   {
     if (option (OPTMENUSCROLL) || (menu->pagelen <= 0))
       menu->top = menu->current - c;
     else
-      menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 - 
menu->current) / (menu->pagelen - c)) - c;
+      menu->top = menu->current - menu->pagelen + 1 + c;
   }
 
   if (!option (OPTMENUMOVEOFF)) /* make entries stick to bottom */
@@ -467,13 +467,23 @@
 
 void menu_next_page (MUTTMENU *menu)
 {
+  int c = MIN (MenuContext, menu->pagelen / 2);
+  int adj = 0;
+  if (menu->current < menu->top + c)
+    adj = menu->top + c - menu->current;
+  else if (menu->current > menu->top + menu->pagelen - 1 - c)
+    adj = menu->top + menu->pagelen - 1 - c - menu->current;
+
   if (menu->max)
   {
     if (menu->top + menu->pagelen < menu->max)
     {
       menu->top += menu->pagelen;
-      if (menu->current < menu->top)
-       menu->current = menu->top;
+      if (!option (OPTMENUMOVEOFF) && menu->top + menu->pagelen > menu->max)
+       menu->top = menu->max - menu->pagelen;
+      if (menu->current < menu->top + c)
+       menu->current += menu->pagelen + adj;
+      menu->current = MIN (menu->current, menu->max - 1);
       menu->redraw = REDRAW_INDEX;
     }
     else if (menu->current != menu->max - 1 && !menu->dialog)
@@ -491,13 +501,19 @@
 void menu_prev_page (MUTTMENU *menu)
 {
   int c = MIN (MenuContext, menu->pagelen / 2);
+  int adj = 0;
+  if (menu->current < menu->top + c)
+    adj = menu->top + c - menu->current;
+  else if (menu->current > menu->top + menu->pagelen - 1 - c)
+    adj = menu->top + menu->pagelen - 1 - c - menu->current;
 
-  if (menu->top > c)
+  if (menu->top > 0)
   {
     if ((menu->top -= menu->pagelen) < 0)
       menu->top = 0;
-    if (menu->current >= menu->top + menu->pagelen)
-      menu->current = menu->top + menu->pagelen - 1;
+    if (menu->current > menu->top + menu->pagelen - 1 - c)
+      menu->current -= menu->pagelen - adj;
+    menu->current = MAX (menu->current, 0);
     menu->redraw = REDRAW_INDEX;
   }
   else if (menu->current && !menu->dialog)