X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-ui%2Fmenu.c;h=1ce9f4766c1a6f65fc118e0e73bf459258694cfe;hp=a8f9925a1f75bf2b2334fc834df39b551dab2705;hb=dd5354f76c36f71044f6ddeee61241691c7195ff;hpb=4a0b020a3048f079979bea43c04f9fe388f9354d diff --git a/lib-ui/menu.c b/lib-ui/menu.c index a8f9925..1ce9f47 100644 --- a/lib-ui/menu.c +++ b/lib-ui/menu.c @@ -7,26 +7,17 @@ * please see the file GPL in the top level source directory. */ -#if HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include +#include #include "curses.h" #include "enter.h" #include "menu.h" #include "mutt.h" -#include "mbyte.h" -#include "sidebar.h" +#include "charset.h" #include - -#include -#include +#include #define SW (option(OPTMBOXPANE)?SidebarWidth:0) @@ -126,7 +117,7 @@ static void print_enriched_string (int attr, unsigned char *s, int do_color) if (do_color) attrset (attr); } - else if ((k = mbrtowc (&wc, (char *) s, n, &mbstate)) > 0) { + else if ((k = mbrtowc (&wc, (char *) s, n, &mbstate)) != (size_t)-1) { addnstr ((char *) s, k); s += k, n -= k; } @@ -145,16 +136,11 @@ static void menu_make_entry (char *s, int l, MUTTMENU * menu, int i) menu->make_entry (s, l, menu, i); } -void menu_pad_string (char *s, size_t n) +static void menu_pad_string (char *s, size_t n) { - int shift = option (OPTARROWCURSOR) ? 3 : 0; - int cols; + int cols = COLS - SW; char *tmpbuf = p_new(char, n); - if (option (OPTMBOXPANE)) - cols = COLS - shift - SidebarWidth; - else - cols = COLS - shift; mutt_format_string (tmpbuf, n, cols, cols, 0, ' ', s, m_strlen(s), 1); tmpbuf[n - 1] = 0; snprintf (s, n, "%s", tmpbuf); /* overkill */ @@ -171,7 +157,7 @@ void menu_redraw_full (MUTTMENU * menu) if (option (OPTHELP)) { SETCOLOR (MT_COLOR_STATUS); move (option (OPTSTATUSONTOP) ? LINES - 2 : 0, SW); - mutt_paddstr (COLS-SW, menu->help); + mutt_paddstr (COLS-SW, ""); SETCOLOR (MT_COLOR_NORMAL); menu->offset = 1; menu->pagelen = LINES - 3; @@ -211,50 +197,25 @@ void menu_redraw_index (MUTTMENU * menu) menu_make_entry (buf, sizeof (buf), menu, i); menu_pad_string (buf, sizeof (buf)); - if (option (OPTARROWCURSOR)) { - attrset (menu->color (i)); - CLEARLINE_WIN (i - menu->top + menu->offset); + attrset (menu->color (i)); - if (i == menu->current) { - attrset (menu->color (i)); - ADDCOLOR (MT_COLOR_INDICATOR); - BKGDSET (MT_COLOR_INDICATOR); - addstr ("->"); - attrset (menu->color (i)); - addch (' '); - } - else { - attrset (menu->color (i)); - move (i - menu->top + menu->offset, SW); - addstr (" "); - } - - print_enriched_string (menu->color (i), (unsigned char *) buf, 1); - SETCOLOR (MT_COLOR_NORMAL); - BKGDSET (MT_COLOR_NORMAL); + if (i == menu->current) { + ADDCOLOR (MT_COLOR_INDICATOR); + BKGDSET (MT_COLOR_INDICATOR); } - else { - attrset (menu->color (i)); - - if (i == menu->current) { - ADDCOLOR (MT_COLOR_INDICATOR); - BKGDSET (MT_COLOR_INDICATOR); - } - CLEARLINE_WIN (i - menu->top + menu->offset); + CLEARLINE_WIN (i - menu->top + menu->offset); - move (i - menu->top + menu->offset, SW); - print_enriched_string (menu->color (i), (unsigned char *) buf, - i != menu->current); - SETCOLOR (MT_COLOR_NORMAL); - BKGDSET (MT_COLOR_NORMAL); - } - } - else + move (i - menu->top + menu->offset, SW); + print_enriched_string (menu->color (i), (unsigned char *) buf, + i != menu->current); + SETCOLOR (MT_COLOR_NORMAL); + BKGDSET (MT_COLOR_NORMAL); + } else { CLEARLINE_WIN (i - menu->top + menu->offset); + } } - sidebar_draw (1); -/* sidebar_draw_frames(); */ + sidebar_draw (); menu->redraw = 0; } @@ -272,50 +233,27 @@ void menu_redraw_motion (MUTTMENU * menu) SETCOLOR (MT_COLOR_NORMAL); BKGDSET (MT_COLOR_NORMAL); - if (option (OPTARROWCURSOR)) { - /* clear the pointer */ - attrset (menu->color (menu->oldcurrent)); - addstr (" "); + /* erase the current indicator */ + attrset (menu->color (menu->oldcurrent)); + clrtoeol (); + menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); + menu_pad_string (buf, sizeof (buf)); + print_enriched_string (menu->color (menu->oldcurrent), + (unsigned char *) buf, 1); - if (menu->redraw & REDRAW_MOTION_RESYNCH) { - clrtoeol (); - menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); - menu_pad_string (buf, sizeof (buf)); - move (menu->oldcurrent + menu->offset - menu->top, SW + 3); - print_enriched_string (menu->color (menu->oldcurrent), - (unsigned char *) buf, 1); - SETCOLOR (MT_COLOR_NORMAL); - } + /* now draw the new one to reflect the change */ + menu_make_entry (buf, sizeof (buf), menu, menu->current); + menu_pad_string (buf, sizeof (buf)); + attrset (menu->color (menu->current)); + ADDCOLOR (MT_COLOR_INDICATOR); + BKGDSET (MT_COLOR_INDICATOR); + CLEARLINE_WIN (menu->current - menu->top + menu->offset); + move (menu->current + menu->offset - menu->top, SW); + print_enriched_string (menu->color (menu->current), (unsigned char *) buf, + 0); + SETCOLOR (MT_COLOR_NORMAL); + BKGDSET (MT_COLOR_NORMAL); - /* now draw it in the new location */ - move (menu->current + menu->offset - menu->top, SW); - attrset (menu->color (menu->current)); - ADDCOLOR (MT_COLOR_INDICATOR); - addstr ("->"); - SETCOLOR (MT_COLOR_NORMAL); - } - else { - /* erase the current indicator */ - attrset (menu->color (menu->oldcurrent)); - clrtoeol (); - menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); - menu_pad_string (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)); - attrset (menu->color (menu->current)); - ADDCOLOR (MT_COLOR_INDICATOR); - BKGDSET (MT_COLOR_INDICATOR); - CLEARLINE_WIN (menu->current - menu->top + menu->offset); - move (menu->current + menu->offset - menu->top, SW); - print_enriched_string (menu->color (menu->current), (unsigned char *) buf, - 0); - SETCOLOR (MT_COLOR_NORMAL); - BKGDSET (MT_COLOR_NORMAL); - } menu->redraw &= REDRAW_STATUS; } @@ -327,35 +265,19 @@ void menu_redraw_current (MUTTMENU * menu) menu_make_entry (buf, sizeof (buf), menu, menu->current); menu_pad_string (buf, sizeof (buf)); - if (option (OPTARROWCURSOR)) { - int attr = menu->color (menu->current); + attrset (menu->color (menu->current)); + ADDCOLOR (MT_COLOR_INDICATOR); + BKGDSET (MT_COLOR_INDICATOR); + clrtoeol (); + print_enriched_string (menu->color (menu->current), (unsigned char *) buf, + 0); + SETCOLOR (MT_COLOR_NORMAL); + BKGDSET (MT_COLOR_NORMAL); - attrset (attr); - clrtoeol (); - attrset (menu->color (menu->current)); - ADDCOLOR (MT_COLOR_INDICATOR); - addstr ("->"); - attrset (attr); - addch (' '); - menu_pad_string (buf, sizeof (buf)); - print_enriched_string (menu->color (menu->current), (unsigned char *) buf, - 1); - SETCOLOR (MT_COLOR_NORMAL); - } - else { - attrset (menu->color (menu->current)); - ADDCOLOR (MT_COLOR_INDICATOR); - BKGDSET (MT_COLOR_INDICATOR); - clrtoeol (); - print_enriched_string (menu->color (menu->current), (unsigned char *) buf, - 0); - SETCOLOR (MT_COLOR_NORMAL); - BKGDSET (MT_COLOR_NORMAL); - } menu->redraw &= REDRAW_STATUS; } -void menu_redraw_prompt (MUTTMENU * menu) +static void menu_redraw_prompt (MUTTMENU * menu) { if (menu->dialog) { if (option (OPTMSGERR)) { @@ -407,7 +329,7 @@ void menu_check_recenter (MUTTMENU * menu) void menu_jump (MUTTMENU * menu) { int n; - char buf[SHORT_STRING]; + char buf[STRING]; if (menu->max) { mutt_ungetch (LastKey, 0); @@ -468,7 +390,7 @@ void menu_prev_line (MUTTMENU * menu) * halfdown: jumplen == pagelen/2 */ #define DIRECTION ((neg * 2) + 1) -void menu_length_jump (MUTTMENU *menu, int jumplen) { +static void menu_length_jump (MUTTMENU *menu, int jumplen) { int tmp, neg = (jumplen >= 0) ? 0 : -1; int c = MIN (MenuContext, menu->pagelen / 2); @@ -606,7 +528,7 @@ void menu_current_bottom (MUTTMENU * menu) mutt_error _("No entries."); } -void menu_next_entry (MUTTMENU * menu) +static void menu_next_entry (MUTTMENU * menu) { if (menu->current < menu->max - 1) { menu->current++; @@ -616,7 +538,7 @@ void menu_next_entry (MUTTMENU * menu) mutt_error _("You are on the last entry."); } -void menu_prev_entry (MUTTMENU * menu) +static void menu_prev_entry (MUTTMENU * menu) { if (menu->current) { menu->current--; @@ -677,7 +599,7 @@ static int menu_search (MUTTMENU * menu, int op) int r; int searchDir; regex_t re; - char buf[SHORT_STRING]; + char buf[STRING]; if (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE) { m_strcpy(buf, sizeof(buf), NONULL(menu->searchBuf)); @@ -813,9 +735,7 @@ int mutt_menuLoop (MUTTMENU * menu) menu->oldcurrent = menu->current; - if (option (OPTARROWCURSOR)) - move (menu->current - menu->top + menu->offset, SW + 2); - else if (option (OPTBRAILLEFRIENDLY)) + if (option (OPTBRAILLEFRIENDLY)) move (menu->current - menu->top + menu->offset, SW); else move (menu->current - menu->top + menu->offset, COLS - 1); @@ -862,14 +782,12 @@ int mutt_menuLoop (MUTTMENU * menu) mutt_curs_set (1); -#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM) if (SigWinch) { mutt_resize_screen (); menu->redraw = REDRAW_FULL; SigWinch = 0; clearok (stdscr, TRUE); /*force complete redraw */ } -#endif if (i == -1) continue; @@ -997,10 +915,6 @@ int mutt_menuLoop (MUTTMENU * menu) mutt_what_key (); break; - case OP_REBUILD_CACHE: - mx_rebuild_cache (); - break; - case OP_REDRAW: clearok (stdscr, TRUE); menu->redraw = REDRAW_FULL;