summaryrefslogtreecommitdiffstats
path: root/gnu
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1994-10-10 22:32:07 +0000
committerache <ache@FreeBSD.org>1994-10-10 22:32:07 +0000
commit8c467cb03adc63ae0166cabfb69353426f03eba2 (patch)
tree5a7e1593544e61d4faa63ba1cd4221cf056f0d73 /gnu
parentce9ee5725345fea27a6b1fc87a4afa4919f40684 (diff)
downloadFreeBSD-src-8c467cb03adc63ae0166cabfb69353426f03eba2.zip
FreeBSD-src-8c467cb03adc63ae0166cabfb69353426f03eba2.tar.gz
Implement HOME/END keys for line edit
Diffstat (limited to 'gnu')
-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 e04756a..67f2b25 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 cd5fd7e..4c51a1c 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);
OpenPOWER on IntegriCloud