Hiding user input

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 Brown wrote:

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

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&gt;
would work on the platforms support termios, termio or sgtty, and
Win32.

···

--
Nobu Nakada

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

···

On Jul 30, 2007, at 11:51 PM, Nobuyoshi Nakada wrote:

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?

Will this work over sockets, though? The idea is that I don't have access to the user's terminal.

Thanks,
aRi
-------------------------------------------|
Nietzsche is my copilot

···

On Jul 31, 2007, at 12:51 AM, Nobuyoshi Nakada wrote:

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

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

Hi,

At Tue, 31 Jul 2007 22:19:44 +0900,
James Edward Gray II wrote in [ruby-talk:262624]:

>> 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.

Does noecho over sockets have any meanings?

···

--
Nobu Nakada

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

···

On Jul 31, 2007, at 12:00 PM, Nobuyoshi Nakada wrote:

Hi,

At Tue, 31 Jul 2007 22:19:44 +0900,
James Edward Gray II wrote in [ruby-talk:262624]:

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.

Does noecho over sockets have any meanings?

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

···

On Jul 31, 2007, at 1:19 PM, James Edward Gray II wrote:

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.

Hi,

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

> 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.

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

···

--
Nobu Nakada

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

···

On Jul 31, 2007, at 12:36 PM, Ari Brown wrote:

On Jul 31, 2007, at 1:19 PM, James Edward Gray II wrote:

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.