--- mutt-1.4.2.1/menu.c.orig 2004-02-14 11:15:52.874537592 +0100 +++ mutt-1.4.2.1/menu.c 2004-02-14 11:17:58.135495032 +0100 @@ -148,7 +148,7 @@ menu->make_entry (s, l, menu, i); } -void menu_pad_string (char *s, size_t n) +void menu_pad_string (MUTTMENU *menu, char *s, size_t l) { int shift = option (OPTARROWCURSOR) ? 3 : 0; int cols = COLS - shift; @@ -196,69 +196,89 @@ menu->redraw &= ~REDRAW_STATUS; } -void menu_redraw_index (MUTTMENU *menu) +void menu_item_pos(MUTTMENU *menu, int item, int *row, int *col) { - char buf[STRING]; - int i; - - for (i = menu->top; i < menu->top + menu->pagelen; i++) - { - if (i < menu->max) - { - menu_make_entry (buf, sizeof (buf), menu, i); - menu_pad_string (buf, sizeof (buf)); + *row = (item - menu->top) % menu->pagelen; + *col = (item - menu->top) / menu->pagelen; +} - if (option (OPTARROWCURSOR)) - { - attrset (menu->color (i)); - CLEARLINE (i - menu->top + menu->offset); +void menu_redraw_index (MUTTMENU *menu) +{ + char buf[STRING]; + int i; + int row, col; - if (i == menu->current) + for (i = menu->top; i < menu->top + (menu->pagelen * menu->columns); i++) { - SETCOLOR (MT_COLOR_INDICATOR); - addstr ("->"); - attrset (menu->color (i)); - addch (' '); - } - else - move (i - menu->top + menu->offset, 3); + menu_item_pos(menu, i, &row, &col); + if (i < menu->max) + { + menu_make_entry (buf, sizeof (buf), menu, i); + menu_pad_string (menu, buf, sizeof (buf)); - print_enriched_string (menu->color(i), (unsigned char *) buf, 1); - SETCOLOR (MT_COLOR_NORMAL); - } - else - { - if (i == menu->current) - { - SETCOLOR (MT_COLOR_INDICATOR); - BKGDSET (MT_COLOR_INDICATOR); + if (option (OPTARROWCURSOR)) + { + attrset (menu->color (i)); + + move(menu->offset + row, col * (COLS / menu->columns)); + + if (i == menu->current) + { + SETCOLOR (MT_COLOR_INDICATOR); + addstr ("->"); + attrset (menu->color (i)); + addch (' '); + } + else + move(row + menu->offset, col * COLS / menu->columns + 3); + + print_enriched_string (menu->color(i), (unsigned char *) buf, + 1); + SETCOLOR (MT_COLOR_NORMAL); + } + else + { /* !option(OPTARROWCURSOR) */ + if (i == menu->current) + { + SETCOLOR (MT_COLOR_INDICATOR); + BKGDSET (MT_COLOR_INDICATOR); + } + else + attrset (menu->color (i)); + + move(row + menu->offset, col * (COLS / menu->columns)); + + print_enriched_string (menu->color(i), (unsigned char *) buf, + i != menu->current); + + SETCOLOR (MT_COLOR_NORMAL); + BKGDSET (MT_COLOR_NORMAL); + } + } + else + { + if (col == 0) + { + move(row + menu->offset, col); clrtoeol(); + } + } } - else - attrset (menu->color (i)); - - CLEARLINE (i - menu->top + menu->offset); - print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current); - SETCOLOR (MT_COLOR_NORMAL); - BKGDSET (MT_COLOR_NORMAL); - } - } - else - CLEARLINE (i - menu->top + menu->offset); - } - menu->redraw = 0; + menu->redraw = 0; } void menu_redraw_motion (MUTTMENU *menu) { - char buf[STRING]; - + char buf[STRING]; + int row, col; + if (menu->dialog) { menu->redraw &= ~REDRAW_MOTION; return; } - - move (menu->oldcurrent + menu->offset - menu->top, 0); + + menu_item_pos(menu, menu->oldcurrent, &row, &col); + move(row + menu->offset, col * (COLS / menu->columns)); SETCOLOR (MT_COLOR_NORMAL); BKGDSET (MT_COLOR_NORMAL); @@ -270,16 +290,18 @@ if (menu->redraw & REDRAW_MOTION_RESYNCH) { - clrtoeol (); + move(row + menu->offset, col * (COLS / menu->columns)); 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)); + move(row + menu->offset, col * COLS / menu->columns + 3); print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1); SETCOLOR (MT_COLOR_NORMAL); } /* now draw it in the new location */ - move (menu->current + menu->offset - menu->top, 0); + + menu_item_pos(menu, menu->current, &row, &col); + move(row + menu->offset, col * COLS / menu->columns); SETCOLOR (MT_COLOR_INDICATOR); addstr ("->"); SETCOLOR (MT_COLOR_NORMAL); @@ -288,17 +310,19 @@ { /* erase the current indicator */ attrset (menu->color (menu->oldcurrent)); - clrtoeol (); + move(row + menu->offset, col * (COLS / menu->columns)); 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); + + menu_item_pos(menu, menu->current, &row, &col); /* 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); BKGDSET (MT_COLOR_INDICATOR); - CLEARLINE (menu->current - menu->top + menu->offset); + move(row + menu->offset, col * (COLS / menu->columns)); print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0); SETCOLOR (MT_COLOR_NORMAL); BKGDSET (MT_COLOR_NORMAL); @@ -309,21 +333,22 @@ void menu_redraw_current (MUTTMENU *menu) { char buf[STRING]; + int row, col; - move (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)); + menu_item_pos(menu, menu->current, &row, &col); if (option (OPTARROWCURSOR)) { int attr = menu->color (menu->current); attrset (attr); - clrtoeol (); + move(row + menu->offset, col * (COLS / menu->columns)); SETCOLOR (MT_COLOR_INDICATOR); addstr ("->"); attrset (attr); addch (' '); - menu_pad_string (buf, sizeof (buf)); + menu_pad_string (menu, buf, sizeof (buf)); print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 1); SETCOLOR (MT_COLOR_NORMAL); } @@ -331,7 +356,7 @@ { SETCOLOR (MT_COLOR_INDICATOR); BKGDSET (MT_COLOR_INDICATOR); - clrtoeol (); + move(row + menu->offset, col * (COLS / menu->columns)); print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0); SETCOLOR (MT_COLOR_NORMAL); BKGDSET (MT_COLOR_NORMAL); @@ -360,18 +385,18 @@ void menu_check_recenter (MUTTMENU *menu) { - if (menu->max <= menu->pagelen && menu->top != 0) + if (menu->max <= menu->pagelen * menu->columns && menu->top != 0) { menu->top = 0; set_option (OPTNEEDREDRAW); menu->redraw |= REDRAW_INDEX; } - else if (menu->current >= menu->top + menu->pagelen) + else if (menu->current >= menu->top + menu->pagelen * menu->columns) { if (option (OPTMENUSCROLL) || (menu->pagelen <= 0)) - menu->top = menu->current - menu->pagelen + 1; + menu->top = menu->current - menu->pagelen * menu->columns + 1; else - menu->top += menu->pagelen * ((menu->current - menu->top) / menu->pagelen); + menu->top += menu->pagelen * menu->columns * ((menu->current - menu->top) / (menu->pagelen * menu->columns)); menu->redraw |= REDRAW_INDEX; } else if (menu->current < menu->top) @@ -380,7 +405,7 @@ menu->top = menu->current; else { - menu->top -= menu->pagelen * ((menu->top + menu->pagelen - 1 - menu->current) / menu->pagelen); + menu->top -= menu->pagelen * menu->columns * ((menu->top + menu->pagelen - 1 - menu->current) / menu->pagelen); if (menu->top < 0) menu->top = 0; } @@ -671,6 +696,7 @@ p->pagelen = PAGELEN; p->color = default_color; p->search = menu_search_generic; + p->columns = 1; return (p); }