Now line_edit() uses passed string as initial prompt

This commit is contained in:
Andrey A. Chernov 1994-11-02 01:40:34 +00:00
parent d29895dc1a
commit 76ab56f350
2 changed files with 11 additions and 3 deletions

View File

@ -85,6 +85,7 @@ int dialog_inputbox(unsigned char *title, unsigned char *prompt, int height, int
print_button(dialog, " OK ", y, x, TRUE);
first = 1;
strcpy(instr, result);
while (key != ESC) {
if (button == -1) { /* Input box selected */

View File

@ -32,13 +32,20 @@ int line_edit(WINDOW* dialog, int box_y, int box_x, int box_width, chtype attr,
static int input_x, scroll;
static unsigned char instr[MAX_LEN+1];
if (first) {
wattrset(dialog, attr);
keypad(dialog, TRUE);
if (first) {
memset(instr, 0, sizeof(instr));
input_x = scroll = 0;
strcpy(instr, result);
i = strlen(instr);
input_x = i % box_width;
scroll = i - input_x;
wmove(dialog, box_y, box_x);
for (i = 0; i < box_width; i++)
waddch(dialog, instr[scroll+i] ? instr[scroll+i] : ' ');
}
wattrset(dialog, attr);
wmove(dialog, box_y, box_x + input_x);
wrefresh(dialog);
for (;;) {