New Release: RawLine 0.2.0

Posted by h3rald Wed, 02 Apr 2008 11:33:00 GMT

InLine RawLine 0.2.0 is out!

RawLine is the new name for InLine, in case you didn’t guess. The name was changed to avoid name collision problems with the RubyInline project.

Here’s what’s new:

  • Added /examples and /test directory to gem.
  • Escape codes can now be used in prompt.
  • It is now possible to use bind(key, &block) with a String as key, even if the corresponding escape sequence is not defined.
  • Added Editor#write_line(string) to print a any string (and “hit return”).
  • Library name changed to “RawLine” to avoid name collision issues (Bug 18879).
  • Provided alternative implementation for left and right arrows if terminal supports escape sequences (on Windows, it requires the Win32Console gem).

In particular, I decided to provide an “optimized implementation” for the left and right arrows using escape sequences rather than shameful hacks. This is now possible because the Win32Console gem now enables ANSI escape sequences on Windows as well (weehee!).

So:

  • If you’re on *nix all good, your terminal is smart and can understand escape sequences => the new implementation will be used.
  • If you’re on Windows and you installed Win32Console, your termnal is smart and can understand escape sequences => the new implementation will be used.
  • If you’re on Windows and you didn’t install Win32Console, then your terminal is stupid and it doesn’t understand escape sequences, so the old implementation will be used.

The new implementation is significantly faster than the old one, on Windows at least, and the cursor now blinks properly when left or right arrows are pressed.

I re-emplemented only cursor movement because I’m still having some problems in getting the delete/insert escapes to work properly (or better: how I want them to work!).

Posted in  | Tags , , ,  | no comments | no trackbacks

InLine name change: what's your opinion?

Posted by h3rald Thu, 27 Mar 2008 12:30:00 GMT

I’ve been kindly asked by the lead developer of RubyInLine to change the name of my InLine project, due to potential confusion and conflicts.

This makes sense, and I’m ready to change the name of my project, although I’m not that good at choosing original and smart names, so well, any suggestion is more than welcome!

I was thinking of something like:

  • RawLine
  • EditLine
  • RawInput
  • RubyInput
  • RubyLine

I personally think that RawLine is probably the best option, but please, if have any better idea just speak up!

P.S.: “RedLine” is taken, unfortunately, otherwise it would have been my first choice since the beginning.

Posted in  | Tags , , ,  | 3 comments | no trackbacks

RawLine - a 100% Ruby solution for console inline editing

Posted by h3rald Mon, 10 Mar 2008 12:59:00 GMT

One of the many things I like about Ruby is its cross-platform nature: as a general rule, Ruby code runs on everything which supports Ruby, regardless of its architecture and platform (yes, there are quite a few exceptions, but let’s accept this generalization for now).

More specifically, I liked the fact that I could use the GNU Readline library with Ruby seamlessly on both Windows and Linux. Readline offers quite a lot of features which are useful for those people like me who enjoy creating command-line scripts, in a nutshell, it provides:

  • File/Word completion
  • History support
  • Custom key bindings which can be modified via .inputrc
  • Emacs and Vi edit modes

Basically it makes your command-line interface fast and powerful, and that’s not an overstatement. Ruby’s own IRB can be enhanced by enabling readline and completion, and it works great—at least on *nix systems.

For some weird reason, some people had problems with Readline on Windows: in particular, things get nasty when you start editing long lines. Text gets garbled, the cursor goes up one or two lines and doesn’t come back, and other similar leprechaun’s tricks, which are not that funny after a while.

Apparently there’s no alternative to Readline in the Ruby world. If you wan’t tab completion that’s it, you’re stuck. Would it be difficult to implement some of Readline functionality natively in Ruby? Maybe, but the problem is that for some reason the Ruby Standard Library doesn’t have low level methods to operate on keystrokes…

…but luckily, the HighLine gem does! James Edward Gray II keeps pointing out here and here that HighLine’s own get_character method does just that: it returns the corresponding character code(s) right when a key is pressed, unlike IO#gets() which waits for the user to press ENTER.

Believe it or not, that tiny method can do wonders…

Read more...

Posted in  | Tags , , ,  | 9 comments | no trackbacks

A closer look at Komodo Edit

Posted by h3rald Sun, 25 Nov 2007 14:23:00 GMT

Digg!

What’s your favorite code editor?

This is a common question which still keeps popping up on community boards, mailing lists, comments, etc. Every programmer who writes code in some programming language normally has an editor of choice. Being realistic, most of the times it’s not only one program but several, depending on the language and on the features needed at the time. Yes, great, but how do you choose your favorite editor? By trying a lot of them of course: that’s what I’ve been doing since I started programming. Lately I’ve become fond of Vim (or better, gVim), although I have a few other editors I may recommend, e.g.:

Recently, however, I came across my nth “what’s your favorite editor” thread and someone mentioned Komodo Edit. I knew of it already, actually, but I never had a chance to give it a proper try. ActiveState is well known mainly for two things:

  • Their effort in offering a lot of commercial, windows-based Perl libraries
  • Their commercial IDE, Komodo IDE, which I personally tried quite a long time ago

The problems of Komodo IDE are foundamentally two:

  • It costs money – this is not great in a world where Eclipse and Netbeans are free
  • It is an IDE – which normally means ‘heavy as hell’.

It’s a matter of taste and needs: some people feel more confortable with using an editor for certain tasks, while sometimes an IDE may be the best solution, despite its potential slowness and bulk.

Komodo Edit solves the above-mentioned problems because:

  • It’s free
  • It’s an editor

Actually I wouldn’t call it an editor, because it offers quite a lot of features which are normally absent in editors—it’s something in-between, which definitely deserves a try.

Read more...

Posted in  | Tags , ,  | 11 comments | no trackbacks