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

Re: mutt/2019: menu_context itches



On 2005-10-31 19:55:01 +0100, Alain Bench wrote:

>      Your patch fixes the break-dance in said conditions, but
>  unfortunately creates other problems in other conditions. Especially
>  cursor altitude is no more stable in odd menu height, in all conditions
>  $menu_context keeps one less margin below indicator, and scrolling down
>  with $menu_context=0 overwrites pager status line.

ooops.

>      Or same but clearer the
>  patch-1.5.11.ab.menu_context_itches_2019.2a (against straight
>  1.5.11) I upload to Gnats. With big $menu_context this should
>  always give stable altitude cursor: Centered on an odd height
>  menu, and just below center on an even one.

I had missed your patch.

I don't like the explicit special-casing, though...  So, why don't
we change the flow of control a little bit, as in the patch below?

(Let me know if I'm missing another corner case with that version. ;-)

-- 
Thomas Roessler · Personal soap box at <http://log.does-not-exist.org/>.





diff -u -r3.22 menu.c
--- menu.c      31 Oct 2005 10:29:45 -0000      3.22
+++ menu.c      1 Nov 2005 08:29:12 -0000
@@ -384,19 +384,32 @@
       set_option (OPTNEEDREDRAW);
     }
   }
-  else if (menu->current >= menu->top + menu->pagelen - c) /* indicator below 
bottom threshold */
-  {
-    if (option (OPTMENUSCROLL) || (menu->pagelen <= 0))
-      menu->top = menu->current - menu->pagelen + c;
-    else
-      menu->top += (menu->pagelen - c) * ((menu->current - menu->top) / 
(menu->pagelen - c)) - c;
-  }
-  else if (menu->current < menu->top + c) /* indicator above top threshold */
+  else 
   {
-    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;
+    /* 
+     * 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))
+       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) /* indicator below 
bottom threshold */
+    {
+      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 (!option (OPTMENUMOVEOFF)) /* make entries stick to bottom */