X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=lib-ui%2Fmenu.c;h=6917d94c9801db2c782bc57a15e047ffadf9a2aa;hb=8297f3a57ccff9c0663551658cdd5d3bf166249d;hp=f8a2565fb423892f5e9616a5d9093901b15c7090;hpb=8ab1ab66eb1c4b95f9b2a5ed9c2b2cf1dfa74544;p=apps%2Fmadmutt.git diff --git a/lib-ui/menu.c b/lib-ui/menu.c index f8a2565..6917d94 100644 --- a/lib-ui/menu.c +++ b/lib-ui/menu.c @@ -9,14 +9,12 @@ #include -#include "enter.h" #include "menu.h" #include "mutt.h" #include "charset.h" #include -#include extern size_t UngetCount; @@ -112,13 +110,9 @@ static void menu_pad_string (char *s, size_t n) void menu_redraw_full (MUTTMENU * menu) { SETCOLOR(main_w, MT_COLOR_NORMAL); - /* wclear() doesn't optimize screen redraws */ - wmove (main_w, 0, 0); - wclrtobot (main_w); - - SETCOLOR(main_w, MT_COLOR_STATUS); - wmove (main_w, option (OPTSTATUSONTOP) ? LINES - 2 : 0, 0); - mutt_paddstr (main_w, getmaxx(main_w), ""); + 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; @@ -133,7 +127,7 @@ void menu_redraw_status (MUTTMENU * menu) snprintf (buf, sizeof (buf), M_MODEFMT, menu->title); SETCOLOR(main_w, MT_COLOR_STATUS); - wmove (main_w, option (OPTSTATUSONTOP) ? 0 : LINES - 2, 0); + wmove (main_w, 0, 0); mutt_paddstr (main_w, getmaxx(main_w), buf); SETCOLOR(main_w, MT_COLOR_NORMAL); menu->redraw &= ~REDRAW_STATUS; @@ -181,12 +175,12 @@ void menu_redraw_motion (MUTTMENU * menu) return; } - wmove (main_w, menu->oldcurrent + menu->offset - menu->top, 0); SETCOLOR(main_w, MT_COLOR_NORMAL); BKGDSET(main_w, MT_COLOR_NORMAL); /* erase the current indicator */ - wattrset (main_w, menu->color (menu->oldcurrent)); + 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)); @@ -213,13 +207,13 @@ void menu_redraw_current (MUTTMENU * menu) { char buf[STRING]; - wmove (main_w, menu->current + menu->offset - menu->top, 0); menu_make_entry (buf, sizeof (buf), menu, menu->current); menu_pad_string (buf, sizeof (buf)); 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); @@ -240,9 +234,9 @@ static void menu_redraw_prompt (MUTTMENU * menu) if (*Errorbuf) mutt_clear_error (); - SETCOLOR(main_w, MT_COLOR_NORMAL); - mvwaddstr (main_w, LINES - 1, 0, menu->prompt); - wclrtoeol (main_w); + SETCOLOR(stdscr, MT_COLOR_NORMAL); + mvwaddstr(stdscr, LINES - 1, 0, menu->prompt); + wclrtoeol(stdscr); } } @@ -251,27 +245,18 @@ void menu_check_recenter (MUTTMENU * menu) 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) @@ -305,20 +290,17 @@ void menu_next_line (MUTTMENU * menu) 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) @@ -353,7 +335,7 @@ static void menu_length_jump (MUTTMENU *menu, int jumplen) { 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? */ @@ -510,7 +492,7 @@ static int menu_search_generic (MUTTMENU * m, regex_t * re, int n) 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) @@ -524,7 +506,7 @@ MUTTMENU *mutt_new_menu (void) p->pagelen = LINES - 3; p->color = default_color; p->search = menu_search_generic; - return (p); + return p; } void mutt_menuDestroy (MUTTMENU ** p) @@ -558,7 +540,7 @@ static int menu_search (MUTTMENU * menu, int op) 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; } @@ -566,7 +548,7 @@ static int menu_search (MUTTMENU * menu, int op) if (!menu->searchBuf) { mutt_error _("No search pattern."); - return (-1); + return -1; } } @@ -580,7 +562,7 @@ static int menu_search (MUTTMENU * menu, int op) regerror (r, &re, buf, sizeof (buf)); regfree (&re); mutt_error ("%s", buf); - return (-1); + return -1; } r = menu->current + searchDir; @@ -596,7 +578,7 @@ static int menu_search (MUTTMENU * menu, int op) regfree (&re); mutt_error _("Not found."); - return (-1); + return -1; } static int menu_dialog_translate_op (int i) @@ -647,7 +629,7 @@ int menu_redraw (MUTTMENU * menu) 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) @@ -695,11 +677,11 @@ int mutt_menuLoop (MUTTMENU * menu) i = km_dokey (menu->menu); if (i == OP_TAG_PREFIX || i == OP_TAG_PREFIX_COND) { if (menu->tagged) { - mvwaddstr (main_w, LINES - 1, 0, "Tag-"); - wclrtoeol (main_w); + mvwaddstr(stdscr, LINES - 1, 0, "Tag-"); + wclrtoeol(stdscr); i = km_dokey (menu->menu); menu->tagprefix = 1; - CLEARLINE(main_w, LINES - 1); + CLEARLINE(stdscr, LINES - 1); } else if (i == OP_TAG_PREFIX) { mutt_error _("No tagged entries."); @@ -854,10 +836,6 @@ int mutt_menuLoop (MUTTMENU * menu) MAYBE_REDRAW (menu->redraw); break; - case OP_WHAT_KEY: - mutt_what_key (); - break; - case OP_REDRAW: clearok (main_w, TRUE); menu->redraw = REDRAW_FULL; @@ -876,7 +854,7 @@ int mutt_menuLoop (MUTTMENU * menu) break; default: - return (i); + return i; } } /* not reached */