summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>1994-10-10 22:32:07 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>1994-10-10 22:32:07 +0000
commit296c81b4e8cae5c6504d6aee474731d66923ca9e (patch)
tree5a7e1593544e61d4faa63ba1cd4221cf056f0d73
parent7f6f3361ff9d251e7cdbfe653838c3d3fa6f7152 (diff)
Notes
-rwxr-xr-xgnu/usr.bin/dialog/TESTS/inputbox3
-rw-r--r--gnu/usr.bin/dialog/inputbox.c28
2 files changed, 26 insertions, 5 deletions
diff --git a/gnu/usr.bin/dialog/TESTS/inputbox b/gnu/usr.bin/dialog/TESTS/inputbox
index e04756a51285..67f2b258891d 100755
--- a/gnu/usr.bin/dialog/TESTS/inputbox
+++ b/gnu/usr.bin/dialog/TESTS/inputbox
@@ -8,7 +8,8 @@ to input a string as the answer. You can \n\
input strings of length longer than the \n\
width of the input box, in that case, the \n\
input field will be automatically scrolled. \n\
-You can use BACKSPACE to correct errors. \n\n\
+You can use BACKSPACE, LEFT, RIGHT, HOME, END \n\
+to correct errors. \n\n\
Try inputing your name below:" 16 51 2> /tmp/inputbox.tmp.$$
retval=$?
diff --git a/gnu/usr.bin/dialog/inputbox.c b/gnu/usr.bin/dialog/inputbox.c
index cd5fd7ec4358..4c51a1cef728 100644
--- a/gnu/usr.bin/dialog/inputbox.c
+++ b/gnu/usr.bin/dialog/inputbox.c
@@ -91,6 +91,26 @@ int dialog_inputbox(unsigned char *title, unsigned char *prompt, int height, int
case KEY_UP:
case KEY_DOWN:
break;
+ case KEY_HOME:
+ input_x = scroll = 0;
+ wmove(dialog, box_y, box_x);
+ for (i = 0; i < box_width; i++)
+ waddch(dialog, instr[i] ? instr[i] : ' ');
+ wmove(dialog, box_y, box_x);
+ wrefresh(dialog);
+ continue;
+ case KEY_END:
+ for (i = strlen(instr) - 1; i >= scroll + input_x && instr[i] == ' '; i--)
+ instr[i] = '\0';
+ i++;
+ 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] : ' ');
+ wmove(dialog, box_y, input_x + box_x);
+ wrefresh(dialog);
+ continue;
case KEY_LEFT:
if (input_x || scroll) {
wattrset(dialog, inputbox_attr);
@@ -145,10 +165,10 @@ int dialog_inputbox(unsigned char *title, unsigned char *prompt, int height, int
}
else
input_x--;
- wmove(dialog, box_y, input_x + box_x);
+ wmove(dialog, box_y, input_x + box_x);
for (i = input_x; i < box_width; i++)
waddch(dialog, instr[scroll+i] ? instr[scroll+i] : ' ');
- wmove(dialog, box_y, input_x + box_x);
+ wmove(dialog, box_y, input_x + box_x);
wrefresh(dialog);
}
continue;
@@ -169,8 +189,8 @@ int dialog_inputbox(unsigned char *title, unsigned char *prompt, int height, int
}
else {
wmove(dialog, box_y, input_x + box_x);
- for (i = input_x; i < box_width && instr[scroll+i]; i++)
- waddch(dialog, instr[scroll+i]);
+ for (i = input_x; i < box_width; i++)
+ waddch(dialog, instr[scroll+i] ? instr[scroll+i] : ' ');
wmove(dialog, box_y, ++input_x + box_x);
}
wrefresh(dialog);