Forum: Ruby Hiding user input

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ari B. (Guest)
on 2007-07-31 07:24
(Received via mailing list)
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.
Dan Z. (Guest)
on 2007-07-31 08:06
(Received via mailing list)
Ari B. wrote:
>
>
>
>

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 N. (Guest)
on 2007-07-31 08:53
(Received via mailing list)
Hi,

At Tue, 31 Jul 2007 12:24:00 +0900,
Ari B. 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.
James G. (Guest)
on 2007-07-31 17:21
(Received via mailing list)
On Jul 30, 2007, at 11:51 PM, Nobuyoshi N. wrote:

> Hi,
>
> At Tue, 31 Jul 2007 12:24:00 +0900,
> Ari B. 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 G. II
Ari B. (Guest)
on 2007-07-31 20:49
(Received via mailing list)
On Jul 31, 2007, at 12:51 AM, Nobuyoshi N. wrote:
>   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.

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 N. (Guest)
on 2007-07-31 21:03
(Received via mailing list)
Hi,

At Tue, 31 Jul 2007 22:19:44 +0900,
James Edward G. 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?
James G. (Guest)
on 2007-07-31 21:20
(Received via mailing list)
On Jul 31, 2007, at 12:00 PM, Nobuyoshi N. wrote:

>> 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 G. II
Ari B. (Guest)
on 2007-07-31 21:37
(Received via mailing list)
On Jul 31, 2007, at 1:19 PM, James Edward G. 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 G. (Guest)
on 2007-07-31 21:46
(Received via mailing list)
On Jul 31, 2007, at 12:36 PM, Ari B. wrote:

>
> On Jul 31, 2007, at 1:19 PM, James Edward G. 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 G. II
Nobuyoshi N. (Guest)
on 2007-07-31 22:13
(Received via mailing list)
Hi,

At Wed, 1 Aug 2007 02:19:20 +0900,
James Edward G. 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.
This topic is locked and can not be replied to.