aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lxdialog/menubox.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/scripts/lxdialog/menubox.c b/scripts/lxdialog/menubox.c
index 89fcf418a07a..461ee08edc05 100644
--- a/scripts/lxdialog/menubox.c
+++ b/scripts/lxdialog/menubox.c
@@ -94,9 +94,9 @@ static void print_item(WINDOW * win, const char *item, int choice,
94 } 94 }
95 if (selected) { 95 if (selected) {
96 wmove(win, choice, ITEM_IDENT + 1); 96 wmove(win, choice, ITEM_IDENT + 1);
97 wrefresh(win);
98 } 97 }
99 free(menu_item); 98 free(menu_item);
99 wrefresh(win);
100} 100}
101 101
102/* 102/*
@@ -125,6 +125,7 @@ static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x,
125 125
126 y = y + height + 1; 126 y = y + height + 1;
127 wmove(win, y, x); 127 wmove(win, y, x);
128 wrefresh(win);
128 129
129 if ((height < item_no) && (scroll + height < item_no)) { 130 if ((height < item_no) && (scroll + height < item_no)) {
130 wattrset(win, darrow_attr); 131 wattrset(win, darrow_attr);
@@ -139,6 +140,7 @@ static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x,
139 } 140 }
140 141
141 wmove(win, cur_y, cur_x); 142 wmove(win, cur_y, cur_x);
143 wrefresh(win);
142} 144}
143 145
144/* 146/*
@@ -157,6 +159,17 @@ static void print_buttons(WINDOW * win, int height, int width, int selected)
157 wrefresh(win); 159 wrefresh(win);
158} 160}
159 161
162/* scroll up n lines (n may be negative) */
163static void do_scroll(WINDOW *win, int *scroll, int n)
164{
165 /* Scroll menu up */
166 scrollok(win, TRUE);
167 wscrl(win, n);
168 scrollok(win, FALSE);
169 *scroll = *scroll + n;
170 wrefresh(win);
171}
172
160/* 173/*
161 * Display a menu for choosing among a number of options 174 * Display a menu for choosing among a number of options
162 */ 175 */
@@ -286,11 +299,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width,
286 if (key == KEY_UP || key == '-') { 299 if (key == KEY_UP || key == '-') {
287 if (choice < 2 && scroll) { 300 if (choice < 2 && scroll) {
288 /* Scroll menu down */ 301 /* Scroll menu down */
289 scrollok(menu, TRUE); 302 do_scroll(menu, &scroll, -1);
290 wscrl(menu, -1);
291 scrollok(menu, FALSE);
292
293 scroll--;
294 303
295 print_item(menu, items[scroll * 2 + 1], 0, FALSE, 304 print_item(menu, items[scroll * 2 + 1], 0, FALSE,
296 (items[scroll * 2][0] != ':')); 305 (items[scroll * 2][0] != ':'));
@@ -306,11 +315,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width,
306 if ((choice > max_choice - 3) && 315 if ((choice > max_choice - 3) &&
307 (scroll + max_choice < item_no)) { 316 (scroll + max_choice < item_no)) {
308 /* Scroll menu up */ 317 /* Scroll menu up */
309 scrollok(menu, TRUE); 318 do_scroll(menu, &scroll, 1);
310 wscrl(menu, 1);
311 scrollok(menu, FALSE);
312
313 scroll++;
314 319
315 print_item(menu, items[(scroll + max_choice - 1) * 2 + 1], 320 print_item(menu, items[(scroll + max_choice - 1) * 2 + 1],
316 max_choice - 1, FALSE, 321 max_choice - 1, FALSE,
@@ -322,8 +327,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width,
322 scrollok(menu, TRUE); 327 scrollok(menu, TRUE);
323 for (i = 0; (i < max_choice); i++) { 328 for (i = 0; (i < max_choice); i++) {
324 if (scroll > 0) { 329 if (scroll > 0) {
325 wscrl(menu, -1); 330 do_scroll(menu, &scroll, -1);
326 scroll--;
327 print_item(menu, items[scroll * 2 + 1], 0, FALSE, 331 print_item(menu, items[scroll * 2 + 1], 0, FALSE,
328 (items[scroll * 2][0] != ':')); 332 (items[scroll * 2][0] != ':'));
329 } else { 333 } else {
@@ -331,15 +335,11 @@ int dialog_menu(const char *title, const char *prompt, int height, int width,
331 choice--; 335 choice--;
332 } 336 }
333 } 337 }
334 scrollok(menu, FALSE);
335 338
336 } else if (key == KEY_NPAGE) { 339 } else if (key == KEY_NPAGE) {
337 for (i = 0; (i < max_choice); i++) { 340 for (i = 0; (i < max_choice); i++) {
338 if (scroll + max_choice < item_no) { 341 if (scroll + max_choice < item_no) {
339 scrollok(menu, TRUE); 342 do_scroll(menu, &scroll, 1);
340 wscrl(menu, 1);
341 scrollok(menu, FALSE);
342 scroll++;
343 print_item(menu, items[(scroll + max_choice - 1) * 2 + 1], 343 print_item(menu, items[(scroll + max_choice - 1) * 2 + 1],
344 max_choice - 1, FALSE, 344 max_choice - 1, FALSE,
345 (items [(scroll + max_choice - 1) * 2][0] != ':')); 345 (items [(scroll + max_choice - 1) * 2][0] != ':'));
@@ -348,7 +348,6 @@ int dialog_menu(const char *title, const char *prompt, int height, int width,
348 choice++; 348 choice++;
349 } 349 }
350 } 350 }
351
352 } else 351 } else
353 choice = i; 352 choice = i;
354 353