Skip to content

Commit 00213b1

Browse files
pasky
authored andcommitted
kconfig: Remove support for lxdialog --checklist
Remove support for lxdialog --checklist The checklist lxdialog functionality is not used by menuconfig (only the radiolist variant is used) and supporting it would significantly complicate the forthcoming liblxdialog API. Signed-off-by: Petr Baudis <[email protected]> Signed-off-by: Sam Ravnborg <[email protected]>
1 parent 352dd1d commit 00213b1

File tree

3 files changed

+17
-51
lines changed

3 files changed

+17
-51
lines changed

scripts/kconfig/lxdialog/checklist.c

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#include "dialog.h"
2525

26-
static int list_width, check_x, item_x, checkflag;
26+
static int list_width, check_x, item_x;
2727

2828
/*
2929
* Print list item
@@ -41,10 +41,7 @@ static void print_item(WINDOW * win, const char *item, int status, int choice,
4141

4242
wmove(win, choice, check_x);
4343
wattrset(win, selected ? check_selected_attr : check_attr);
44-
if (checkflag == FLAG_CHECK)
45-
wprintw(win, "[%c]", status ? 'X' : ' ');
46-
else
47-
wprintw(win, "(%c)", status ? 'X' : ' ');
44+
wprintw(win, "(%c)", status ? 'X' : ' ');
4845

4946
wattrset(win, selected ? tag_selected_attr : tag_attr);
5047
mvwaddch(win, choice, item_x, item[0]);
@@ -109,18 +106,16 @@ static void print_buttons(WINDOW * dialog, int height, int width, int selected)
109106

110107
/*
111108
* 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).
113110
*/
114111
int dialog_checklist(const char *title, const char *prompt, int height,
115112
int width, int list_height, int item_no,
116-
const char *const *items, int flag)
113+
const char *const *items)
117114
{
118115
int i, x, y, box_x, box_y;
119116
int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status;
120117
WINDOW *dialog, *list;
121118

122-
checkflag = flag;
123-
124119
/* Allocate space for storing item on/off status */
125120
if ((status = malloc(sizeof(int) * item_no)) == NULL) {
126121
endwin();
@@ -303,34 +298,20 @@ int dialog_checklist(const char *title, const char *prompt, int height,
303298
case ' ':
304299
case '\n':
305300
if (!button) {
306-
if (flag == FLAG_CHECK) {
307-
status[scroll + choice] = !status[scroll + choice];
308-
wmove(list, choice, check_x);
309-
wattrset(list, check_selected_attr);
310-
wprintw(list, "[%c]", status[scroll + choice] ? 'X' : ' ');
311-
} else {
312-
if (!status[scroll + 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-
}
301+
if (!status[scroll + choice]) {
302+
for (i = 0; i < item_no; i++)
303+
status[i] = 0;
304+
status[scroll + choice] = 1;
305+
for (i = 0; i < max_choice; i++)
306+
print_item(list, items[(scroll + i) * 3 + 1],
307+
status[scroll + i], i, i == choice);
320308
}
321309
wnoutrefresh(list);
322310
wrefresh(dialog);
323311

324-
for (i = 0; i < item_no; i++) {
325-
if (status[i]) {
326-
if (flag == FLAG_CHECK) {
327-
fprintf(stderr, "\"%s\" ", items[i * 3]);
328-
} else {
329-
fprintf(stderr, "%s", items[i * 3]);
330-
}
331-
332-
}
333-
}
312+
for (i = 0; i < item_no; i++)
313+
if (status[i])
314+
fprintf(stderr, "%s", items[i * 3]);
334315
} else
335316
fprintf(stderr, "%s", items[(scroll + choice) * 3]);
336317
delwin(dialog);

scripts/kconfig/lxdialog/dialog.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width,
160160
const char *const *items);
161161
int dialog_checklist(const char *title, const char *prompt, int height,
162162
int width, int list_height, int item_no,
163-
const char *const *items, int flag);
163+
const char *const *items);
164164
extern char dialog_input_result[];
165165
int dialog_inputbox(const char *title, const char *prompt, int height,
166166
int width, const char *init);
@@ -175,10 +175,3 @@ int dialog_inputbox(const char *title, const char *prompt, int height,
175175
* -- uppercase chars are used to invoke the button (M_EVENT + 'O')
176176
*/
177177
#define M_EVENT (KEY_MAX+1)
178-
179-
/*
180-
* The `flag' parameter in checklist is used to select between
181-
* radiolist and checklist
182-
*/
183-
#define FLAG_CHECK 1
184-
#define FLAG_RADIO 0

scripts/kconfig/lxdialog/lxdialog.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ struct Mode {
3131
jumperFn *jumper;
3232
};
3333

34-
jumperFn j_menu, j_checklist, j_radiolist, j_yesno, j_textbox, j_inputbox;
34+
jumperFn j_menu, j_radiolist, j_yesno, j_textbox, j_inputbox;
3535
jumperFn j_msgbox, j_infobox;
3636

3737
static struct Mode modes[] = {
3838
{"--menu", 9, 0, 3, j_menu},
39-
{"--checklist", 9, 0, 3, j_checklist},
4039
{"--radiolist", 9, 0, 3, j_radiolist},
4140
{"--yesno", 5, 5, 1, j_yesno},
4241
{"--textbox", 5, 5, 1, j_textbox},
@@ -151,7 +150,6 @@ static void Usage(const char *name)
151150
\nBox options:\
152151
\n\
153152
\n --menu <text> <height> <width> <menu height> <tag1> <item1>...\
154-
\n --checklist <text> <height> <width> <list height> <tag1> <item1> <status1>...\
155153
\n --radiolist <text> <height> <width> <list height> <tag1> <item1> <status1>...\
156154
\n --textbox <file> <height> <width>\
157155
\n --inputbox <text> <height> <width> [<init>]\
@@ -170,16 +168,10 @@ int j_menu(const char *t, int ac, const char *const *av)
170168
atoi(av[5]), av[6], (ac - 6) / 2, av + 7);
171169
}
172170

173-
int j_checklist(const char *t, int ac, const char *const *av)
174-
{
175-
return dialog_checklist(t, av[2], atoi(av[3]), atoi(av[4]),
176-
atoi(av[5]), (ac - 6) / 3, av + 6, FLAG_CHECK);
177-
}
178-
179171
int j_radiolist(const char *t, int ac, const char *const *av)
180172
{
181173
return dialog_checklist(t, av[2], atoi(av[3]), atoi(av[4]),
182-
atoi(av[5]), (ac - 6) / 3, av + 6, FLAG_RADIO);
174+
atoi(av[5]), (ac - 6) / 3, av + 6);
183175
}
184176

185177
int j_textbox(const char *t, int ac, const char *const *av)

0 commit comments

Comments
 (0)