Highlight only space available for editing

This commit is contained in:
Andrey A. Chernov 1994-11-19 00:45:02 +00:00
parent 1479d21fc1
commit 3fa6f2210c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=4664

View file

@ -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 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; chtype old_attr;
static int input_x, scroll; static int input_x, scroll;
static unsigned char instr[MAX_LEN+1]; 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 #endif
old_attr = getattrs(dialog); old_attr = getattrs(dialog);
wattrset(dialog, attr);
keypad(dialog, TRUE); keypad(dialog, TRUE);
if (first) { 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; scroll = i - input_x;
} }
wmove(dialog, box_y, box_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] : ' '); 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); wmove(dialog, box_y, box_x + input_x);
for (;;) { for (;;) {
@ -186,8 +193,10 @@ int line_edit(WINDOW* dialog, int box_y, int box_x, int flen, int box_width, cht
ret: ret:
wattrset(dialog, old_attr); wattrset(dialog, old_attr);
wmove(dialog, box_y, box_x); wmove(dialog, box_y, box_x);
for (i = 0; i < box_width; i++) len = strlen(instr);
waddch(dialog, instr[scroll+i] ? instr[scroll+i] : ' '); len = MIN(len,box_width);
for (i = 0; i < len; i++)
waddch(dialog, instr[scroll+i]);
wmove(dialog, box_y, input_x + box_x); wmove(dialog, box_y, input_x + box_x);
wrefresh(dialog); wrefresh(dialog);
strcpy(result, instr); strcpy(result, instr);