MCPcopy Create free account
hub / github.com/Entware/Entware / dialog_checklist

Function dialog_checklist

scripts/config/lxdialog/checklist.c:104–319  ·  view source on GitHub ↗

* Display a dialog box with a list of options that can be turned on or off * in the style of radiolist (only one option turned on at a time). */

Source from the content-addressed store, hash-verified

102 * in the style of radiolist (only one option turned on at a time).
103 */
104int dialog_checklist(const char *title, const char *prompt, int height,
105 int width, int list_height)
106{
107 int i, x, y, box_x, box_y;
108 int key = 0, button = 0, choice = 0, scroll = 0, max_choice;
109 WINDOW *dialog, *list;
110
111 /* which item to highlight */
112 item_foreach() {
113 if (item_is_tag('X'))
114 choice = item_n();
115 if (item_is_selected()) {
116 choice = item_n();
117 break;
118 }
119 }
120
121do_resize:
122 if (getmaxy(stdscr) < (height + CHECKLIST_HEIGTH_MIN))
123 return -ERRDISPLAYTOOSMALL;
124 if (getmaxx(stdscr) < (width + CHECKLIST_WIDTH_MIN))
125 return -ERRDISPLAYTOOSMALL;
126
127 max_choice = MIN(list_height, item_count());
128
129 /* center dialog box on screen */
130 x = (getmaxx(stdscr) - width) / 2;
131 y = (getmaxy(stdscr) - height) / 2;
132
133 draw_shadow(stdscr, y, x, height, width);
134
135 dialog = newwin(height, width, y, x);
136 keypad(dialog, TRUE);
137
138 draw_box(dialog, 0, 0, height, width,
139 dlg.dialog.atr, dlg.border.atr);
140 wattrset(dialog, dlg.border.atr);
141 mvwaddch(dialog, height - 3, 0, ACS_LTEE);
142 for (i = 0; i < width - 2; i++)
143 waddch(dialog, ACS_HLINE);
144 wattrset(dialog, dlg.dialog.atr);
145 waddch(dialog, ACS_RTEE);
146
147 print_title(dialog, title, width);
148
149 wattrset(dialog, dlg.dialog.atr);
150 print_autowrap(dialog, prompt, width - 2, 1, 3);
151
152 list_width = width - 6;
153 box_y = height - list_height - 5;
154 box_x = (width - list_width) / 2 - 1;
155
156 /* create new window for the list */
157 list = subwin(dialog, list_height, list_width, y + box_y + 1,
158 x + box_x + 1);
159
160 keypad(list, TRUE);
161

Callers 1

conf_choiceFunction · 0.85

Calls 15

item_nFunction · 0.85
item_is_selectedFunction · 0.85
item_countFunction · 0.85
draw_shadowFunction · 0.85
draw_boxFunction · 0.85
print_titleFunction · 0.85
print_autowrapFunction · 0.85
item_strFunction · 0.85
item_setFunction · 0.85
print_itemFunction · 0.85
item_set_selectedFunction · 0.85
on_key_escFunction · 0.85

Tested by

no test coverage detected