summaryrefslogtreecommitdiffstats
path: root/menu.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2016-04-27 17:56:51 -0700
committerKevin McCarthy <kevin@8t8.us>2016-04-27 17:56:51 -0700
commit26b9d967846742ea90ddc37a8b0dd71dde2e0be6 (patch)
tree06ab458ca63e880f090b56ac2c4b1aa48b8bd6b0 /menu.c
parent79728dfeef62bbd27842019857105273be411e68 (diff)
Modify the menu code to use windows.
Change menu.c to use the mutt_window_t structures and functions. The index/stats/help/message window pointers are stored inside the menu_t. This is useful for the pager, where the "index" we want to use is a mini-index.
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c77
1 files changed, 40 insertions, 37 deletions
diff --git a/menu.c b/menu.c
index 828df9c1..a715fb91 100644
--- a/menu.c
+++ b/menu.c
@@ -180,11 +180,11 @@ static void menu_make_entry (char *s, int l, MUTTMENU *menu, int i)
menu->make_entry (s, l, menu, i);
}
-static void menu_pad_string (char *s, size_t n)
+static void menu_pad_string (MUTTMENU *menu, char *s, size_t n)
{
char *scratch = safe_strdup (s);
int shift = option (OPTARROWCURSOR) ? 3 : 0;
- int cols = COLS - shift;
+ int cols = menu->indexwin->cols - shift;
mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
s[n - 1] = 0;
@@ -193,6 +193,9 @@ static void menu_pad_string (char *s, size_t n)
void menu_redraw_full (MUTTMENU *menu)
{
+#if ! (defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM))
+ mutt_reflow_windows ();
+#endif
NORMAL_COLOR;
/* clear() doesn't optimize screen redraws */
move (0, 0);
@@ -201,17 +204,12 @@ void menu_redraw_full (MUTTMENU *menu)
if (option (OPTHELP))
{
SETCOLOR (MT_COLOR_STATUS);
- move (option (OPTSTATUSONTOP) ? LINES-2 : 0, 0);
- mutt_paddstr (COLS, menu->help);
+ mutt_window_move (menu->helpwin, 0, 0);
+ mutt_paddstr (menu->helpwin->cols, menu->help);
NORMAL_COLOR;
- menu->offset = 1;
- menu->pagelen = LINES - 3;
- }
- else
- {
- menu->offset = option (OPTSTATUSONTOP) ? 1 : 0;
- menu->pagelen = LINES - 2;
}
+ menu->offset = 0;
+ menu->pagelen = menu->indexwin->rows;
mutt_show_error ();
@@ -224,8 +222,8 @@ void menu_redraw_status (MUTTMENU *menu)
snprintf (buf, sizeof (buf), M_MODEFMT, menu->title);
SETCOLOR (MT_COLOR_STATUS);
- move (option (OPTSTATUSONTOP) ? 0 : LINES - 2, 0);
- mutt_paddstr (COLS, buf);
+ mutt_window_move (menu->statuswin, 0, 0);
+ mutt_paddstr (menu->statuswin->cols, buf);
NORMAL_COLOR;
menu->redraw &= ~REDRAW_STATUS;
}
@@ -244,10 +242,10 @@ void menu_redraw_index (MUTTMENU *menu)
attr = menu->color(i);
menu_make_entry (buf, sizeof (buf), menu, i);
- menu_pad_string (buf, sizeof (buf));
+ menu_pad_string (menu, buf, sizeof (buf));
ATTRSET(attr);
- move(i - menu->top + menu->offset, 0);
+ mutt_window_move (menu->indexwin, i - menu->top + menu->offset, 0);
do_color = 1;
if (i == menu->current)
@@ -270,7 +268,7 @@ void menu_redraw_index (MUTTMENU *menu)
else
{
NORMAL_COLOR;
- CLEARLINE(i - menu->top + menu->offset);
+ mutt_window_clearline (menu->indexwin, i - menu->top + menu->offset);
}
}
NORMAL_COLOR;
@@ -287,7 +285,7 @@ void menu_redraw_motion (MUTTMENU *menu)
return;
}
- move (menu->oldcurrent + menu->offset - menu->top, 0);
+ mutt_window_move (menu->indexwin, menu->oldcurrent + menu->offset - menu->top, 0);
ATTRSET(menu->color (menu->oldcurrent));
if (option (OPTARROWCURSOR))
@@ -298,27 +296,27 @@ void menu_redraw_motion (MUTTMENU *menu)
if (menu->redraw & REDRAW_MOTION_RESYNCH)
{
menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
- menu_pad_string (buf, sizeof (buf));
- move (menu->oldcurrent + menu->offset - menu->top, 3);
+ menu_pad_string (menu, buf, sizeof (buf));
+ mutt_window_move (menu->indexwin, menu->oldcurrent + menu->offset - menu->top, 3);
print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
}
/* now draw it in the new location */
SETCOLOR(MT_COLOR_INDICATOR);
- mvaddstr(menu->current + menu->offset - menu->top, 0, "->");
+ mutt_window_mvaddstr (menu->indexwin, menu->current + menu->offset - menu->top, 0, "->");
}
else
{
/* erase the current indicator */
menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
- menu_pad_string (buf, sizeof (buf));
+ menu_pad_string (menu, buf, sizeof (buf));
print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
/* now draw the new one to reflect the change */
menu_make_entry (buf, sizeof (buf), menu, menu->current);
- menu_pad_string (buf, sizeof (buf));
+ menu_pad_string (menu, buf, sizeof (buf));
SETCOLOR(MT_COLOR_INDICATOR);
- move(menu->current - menu->top + menu->offset, 0);
+ mutt_window_move (menu->indexwin, menu->current + menu->offset - menu->top, 0);
print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
}
menu->redraw &= REDRAW_STATUS;
@@ -329,10 +327,10 @@ void menu_redraw_current (MUTTMENU *menu)
{
char buf[LONG_STRING];
int attr = menu->color (menu->current);
-
- move (menu->current + menu->offset - menu->top, 0);
+
+ mutt_window_move (menu->indexwin, menu->current + menu->offset - menu->top, 0);
menu_make_entry (buf, sizeof (buf), menu, menu->current);
- menu_pad_string (buf, sizeof (buf));
+ menu_pad_string (menu, buf, sizeof (buf));
SETCOLOR(MT_COLOR_INDICATOR);
if (option (OPTARROWCURSOR))
@@ -340,7 +338,7 @@ void menu_redraw_current (MUTTMENU *menu)
addstr ("->");
ATTRSET(attr);
addch (' ');
- menu_pad_string (buf, sizeof (buf));
+ menu_pad_string (menu, buf, sizeof (buf));
print_enriched_string (attr, (unsigned char *) buf, 1);
}
else
@@ -362,8 +360,8 @@ static void menu_redraw_prompt (MUTTMENU *menu)
if (*Errorbuf)
mutt_clear_error ();
- mvaddstr (LINES - 1, 0, menu->prompt);
- clrtoeol ();
+ mutt_window_mvaddstr (menu->messagewin, 0, 0, menu->prompt);
+ mutt_window_clrtoeol (menu->messagewin);
}
}
@@ -688,9 +686,13 @@ MUTTMENU *mutt_new_menu (int menu)
p->menu = menu;
p->current = 0;
p->top = 0;
- p->offset = 1;
+ p->offset = 0;
p->redraw = REDRAW_FULL;
- p->pagelen = PAGELEN;
+ p->pagelen = MuttIndexWindow->rows;
+ p->indexwin = MuttIndexWindow;
+ p->statuswin = MuttStatusWindow;
+ p->helpwin = MuttHelpWindow;
+ p->messagewin = MuttMessageWindow;
p->color = default_color;
p->search = menu_search_generic;
return (p);
@@ -873,11 +875,12 @@ int mutt_menuLoop (MUTTMENU *menu)
if (option (OPTARROWCURSOR))
- move (menu->current - menu->top + menu->offset, 2);
+ mutt_window_move (menu->indexwin, menu->current - menu->top + menu->offset, 2);
else if (option (OPTBRAILLEFRIENDLY))
- move (menu->current - menu->top + menu->offset, 0);
+ mutt_window_move (menu->indexwin, menu->current - menu->top + menu->offset, 0);
else
- move (menu->current - menu->top + menu->offset, COLS - 1);
+ mutt_window_move (menu->indexwin, menu->current - menu->top + menu->offset,
+ menu->indexwin->cols - 1);
mutt_refresh ();
@@ -890,11 +893,11 @@ int mutt_menuLoop (MUTTMENU *menu)
{
if (menu->tagged)
{
- mvaddstr (LINES - 1, 0, "Tag-");
- clrtoeol ();
+ mutt_window_mvaddstr (menu->messagewin, 0, 0, "Tag-");
+ mutt_window_clrtoeol (menu->messagewin);
i = km_dokey (menu->menu);
menu->tagprefix = 1;
- CLEARLINE (LINES - 1);
+ mutt_window_clearline (menu->messagewin, 0);
}
else if (i == OP_TAG_PREFIX)
{