aboutsummaryrefslogtreecommitdiff
path: root/msgbox.c
diff options
context:
space:
mode:
Diffstat (limited to 'msgbox.c')
-rw-r--r--msgbox.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/msgbox.c b/msgbox.c
index d9a2eb1c9065..5264368b67dc 100644
--- a/msgbox.c
+++ b/msgbox.c
@@ -1,9 +1,9 @@
/*
- * $Id: msgbox.c,v 1.81 2018/06/21 23:29:59 tom Exp $
+ * $Id: msgbox.c,v 1.89 2020/11/23 00:32:02 tom Exp $
*
* msgbox.c -- implements the message box and info box
*
- * Copyright 2000-2012,2018 Thomas E. Dickey
+ * Copyright 2000-2019,2020 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
@@ -45,15 +45,14 @@ dialog_msgbox(const char *title, const char *cprompt, int height, int width,
};
/* *INDENT-ON* */
- int x, y, last = 0, page;
+ int x, y, page;
int button;
- int key = 0, fkey;
+ int key, fkey;
int result = DLG_EXIT_UNKNOWN;
WINDOW *dialog = 0;
char *prompt;
const char **buttons = dlg_ok_label();
int offset = 0;
- int check;
bool show = TRUE;
int min_width = (pauseopt == 1 ? 12 : 0);
bool save_nocancel = dialog_vars.nocancel;
@@ -91,16 +90,10 @@ dialog_msgbox(const char *title, const char *cprompt, int height, int width,
x = dlg_box_x_ordinate(width);
y = dlg_box_y_ordinate(height);
-#ifdef KEY_RESIZE
- if (dialog != 0)
- dlg_move_window(dialog, height, width, y, x);
- else
-#endif
- {
- dialog = dlg_new_window(height, width, y, x);
- dlg_register_window(dialog, "msgbox", binding);
- dlg_register_buttons(dialog, "msgbox", buttons);
- }
+ dialog = dlg_new_window(height, width, y, x);
+ dlg_register_window(dialog, "msgbox", binding);
+ dlg_register_buttons(dialog, "msgbox", buttons);
+
page = height - (1 + 3 * MARGIN);
dlg_mouse_setbase(x, y);
@@ -111,12 +104,16 @@ dialog_msgbox(const char *title, const char *cprompt, int height, int width,
dlg_attrset(dialog, dialog_attr);
if (pauseopt) {
+ int last = 0;
+
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);
dlg_draw_helpline(dialog, FALSE);
while (result == DLG_EXIT_UNKNOWN) {
+ int check;
+
if (show) {
last = dlg_print_scrolled(dialog, prompt, offset,
page, width, pauseopt);
@@ -124,9 +121,10 @@ dialog_msgbox(const char *title, const char *cprompt, int height, int width,
show = FALSE;
}
key = dlg_mouse_wgetch(dialog, &fkey);
- if (dlg_result_key(key, fkey, &result))
- break;
-
+ if (dlg_result_key(key, fkey, &result)) {
+ if (!dlg_button_key(result, &button, &key, &fkey))
+ break;
+ }
if (!fkey && (check = dlg_char_to_button(key, buttons)) >= 0) {
result = dlg_ok_buttoncode(check);
break;
@@ -137,11 +135,11 @@ dialog_msgbox(const char *title, const char *cprompt, int height, int width,
#ifdef KEY_RESIZE
case KEY_RESIZE:
dlg_will_resize(dialog);
- dlg_clear();
free(prompt);
height = req_high;
width = req_wide;
show = TRUE;
+ _dlg_resize_cleanup(dialog);
goto restart;
#endif
case DLGK_FIELD_NEXT:
@@ -163,6 +161,9 @@ dialog_msgbox(const char *title, const char *cprompt, int height, int width,
FALSE, width);
break;
case DLGK_ENTER:
+ result = dlg_enter_buttoncode(button);
+ break;
+ case DLGK_LEAVE:
result = dlg_ok_buttoncode(button);
break;
default:
@@ -180,7 +181,7 @@ dialog_msgbox(const char *title, const char *cprompt, int height, int width,
}
break;
}
- } else {
+ } else if (key > 0) {
beep();
}
}
@@ -191,6 +192,7 @@ dialog_msgbox(const char *title, const char *cprompt, int height, int width,
dlg_trace_win(dialog);
result = DLG_EXIT_OK;
}
+ dlg_add_last_key(-1);
dlg_del_window(dialog);
dlg_mouse_free_regions();