aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorBenjamin Poirier <bpoirier@suse.de>2012-08-23 14:55:05 -0400
committerMichal Marek <mmarek@suse.cz>2012-09-27 12:08:14 -0400
commit1d1e2caebbf1f4f25ad473e90650cdc9291fdd22 (patch)
treeb6dd5a253abef0e91389e2ea113b72bd4439f538 /scripts
parent537ddae75c0f41343928d39f308f3ca670f000a8 (diff)
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')
-rw-r--r--scripts/kconfig/lxdialog/dialog.h2
-rw-r--r--scripts/kconfig/lxdialog/textbox.c24
-rw-r--r--scripts/kconfig/mconf.c8
3 files changed, 28 insertions, 6 deletions
diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h
index 35ca0286d105..2a01cdfae5a8 100644
--- a/scripts/kconfig/lxdialog/dialog.h
+++ b/scripts/kconfig/lxdialog/dialog.h
@@ -211,7 +211,7 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width);
211int dialog_msgbox(const char *title, const char *prompt, int height, 211int dialog_msgbox(const char *title, const char *prompt, int height,
212 int width, int pause); 212 int width, int pause);
213int dialog_textbox(const char *title, const char *file, int height, int width, 213int dialog_textbox(const char *title, const char *file, int height, int width,
214 int *keys); 214 int *keys, int *_vscroll, int *_hscroll);
215int dialog_menu(const char *title, const char *prompt, 215int dialog_menu(const char *title, const char *prompt,
216 const void *selected, int *s_scroll); 216 const void *selected, int *s_scroll);
217int dialog_checklist(const char *title, const char *prompt, int height, 217int dialog_checklist(const char *title, const char *prompt, int height,
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,
51 * keys is a null-terminated array 51 * keys is a null-terminated array
52 */ 52 */
53int dialog_textbox(const char *title, const char *tbuf, int initial_height, 53int dialog_textbox(const char *title, const char *tbuf, int initial_height,
54 int initial_width, int *keys) 54 int initial_width, int *keys, int *_vscroll, int *_hscroll)
55{ 55{
56 int i, x, y, cur_x, cur_y, key = 0; 56 int i, x, y, cur_x, cur_y, key = 0;
57 int height, width, boxh, boxw; 57 int height, width, boxh, boxw;
@@ -65,6 +65,15 @@ int dialog_textbox(const char *title, const char *tbuf, int initial_height,
65 buf = tbuf; 65 buf = tbuf;
66 page = buf; /* page is pointer to start of page to be displayed */ 66 page = buf; /* page is pointer to start of page to be displayed */
67 67
68 if (_vscroll && *_vscroll) {
69 begin_reached = 0;
70
71 for (i = 0; i < *_vscroll; i++)
72 get_line();
73 }
74 if (_hscroll)
75 hscroll = *_hscroll;
76
68do_resize: 77do_resize:
69 getmaxyx(stdscr, height, width); 78 getmaxyx(stdscr, height, width);
70 if (height < 8 || width < 8) 79 if (height < 8 || width < 8)
@@ -275,6 +284,19 @@ do_resize:
275 } 284 }
276 delwin(box); 285 delwin(box);
277 delwin(dialog); 286 delwin(dialog);
287 if (_vscroll) {
288 const char *s;
289
290 s = buf;
291 *_vscroll = 0;
292 back_lines(page_length);
293 while (s < page && (s = strchr(s, '\n'))) {
294 (*_vscroll)++;
295 s++;
296 }
297 }
298 if (_hscroll)
299 *_hscroll = hscroll;
278 return key; 300 return key;
279} 301}
280 302
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index e097efb9c3ef..b3a37c2b16ae 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -280,7 +280,7 @@ static void conf_string(struct menu *menu);
280static void conf_load(void); 280static void conf_load(void);
281static void conf_save(void); 281static void conf_save(void);
282static int show_textbox_ext(const char *title, const char *text, int r, int c, 282static int show_textbox_ext(const char *title, const char *text, int r, int c,
283 int *keys); 283 int *keys, int *vscroll, int *hscroll);
284static void show_textbox(const char *title, const char *text, int r, int c); 284static void show_textbox(const char *title, const char *text, int r, int c);
285static void show_helptext(const char *title, const char *text); 285static void show_helptext(const char *title, const char *text);
286static void show_help(struct menu *menu); 286static void show_help(struct menu *menu);
@@ -621,15 +621,15 @@ static void conf(struct menu *menu)
621} 621}
622 622
623static int show_textbox_ext(const char *title, const char *text, int r, int c, 623static int show_textbox_ext(const char *title, const char *text, int r, int c,
624 int *keys) 624 int *keys, int *vscroll, int *hscroll)
625{ 625{
626 dialog_clear(); 626 dialog_clear();
627 return dialog_textbox(title, text, r, c, keys); 627 return dialog_textbox(title, text, r, c, keys, vscroll, hscroll);
628} 628}
629 629
630static void show_textbox(const char *title, const char *text, int r, int c) 630static void show_textbox(const char *title, const char *text, int r, int c)
631{ 631{
632 show_textbox_ext(title, text, r, c, (int []) {0}); 632 show_textbox_ext(title, text, r, c, (int []) {0}, NULL, NULL);
633} 633}
634 634
635static void show_helptext(const char *title, const char *text) 635static void show_helptext(const char *title, const char *text)