Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 274308
b: refs/heads/master
c: e631a57
h: refs/heads/master
v: v3
  • Loading branch information
Cheng Renquan authored and Michal Marek committed Sep 9, 2011
1 parent 57fa4a1 commit bac6f57
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 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: 5ea9f64ffc073bf2882f6aa83b0dad3609b1e67a
refs/heads/master: e631a57a19e103c3bb59495b236634ec62e2a850
29 changes: 23 additions & 6 deletions trunk/scripts/kconfig/nconf.gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ int dialog_inputbox(WINDOW *main_window,
int i, x, y;
int res = -1;
int cursor_position = strlen(init);
int cursor_form_win;
char *result = *resultp;

if (strlen(init)+1 > *result_len) {
Expand Down Expand Up @@ -410,7 +411,9 @@ int dialog_inputbox(WINDOW *main_window,
fill_window(prompt_win, prompt);

mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
mvwprintw(form_win, 0, 0, "%s", result);
cursor_form_win = min(cursor_position, prompt_width-1);
mvwprintw(form_win, 0, 0, "%s",
result + cursor_position-cursor_form_win);

/* create panels */
panel = new_panel(win);
Expand All @@ -436,25 +439,31 @@ int dialog_inputbox(WINDOW *main_window,
&result[cursor_position],
len-cursor_position+1);
cursor_position--;
cursor_form_win--;
len--;
}
break;
case KEY_DC:
if (cursor_position >= 0 && cursor_position < len) {
memmove(&result[cursor_position],
&result[cursor_position+1],
len-cursor_position+1);
len--;
}
break;
case KEY_UP:
case KEY_RIGHT:
if (cursor_position < len &&
cursor_position < min(*result_len, prompt_width))
if (cursor_position < len) {
cursor_position++;
cursor_form_win++;
}
break;
case KEY_DOWN:
case KEY_LEFT:
if (cursor_position > 0)
if (cursor_position > 0) {
cursor_position--;
cursor_form_win--;
}
break;
default:
if ((isgraph(res) || isspace(res))) {
Expand All @@ -470,16 +479,24 @@ int dialog_inputbox(WINDOW *main_window,
len-cursor_position+1);
result[cursor_position] = res;
cursor_position++;
cursor_form_win++;
len++;
} else {
mvprintw(0, 0, "unknown key: %d\n", res);
}
break;
}
if (cursor_form_win < 0)
cursor_form_win = 0;
else if (cursor_form_win > prompt_width-1)
cursor_form_win = prompt_width-1;

wmove(form_win, 0, 0);
wclrtoeol(form_win);
mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
mvwprintw(form_win, 0, 0, "%s", result);
wmove(form_win, 0, cursor_position);
mvwprintw(form_win, 0, 0, "%s",
result + cursor_position-cursor_form_win);
wmove(form_win, 0, cursor_form_win);
touchwin(win);
refresh_all_windows(main_window);

Expand Down

0 comments on commit bac6f57

Please sign in to comment.