Hello, I'd like to suggest menu_context for inclusion in mutt 1.5.8. 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). I couldn't live without that patch any more, since the context will make it immediately visible if there's new mail. Without it, the indicator could still sit at the bottom of the screen with the new messages being on the next page. (Of course, this behaviour is optional, and the default is the old behaviour.) 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) Christoph Berg <cb@xxxxxxxx> ------------------------------------------------------------------------ diff -urp ../MUTT/mutt/PATCHES mutt/PATCHES --- ../MUTT/mutt/PATCHES 2002-12-09 18:44:54.000000000 +0100 +++ mutt/PATCHES 2005-02-10 00:52:29.000000000 +0100 @@ -0,0 +1 @@ +patch-1.5.7.cb.menu_context.7 diff -urp ../MUTT/mutt/globals.h mutt/globals.h --- ../MUTT/mutt/globals.h 2005-02-10 00:26:04.000000000 +0100 +++ mutt/globals.h 2005-02-10 00:32:37.000000000 +0100 @@ -160,6 +160,7 @@ WHERE unsigned short Counter INITVAL (0) WHERE short ConnectTimeout; WHERE short HistSize; +WHERE short MenuContext; WHERE short PagerContext; WHERE short PagerIndexLines; WHERE short ReadInc; diff -urp ../MUTT/mutt/init.h mutt/init.h --- ../MUTT/mutt/init.h 2005-02-10 00:26:04.000000000 +0100 +++ mutt/init.h 2005-02-10 00:32:37.000000000 +0100 @@ -1090,6 +1090,19 @@ struct option_t MuttVars[] = { ** 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 -urp ../MUTT/mutt/menu.c mutt/menu.c --- ../MUTT/mutt/menu.c 2005-02-10 00:26:04.000000000 +0100 +++ mutt/menu.c 2005-02-10 00:32:37.000000000 +0100 @@ -371,32 +371,37 @@ void menu_redraw_prompt (MUTTMENU *menu) 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) @@ -480,7 +485,9 @@ void menu_next_page (MUTTMENU *menu) 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 -urp ../MUTT/mutt/mutt.h mutt/mutt.h --- ../MUTT/mutt/mutt.h 2005-02-10 00:26:04.000000000 +0100 +++ mutt/mutt.h 2005-02-10 00:32:37.000000000 +0100 @@ -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,
Attachment:
signature.asc
Description: Digital signature