Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Tab and arrow-keys in gets

Reply
Thread Tools

Tab and arrow-keys in gets

 
 
Magnus Holm
Guest
Posts: n/a
 
      02-20-2007
Hi!

I'm making a simple Ruby shell. It's all basing on an endless
while-loop and $stdin.gets. But here (on my Linux box) I cannot use
the arrow key. It just shows: "^[[A". And it would be great too have a
tab-feature.

But how do you implement these features?

 
Reply With Quote
 
 
 
 
Michael Fellinger
Guest
Posts: n/a
 
      02-21-2007
On 2/21/07, Magnus Holm <(E-Mail Removed)> wrote:
> Hi!
>
> I'm making a simple Ruby shell. It's all basing on an endless
> while-loop and $stdin.gets. But here (on my Linux box) I cannot use
> the arrow key. It just shows: "^[[A". And it would be great too have a
> tab-feature.
>
> But how do you implement these features?


require 'readline'

while line = Readline.readline('foo> ', true)
puts "You gave me: #{line}"
end

Have fun

Some (very) basic docs are at:
http://svn.ruby-lang.org/cgi-bin/vie...ME?view=markup

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Return of gets gets John Joyce Ruby 0 04-23-2007 01:38 PM
gets gets John Joyce Ruby 2 03-26-2007 04:00 PM
How can I capture tab key event and cancel default action of Tab key? HopfZ Javascript 0 01-08-2007 10:04 PM
XMLHttpRequest gets data to display in element but data gets appended not replaces previous! libsfan01 Javascript 5 12-20-2006 06:25 AM
Not only the selected HREF gets surrounded, but the whole row gets surrounded Stefan Mueller HTML 5 07-10-2006 11:53 AM



Advertisments