aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/kconfig/nconf.gui.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c
index d64bc1c24c20..4b9d8b66087d 100644
--- a/scripts/kconfig/nconf.gui.c
+++ b/scripts/kconfig/nconf.gui.c
@@ -367,6 +367,7 @@ int dialog_inputbox(WINDOW *main_window,
367 int i, x, y; 367 int i, x, y;
368 int res = -1; 368 int res = -1;
369 int cursor_position = strlen(init); 369 int cursor_position = strlen(init);
370 int cursor_form_win;
370 char *result = *resultp; 371 char *result = *resultp;
371 372
372 if (strlen(init)+1 > *result_len) { 373 if (strlen(init)+1 > *result_len) {
@@ -410,7 +411,9 @@ int dialog_inputbox(WINDOW *main_window,
410 fill_window(prompt_win, prompt); 411 fill_window(prompt_win, prompt);
411 412
412 mvwprintw(form_win, 0, 0, "%*s", prompt_width, " "); 413 mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
413 mvwprintw(form_win, 0, 0, "%s", result); 414 cursor_form_win = min(cursor_position, prompt_width-1);
415 mvwprintw(form_win, 0, 0, "%s",
416 result + cursor_position-cursor_form_win);
414 417
415 /* create panels */ 418 /* create panels */
416 panel = new_panel(win); 419 panel = new_panel(win);
@@ -436,6 +439,8 @@ int dialog_inputbox(WINDOW *main_window,
436 &result[cursor_position], 439 &result[cursor_position],
437 len-cursor_position+1); 440 len-cursor_position+1);
438 cursor_position--; 441 cursor_position--;
442 cursor_form_win--;
443 len--;
439 } 444 }
440 break; 445 break;
441 case KEY_DC: 446 case KEY_DC:
@@ -443,18 +448,22 @@ int dialog_inputbox(WINDOW *main_window,
443 memmove(&result[cursor_position], 448 memmove(&result[cursor_position],
444 &result[cursor_position+1], 449 &result[cursor_position+1],
445 len-cursor_position+1); 450 len-cursor_position+1);
451 len--;
446 } 452 }
447 break; 453 break;
448 case KEY_UP: 454 case KEY_UP:
449 case KEY_RIGHT: 455 case KEY_RIGHT:
450 if (cursor_position < len && 456 if (cursor_position < len) {
451 cursor_position < min(*result_len, prompt_width))
452 cursor_position++; 457 cursor_position++;
458 cursor_form_win++;
459 }
453 break; 460 break;
454 case KEY_DOWN: 461 case KEY_DOWN:
455 case KEY_LEFT: 462 case KEY_LEFT:
456 if (cursor_position > 0) 463 if (cursor_position > 0) {
457 cursor_position--; 464 cursor_position--;
465 cursor_form_win--;
466 }
458 break; 467 break;
459 default: 468 default:
460 if ((isgraph(res) || isspace(res))) { 469 if ((isgraph(res) || isspace(res))) {
@@ -470,16 +479,24 @@ int dialog_inputbox(WINDOW *main_window,
470 len-cursor_position+1); 479 len-cursor_position+1);
471 result[cursor_position] = res; 480 result[cursor_position] = res;
472 cursor_position++; 481 cursor_position++;
482 cursor_form_win++;
483 len++;
473 } else { 484 } else {
474 mvprintw(0, 0, "unknown key: %d\n", res); 485 mvprintw(0, 0, "unknown key: %d\n", res);
475 } 486 }
476 break; 487 break;
477 } 488 }
489 if (cursor_form_win < 0)
490 cursor_form_win = 0;
491 else if (cursor_form_win > prompt_width-1)
492 cursor_form_win = prompt_width-1;
493
478 wmove(form_win, 0, 0); 494 wmove(form_win, 0, 0);
479 wclrtoeol(form_win); 495 wclrtoeol(form_win);
480 mvwprintw(form_win, 0, 0, "%*s", prompt_width, " "); 496 mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
481 mvwprintw(form_win, 0, 0, "%s", result); 497 mvwprintw(form_win, 0, 0, "%s",
482 wmove(form_win, 0, cursor_position); 498 result + cursor_position-cursor_form_win);
499 wmove(form_win, 0, cursor_form_win);
483 touchwin(win); 500 touchwin(win);
484 refresh_all_windows(main_window); 501 refresh_all_windows(main_window);
485 502