[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Hiding user input

Ari Brown

7/31/2007 3:24:00 AM

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.



9 Answers

Dan Zwell

7/31/2007 4:05:00 AM

0

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

Nobuyoshi Nakada

7/31/2007 4:51:00 AM

0

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

--
Nobu Nakada

James Gray

7/31/2007 1:20:00 PM

0

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?

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

Ari Brown

7/31/2007 4:48:00 PM

0


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

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



Nobuyoshi Nakada

7/31/2007 5:00:00 PM

0

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

James Gray

7/31/2007 5:19:00 PM

0

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?

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

Ari Brown

7/31/2007 5:36:00 PM

0


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.

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




James Gray

7/31/2007 5:45:00 PM

0

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.

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

Nobuyoshi Nakada

7/31/2007 6:11:00 PM

0

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