xref: /freebsd/contrib/bsddialog/examples_library/radiolist.c (revision ec0ea6efa1ad229d75c394c1a9b9cac33af2b1d3)
1 /*-
2  * SPDX-License-Identifier: CC0-1.0
3  *
4  * Written in 2021 by Alfonso Sabato Siciliano.
5  * To the extent possible under law, the author has dedicated all copyright
6  * and related and neighboring rights to this software to the public domain
7  * worldwide. This software is distributed without any warranty, see:
8  *   <http://creativecommons.org/publicdomain/zero/1.0/>.
9  */
10 
11 #include <stdio.h>
12 #include <string.h>
13 
14 #include <bsddialog.h>
15 
16 int main()
17 {
18 	int i, output;
19 	struct bsddialog_conf conf;
20 	struct bsddialog_menuitem items[5] = {
21 	    {"", true,  0, "Name 1", "Desc 1", "Bottom Desc 1"},
22 	    {"", false, 0, "Name 2", "Desc 2", "Bottom Desc 2"},
23 	    {"", true,  0, "Name 3", "Desc 3", "Bottom Desc 3"},
24 	    {"", false, 0, "Name 4", "Desc 4", "Bottom Desc 4"},
25 	    {"", true,  0, "Name 5", "Desc 5", "Bottom Desc 5"}
26 	};
27 
28 	bsddialog_initconf(&conf);
29 	conf.title = "radiolist";
30 
31 	if (bsddialog_init() < 0)
32 		return -1;
33 
34 	output = bsddialog_radiolist(&conf, "Example", 15, 30, 5, 5, items, NULL);
35 
36 	bsddialog_end();
37 
38 	printf("Radiolist:\n");
39 	for (i=0; i<5; i++)
40 		printf(" (%c) %s\n", items[i].on ? '*' : ' ', items[i].name);
41 
42 
43 	return output;
44 }
45