Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 333629
b: refs/heads/master
c: 537ddae
h: refs/heads/master
i:
  333627: b4cd01d
v: v3
  • Loading branch information
Benjamin Poirier authored and Michal Marek committed Sep 27, 2012
1 parent 235191c commit de3336a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b9d29abd98a2bbeb3a6c49c1607348c92bc80105
refs/heads/master: 537ddae75c0f41343928d39f308f3ca670f000a8
3 changes: 2 additions & 1 deletion trunk/scripts/kconfig/lxdialog/dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ int first_alpha(const char *string, const char *exempt);
int dialog_yesno(const char *title, const char *prompt, int height, int width);
int dialog_msgbox(const char *title, const char *prompt, int height,
int width, int pause);
int dialog_textbox(const char *title, const char *file, int height, int width);
int dialog_textbox(const char *title, const char *file, int height, int width,
int *keys);
int dialog_menu(const char *title, const char *prompt,
const void *selected, int *s_scroll);
int dialog_checklist(const char *title, const char *prompt, int height,
Expand Down
31 changes: 21 additions & 10 deletions trunk/scripts/kconfig/lxdialog/textbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw,

/*
* Display text from a file in a dialog box.
*
* keys is a null-terminated array
*/
int dialog_textbox(const char *title, const char *tbuf,
int initial_height, int initial_width)
int dialog_textbox(const char *title, const char *tbuf, int initial_height,
int initial_width, int *keys)
{
int i, x, y, cur_x, cur_y, key = 0;
int height, width, boxh, boxw;
int passed_end;
WINDOW *dialog, *box;
bool done = false;

begin_reached = 1;
end_reached = 0;
Expand Down Expand Up @@ -122,17 +124,17 @@ int dialog_textbox(const char *title, const char *tbuf,
attr_clear(box, boxh, boxw, dlg.dialog.atr);
refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x);

while ((key != KEY_ESC) && (key != '\n')) {
while (!done) {
key = wgetch(dialog);
switch (key) {
case 'E': /* Exit */
case 'e':
case 'X':
case 'x':
case 'q':
delwin(box);
delwin(dialog);
return 0;
case '\n':
done = true;
break;
case 'g': /* First page */
case KEY_HOME:
if (!begin_reached) {
Expand All @@ -156,6 +158,8 @@ int dialog_textbox(const char *title, const char *tbuf,
case 'k':
case KEY_UP:
if (!begin_reached) {
int passed_end = 0;

back_lines(page_length + 1);

/* We don't call print_page() here but use
Expand All @@ -169,7 +173,6 @@ int dialog_textbox(const char *title, const char *tbuf,
wscrl(box, -1); /* Scroll box region down one line */
scrollok(box, FALSE);
page_length = 0;
passed_end = 0;
for (i = 0; i < boxh; i++) {
if (!i) {
/* print first line of page */
Expand Down Expand Up @@ -252,19 +255,27 @@ int dialog_textbox(const char *title, const char *tbuf,
cur_y, cur_x);
break;
case KEY_ESC:
key = on_key_esc(dialog);
if (on_key_esc(dialog) == KEY_ESC)
done = true;
break;
case KEY_RESIZE:
back_lines(height);
delwin(box);
delwin(dialog);
on_key_resize();
goto do_resize;
default:
for (i = 0; keys[i]; i++) {
if (key == keys[i]) {
done = true;
break;
}
}
}
}
delwin(box);
delwin(dialog);
return key; /* ESC pressed */
return key;
}

/*
Expand Down
12 changes: 10 additions & 2 deletions trunk/scripts/kconfig/mconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ static void conf_choice(struct menu *menu);
static void conf_string(struct menu *menu);
static void conf_load(void);
static void conf_save(void);
static int show_textbox_ext(const char *title, const char *text, int r, int c,
int *keys);
static void show_textbox(const char *title, const char *text, int r, int c);
static void show_helptext(const char *title, const char *text);
static void show_help(struct menu *menu);
Expand Down Expand Up @@ -618,10 +620,16 @@ static void conf(struct menu *menu)
}
}

static void show_textbox(const char *title, const char *text, int r, int c)
static int show_textbox_ext(const char *title, const char *text, int r, int c,
int *keys)
{
dialog_clear();
dialog_textbox(title, text, r, c);
return dialog_textbox(title, text, r, c, keys);
}

static void show_textbox(const char *title, const char *text, int r, int c)
{
show_textbox_ext(title, text, r, c, (int []) {0});
}

static void show_helptext(const char *title, const char *text)
Expand Down

0 comments on commit de3336a

Please sign in to comment.