MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / section_dialogs

Function section_dialogs

scripts/examples/example.c:234–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232/* ------------------------------------------------------------------------- */
233
234void section_dialogs(void)
235{
236 char* items[4];
237 int selected[4];
238 char typed[64];
239 char line[LINEN];
240 int picked;
241 int confirmed;
242 int number;
243 int i;
244
245 gui_message("gui_message: one OK button. Use it for results and dead ends.");
246
247 if (!gui_confirm("gui_confirm: yes/no. Continue the dialog tour?")) {
248 printf("user declined at gui_confirm\n");
249 return;
250 }
251
252 items[0] = "Alpha";
253 items[1] = "Beta";
254 items[2] = "Gamma";
255 items[3] = "Delta";
256
257 /* gui_pick_one returns the index picked, or -1 if the user backed out.
258 * Always handle -1: it is the normal way to cancel. */
259 picked = gui_pick_one("gui_pick_one: choose a row (B cancels)", items, 4);
260 if (picked < 0) {
261 printf("gui_pick_one: cancelled\n");
262 }
263 else {
264 printf("gui_pick_one: %d (%s)\n", picked, items[picked]);
265 }
266
267 /* gui_pick_many takes an int[] of the same length: 1 = preselected on the
268 * way in, and on the way out it holds the user's answer. The return value
269 * is 1 when confirmed, 0 when cancelled (the array is untouched then). */
270 selected[0] = 1;
271 selected[1] = 0;
272 selected[2] = 1;
273 selected[3] = 0;
274 confirmed = gui_pick_many("gui_pick_many: Alpha and Gamma start ticked", items, 4, selected);
275 printf("gui_pick_many: confirmed=%d\n", confirmed);
276 if (confirmed) {
277 for (i = 0; i < 4; i++) {
278 if (selected[i]) {
279 printf(" chosen: %s\n", items[i]);
280 }
281 }
282 }
283
284 /* gui_keyboard writes into a buffer you own; the third argument is that
285 * buffer's size including the terminator. An empty result means the user
286 * cancelled or typed nothing — you cannot tell the two apart. */
287 typed[0] = '\0';
288 gui_keyboard(typed, "gui_keyboard: type something", 64);
289 printf("gui_keyboard: '%s'\n", typed);
290
291 /* gui_numpad enforces [min, max] in the keyboard itself, so there is no

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected