Hiding user input

A

Ari Brown

Before you all read on, there is a restriction...

Without Highline!!!!!!!!
Sorry, James, I love the library, but I need this to work over IO.

How can I hide user input (as they type) without highline? Am I able
to use blocks after gets()?
I'm hoping I can do something like this:

name = gets.chomp {|let| let.echo = false}

or something. I don't care how odd or crazy a solution, method, or
whatever is. I'm looking for guidance in an almost pitch-black room
of metaphors and elongation of said metaphors.

Thanks,
aRi
--------------------------------------------|
If you're not living on the edge,
then you're just wasting space.
 
D

Dan Zwell

Ari said:
Before you all read on, there is a restriction...

Without Highline!!!!!!!!
Sorry, James, I love the library, but I need this to work over IO.

How can I hide user input (as they type) without highline? Am I able to
use blocks after gets()?
I'm hoping I can do something like this:

name = gets.chomp {|let| let.echo = false}

or something. I don't care how odd or crazy a solution, method, or
whatever is. I'm looking for guidance in an almost pitch-black room of
metaphors and elongation of said metaphors.

Thanks,
aRi
--------------------------------------------|
If you're not living on the edge,
then you're just wasting space.

Ari,

If it's on linux/unix, maybe mac as well,
system('stty -echo')

Just make sure you later call
system('stty echo'), because it would be extremely rude not to. I would
also surround the whole program in a begin / ensure / end block so that
you can ensure "stty echo" gets called at the end.

Dan
 
N

Nobuyoshi Nakada

Hi,

At Tue, 31 Jul 2007 12:24:00 +0900,
Ari Brown wrote in [ruby-talk:262575]:
Without Highline!!!!!!!!
Sorry, James, I love the library, but I need this to work over IO.

Highline doesn't work over IO?
How can I hide user input (as they type) without highline? Am I able
to use blocks after gets()?
I'm hoping I can do something like this:

name = gets.chomp {|let| let.echo = false}

require 'io/console'
name = STDIN.noecho {|i| i.gets}.chomp

io/console <http://www.rubyist.net/~nobu/ruby/io-console.tar.bz2>
would work on the platforms support termios, termio or sgtty, and
Win32.
 
J

James Edward Gray II

Hi,

At Tue, 31 Jul 2007 12:24:00 +0900,
Ari Brown wrote in [ruby-talk:262575]:
Without Highline!!!!!!!!
Sorry, James, I love the library, but I need this to work over IO.

Highline doesn't work over IO?

I've not tested it over sockets, but I would like it to work there.
If there are problems, I would prefer we patch them.

James Edward Gray II
 
N

Nobuyoshi Nakada

Hi,

At Tue, 31 Jul 2007 22:19:44 +0900,
James Edward Gray II wrote in [ruby-talk:262624]:
I've not tested it over sockets, but I would like it to work there.
If there are problems, I would prefer we patch them.

Does noecho over sockets have any meanings?
 
J

James Edward Gray II

Hi,

At Tue, 31 Jul 2007 22:19:44 +0900,
James Edward Gray II wrote in [ruby-talk:262624]:
I've not tested it over sockets, but I would like it to work there.
If there are problems, I would prefer we patch them.

Does noecho over sockets have any meanings?

Exactly.

If you are talking to something like a Telnet client you would need
to use that protocol to query the client about its capabilities and
request that it change its input mode.

James Edward Gray II
 
A

Ari Brown

If you are talking to something like a Telnet client you would need
to use that protocol to query the client about its capabilities and
request that it change its input mode.

Is there a nice easy way to do that in Ruby? Because this seems to be
EXACTLY what I need.

Thanks,
---------------------------------------------------------------|
~Ari
"I don't suffer from insanity. I enjoy every minute of it" --1337est
man alive
 
J

James Edward Gray II

Is there a nice easy way to do that in Ruby? Because this seems to
be EXACTLY what I need.

A very quick search didn't turn up a library that would handle this
for you, sadly. You may need to learn enough of the protocol to send
the needed commands manually.

James Edward Gray II
 
N

Nobuyoshi Nakada

Hi,

At Wed, 1 Aug 2007 02:19:20 +0900,
James Edward Gray II wrote in [ruby-talk:262677]:
Exactly.

If you are talking to something like a Telnet client you would need
to use that protocol to query the client about its capabilities and
request that it change its input mode.

In such case, pty would be used in common? I'm not sure if
sockets have such capabilities at all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,123
Latest member
Layne6498
Top