Hi everyone,
as a matter of exercise, I've implemented a new mutt option (see the
description in init.h for the details).
If you like it, please feel free to merge.
Kind regards,
Piotr Durlej
---
globals.h | 1 +
init.h | 14 ++++++++++++++
pager.c | 10 ++++++++--
3 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/globals.h b/globals.h
index fd63bd43..e20c4739 100644
--- a/globals.h
+++ b/globals.h
@@ -236,6 +236,7 @@ WHERE short HistSize;
WHERE short MenuContext;
WHERE short PagerContext;
WHERE short PagerIndexLines;
+WHERE short PagerMinIndexLines;
WHERE short PagerSkipQuotedContext;
WHERE short ReadInc;
WHERE short ReflowWrap;
diff --git a/init.h b/init.h
index dcb664f8..0d3fe87c 100644
--- a/init.h
+++ b/init.h
@@ -2440,6 +2440,20 @@ struct option_t MuttVars[] = {
** is less than $$pager_index_lines, then the index will only use as
** many lines as it needs.
*/
+ { "pager_min_index_lines", DT_NUM, R_PAGER, {.p=&PagerMinIndexLines}, {.l=0}
},
+ /*
+ ** .pp
+ ** Controls the \fIminimum\fP number of lines of the mini-index.
+ ** .pp
+ ** If the number of messages in the current folder is less than
+ ** $$pager_min_index_lines, then the index will be padded with empty lines,
+ ** allowing for a mini-index of a constant height.
+ ** This option is otherwise same as the $$pager_index_lines option.
+ ** .pp
+ ** When both $pager_min_index_lines and $pager_index_lines are set, the
+ ** $pager_min_index_lines option determines the minimum number of rows, and
+ ** the $pager_index_lines controls the maximum.
+ */
{ "pager_skip_quoted_context", DT_NUM, R_NONE, {.p=&PagerSkipQuotedContext},
{.l=0} },
/*
** .pp
diff --git a/pager.c b/pager.c
index 8df571ab..40b49425 100644
--- a/pager.c
+++ b/pager.c
@@ -1819,11 +1819,14 @@ static void pager_menu_redraw (MUTTMENU *pager_menu)
memcpy (rd->pager_status_window, MuttStatusWindow, sizeof(mutt_window_t));
rd->index_status_window->rows = rd->index_window->rows = 0;
- if (IsHeader (rd->extra) && PagerIndexLines)
+ if (IsHeader (rd->extra) && (PagerIndexLines || PagerMinIndexLines))
{
memcpy (rd->index_window, MuttIndexWindow, sizeof(mutt_window_t));
rd->index_window->rows = rd->indexlen > 0 ? rd->indexlen - 1 : 0;
+ if (PagerMinIndexLines && rd->index_window->rows <= PagerMinIndexLines)
+ rd->index_window->rows = PagerMinIndexLines - 1;
+
if (option (OPTSTATUSONTOP))
{
memcpy (rd->index_status_window, MuttStatusWindow,
sizeof(mutt_window_t));
@@ -1879,7 +1882,7 @@ static void pager_menu_redraw (MUTTMENU *pager_menu)
}
#endif
- if (IsHeader (rd->extra) && PagerIndexLines)
+ if (IsHeader (rd->extra) && (PagerIndexLines || PagerMinIndexLines))
{
if (rd->index == NULL)
{
@@ -1905,6 +1908,9 @@ static void pager_menu_redraw (MUTTMENU *pager_menu)
else
rd->index->top = rd->index->current - rd->indicator;
+ if (rd->index->top < 0)
+ rd->index->top = 0;
+
menu_redraw_index(rd->index);
}
--
2.44.0