Tab and arrow-keys in gets

M

Magnus Holm

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?
 
M

Michael Fellinger

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?view=markup
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top