[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Tab and arrow-keys in gets

Magnus Holm

2/20/2007 11:17:00 PM

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?

1 Answer

Michael Fellinger

2/21/2007 1:13:00 AM

0

On 2/21/07, Magnus Holm <judofyr@gmail.com> 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/viewvc.cgi/trunk/ext/readline/README?v...