aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/lxdialog/checklist.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig/lxdialog/checklist.c')
-rw-r--r--scripts/kconfig/lxdialog/checklist.c47
1 files changed, 14 insertions, 33 deletions
diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c
index 3fb681fb963..db07ae73e05 100644
--- a/scripts/kconfig/lxdialog/checklist.c
+++ b/scripts/kconfig/lxdialog/checklist.c
@@ -23,7 +23,7 @@
23 23
24#include "dialog.h" 24#include "dialog.h"
25 25
26static int list_width, check_x, item_x, checkflag; 26static int list_width, check_x, item_x;
27 27
28/* 28/*
29 * Print list item 29 * Print list item
@@ -41,10 +41,7 @@ static void print_item(WINDOW * win, const char *item, int status, int choice,
41 41
42 wmove(win, choice, check_x); 42 wmove(win, choice, check_x);
43 wattrset(win, selected ? check_selected_attr : check_attr); 43 wattrset(win, selected ? check_selected_attr : check_attr);
44 if (checkflag == FLAG_CHECK) 44 wprintw(win, "(%c)", status ? 'X' : ' ');
45 wprintw(win, "[%c]", status ? 'X' : ' ');
46 else
47 wprintw(win, "(%c)", status ? 'X' : ' ');
48 45
49 wattrset(win, selected ? tag_selected_attr : tag_attr); 46 wattrset(win, selected ? tag_selected_attr : tag_attr);
50 mvwaddch(win, choice, item_x, item[0]); 47 mvwaddch(win, choice, item_x, item[0]);
@@ -109,18 +106,16 @@ static void print_buttons(WINDOW * dialog, int height, int width, int selected)
109 106
110/* 107/*
111 * Display a dialog box with a list of options that can be turned on or off 108 * Display a dialog box with a list of options that can be turned on or off
112 * The `flag' parameter is used to select between radiolist and checklist. 109 * in the style of radiolist (only one option turned on at a time).
113 */ 110 */
114int dialog_checklist(const char *title, const char *prompt, int height, 111int dialog_checklist(const char *title, const char *prompt, int height,
115 int width, int list_height, int item_no, 112 int width, int list_height, int item_no,
116 const char *const *items, int flag) 113 const char *const *items)
117{ 114{
118 int i, x, y, box_x, box_y; 115 int i, x, y, box_x, box_y;
119 int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; 116 int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status;
120 WINDOW *dialog, *list; 117 WINDOW *dialog, *list;
121 118
122 checkflag = flag;
123
124 /* Allocate space for storing item on/off status */ 119 /* Allocate space for storing item on/off status */
125 if ((status = malloc(sizeof(int) * item_no)) == NULL) { 120 if ((status = malloc(sizeof(int) * item_no)) == NULL) {
126 endwin(); 121 endwin();
@@ -303,34 +298,20 @@ int dialog_checklist(const char *title, const char *prompt, int height,
303 case ' ': 298 case ' ':
304 case '\n': 299 case '\n':
305 if (!button) { 300 if (!button) {
306 if (flag == FLAG_CHECK) { 301 if (!status[scroll + choice]) {
307 status[scroll + choice] = !status[scroll + choice]; 302 for (i = 0; i < item_no; i++)
308 wmove(list, choice, check_x); 303 status[i] = 0;
309 wattrset(list, check_selected_attr); 304 status[scroll + choice] = 1;
310 wprintw(list, "[%c]", status[scroll + choice] ? 'X' : ' '); 305 for (i = 0; i < max_choice; i++)
311 } else { 306 print_item(list, items[(scroll + i) * 3 + 1],
312 if (!status[scroll + choice]) { 307 status[scroll + i], i, i == choice);
313 for (i = 0; i < item_no; i++)
314 status[i] = 0;
315 status[scroll + choice] = 1;
316 for (i = 0; i < max_choice; i++)
317 print_item(list, items[(scroll + i) * 3 + 1],
318 status[scroll + i], i, i == choice);
319 }
320 } 308 }
321 wnoutrefresh(list); 309 wnoutrefresh(list);
322 wrefresh(dialog); 310 wrefresh(dialog);
323 311
324 for (i = 0; i < item_no; i++) { 312 for (i = 0; i < item_no; i++)
325 if (status[i]) { 313 if (status[i])
326 if (flag == FLAG_CHECK) { 314 fprintf(stderr, "%s", items[i * 3]);
327 fprintf(stderr, "\"%s\" ", items[i * 3]);
328 } else {
329 fprintf(stderr, "%s", items[i * 3]);
330 }
331
332 }
333 }
334 } else 315 } else
335 fprintf(stderr, "%s", items[(scroll + choice) * 3]); 316 fprintf(stderr, "%s", items[(scroll + choice) * 3]);
336 delwin(dialog); 317 delwin(dialog);