diff options
author | Alfonso Siciliano <alfsiciliano@gmail.com> | 2022-01-28 08:14:55 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2022-01-28 08:14:55 +0000 |
commit | 02db4a1234b3bd9cf153e567827fd387cf91bfb2 (patch) | |
tree | 6a8d148a11a4a9d58ba1adb078d72e491339652b /examples_library/mixedlist.c | |
parent | 77a55d2c3b4dd48a9a608736a9ba7ebce700bae1 (diff) |
Diffstat (limited to 'examples_library/mixedlist.c')
-rw-r--r-- | examples_library/mixedlist.c | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/examples_library/mixedlist.c b/examples_library/mixedlist.c index 2a4e9102164c..7f299218cb62 100644 --- a/examples_library/mixedlist.c +++ b/examples_library/mixedlist.c @@ -15,7 +15,8 @@ int main() { - int i, j, output; + int output; + unsigned int i, j; struct bsddialog_conf conf; struct bsddialog_menuitem item; struct bsddialog_menuitem check[5] = { @@ -41,30 +42,42 @@ int main() { BSDDIALOG_RADIOLIST, 5, radio } }; - bsddialog_initconf(&conf); - conf.title = "mixedmenu"; - - if (bsddialog_init() < 0) - return -1; + if (bsddialog_init() == BSDDIALOG_ERROR) { + printf("Error: %s\n", bsddialog_geterror()); + return (1); + } - output = bsddialog_mixedlist(&conf, "dialog4ports", 20, 30, 11, 3, group, - NULL,NULL); + bsddialog_initconf(&conf); + conf.title = "mixedlist"; + output = bsddialog_mixedlist(&conf, "Example", 20, 30, 11, 3, group, + NULL, NULL); bsddialog_end(); + if (output == BSDDIALOG_ERROR) { + printf("Error: %s\n", bsddialog_geterror()); + return (1); + } + + if (output == BSDDIALOG_CANCEL) { + printf("Cancel\n"); + return (0); + } + printf("Mixedlist:\n"); - for (i=0; i<3; i++) { - for (j=0; j<group[i].nitems; j++) { + for (i = 0; i < 3; i++) { + for (j = 0; j < group[i].nitems; j++) { item = group[i].items[j]; if (group[i].type == BSDDIALOG_SEPARATOR) printf("----- %s -----\n", item.name); else if (group[i].type == BSDDIALOG_RADIOLIST) - printf(" (%c) %s\n", item.on ? '*' : ' ', item.name); - else /* BSDDIALOG_PORTCHECKLIST */ - printf(" [%c] %s\n", item.on ? 'X' : ' ', item.name); + printf(" (%c) %s\n", + item.on ? '*' : ' ', item.name); + else /* BSDDIALOG_CHECKLIST */ + printf(" [%c] %s\n", + item.on ? 'X' : ' ', item.name); } } - - - return output; -} + + return (output); +}
\ No newline at end of file |