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

Re: PATCH: index_context: like pager_context



Re: Mike Schiraldi in <20040118234027.GB9036@xxxxxxxxxxxx>
> A long time ago, i wrote a patch that adds a variable, index_context, which
> works like pager_context: When moving the indicator through the index,
> scrolling will start happening n lines early -- in other words, before you
> reach the end of the screen. This is useful for exactly the same reason
> pager_context is useful -- it allows you to always see a few messages ahead
> and it lets you know when you're getting close to the end.
> 
> I've been using this for years, and it seems to work great. But it sure
> would be nice if it was included into mutt so i wouldn't have to keep
> applying the patch myself.

I've been using an older version of this patch for several months now
(patch-1.4.mgs.index-context.4) and I really love it. I've tested the
patch Mike sent with his mail and it seems to work equally well (some
lines concerning index redraw were moved around).

> See attached.

Attached is a version of that patch with a proper PATCHES entry.

Christoph
-- 
Christoph Berg <cb@xxxxxxxxxxxxxxxx>, http://www.df7cb.de/
Wohnheim D, 2405, Universität des Saarlandes, 0681/9657944
diff -ur ../MUTT/mutt/PATCHES mutt/PATCHES
--- ../MUTT/mutt/PATCHES        2002-12-09 18:44:54.000000000 +0100
+++ mutt/PATCHES        2004-01-19 14:18:37.000000000 +0100
@@ -0,0 +1 @@
+patch-1.5.5.1.mgs.index-context.5
Nur in mutt: PATCHES~.
diff -ur ../MUTT/mutt/globals.h mutt/globals.h
--- ../MUTT/mutt/globals.h      2003-07-15 13:41:32.000000000 +0200
+++ mutt/globals.h      2004-01-19 14:17:42.000000000 +0100
@@ -142,6 +142,7 @@
 
 WHERE short ConnectTimeout;
 WHERE short HistSize;
+WHERE short IndexContext;
 WHERE short PagerContext;
 WHERE short PagerIndexLines;
 WHERE short ReadInc;
diff -ur ../MUTT/mutt/init.h mutt/init.h
--- ../MUTT/mutt/init.h 2004-01-05 19:49:00.000000000 +0100
+++ mutt/init.h 2004-01-19 14:17:42.000000000 +0100
@@ -883,6 +883,12 @@
   { "indent_str",      DT_SYN,  R_NONE, UL "indent_string", 0 },
   /*
   */
+  { "index_context",   DT_NUM,  R_NONE, UL &IndexContext, 0 },
+  /*
+  ** .pp
+  ** This variable controls the number of lines of context that are given
+  ** when scrolling through the message index.
+  */
   { "index_format",    DT_STR,  R_BOTH, UL &HdrFmt, UL "%4C %Z %{%b %d} 
%-15.15L (%?l?%4l&%4c?) %s" },
   /*
   ** .pp
diff -ur ../MUTT/mutt/menu.c mutt/menu.c
--- ../MUTT/mutt/menu.c 2004-01-05 19:49:00.000000000 +0100
+++ mutt/menu.c 2004-01-19 14:17:42.000000000 +0100
@@ -373,32 +373,34 @@
 
 void menu_check_recenter (MUTTMENU *menu)
 {
+  int ic = MIN (IndexContext, menu->pagelen / 2);
+  int old_top = menu->top;
+
   if (menu->max <= menu->pagelen && menu->top != 0)
   {
     menu->top = 0;
     set_option (OPTNEEDREDRAW);
-    menu->redraw |= REDRAW_INDEX;
   }
-  else if (menu->current >= menu->top + menu->pagelen)
+  else if (menu->current >= menu->top + menu->pagelen - ic)
   {
     if (option (OPTMENUSCROLL) || (menu->pagelen <= 0))
-      menu->top = menu->current - menu->pagelen + 1;
+      menu->top = menu->current - menu->pagelen + ic + 1;
     else
       menu->top += menu->pagelen * ((menu->current - menu->top) / 
menu->pagelen);
-    menu->redraw |= REDRAW_INDEX;
   }
-  else if (menu->current < menu->top)
+  else if (menu->current < menu->top + ic)
   {
     if (option (OPTMENUSCROLL) || (menu->pagelen <= 0))
-      menu->top = menu->current;
+      menu->top = menu->current - ic;
     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 = 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)
@@ -482,7 +484,9 @@
 
 void menu_prev_page (MUTTMENU *menu)
 {
-  if (menu->top > 0)
+  int ic = MIN (IndexContext, menu->pagelen / 2);
+
+  if (menu->top > ic)
   {
     if ((menu->top -= menu->pagelen) < 0)
       menu->top = 0;

Attachment: signature.asc
Description: Digital signature