1 --- mutt-1.4.2.1/menu.c.orig 2004-02-14 11:15:52.874537592 +0100
2 +++ mutt-1.4.2.1/menu.c 2004-02-14 11:17:58.135495032 +0100
4 menu->make_entry (s, l, menu, i);
7 -void menu_pad_string (char *s, size_t n)
8 +void menu_pad_string (MUTTMENU *menu, char *s, size_t l)
10 int shift = option (OPTARROWCURSOR) ? 3 : 0;
11 int cols = COLS - shift;
13 menu->redraw &= ~REDRAW_STATUS;
16 -void menu_redraw_index (MUTTMENU *menu)
17 +void menu_item_pos(MUTTMENU *menu, int item, int *row, int *col)
22 - for (i = menu->top; i < menu->top + menu->pagelen; i++)
26 - menu_make_entry (buf, sizeof (buf), menu, i);
27 - menu_pad_string (buf, sizeof (buf));
28 + *row = (item - menu->top) % menu->pagelen;
29 + *col = (item - menu->top) / menu->pagelen;
32 - if (option (OPTARROWCURSOR))
34 - attrset (menu->color (i));
35 - CLEARLINE (i - menu->top + menu->offset);
36 +void menu_redraw_index (MUTTMENU *menu)
42 - if (i == menu->current)
43 + for (i = menu->top; i < menu->top + (menu->pagelen * menu->columns); i++)
45 - SETCOLOR (MT_COLOR_INDICATOR);
47 - attrset (menu->color (i));
51 - move (i - menu->top + menu->offset, 3);
52 + menu_item_pos(menu, i, &row, &col);
55 + menu_make_entry (buf, sizeof (buf), menu, i);
56 + menu_pad_string (menu, buf, sizeof (buf));
58 - print_enriched_string (menu->color(i), (unsigned char *) buf, 1);
59 - SETCOLOR (MT_COLOR_NORMAL);
63 - if (i == menu->current)
65 - SETCOLOR (MT_COLOR_INDICATOR);
66 - BKGDSET (MT_COLOR_INDICATOR);
67 + if (option (OPTARROWCURSOR))
69 + attrset (menu->color (i));
71 + move(menu->offset + row, col * (COLS / menu->columns));
73 + if (i == menu->current)
75 + SETCOLOR (MT_COLOR_INDICATOR);
77 + attrset (menu->color (i));
81 + move(row + menu->offset, col * COLS / menu->columns + 3);
83 + print_enriched_string (menu->color(i), (unsigned char *) buf,
85 + SETCOLOR (MT_COLOR_NORMAL);
88 + { /* !option(OPTARROWCURSOR) */
89 + if (i == menu->current)
91 + SETCOLOR (MT_COLOR_INDICATOR);
92 + BKGDSET (MT_COLOR_INDICATOR);
95 + attrset (menu->color (i));
97 + move(row + menu->offset, col * (COLS / menu->columns));
99 + print_enriched_string (menu->color(i), (unsigned char *) buf,
100 + i != menu->current);
102 + SETCOLOR (MT_COLOR_NORMAL);
103 + BKGDSET (MT_COLOR_NORMAL);
110 + move(row + menu->offset, col); clrtoeol();
115 - attrset (menu->color (i));
117 - CLEARLINE (i - menu->top + menu->offset);
118 - print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
119 - SETCOLOR (MT_COLOR_NORMAL);
120 - BKGDSET (MT_COLOR_NORMAL);
124 - CLEARLINE (i - menu->top + menu->offset);
130 void menu_redraw_motion (MUTTMENU *menu)
139 menu->redraw &= ~REDRAW_MOTION;
143 - move (menu->oldcurrent + menu->offset - menu->top, 0);
145 + menu_item_pos(menu, menu->oldcurrent, &row, &col);
146 + move(row + menu->offset, col * (COLS / menu->columns));
147 SETCOLOR (MT_COLOR_NORMAL);
148 BKGDSET (MT_COLOR_NORMAL);
150 @@ -270,16 +290,18 @@
152 if (menu->redraw & REDRAW_MOTION_RESYNCH)
155 + move(row + menu->offset, col * (COLS / menu->columns));
156 menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
157 - menu_pad_string (buf, sizeof (buf));
158 - move (menu->oldcurrent + menu->offset - menu->top, 3);
159 + menu_pad_string (menu, buf, sizeof (buf));
160 + move(row + menu->offset, col * COLS / menu->columns + 3);
161 print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
162 SETCOLOR (MT_COLOR_NORMAL);
165 /* now draw it in the new location */
166 - move (menu->current + menu->offset - menu->top, 0);
168 + menu_item_pos(menu, menu->current, &row, &col);
169 + move(row + menu->offset, col * COLS / menu->columns);
170 SETCOLOR (MT_COLOR_INDICATOR);
172 SETCOLOR (MT_COLOR_NORMAL);
173 @@ -288,17 +310,19 @@
175 /* erase the current indicator */
176 attrset (menu->color (menu->oldcurrent));
178 + move(row + menu->offset, col * (COLS / menu->columns));
179 menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
180 - menu_pad_string (buf, sizeof (buf));
181 + menu_pad_string (menu, buf, sizeof (buf));
182 print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
185 + menu_item_pos(menu, menu->current, &row, &col);
186 /* now draw the new one to reflect the change */
187 menu_make_entry (buf, sizeof (buf), menu, menu->current);
188 - menu_pad_string (buf, sizeof (buf));
189 + menu_pad_string (menu, buf, sizeof (buf));
190 SETCOLOR (MT_COLOR_INDICATOR);
191 BKGDSET (MT_COLOR_INDICATOR);
192 - CLEARLINE (menu->current - menu->top + menu->offset);
193 + move(row + menu->offset, col * (COLS / menu->columns));
194 print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
195 SETCOLOR (MT_COLOR_NORMAL);
196 BKGDSET (MT_COLOR_NORMAL);
197 @@ -309,21 +333,22 @@
198 void menu_redraw_current (MUTTMENU *menu)
203 - move (menu->current + menu->offset - menu->top, 0);
204 menu_make_entry (buf, sizeof (buf), menu, menu->current);
205 - menu_pad_string (buf, sizeof (buf));
206 + menu_pad_string (menu, buf, sizeof (buf));
208 + menu_item_pos(menu, menu->current, &row, &col);
209 if (option (OPTARROWCURSOR))
211 int attr = menu->color (menu->current);
214 + move(row + menu->offset, col * (COLS / menu->columns));
215 SETCOLOR (MT_COLOR_INDICATOR);
219 - menu_pad_string (buf, sizeof (buf));
220 + menu_pad_string (menu, buf, sizeof (buf));
221 print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 1);
222 SETCOLOR (MT_COLOR_NORMAL);
226 SETCOLOR (MT_COLOR_INDICATOR);
227 BKGDSET (MT_COLOR_INDICATOR);
229 + move(row + menu->offset, col * (COLS / menu->columns));
230 print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
231 SETCOLOR (MT_COLOR_NORMAL);
232 BKGDSET (MT_COLOR_NORMAL);
233 @@ -360,18 +385,18 @@
235 void menu_check_recenter (MUTTMENU *menu)
237 - if (menu->max <= menu->pagelen && menu->top != 0)
238 + if (menu->max <= menu->pagelen * menu->columns && menu->top != 0)
241 set_option (OPTNEEDREDRAW);
242 menu->redraw |= REDRAW_INDEX;
244 - else if (menu->current >= menu->top + menu->pagelen)
245 + else if (menu->current >= menu->top + menu->pagelen * menu->columns)
247 if (option (OPTMENUSCROLL) || (menu->pagelen <= 0))
248 - menu->top = menu->current - menu->pagelen + 1;
249 + menu->top = menu->current - menu->pagelen * menu->columns + 1;
251 - menu->top += menu->pagelen * ((menu->current - menu->top) / menu->pagelen);
252 + menu->top += menu->pagelen * menu->columns * ((menu->current - menu->top) / (menu->pagelen * menu->columns));
253 menu->redraw |= REDRAW_INDEX;
255 else if (menu->current < menu->top)
257 menu->top = menu->current;
260 - menu->top -= menu->pagelen * ((menu->top + menu->pagelen - 1 - menu->current) / menu->pagelen);
261 + menu->top -= menu->pagelen * menu->columns * ((menu->top + menu->pagelen - 1 - menu->current) / menu->pagelen);
266 p->pagelen = PAGELEN;
267 p->color = default_color;
268 p->search = menu_search_generic;