IRB : Auto_Indent in Windows

K

Ken A.

Hi. I managed to set auto_indent, but it just don't work quite the way
we expect, at least in Windows. eg, in irb console I type:

def my_method
a = "some text"
end

but I need (visually speaking)

def my_method
a = "some text"
end

Can I fix it? or it's a limitation on Windows?
 
J

James Tucker

It would need to re-write the line after the \n, which requires going
up a line and re-writing.
or... it would require not echoing keys to the terminal.

Neither are easy to support on windows due to bugs and limitations in
the curses and readline implementations, although I expect with some
added complexity to irb (unless it's already there of course), this
could be done quite trivially on *nix systems.
 
L

Luis Lavena

Hi. I managed to set auto_indent, but it just don't work quite the way
we expect, at least in Windows. eg, in irb console I type:

def my_method
a = "some text"
end

but I need (visually speaking)

def my_method
a = "some text"
end

Can I fix it? or it's a limitation on Windows?

No, is a IRB limitation.

There is no way "in advance" that IRB understand that you're doing
'end' and it should be indented one level lower than previous
indentantion.

IF tricky, adding something like that can create problems with users
just doing:

def foo; "bar"; end

and IRB trying "as you time" to reindent the code...

I'll suggest you code in some IDE, like Komodo or NetBeans that
automatically indent your code.

HTH,

Luis
 
G

Giles Bowkett

I expect with some
added complexity to irb (unless it's already there of course), this
could be done quite trivially on *nix systems.

Triviality is a relative term. I don't have the faintest idea where to
start on something like that but I would be thrilled to figure it out.
I'd throw it into my IRB enhancements gem quicker than the Flash plus
Red Bull. I think IRB just drops its output into STDOUT, so
repositioning it after the fact sounds pretty challenging. Would it
just be something to regex the output before dumping to STDOUT? I
think currently all the auto-indentation is handled by modifying the
prompt.

--
Giles Bowkett

Podcast: http://hollywoodgrit.blogspot.com
Blog: http://gilesbowkett.blogspot.com
Portfolio: http://www.gilesgoatboy.org
Tumblelog: http://giles.tumblr.com
 

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

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,285
Latest member
CryptoTaxxSoftware

Latest Threads

Top