l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
October 7: Social gathering
Next Installfest:
TBD
Latest News:
Aug. 18: Discounts to "Velocity" in NY; come to tonight's "Photography" talk
Page last updated:
2002 Jun 21 12:52

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] preventing display of typed text?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] preventing display of typed text?



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
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Sunset Systems
Who graciously hosts our website & mailing lists!