I've updated the menu_context patch to reintroduce the menu_move_off
authorChristoph Berg <cb@df7cb.de>
Mon, 28 Feb 2005 15:15:23 +0000 (15:15 +0000)
committerChristoph Berg <cb@df7cb.de>
Mon, 28 Feb 2005 15:15:23 +0000 (15:15 +0000)
variable that hasn't made it into 1.5.8. The patch fixes
menu_prev_line and menu_next_line which didn't work with
menu_context > 0 and also makes <current-middle> work even if there
are less messages than screen lines (thanks to René Clerc and
Vincent Lefevre for spotting these issues).

init.h
menu.c
mutt.h

diff --git a/init.h b/init.h
index b1088e330a0e30fb7b91265175e9d497d723d948..413103ad1d5b0a157bc5916fc5417c9de2df1212 100644 (file)
--- a/init.h
+++ b/init.h
@@ -1096,6 +1096,13 @@ struct option_t MuttVars[] = {
   ** 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, 0 },
+  /*
+  ** .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 --git a/menu.c b/menu.c
index 18e00d624ffb1bc2667d56fca465f57d100b7569..0600c03e2b08a02656e9cbfd70f9043ad47ca8cb 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -374,7 +374,7 @@ void menu_check_recenter (MUTTMENU *menu)
   int c = MIN (MenuContext, menu->pagelen / 2);
   int old_top = menu->top;
 
-  if (menu->max <= menu->pagelen) /* less entries than lines */
+  if (!option (OPTMENUMOVEOFF) && menu->max <= menu->pagelen) /* less entries than lines */
   {
     if (menu->top != 0) {
       menu->top = 0;
@@ -396,8 +396,8 @@ void menu_check_recenter (MUTTMENU *menu)
       menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 - menu->current) / (menu->pagelen - c)) - c;
   }
 
-  /* make entries stick to bottom */
-  menu->top = MIN (menu->top, menu->max - menu->pagelen);
+  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)
@@ -433,10 +433,13 @@ void menu_next_line (MUTTMENU *menu)
 {
   if (menu->max)
   {
-    if (menu->top + 1 < menu->max)
+    int c = MIN (MenuContext, menu->pagelen / 2);
+
+    if (menu->top + 1 < menu->max - c
+      && (option(OPTMENUMOVEOFF) || (menu->max > menu->pagelen && menu->top < menu->max - menu->pagelen)))
     {
       menu->top++;
-      if (menu->current < menu->top)
+      if (menu->current < menu->top + c && menu->current < menu->max - 1)
        menu->current++;
       menu->redraw = REDRAW_INDEX;
     }
@@ -451,8 +454,10 @@ void menu_prev_line (MUTTMENU *menu)
 {
   if (menu->top > 0)
   {
+    int c = MIN (MenuContext, menu->pagelen / 2);
+
     menu->top--;
-    if (menu->current >= menu->top + menu->pagelen)
+    if (menu->current >= menu->top + menu->pagelen - c && menu->current > 1)
       menu->current--;
     menu->redraw = REDRAW_INDEX;
   }
diff --git a/mutt.h b/mutt.h
index 289f6ec0bdd3e5f8a9bc3b06e908e898462d666d..1376c5b304131539e86e9fbd0b34fac8f2952fd2 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -388,6 +388,7 @@ enum
   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,