summaryrefslogtreecommitdiffstats
path: root/contrib/dialog/progressbox.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/progressbox.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/progressbox.c')
-rw-r--r--contrib/dialog/progressbox.c60
1 files changed, 44 insertions, 16 deletions
diff --git a/contrib/dialog/progressbox.c b/contrib/dialog/progressbox.c
index 024e288..077339c 100644
--- a/contrib/dialog/progressbox.c
+++ b/contrib/dialog/progressbox.c
@@ -1,5 +1,5 @@
/*
- * $Id: progressbox.c,v 1.13 2011/06/27 08:18:20 tom Exp $
+ * $Id: progressbox.c,v 1.21 2012/07/03 00:12:52 tom Exp $
*
* progressbox.c -- implements the progress box
*
@@ -99,6 +99,7 @@ print_line(MY_OBJ * obj, WINDOW *win, int row, int width)
#endif
getyx(win, y, x);
+ (void) y;
/* Clear 'residue' of previous line */
for (i = 0; i < width - x; i++)
(void) waddch(win, ' ');
@@ -111,54 +112,79 @@ pause_for_ok(WINDOW *dialog, int height, int width)
static DLG_KEYS_BINDING binding[] = {
HELPKEY_BINDINGS,
ENTERKEY_BINDINGS,
- DLG_KEYS_DATA( DLGK_ENTER, ' ' ),
+ TRAVERSE_BINDINGS,
END_KEYS_BINDING
};
/* *INDENT-ON* */
- int button = 0;
+ int button;
int key = 0, fkey;
int result = DLG_EXIT_UNKNOWN;
const char **buttons = dlg_ok_label();
int check;
+ int save_nocancel = dialog_vars.nocancel;
+ bool redraw = TRUE;
+
+ dialog_vars.nocancel = TRUE;
+ button = dlg_default_button();
dlg_register_window(dialog, "progressbox", binding);
dlg_register_buttons(dialog, "progressbox", buttons);
- dlg_draw_bottom_box(dialog);
+ dlg_draw_bottom_box2(dialog, border_attr, border2_attr, dialog_attr);
mouse_mkbutton(height - 2, width / 2 - 4, 6, '\n');
- dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width);
while (result == DLG_EXIT_UNKNOWN) {
+ if (redraw) {
+ redraw = FALSE;
+ if (button < 0)
+ button = 0;
+ dlg_draw_buttons(dialog,
+ height - 2, 0,
+ buttons, button,
+ FALSE, width);
+ }
+
key = dlg_mouse_wgetch(dialog, &fkey);
if (dlg_result_key(key, fkey, &result))
break;
if (!fkey && (check = dlg_char_to_button(key, buttons)) >= 0) {
- result = check ? DLG_EXIT_HELP : DLG_EXIT_OK;
+ result = dlg_ok_buttoncode(check);
break;
}
if (fkey) {
switch (key) {
- case DLGK_ENTER:
- result = button ? DLG_EXIT_HELP : DLG_EXIT_OK;
+ case DLGK_FIELD_NEXT:
+ button = dlg_next_button(buttons, button);
+ redraw = TRUE;
break;
- case DLGK_MOUSE(0):
- result = DLG_EXIT_OK;
+ case DLGK_FIELD_PREV:
+ button = dlg_prev_button(buttons, button);
+ redraw = TRUE;
break;
- case DLGK_MOUSE(1):
- result = DLG_EXIT_HELP;
+ case DLGK_ENTER:
+ result = dlg_ok_buttoncode(button);
break;
default:
- beep();
+ if (is_DLGK_MOUSE(key)) {
+ result = dlg_ok_buttoncode(key - M_EVENT);
+ if (result < 0)
+ result = DLG_EXIT_OK;
+ } else {
+ beep();
+ }
break;
}
+
} else {
beep();
}
}
dlg_unregister_window(dialog);
+
+ dialog_vars.nocancel = save_nocancel;
return result;
}
@@ -188,16 +214,17 @@ dlg_progressbox(const char *title,
dialog = dlg_new_window(height, width, y, x);
- dlg_draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
+ dlg_draw_box2(dialog, 0, 0, height, width, dialog_attr, border_attr, border2_attr);
dlg_draw_title(dialog, title);
dlg_draw_helpline(dialog, FALSE);
if (*prompt != '\0') {
int y2, x2;
- wattrset(dialog, dialog_attr);
+ (void) wattrset(dialog, dialog_attr);
dlg_print_autowrap(dialog, prompt, height, width);
getyx(dialog, y2, x2);
+ (void) x2;
++y2;
wmove(dialog, y2, MARGIN);
for (i = 0; i < getmaxx(dialog) - 2 * MARGIN; i++)
@@ -236,6 +263,7 @@ dlg_progressbox(const char *title,
print_line(obj, text, thigh - 1, width - (2 * MARGIN));
}
(void) wrefresh(text);
+ dlg_trace_win(dialog);
if (obj->is_eof)
break;
}
@@ -254,7 +282,7 @@ dlg_progressbox(const char *title,
free(prompt);
free(obj);
- return DLG_EXIT_OK;
+ return result;
}
/*
OpenPOWER on IntegriCloud