diff options
author | Benjamin Poirier <bpoirier@suse.de> | 2012-08-23 14:55:05 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2012-09-27 18:08:14 +0200 |
commit | 1d1e2caebbf1f4f25ad473e90650cdc9291fdd22 (patch) | |
tree | b6dd5a253abef0e91389e2ea113b72bd4439f538 /scripts/kconfig/lxdialog/textbox.c | |
parent | 537ddae75c0f41343928d39f308f3ca670f000a8 (diff) | |
download | linux-1d1e2caebbf1f4f25ad473e90650cdc9291fdd22.tar.bz2 |
menuconfig: Extend dialog_textbox so that it can return to a scrolled position
We can now display other UI elements (menus) "on top" of a textbox and then
seemingly come back to it in the same state it was left.
Signed-off-by: Benjamin Poirier <bpoirier@suse.de>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts/kconfig/lxdialog/textbox.c')
-rw-r--r-- | scripts/kconfig/lxdialog/textbox.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdialog/textbox.c index eb4ee92ad2b3..506a095c387c 100644 --- a/scripts/kconfig/lxdialog/textbox.c +++ b/scripts/kconfig/lxdialog/textbox.c @@ -51,7 +51,7 @@ static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw, * keys is a null-terminated array */ int dialog_textbox(const char *title, const char *tbuf, int initial_height, - int initial_width, int *keys) + int initial_width, int *keys, int *_vscroll, int *_hscroll) { int i, x, y, cur_x, cur_y, key = 0; int height, width, boxh, boxw; @@ -65,6 +65,15 @@ int dialog_textbox(const char *title, const char *tbuf, int initial_height, buf = tbuf; page = buf; /* page is pointer to start of page to be displayed */ + if (_vscroll && *_vscroll) { + begin_reached = 0; + + for (i = 0; i < *_vscroll; i++) + get_line(); + } + if (_hscroll) + hscroll = *_hscroll; + do_resize: getmaxyx(stdscr, height, width); if (height < 8 || width < 8) @@ -275,6 +284,19 @@ do_resize: } delwin(box); delwin(dialog); + if (_vscroll) { + const char *s; + + s = buf; + *_vscroll = 0; + back_lines(page_length); + while (s < page && (s = strchr(s, '\n'))) { + (*_vscroll)++; + s++; + } + } + if (_hscroll) + *_hscroll = hscroll; return key; } |