From f3966ba4dba2930bf641566bbca8a2c295ac3832 Mon Sep 17 00:00:00 2001 From: jkh Date: Sat, 14 Dec 1996 16:14:21 +0000 Subject: 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. --- gnu/lib/libdialog/ui_objects.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'gnu/lib/libdialog/ui_objects.c') 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); } -- cgit v1.1