summaryrefslogtreecommitdiffstats
path: root/contrib/dialog/checklist.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/dialog/checklist.c')
-rw-r--r--contrib/dialog/checklist.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/contrib/dialog/checklist.c b/contrib/dialog/checklist.c
index cdefe77..4b73ceb 100644
--- a/contrib/dialog/checklist.c
+++ b/contrib/dialog/checklist.c
@@ -1,5 +1,5 @@
/*
- * $Id: checklist.c,v 1.124 2011/01/19 00:27:53 tom Exp $
+ * $Id: checklist.c,v 1.127 2011/06/29 23:04:09 tom Exp $
*
* checklist.c -- implements the checklist box
*
@@ -149,6 +149,7 @@ dlg_checklist(const char *title,
{
/* *INDENT-OFF* */
static DLG_KEYS_BINDING binding[] = {
+ HELPKEY_BINDINGS,
ENTERKEY_BINDINGS,
DLG_KEYS_DATA( DLGK_FIELD_NEXT, KEY_RIGHT ),
DLG_KEYS_DATA( DLGK_FIELD_NEXT, TAB ),
@@ -193,6 +194,24 @@ dlg_checklist(const char *title,
dlg_does_output();
dlg_tab_correct_str(prompt);
+ /*
+ * If this is a radiobutton list, ensure that no more than one item is
+ * selected initially. Allow none to be selected, since some users may
+ * wish to provide this flavor.
+ */
+ if (flag == FLAG_RADIO) {
+ bool first = TRUE;
+
+ for (i = 0; i < item_no; i++) {
+ if (items[i].state) {
+ if (first) {
+ first = FALSE;
+ } else {
+ items[i].state = 0;
+ }
+ }
+ }
+ }
#ifdef KEY_RESIZE
retry:
#endif
@@ -291,11 +310,12 @@ dlg_checklist(const char *title,
choice = max_choice - 1;
}
/* Print the list */
- for (i = 0; i < max_choice; i++)
+ for (i = 0; i < max_choice; i++) {
print_item(list,
&items[i + scrollamt],
states,
i, i == choice);
+ }
(void) wnoutrefresh(list);
/* register the new window, along with its borders */
@@ -565,7 +585,7 @@ dlg_checklist(const char *title,
if (fkey) {
switch (key) {
case DLGK_ENTER:
- result = dlg_ok_buttoncode(button);
+ result = dlg_enter_buttoncode(button);
break;
case DLGK_FIELD_PREV:
button = dlg_prev_button(buttons, button);
OpenPOWER on IntegriCloud