From f028f2ec9ddbd45d2116e3d79e1ca2b526181ec9 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Fri, 11 Feb 2011 16:37:06 +0000 Subject: Fix STR #2560: use bullet instead of asterisk to hide secret input. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8413 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Input_.cxx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Fl_Input_.cxx b/src/Fl_Input_.cxx index 2c4e5336c..27655e4e2 100644 --- a/src/Fl_Input_.cxx +++ b/src/Fl_Input_.cxx @@ -37,6 +37,12 @@ #include #define MAXBUF 1024 +#if defined(USE_X11) && !USE_XFT +const int secret_char = '*'; // asterisk to hide secret input +#else +const int secret_char = 0x2022; // bullet to hide secret input +#endif +static int l_secret; extern void fl_draw(const char*, int, float, float); @@ -67,7 +73,10 @@ const char* Fl_Input_::expand(const char* p, char* buf) const { if (input_type()==FL_SECRET_INPUT) { while (o= 1) *o++ = '*'; + if (fl_utf8len((char)p[0]) >= 1) { + l_secret = fl_utf8encode(secret_char, o); + o += l_secret; + } p++; } @@ -124,10 +133,12 @@ double Fl_Input_::expandpos( ) const { int n = 0; int chr = 0; + int l; if (input_type()==FL_SECRET_INPUT) { while (p= 1) n++; - p++; + l = fl_utf8len((char)p[0]); + if (l >= 1) n += l_secret; + p += l; } } else while (p