diff options
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  | 
