#include <lib-ui/lib-ui.h>
-#include "enter.h"
#include "menu.h"
#include "mutt.h"
#include "charset.h"
#include <imap/imap.h>
-#include <lib-ui/sidebar.h>
-
-#define SW (option(OPTMBOXPANE)?SidebarWidth:0)
extern size_t UngetCount;
while (*s) {
if (*s < M_TREE_MAX) {
if (do_color)
- SETCOLOR (MT_COLOR_TREE);
+ SETCOLOR(main_w, MT_COLOR_TREE);
while (*s && *s < M_TREE_MAX) {
switch (*s) {
case M_TREE_LLCORNER:
- waddch (stdscr, ACS_LLCORNER);
+ waddch (main_w, ACS_LLCORNER);
break;
case M_TREE_ULCORNER:
- waddch (stdscr, ACS_ULCORNER);
+ waddch (main_w, ACS_ULCORNER);
break;
case M_TREE_LTEE:
- waddch (stdscr, ACS_LTEE);
+ waddch (main_w, ACS_LTEE);
break;
case M_TREE_HLINE:
- waddch (stdscr, ACS_HLINE);
+ waddch (main_w, ACS_HLINE);
break;
case M_TREE_VLINE:
- waddch (stdscr, ACS_VLINE);
+ waddch (main_w, ACS_VLINE);
break;
case M_TREE_TTEE:
- waddch (stdscr, ACS_TTEE);
+ waddch (main_w, ACS_TTEE);
break;
case M_TREE_BTEE:
- waddch (stdscr, ACS_BTEE);
+ waddch (main_w, ACS_BTEE);
break;
case M_TREE_SPACE:
- waddch (stdscr, ' ');
+ waddch (main_w, ' ');
break;
case M_TREE_RARROW:
- waddch (stdscr, '>');
+ waddch (main_w, '>');
break;
case M_TREE_STAR:
- waddch (stdscr, '*'); /* fake thread indicator */
+ waddch (main_w, '*'); /* fake thread indicator */
break;
case M_TREE_HIDDEN:
- waddch (stdscr, '&');
+ waddch (main_w, '&');
break;
case M_TREE_EQUALS:
- waddch (stdscr, '=');
+ waddch (main_w, '=');
break;
case M_TREE_MISSING:
- waddch (stdscr, '?');
+ waddch (main_w, '?');
break;
}
s++, n--;
}
if (do_color)
- wattrset (stdscr, attr);
+ wattrset (main_w, attr);
}
else if ((k = mbrtowc (&wc, (char *) s, n, &mbstate)) != (size_t)-1) {
- waddnstr (stdscr, (char *) s, k);
+ waddnstr (main_w, (char *) s, k);
s += k, n -= k;
}
else
static void menu_pad_string (char *s, size_t n)
{
- int cols = COLS - SW;
+ int cols = getmaxx(main_w);
char *tmpbuf = p_new(char, n);
mutt_format_string (tmpbuf, n, cols, cols, 0, ' ', s, m_strlen(s), 1);
void menu_redraw_full (MUTTMENU * menu)
{
- SETCOLOR (MT_COLOR_NORMAL);
- /* wclear(stdscr) doesn't optimize screen redraws */
- wmove (stdscr, 0, 0);
- wclrtobot (stdscr);
-
- SETCOLOR (MT_COLOR_STATUS);
- wmove (stdscr, option (OPTSTATUSONTOP) ? LINES - 2 : 0, SW);
- mutt_paddstr (COLS-SW, "");
- SETCOLOR (MT_COLOR_NORMAL);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
+ werase(main_w);
+ SETCOLOR(main_w, MT_COLOR_SIDEBAR);
+ mvwhline(main_w, LINES - 2, 0, ACS_HLINE, getmaxx(main_w));
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
menu->offset = 1;
menu->pagelen = LINES - 3;
mutt_show_error ();
char buf[STRING];
snprintf (buf, sizeof (buf), M_MODEFMT, menu->title);
- SETCOLOR (MT_COLOR_STATUS);
- wmove (stdscr, option (OPTSTATUSONTOP) ? 0 : LINES - 2, SW);
- mutt_paddstr (COLS-SW, buf);
- SETCOLOR (MT_COLOR_NORMAL);
+ SETCOLOR(main_w, MT_COLOR_STATUS);
+ wmove (main_w, 0, 0);
+ mutt_paddstr (main_w, getmaxx(main_w), buf);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
menu->redraw &= ~REDRAW_STATUS;
}
menu_make_entry (buf, sizeof (buf), menu, i);
menu_pad_string (buf, sizeof (buf));
- wattrset (stdscr, menu->color (i));
+ wattrset (main_w, menu->color (i));
if (i == menu->current) {
- ADDCOLOR (MT_COLOR_INDICATOR);
- BKGDSET (MT_COLOR_INDICATOR);
+ ADDCOLOR(main_w, MT_COLOR_INDICATOR);
+ BKGDSET(main_w, MT_COLOR_INDICATOR);
}
- CLEARLINE_WIN (i - menu->top + menu->offset);
+ CLEARLINE(main_w, i - menu->top + menu->offset);
- wmove (stdscr, i - menu->top + menu->offset, SW);
+ wmove (main_w, i - menu->top + menu->offset, 0);
print_enriched_string (menu->color (i), (unsigned char *) buf,
i != menu->current);
- SETCOLOR (MT_COLOR_NORMAL);
- BKGDSET (MT_COLOR_NORMAL);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
+ BKGDSET(main_w, MT_COLOR_NORMAL);
} else {
- CLEARLINE_WIN (i - menu->top + menu->offset);
+ CLEARLINE(main_w, i - menu->top + menu->offset);
}
}
sidebar_draw ();
return;
}
- wmove (stdscr, menu->oldcurrent + menu->offset - menu->top, SW);
- SETCOLOR (MT_COLOR_NORMAL);
- BKGDSET (MT_COLOR_NORMAL);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
+ BKGDSET(main_w, MT_COLOR_NORMAL);
/* erase the current indicator */
- wattrset (stdscr, menu->color (menu->oldcurrent));
- wclrtoeol (stdscr);
+ wattrset(main_w, menu->color(menu->oldcurrent));
+ wmove (main_w, menu->oldcurrent + menu->offset - menu->top, 0);
+ wclrtoeol (main_w);
menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
menu_pad_string (buf, sizeof (buf));
print_enriched_string (menu->color (menu->oldcurrent),
/* now draw the new one to reflect the change */
menu_make_entry (buf, sizeof (buf), menu, menu->current);
menu_pad_string (buf, sizeof (buf));
- wattrset (stdscr, menu->color (menu->current));
- ADDCOLOR (MT_COLOR_INDICATOR);
- BKGDSET (MT_COLOR_INDICATOR);
- CLEARLINE_WIN (menu->current - menu->top + menu->offset);
- wmove (stdscr, menu->current + menu->offset - menu->top, SW);
+ wattrset (main_w, menu->color (menu->current));
+ ADDCOLOR(main_w, MT_COLOR_INDICATOR);
+ BKGDSET(main_w, MT_COLOR_INDICATOR);
+ CLEARLINE(main_w, menu->current - menu->top + menu->offset);
+ wmove (main_w, menu->current + menu->offset - menu->top, 0);
print_enriched_string (menu->color (menu->current), (unsigned char *) buf,
0);
- SETCOLOR (MT_COLOR_NORMAL);
- BKGDSET (MT_COLOR_NORMAL);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
+ BKGDSET(main_w, MT_COLOR_NORMAL);
menu->redraw &= REDRAW_STATUS;
}
{
char buf[STRING];
- wmove (stdscr, menu->current + menu->offset - menu->top, SW);
menu_make_entry (buf, sizeof (buf), menu, menu->current);
menu_pad_string (buf, sizeof (buf));
- wattrset (stdscr, menu->color (menu->current));
- ADDCOLOR (MT_COLOR_INDICATOR);
- BKGDSET (MT_COLOR_INDICATOR);
- wclrtoeol (stdscr);
+ wattrset (main_w, menu->color (menu->current));
+ ADDCOLOR(main_w, MT_COLOR_INDICATOR);
+ BKGDSET(main_w, MT_COLOR_INDICATOR);
+ wmove (main_w, menu->current + menu->offset - menu->top, 0);
+ wclrtoeol (main_w);
print_enriched_string (menu->color (menu->current), (unsigned char *) buf,
0);
- SETCOLOR (MT_COLOR_NORMAL);
- BKGDSET (MT_COLOR_NORMAL);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
+ BKGDSET(main_w, MT_COLOR_NORMAL);
menu->redraw &= REDRAW_STATUS;
}
if (*Errorbuf)
mutt_clear_error ();
- SETCOLOR (MT_COLOR_NORMAL);
- mvwaddstr (stdscr, LINES - 1, 0, menu->prompt);
- wclrtoeol (stdscr);
+ SETCOLOR(stdscr, MT_COLOR_NORMAL);
+ mvwaddstr(stdscr, LINES - 1, 0, menu->prompt);
+ wclrtoeol(stdscr);
}
}
int c = MIN (MenuContext, menu->pagelen / 2);
int old_top = menu->top;
- if (!option (OPTMENUMOVEOFF) && menu->max <= menu->pagelen) { /* less entries than lines */
- if (menu->top != 0) {
- menu->top = 0;
- set_option (OPTNEEDREDRAW);
- }
+ if ((menu->pagelen <= 0) || (c < MenuContext)) {
+ if (menu->current < menu->top + c)
+ menu->top = menu->current - c;
+ else if (menu->current >= menu->top + menu->pagelen - c)
+ menu->top = menu->current - menu->pagelen + c + 1;
} else {
- if (option (OPTMENUSCROLL) || (menu->pagelen <= 0) || (c < MenuContext)) {
- if (menu->current < menu->top + c)
- menu->top = menu->current - c;
- else if (menu->current >= menu->top + menu->pagelen - c)
- menu->top = menu->current - menu->pagelen + c + 1;
- } else {
- if (menu->current < menu->top + c)
- menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 - menu->current) / (menu->pagelen - c)) - c;
- else if ((menu->current >= menu->top + menu->pagelen - c))
- menu->top += (menu->pagelen - c) * ((menu->current - menu->top) / (menu->pagelen - c)) - c;
- }
+ if (menu->current < menu->top + c)
+ menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 - menu->current) / (menu->pagelen - c)) - c;
+ else if ((menu->current >= menu->top + menu->pagelen - c))
+ menu->top += (menu->pagelen - c) * ((menu->current - menu->top) / (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)
if (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))) {
+ if (menu->top + 1 < menu->max - c) {
menu->top++;
if (menu->current < menu->top + c && menu->current < menu->max - 1)
menu->current++;
menu->redraw = REDRAW_INDEX;
- }
- else
+ } else {
mutt_error _("You cannot scroll down farther.");
- }
- else
+ }
+ } else {
mutt_error _("No entries.");
+ }
}
void menu_prev_line (MUTTMENU * menu)
menu->top += jumplen;
/* jumped too long? */
- if ((neg || !option (OPTMENUMOVEOFF)) && DIRECTION * menu->top > tmp)
+ if (neg && DIRECTION * menu->top > tmp)
menu->top = tmp;
/* need to move the cursor? */
char buf[LONG_STRING];
menu_make_entry (buf, sizeof (buf), m, n);
- return (regexec (re, buf, 0, NULL, 0));
+ return regexec (re, buf, 0, NULL, 0);
}
MUTTMENU *mutt_new_menu (void)
p->top = 0;
p->offset = 1;
p->redraw = REDRAW_FULL;
- p->pagelen = PAGELEN;
+ p->pagelen = LINES - 3;
p->color = default_color;
p->search = menu_search_generic;
- return (p);
+ return p;
}
void mutt_menuDestroy (MUTTMENU ** p)
if (mutt_get_field ((op == OP_SEARCH) ? _("Search for: ") :
_("Reverse search for: "),
buf, sizeof (buf), M_CLEAR) != 0 || !buf[0])
- return (-1);
+ return -1;
m_strreplace(&menu->searchBuf, buf);
menu->searchDir = (op == OP_SEARCH) ? M_SEARCH_DOWN : M_SEARCH_UP;
}
if (!menu->searchBuf) {
mutt_error _("No search pattern.");
- return (-1);
+ return -1;
}
}
regerror (r, &re, buf, sizeof (buf));
regfree (&re);
mutt_error ("%s", buf);
- return (-1);
+ return -1;
}
r = menu->current + searchDir;
regfree (&re);
mutt_error _("Not found.");
- return (-1);
+ return -1;
}
static int menu_dialog_translate_op (int i)
if (menu->redraw & REDRAW_FULL) {
menu_redraw_full (menu);
/* allow the caller to do any local configuration */
- return (OP_REDRAW);
+ return OP_REDRAW;
}
if (!menu->dialog)
return OP_REDRAW;
menu->oldcurrent = menu->current;
-
- if (option (OPTBRAILLEFRIENDLY))
- wmove (stdscr, menu->current - menu->top + menu->offset, SW);
- else
- wmove (stdscr, menu->current - menu->top + menu->offset, COLS - 1);
-
mutt_refresh ();
-
/* try to catch dialog keys before ops */
if (menu->dialog && menu_dialog_dokey (menu, &i) == 0)
return i;
i = km_dokey (menu->menu);
if (i == OP_TAG_PREFIX || i == OP_TAG_PREFIX_COND) {
if (menu->tagged) {
- mvwaddstr (stdscr, LINES - 1, 0, "Tag-");
- wclrtoeol (stdscr);
+ mvwaddstr(stdscr, LINES - 1, 0, "Tag-");
+ wclrtoeol(stdscr);
i = km_dokey (menu->menu);
menu->tagprefix = 1;
- CLEARLINE (LINES - 1);
+ CLEARLINE(stdscr, LINES - 1);
}
else if (i == OP_TAG_PREFIX) {
mutt_error _("No tagged entries.");
MAYBE_REDRAW (menu->redraw);
break;
- case OP_WHAT_KEY:
- mutt_what_key ();
- break;
-
case OP_REDRAW:
- clearok (stdscr, TRUE);
+ clearok (main_w, TRUE);
menu->redraw = REDRAW_FULL;
break;
break;
default:
- return (i);
+ return i;
}
}
/* not reached */