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

Re: mutt/2019: menu_context itches



The following reply was made to PR mutt/2019; it has been noted by GNATS.

From: Thomas Roessler <roessler@xxxxxxxxxxxxxxxxxx>
To: bug-any@xxxxxxxxxxxxx
Cc: Mutt Developers <mutt-dev@xxxxxxxx>
Subject: Re: mutt/2019: menu_context itches
Date: Tue, 1 Nov 2005 09:33:57 +0100

 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=3D0 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. ;-)
 
 --=20
 Thomas Roessler =B7 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 >=3D menu->top + menu->pagelen - c) /* indicator =
 below bottom threshold */
 -  {
 -    if (option (OPTMENUSCROLL) || (menu->pagelen <=3D 0))
 -      menu->top =3D menu->current - menu->pagelen + c;
 -    else
 -      menu->top +=3D (menu->pagelen - c) * ((menu->current - menu->top) / =
 (menu->pagelen - c)) - c;
 -  }
 -  else if (menu->current < menu->top + c) /* indicator above top threshold=
  */
 +  else=20
    {
 -    if (option (OPTMENUSCROLL) || (menu->pagelen <=3D 0))
 -      menu->top =3D menu->current - c;
 -    else
 -      menu->top -=3D (menu->pagelen - c) * ((menu->top + menu->pagelen - 1=
  - menu->current) / (menu->pagelen - c)) - c;
 +    /*=20
 +     * If c =3D menu->pagelen / 2 and menu->pagelen is even, then (obvious=
 ly):
 +     *=20
 +     *   menu->top + menu->pagelen - c =3D=3D menu->top + c
 +     *
 +     * In that case, having an "else if" below leads to what has become kn=
 own as the
 +     * indicator break dance effect.  Instead of special-casing, we just f=
 orget the=20
 +     * "else".
 +     */
 +   =20
 +    if (menu->current < menu->top + c) /* indicator above top threshold */
 +    {
 +      if (option (OPTMENUSCROLL) || (menu->pagelen <=3D 0))
 +      menu->top =3D menu->current - c;
 +      else
 +      menu->top -=3D (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 - 
me=
 nu->current) / (menu->pagelen - c)) - c;
 +    }
 +    if (menu->current >=3D menu->top + menu->pagelen - c) /* indicator bel=
 ow bottom threshold */
 +    {
 +      if (option (OPTMENUSCROLL) || (menu->pagelen <=3D 0))
 +      menu->top =3D menu->current - menu->pagelen + c + 1;
 +      else
 +      menu->top +=3D (menu->pagelen - c) * ((menu->current - menu->top) / 
(menu=
 ->pagelen - c)) - c;
 +    }
    }
 =20
    if (!option (OPTMENUMOVEOFF)) /* make entries stick to bottom */