summaryrefslogtreecommitdiffstats
path: root/contrib/dialog/buttons.c
diff options
context:
space:
mode:
authornwhitehorn <nwhitehorn@FreeBSD.org>2012-10-21 18:25:12 +0000
committernwhitehorn <nwhitehorn@FreeBSD.org>2012-10-21 18:25:12 +0000
commit59ae05f843643afc6998fcc4b2b415d89a8635ee (patch)
tree74dabcbe10843be3b85112de4524f2abb8e4112f /contrib/dialog/buttons.c
parent2ad040bf3f552fc8b740e79fe6db1bf91414d583 (diff)
parenta94245b3d36b447d1f761028da7e072210e64b43 (diff)
downloadFreeBSD-src-59ae05f843643afc6998fcc4b2b415d89a8635ee.zip
FreeBSD-src-59ae05f843643afc6998fcc4b2b415d89a8635ee.tar.gz
Update dialog to 20120706: includes minor useability enhancements and
fixes for warnings encountered with clang.
Diffstat (limited to 'contrib/dialog/buttons.c')
-rw-r--r--contrib/dialog/buttons.c55
1 files changed, 41 insertions, 14 deletions
diff --git a/contrib/dialog/buttons.c b/contrib/dialog/buttons.c
index 0241060..1799851 100644
--- a/contrib/dialog/buttons.c
+++ b/contrib/dialog/buttons.c
@@ -1,9 +1,9 @@
/*
- * $Id: buttons.c,v 1.86 2011/06/28 10:46:46 tom Exp $
+ * $Id: buttons.c,v 1.90 2012/07/01 20:42:05 tom Exp $
*
* buttons.c -- draw buttons, e.g., OK/Cancel
*
- * Copyright 2000-2010,2011 Thomas E. Dickey
+ * Copyright 2000-2011,2012 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@@ -104,11 +104,11 @@ print_button(WINDOW *win, char *label, int y, int x, int selected)
: button_label_inactive_attr);
(void) wmove(win, y, x);
- wattrset(win, selected
- ? button_active_attr
- : button_inactive_attr);
+ (void) wattrset(win, selected
+ ? button_active_attr
+ : button_inactive_attr);
(void) waddstr(win, "<");
- wattrset(win, label_attr);
+ (void) wattrset(win, label_attr);
for (i = 0; i < limit; ++i) {
int first = indx[i];
int last = indx[i + 1];
@@ -120,14 +120,14 @@ print_button(WINDOW *win, char *label, int y, int x, int selected)
const char *temp = (label + first);
int cmp = string_to_char(&temp);
if (dlg_isupper(cmp)) {
- wattrset(win, key_attr);
+ (void) wattrset(win, key_attr);
state = 1;
}
break;
}
#endif
if (dlg_isupper(UCH(label[first]))) {
- wattrset(win, key_attr);
+ (void) wattrset(win, key_attr);
state = 1;
}
break;
@@ -138,9 +138,9 @@ print_button(WINDOW *win, char *label, int y, int x, int selected)
}
waddnstr(win, label + first, last - first);
}
- wattrset(win, selected
- ? button_active_attr
- : button_inactive_attr);
+ (void) wattrset(win, selected
+ ? button_active_attr
+ : button_inactive_attr);
(void) waddstr(win, ">");
(void) wmove(win, y, x + ((int) strspn(label, " ")) + 1);
}
@@ -310,7 +310,7 @@ dlg_draw_buttons(WINDOW *win,
(void) wmove(win, final_y, final_x);
wrefresh(win);
free(buffer);
- wattrset(win, save);
+ (void) wattrset(win, save);
}
/*
@@ -488,10 +488,12 @@ dlg_exit_buttoncode(int button)
const char **
dlg_ok_label(void)
{
- static const char *labels[3];
+ static const char *labels[4];
int n = 0;
labels[n++] = my_ok_label();
+ if (dialog_vars.extra_button)
+ labels[n++] = my_extra_label();
if (dialog_vars.help_button)
labels[n++] = my_help_label();
labels[n] = 0;
@@ -537,6 +539,7 @@ dlg_ok_buttoncode(int button)
} else if (dialog_vars.help_button && (button == n)) {
result = DLG_EXIT_HELP;
}
+ dlg_trace_msg("# dlg_ok_buttoncode(%d) = %d\n", button, result);
return result;
}
@@ -575,7 +578,7 @@ dlg_prev_ok_buttonindex(int current, int extra)
/*
* Find the button-index for the "OK" or "Cancel" button, according to
* whether --defaultno is given. If --nocancel was given, we always return
- * the index for "OK".
+ * the index for the first button (usually "OK" unless --nook was used).
*/
int
dlg_defaultno_button(void)
@@ -586,6 +589,30 @@ dlg_defaultno_button(void)
while (dlg_ok_buttoncode(result) != DLG_EXIT_CANCEL)
++result;
}
+ dlg_trace_msg("# dlg_defaultno_button() = %d\n", result);
+ return result;
+}
+
+/*
+ * Find the button-index for a button named with --default-button. If the
+ * option was not specified, or if the selected button does not exist, return
+ * the index of the first button (usually "OK" unless --nook was used).
+ */
+int
+dlg_default_button(void)
+{
+ int i, n;
+ int result = 0;
+
+ if (dialog_vars.default_button >= 0) {
+ for (i = 0; (n = dlg_ok_buttoncode(i)) >= 0; i++) {
+ if (n == dialog_vars.default_button) {
+ result = i;
+ break;
+ }
+ }
+ }
+ dlg_trace_msg("# dlg_default_button() = %d\n", result);
return result;
}
OpenPOWER on IntegriCloud