summaryrefslogtreecommitdiffstats
path: root/gnu/lib/libdialog/ui_objects.c
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1996-12-14 16:14:21 +0000
committerjkh <jkh@FreeBSD.org>1996-12-14 16:14:21 +0000
commitf3966ba4dba2930bf641566bbca8a2c295ac3832 (patch)
tree0339ac9a93a81373e63f60967bc7e8b041f657cc /gnu/lib/libdialog/ui_objects.c
parent0d930771c96111302a7452571de004b04afae4cc (diff)
downloadFreeBSD-src-f3966ba4dba2930bf641566bbca8a2c295ac3832.zip
FreeBSD-src-f3966ba4dba2930bf641566bbca8a2c295ac3832.tar.gz
Add another hateful global to libdialog (what the heck, there are already
so many). For now, the only extended attribute implemented is NO ECHO, useful for things like passwords. See TESTS/input2.c for an example. This should go into 2.2.
Diffstat (limited to 'gnu/lib/libdialog/ui_objects.c')
-rw-r--r--gnu/lib/libdialog/ui_objects.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/gnu/lib/libdialog/ui_objects.c b/gnu/lib/libdialog/ui_objects.c
index e1ef014..8c178c6 100644
--- a/gnu/lib/libdialog/ui_objects.c
+++ b/gnu/lib/libdialog/ui_objects.c
@@ -29,7 +29,6 @@
#define ESC 27
-
/***********************************************************************
*
* Obj routines
@@ -239,6 +238,22 @@ DelObj(ComposeObj *Obj)
*
***********************************************************************/
+static void
+outstr(WINDOW *win, char *str, int attrs)
+{
+ if (attrs & DITEM_NO_ECHO) {
+ char *cpy;
+ int n = strlen(str);
+
+ cpy = alloca(n + 1);
+ memset(cpy, '*', n);
+ cpy[n] = '\0';
+ waddstr(win, cpy);
+ }
+ else
+ waddstr(win, str);
+}
+
void
RefreshStringObj(StringObj *so)
/*
@@ -256,9 +271,9 @@ RefreshStringObj(StringObj *so)
wmove(so->win, so->y+2, so->x+1);
if (strlen(so->s) > so->w-2) {
strncpy(tmp, (char *) so->s + strlen(so->s) - so->w + 2, so->w - 1);
- waddstr(so->win, tmp);
+ outstr(so->win, tmp, so->attr_mask);
} else {
- waddstr(so->win, so->s);
+ outstr(so->win, so->s, so->attr_mask);
}
return;
@@ -292,6 +307,7 @@ NewStringObj(WINDOW *win, char *title, char *s, int y, int x, int w, int len)
so->w = w;
so->len = len;
so->win = win;
+ so->attr_mask = DialogInputAttrs; /* Grossly use a global to avoid changing API */
/* Draw it on the screen */
RefreshStringObj(so);
@@ -310,7 +326,7 @@ SelectStringObj(StringObj *so)
strcpy(tmp, so->s);
key = line_edit(so->win, so->y+2, so->x+1,
- so->len, so->w-2, inputbox_attr, TRUE, tmp);
+ so->len, so->w-2, inputbox_attr, TRUE, tmp, so->attr_mask);
if ((key == '\n') || (key == '\r') || (key == '\t') || key == (KEY_BTAB) ) {
strcpy(so->s, tmp);
}
OpenPOWER on IntegriCloud