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

Re: [PATCH] menu_context (was: Re: index_context: like pager_context)



Re: Alain Bench in <20040312134805.GA19667@xxxxxxx>
> > The new $menu_move_off option controls whether the menu entries are
> > allowed to move off from the bottom of the menu.
> 
>     Good option. But there is a little glitch in case:
> 
> | set menu_scroll menu_move_off menu_context=7
> 
>     ...and the index has near as much total lines as are visible. Say on
> a 80x25 term you have 22 visible lines, and you <limit>~m-22<enter>. Now
> move down indicator with <next-entry>, <next-undeleted> or such. When
> indicator reaches near bottom, display begins to jump up and down.

Thanks for the report - the problem was even more annoying, the index
jumped up an down on pressing ^L, and also every $timeout seconds. I've
fixed it in menu_context.7.

>     BTW here is an extract of a mail to Mike: It may be of interest, and
> the little problem reported is still valid for menu_context.6
[...]
> | I'm not sure, but seem to have understood that's this very effect on
> | page jumps that caused not inclusion in Mutt... Source: Discussion by
> | Michael Elkins on mutt-dev, msgid <20020329183608.GA3064@xxxxxxxxxxx>.

I'll look at it soon.

Christoph
-- 
cb@xxxxxxxx | http://www.df7cb.de/
patch-1.5.6.cb.menu_context.7
-----------------------------

This patch introduces two new options, menu_context and menu_move_off. It is an
improved version of patch-1.5.5.1.mgs.index-context.5 my Mike Schiraldi (where
menu_context was called index_context).

  6.3.101.  menu_context

  Type: number
  Default: 0

  This variable controls the number of lines of context that are given
  when scrolling through menus. (Similar to ````$pager_context''''.)

  6.3.102.  menu_move_off

  Type: boolean
  Default: yes

  When unset, the bottom entry of menus will never scroll up past the
  bottom of the screen, unless there are less entries than lines.  When
  set, the bottom entry may move off the bottom.

Patch homepage: http://www.df7cb.de/projects/mutt/

Changelog:
  menu_context.6: 2004-03-06
    new option menu_move_off
  menu_context.7: 2004-03-20
    fixed jumping menu in case menu->max <= menu->pagelen
    (Thanks to Alain Bench for the report)

Bugs/Wishlist:

    BTW here is an extract of a mail to Mike: It may be of interest, and
the little problem reported is still valid for menu_context.6

| There is an annoying interaction with page jumps near top of index:
| Like with $index_context=7 and $menu_scroll=yes do a <first-entry>
| then <next-page><previous-page> in index: You should see top page
| again, say lines #1 to #34. But you see lines #8 to #41.
|
|
| More generally, I wonder if it would be possible or interesting to
| have $index_context act on scrolls (line by line), but still have full
| page jumps, perhaps with 0 or 1 line of context. Or *another* variable
| to set lines of context in page jump case. The indicator would still
| be placed $index_context lines from bottom of next page, but the said
| page would be fully new.
|
| I'm not sure, but seem to have understood that's this very effect on
| page jumps that caused not inclusion in Mutt... Source: Discussion by
| Michael Elkins on mutt-dev, msgid <20020329183608.GA3064@xxxxxxxxxxx>.
(Alain Bench)

More generally, $menu_move_off could less strict; e.g. Mutt's pager allows the
bottom line to move off on page scrolls, but not on line scrolls. The menus are
more complex however, since the pager does not have an indicator. Personally I
use "unset menu_move_off", but moving off with page scrolls could be nice in
some situations. On the other hand, I feel that even more options to configure
the menu behaviour would be overkill. Comments welcome. (cb)

Christoph Berg <cb@xxxxxxxx>

------------------------------------------------------------------------

diff -ur ../MUTT/mutt/PATCHES mutt/PATCHES
--- ../MUTT/mutt/PATCHES        2002-12-09 18:44:54.000000000 +0100
+++ mutt/PATCHES        2004-03-20 14:04:28.000000000 +0100
@@ -0,0 +1 @@
+patch-1.5.6.cb.menu_context.7
diff -ur ../MUTT/mutt/globals.h mutt/globals.h
--- ../MUTT/mutt/globals.h      2004-02-13 16:08:31.000000000 +0100
+++ mutt/globals.h      2004-03-06 13:51:46.000000000 +0100
@@ -144,6 +144,7 @@
 
 WHERE short ConnectTimeout;
 WHERE short HistSize;
+WHERE short MenuContext;
 WHERE short PagerContext;
 WHERE short PagerIndexLines;
 WHERE short ReadInc;
diff -ur ../MUTT/mutt/init.h mutt/init.h
--- ../MUTT/mutt/init.h 2004-02-13 16:08:31.000000000 +0100
+++ mutt/init.h 2004-03-20 14:04:28.000000000 +0100
@@ -1030,6 +1030,19 @@
   ** If unset, Mutt will remove your address (see the ``alternates''
   ** command) from the list of recipients when replying to a message.
   */
+  { "menu_context",    DT_NUM,  R_NONE, UL &MenuContext, 0 },
+  /*
+  ** .pp
+  ** This variable controls the number of lines of context that are given
+  ** when scrolling through menus. (Similar to ``$$pager_context''.)
+  */
+  { "menu_move_off",   DT_BOOL, R_NONE, OPTMENUMOVEOFF, 1 },
+  /*
+  ** .pp
+  ** When \fIunset\fP, the bottom entry of menus will never scroll up past
+  ** the bottom of the screen, unless there are less entries than lines.
+  ** When \fIset\fP, the bottom entry may move off the bottom.
+  */
   { "menu_scroll",     DT_BOOL, R_NONE, OPTMENUSCROLL, 0 },
   /*
   ** .pp
diff -ur ../MUTT/mutt/menu.c mutt/menu.c
--- ../MUTT/mutt/menu.c 2004-02-13 16:08:31.000000000 +0100
+++ mutt/menu.c 2004-03-20 14:37:09.000000000 +0100
@@ -367,32 +367,37 @@
 
 void menu_check_recenter (MUTTMENU *menu)
 {
-  if (menu->max <= menu->pagelen && menu->top != 0)
+  int c = MIN (MenuContext, menu->pagelen / 2);
+  int old_top = menu->top;
+
+  if (menu->max <= menu->pagelen) /* less entries than lines */
   {
-    menu->top = 0;
-    set_option (OPTNEEDREDRAW);
-    menu->redraw |= REDRAW_INDEX;
+    if (menu->top != 0) {
+      menu->top = 0;
+      set_option (OPTNEEDREDRAW);
+    }
   }
-  else if (menu->current >= menu->top + menu->pagelen)
+  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 + 1;
+      menu->top = menu->current - menu->pagelen + c + 1;
     else
-      menu->top += menu->pagelen * ((menu->current - menu->top) / 
menu->pagelen);
-    menu->redraw |= REDRAW_INDEX;
+      menu->top += (menu->pagelen - c) * ((menu->current - menu->top) / 
(menu->pagelen - c)) - c;
   }
-  else if (menu->current < menu->top)
+  else if (menu->current < menu->top + c) /* indicator above top threshold */
   {
     if (option (OPTMENUSCROLL) || (menu->pagelen <= 0))
-      menu->top = menu->current;
+      menu->top = menu->current - c;
     else
-    {
-      menu->top -= menu->pagelen * ((menu->top + menu->pagelen - 1 - 
menu->current) / menu->pagelen);
-      if (menu->top < 0)
-       menu->top = 0;
-    }
-    menu->redraw |= REDRAW_INDEX;
+      menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 - 
menu->current) / (menu->pagelen - c)) - c;
   }
+
+  if (!option (OPTMENUMOVEOFF)) /* make entries stick to bottom */
+    menu->top = MIN (menu->top, menu->max - menu->pagelen);
+  menu->top = MAX (menu->top, 0);
+
+  if (menu->top != old_top)
+    menu->redraw |= REDRAW_INDEX;
 }
 
 void menu_jump (MUTTMENU *menu)
@@ -476,7 +481,9 @@
 
 void menu_prev_page (MUTTMENU *menu)
 {
-  if (menu->top > 0)
+  int c = MIN (MenuContext, menu->pagelen / 2);
+
+  if (menu->top > c)
   {
     if ((menu->top -= menu->pagelen) < 0)
       menu->top = 0;
diff -ur ../MUTT/mutt/mutt.h mutt/mutt.h
--- ../MUTT/mutt/mutt.h 2004-02-13 16:08:32.000000000 +0100
+++ mutt/mutt.h 2004-03-06 14:39:56.000000000 +0100
@@ -376,6 +376,7 @@
   OPTMARKERS,
   OPTMARKOLD,
   OPTMENUSCROLL,       /* scroll menu instead of implicit next-page */
+  OPTMENUMOVEOFF,      /* allow menu to scroll past last entry */
   OPTMETAKEY,          /* interpret ALT-x as ESC-x */
   OPTMETOO,
   OPTMHPURGE,

Attachment: signature.asc
Description: Digital signature