summaryrefslogtreecommitdiffstats
path: root/gnu
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1994-11-19 00:45:02 +0000
committerache <ache@FreeBSD.org>1994-11-19 00:45:02 +0000
commitff4e7b036e4b7056ef672d18cd304fdda6e4e4c4 (patch)
treee32d49c930794eac9535ac28cbd374010d9f3d13 /gnu
parent36e48a14003c6b900c9d909f9e0594b65a625331 (diff)
downloadFreeBSD-src-ff4e7b036e4b7056ef672d18cd304fdda6e4e4c4.zip
FreeBSD-src-ff4e7b036e4b7056ef672d18cd304fdda6e4e4c4.tar.gz
Highlight only space available for editing
Diffstat (limited to 'gnu')
-rw-r--r--gnu/lib/libdialog/lineedit.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/gnu/lib/libdialog/lineedit.c b/gnu/lib/libdialog/lineedit.c
index fb2e440..8096a3a 100644
--- a/gnu/lib/libdialog/lineedit.c
+++ b/gnu/lib/libdialog/lineedit.c
@@ -28,7 +28,7 @@
*/
int line_edit(WINDOW* dialog, int box_y, int box_x, int flen, int box_width, chtype attr, int first, unsigned char *result)
{
- int i, key;
+ int i, key, len;
chtype old_attr;
static int input_x, scroll;
static unsigned char instr[MAX_LEN+1];
@@ -39,7 +39,6 @@ int line_edit(WINDOW* dialog, int box_y, int box_x, int flen, int box_width, cht
#endif
old_attr = getattrs(dialog);
- wattrset(dialog, attr);
keypad(dialog, TRUE);
if (first) {
@@ -50,8 +49,16 @@ int line_edit(WINDOW* dialog, int box_y, int box_x, int flen, int box_width, cht
scroll = i - input_x;
}
wmove(dialog, box_y, box_x);
- for (i = 0; i < box_width; i++)
+ wattrset(dialog, attr);
+ len = flen >= 0 ? MIN(flen,box_width) : box_width;
+ for (i = 0; i < len; i++)
waddch(dialog, instr[scroll+i] ? instr[scroll+i] : ' ');
+ wattrset(dialog, old_attr);
+ len = strlen(instr);
+ len = MIN(len,box_width);
+ for ( ; i < len; i++)
+ waddch(dialog, instr[scroll+i]);
+ wattrset(dialog, attr);
wmove(dialog, box_y, box_x + input_x);
for (;;) {
@@ -186,8 +193,10 @@ int line_edit(WINDOW* dialog, int box_y, int box_x, int flen, int box_width, cht
ret:
wattrset(dialog, old_attr);
wmove(dialog, box_y, box_x);
- for (i = 0; i < box_width; i++)
- waddch(dialog, instr[scroll+i] ? instr[scroll+i] : ' ');
+ len = strlen(instr);
+ len = MIN(len,box_width);
+ for (i = 0; i < len; i++)
+ waddch(dialog, instr[scroll+i]);
wmove(dialog, box_y, input_x + box_x);
wrefresh(dialog);
strcpy(result, instr);
OpenPOWER on IntegriCloud