From: Christoph Berg Date: Mon, 28 Feb 2005 15:15:23 +0000 (+0000) Subject: I've updated the menu_context patch to reintroduce the menu_move_off X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e7b130b491a41d9da77332c1239068e0e14670bc;p=neomutt I've updated the menu_context patch to reintroduce the menu_move_off 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 work even if there are less messages than screen lines (thanks to René Clerc and Vincent Lefevre for spotting these issues). --- diff --git a/init.h b/init.h index b1088e330..413103ad1 100644 --- 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 18e00d624..0600c03e2 100644 --- 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 289f6ec0b..1376c5b30 100644 --- 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,