summaryrefslogtreecommitdiff
path: root/lib/messagebox.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/messagebox.c')
-rw-r--r--lib/messagebox.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/lib/messagebox.c b/lib/messagebox.c
index 06753be20c3d..7063ea9d273e 100644
--- a/lib/messagebox.c
+++ b/lib/messagebox.c
@@ -103,7 +103,7 @@ do_message(struct bsddialog_conf *conf, const char *text, int rows, int cols,
struct buttons bs)
{
bool hastext, loop;
- int y, x, h, w, retval, ytextpad, htextpad, unused;
+ int y, x, h, w, retval, ytextpad, htextpad, printrows, unused;
WINDOW *widget, *textpad, *shadow;
wint_t input;
@@ -120,12 +120,13 @@ do_message(struct bsddialog_conf *conf, const char *text, int rows, int cols,
true) != 0)
return (BSDDIALOG_ERROR);
+ printrows = h - 4;
ytextpad = 0;
getmaxyx(textpad, htextpad, unused);
unused++; /* fix unused error */
- textupdate(widget, textpad, htextpad, ytextpad, hastext);
loop = true;
while (loop) {
+ textupdate(widget, textpad, htextpad, ytextpad, hastext);
doupdate();
if (get_wch(&input) == ERR)
continue;
@@ -160,6 +161,30 @@ do_message(struct bsddialog_conf *conf, const char *text, int rows, int cols,
wnoutrefresh(widget);
}
break;
+ case KEY_UP:
+ if (ytextpad > 0)
+ ytextpad--;
+ break;
+ case KEY_DOWN:
+ if (ytextpad + printrows < htextpad)
+ ytextpad++;
+ break;
+ case KEY_HOME:
+ ytextpad = 0;
+ break;
+ case KEY_END:
+ ytextpad = htextpad - printrows;
+ ytextpad = ytextpad < 0 ? 0 : ytextpad;
+ break;
+ case KEY_PPAGE:
+ ytextpad -= printrows;
+ ytextpad = ytextpad < 0 ? 0 : ytextpad;
+ break;
+ case KEY_NPAGE:
+ ytextpad += printrows;
+ if (ytextpad + printrows > htextpad)
+ ytextpad = htextpad - printrows;
+ break;
case KEY_F(1):
if (conf->key.f1_file == NULL &&
conf->key.f1_message == NULL)
@@ -186,6 +211,7 @@ do_message(struct bsddialog_conf *conf, const char *text, int rows, int cols,
textpad, text, &bs, true) != 0)
return (BSDDIALOG_ERROR);
+ printrows = h - 4;
getmaxyx(textpad, htextpad, unused);
ytextpad = 0;
textupdate(widget, textpad, htextpad, ytextpad, hastext);
@@ -193,18 +219,6 @@ do_message(struct bsddialog_conf *conf, const char *text, int rows, int cols,
/* Important to fix grey lines expanding screen */
refresh();
break;
- case KEY_UP:
- if (ytextpad == 0)
- break;
- ytextpad--;
- textupdate(widget, textpad, htextpad, ytextpad, hastext);
- break;
- case KEY_DOWN:
- if (ytextpad + h - 4 >= htextpad)
- break;
- ytextpad++;
- textupdate(widget, textpad, htextpad, ytextpad, hastext);
- break;
default:
if (shortcut_buttons(input, &bs)) {
retval = bs.value[bs.curr];