summaryrefslogtreecommitdiffstats
path: root/gnu
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1994-11-18 01:02:42 +0000
committerache <ache@FreeBSD.org>1994-11-18 01:02:42 +0000
commit3a64b4bb5b7a0f1fdc549df45554da257c6f63f0 (patch)
tree3cf0f4d03f2bf8fc09740aacc3cbf5ab0ebfdf4f /gnu
parent17db408558dd446a3ea986f312138f26779f5c02 (diff)
downloadFreeBSD-src-3a64b4bb5b7a0f1fdc549df45554da257c6f63f0.zip
FreeBSD-src-3a64b4bb5b7a0f1fdc549df45554da257c6f63f0.tar.gz
Add new parameter to line_edit: field length (-1 means unlimited)
Diffstat (limited to 'gnu')
-rw-r--r--gnu/lib/libdialog/dialog.h2
-rw-r--r--gnu/lib/libdialog/inputbox.c2
-rw-r--r--gnu/lib/libdialog/lineedit.c22
-rw-r--r--gnu/lib/libdialog/textbox.c2
4 files changed, 13 insertions, 15 deletions
diff --git a/gnu/lib/libdialog/dialog.h b/gnu/lib/libdialog/dialog.h
index ed4109c..35f6f35 100644
--- a/gnu/lib/libdialog/dialog.h
+++ b/gnu/lib/libdialog/dialog.h
@@ -79,7 +79,7 @@ extern bool use_shadow;
void draw_shadow(WINDOW *win, int y, int x, int height, int width);
#endif
void draw_box(WINDOW *win, int y, int x, int height, int width, chtype box, chtype border);
-int line_edit(WINDOW* dialog, int box_y, int box_x, int box_width, chtype attrs, int first, unsigned char *result);
+int line_edit(WINDOW* dialog, int box_y, int box_x, int flen, int box_width, chtype attrs, int first, unsigned char *result);
int strheight(const char *p);
int strwidth(const char *p);
diff --git a/gnu/lib/libdialog/inputbox.c b/gnu/lib/libdialog/inputbox.c
index a544ec0..b23f288 100644
--- a/gnu/lib/libdialog/inputbox.c
+++ b/gnu/lib/libdialog/inputbox.c
@@ -97,7 +97,7 @@ int dialog_inputbox(unsigned char *title, unsigned char *prompt, int height, int
while (key != ESC) {
if (button == -1) { /* Input box selected */
- key = line_edit(dialog, box_y, box_x, box_width, inputbox_attr, first, instr);
+ key = line_edit(dialog, box_y, box_x, -1, box_width, inputbox_attr, first, instr);
first = 0;
}
else
diff --git a/gnu/lib/libdialog/lineedit.c b/gnu/lib/libdialog/lineedit.c
index c32922d..49e7826 100644
--- a/gnu/lib/libdialog/lineedit.c
+++ b/gnu/lib/libdialog/lineedit.c
@@ -26,7 +26,7 @@
/*
* Line editor
*/
-int line_edit(WINDOW* dialog, int box_y, int box_x, 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;
chtype old_attr;
@@ -54,8 +54,8 @@ int line_edit(WINDOW* dialog, int box_y, int box_x, int box_width, chtype attr,
}
wmove(dialog, box_y, box_x + input_x);
- wrefresh(dialog);
for (;;) {
+ wrefresh(dialog);
key = wgetch(dialog);
switch (key) {
case TAB:
@@ -79,7 +79,6 @@ int line_edit(WINDOW* dialog, int box_y, int box_x, int box_width, chtype attr,
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--)
@@ -91,7 +90,6 @@ int line_edit(WINDOW* dialog, int box_y, int box_x, int box_width, chtype attr,
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) {
@@ -106,11 +104,12 @@ int line_edit(WINDOW* dialog, int box_y, int box_x, int box_width, chtype attr,
else
input_x--;
wmove(dialog, box_y, input_x + box_x);
- wrefresh(dialog);
}
continue;
case KEY_RIGHT:
- if (scroll+input_x < MAX_LEN) {
+ if ( scroll+input_x < MAX_LEN
+ && (flen < 0 || scroll+input_x < flen)
+ ) {
if (!instr[scroll+input_x])
instr[scroll+input_x] = ' ';
if (input_x == box_width-1) {
@@ -125,9 +124,8 @@ int line_edit(WINDOW* dialog, int box_y, int box_x, int box_width, chtype attr,
waddch(dialog, instr[scroll+input_x]);
input_x++;
}
- wrefresh(dialog);
} else
- flash(); /* Alarm user about overflow */
+ beep(); /* Alarm user about overflow */
continue;
case '\b':
case '\177':
@@ -151,7 +149,6 @@ int line_edit(WINDOW* dialog, int box_y, int box_x, int box_width, chtype attr,
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);
}
continue;
default:
@@ -163,7 +160,9 @@ int line_edit(WINDOW* dialog, int box_y, int box_x, int box_width, chtype attr,
for (i = strlen(instr) - 1; i >= scroll + input_x && instr[i] == ' '; i--)
instr[i] = '\0';
i++;
- if (i < MAX_LEN) {
+ if ( i < MAX_LEN
+ && (flen < 0 || i < flen)
+ ) {
memmove(instr+scroll+input_x+1, instr+scroll+input_x, i-scroll+input_x);
instr[scroll+input_x] = key;
if (input_x == box_width-1) {
@@ -178,9 +177,8 @@ int line_edit(WINDOW* dialog, int box_y, int box_x, int box_width, chtype attr,
waddch(dialog, instr[scroll+i] ? instr[scroll+i] : ' ');
wmove(dialog, box_y, ++input_x + box_x);
}
- wrefresh(dialog);
} else
- flash(); /* Alarm user about overflow */
+ beep(); /* Alarm user about overflow */
continue;
}
}
diff --git a/gnu/lib/libdialog/textbox.c b/gnu/lib/libdialog/textbox.c
index 9e01083..2de9a4b 100644
--- a/gnu/lib/libdialog/textbox.c
+++ b/gnu/lib/libdialog/textbox.c
@@ -653,7 +653,7 @@ static int get_search_term(WINDOW *win, unsigned char *search_term, int height,
first = 1;
while (key != ESC) {
- key = line_edit(win, y+1, x+1, box_width, searchbox_attr, first, search_term);
+ key = line_edit(win, y+1, x+1, -1, box_width, searchbox_attr, first, search_term);
first = 0;
switch (key) {
case '\n':
OpenPOWER on IntegriCloud