[vox-tech] preventing display of typed text?

Peter Jay Salzman vox-tech@lists.lugod.org
Fri, 21 Jun 2002 12:48:23 -0700


begin Ryan <ryan@mother.com> 
> On Friday 21 June 2002 07:03 am, Peter Jay Salzman wrote:
> > begin Ryan <ryan@mother.com>
> >
> > > On Thursday 20 June 2002 11:36 pm, Peter Jay Salzman wrote:
> > > > without checking, i've used 2 perl modules that might help:
> > > >
> > > > term which implements the advanced features that termcap provides like
> > > > underlining and boldfacing text
> > > >
> > > > ncurses which basically implements the C style ncurses library.
> > > >
> > > > i would imagine both modules allow you to do this.  in fact, i _know_
> > > > that C/ncurses has a function to block echo in raw mode.  i'm guessing
> > > > that perl/ncurses can do this too.
> > >
> > > I prefer a solution that is platform independant
> >
> > ryan, this is perl code.  what makes you think these modules aren't
> > platform independent?
> >
> > don't you think DOS has it's own terminal handling capabilities?
> 
> I didn't think DOS had curses, and for some reason Term doesn't seem to want 
> to work. (I tried the bit of code from `perldoc -q password`, but perl 
> complains about the module not being in @INC, even though it is as far as I 
> can tell.)
> 
> Can't locate loadable object for module Term::ReadKey in @INC (@INC contains: 
> /usr/lib/perl5/5.6.1/i386-linux /usr/lib/perl5/5.6.1 
> /usr/lib/perl5/site_perl/5.6.1/i386-linux /usr/lib/perl5/site_perl/5.6.1 
> /usr/lib/perl5/site_perl .) at ./passtest.pl line 3
> 
> even though I installed it with CPAN, and it seems to be in the right place;
> 
> $ locate ReadKey.pm
> /usr/lib/perl5/site_perl/5.6.1/i386-linux/Term/ReadKey.pm
> 
> Term::ReadKey sounds to be what I'm looking for, for perl, but it's not 
> working :(

i found exactly the same thing.

i don't have a windows machine to test it on conveniently, but according
to the docs, term:readkey works perfectly under windows.

the trick is that you want to set your terminal to "raw mode".  by
setting under raw mode, you have the option of printing what the person
types or not.

you can go back and forth between raw and cooked mode.  just remember to
flush the buffer before going back to cooked mode.

> > ps- for bash, look at tput.
> 
> Mark's sugguestion of stty helped (it works fine), however, I couldn't find 
> the needed option for tput in the manpage.

tput queries the termcap database and give you the control sequence to
do terminal handling stuff.

tput is a "platform independent" way of getting at terminal
functionality like bold, highlight, mode, etc.   but not "platform
independent" the way you want it.   here, platform independence means
"this will make text bold no matter what kind of terminal you're on".

of course, i don't think that windows and powerpc's have an
/etc/termcap.   although maybe cygwin provides such a thing (i've never
used cygwin).  at this point, you have one foot in "platform
dependence".

> A bit of searching also turned up the escape sequeace '^]]&dS' which works, 
> and seems to turn back off after '^]&' but I have no idea where this will and 
> will not work. :/

it's unique for a given terminal type.

ryan, there are two things going on here:

   * platform independence with respect to terminal type
   * platform independence with respect to operating system

by using a perl interface, you kill both animals with one stone.  you
can use your magic string, but just realize that it won't work for
someone on, say, a wyse terminal.  you can most likely get away with
vt100 emulation since most things understand vt100 these days.

on the other hand, you can use bash's tput utility, but now you're
limiting yourself to platforms that have bash.

since perl is pretty standard on loads of platforms, it's your best bet.

pete