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

Announcement: RedBook v0.5.0 released

Posted by h3rald Sun, 16 Dec 2007 15:07:00 GMT

This new beta release of RedBook introduces quite a few changes when it comes to configuration and setup. Here’s some highlights…

Read more...

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

Announcement: RedBook v0.4.0 released

Posted by h3rald Wed, 28 Nov 2007 15:34:00 GMT

I’m pleased to announce a new release of the RedBook daily logging and time tracking script. This release introduces two new operations, four stats-related directives and a brand new Windows Installer able to setup RedBook in a blink, with (almost) no configuration at all.

Let’s have a closer look…

Read more...

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

Text Link Ads sidebar for Typo

Posted by h3rald Sat, 17 Nov 2007 11:47:00 GMT

I thought it would be nice to share the code of the sidebar I created to display Text Link Ads sponsor links on my Typo powered blog.

There’s actually another plugin which was made for Typo 2.6, but unfortunately it doesn’t work with Typo 4.1.1.

Installation

Just unzip it inside your vendor/plugins directory. The new sidebar should appear in the list of your available sidebars in the Typo’s administration area.

Configuration

In Typo’s administration area, configure the following settings for this sidebar:

  • Title: The title of the sidebar
  • KEY: Your TLA’s XML key
  • Affiliate ID: Your TLA’s affiliate ID
  • Advertise Here: A message shown when no links are displayed.

Download Text Links Ads Sidebar v1.0

Posted in  | Tags ,  | no comments | no trackbacks

Announcement: RedBook v0.3.0 released

Posted by h3rald Thu, 25 Oct 2007 13:18:00 GMT

It’s time for a new beta release of RedBook. This was actually going to be a fairly modest release in terms of features, but I actually ended up implementing a lot more than expected, even things which were planned for the first production release 1.0. So, let’s see what’s new

New operation names (which break compatibility with previous versions)

I had a look at the names I choose for the operations and I noticed that they were either not intuitive enough or too verbose. So I decided to change a fair few of them (thus breaking compatibility with previous versions, but after all that’s what beta releases are for, right?):

OLD NEW
:complete :finish
:load :select
:load_config :config
:load_log :refresh
:timecalc :calc
:stop :quit

New Manual/Home Page

A while ago I discovered TiddlyWiki, but as a matter of fact I never used it for anything practical. From last week though, I started using it a work for taking notes and create short memos, and then I thought of using it to replace RedBook’s standard README file (which was made in a hurry and was kinda cryptical). Now a brand new “manual.html” ships with RedBook—308 KB (30 of actual docs and 278 of Javascript/HTML/CSS magic) with everything you need to know about it. Additionally, an online version is available at the following address:

redbook.h3rald.com

Removed Win32::Console Library

OK this is not good news for people (like me) who use RedBook on Windows, but I promise you’ll forgive me when you read about the other new features below. I discovered by chance that the Win32::Console library (which was used to get colors working on Windows) seems not to handle international characters properly and also seems to be conflicting in some way with the Readline library I decided to include (see below). I don’t know whether this is a problem of the actual library or just of the gem used to pack it.

rbconfig.yml

The config.yml file has been renamed to rbconfig.yml. Additionally, if you place a file with this name in your $HOME directory it will override the one in your RedBook folder (This was done in preparation for the RedBook RubyGem).

New operations

The following new operations are available:

  • :relog—Re-logs a previously-logged message (keeping the same tags and updating the timestamp)
  • :clear—Clears the screen.
  • :ruby—Evaluates arbitrary Ruby code outputting the result (use with care…)

Auto-completion

Some Mac users originally complained that the backspace key wasn’t working in RedBook (and it didn’t in Linux either). Fortunately the solution to this was easy enough: include the GNU Readline library. Readline is now being used in RedBook to:

  • Provide basic (Emacs-style) bindings
  • Auto-completion for keywords and tags
  • Allow the user to automatically customize key bindings via an .inputrc file placed in their $HOME directory (on Windows you’ll have to define a HOME environment variable pointing to a directory of your choice). An example .inputrc file is distributed with RedBook with some specific key bindings.

Support for international characters

Finally, I decided to implement another feature which was originally planned for the 1.0 release: international characters support. This is possible using the Iconv Ruby extension (requires GNU libiconv) which can convert strings between different character sets. The character sets needs to be configured via the rbconfig.yml file.

For more information, check out the ChangeLog

Download RedBook

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

Announcement: RedBook v0.2.0 released

Posted by h3rald Mon, 08 Oct 2007 11:05:00 GMT

“Release Early, Release Often” —Eric S. Raymond, The Cathedral and the Bazaar

In other words, time for another (early) release of RedBook. There are quite a few new features which are worth examining, in particular:

Regexp search for messages

This was actually already available before, just if you inputted a search string which was not a regexp, you’d get an unhandled exception (more or less). This exception is now handled propertly so you get a pretty message instead, if an error occurs when parsing the search string.

Log Backup

A new :backup keyword is available to quickly backup your log file. Here’s what it does:

  • Loads all messages silently
  • Writes them to a file in the same directory as the original log file named <log-alias>.bkp.yml.

Handy, especially if there was a similar keyword to restore the last backup, which is planned for later on.

Support for multiple log files

This is perhaps the most important feature introduced by this release. It is now possible to configure more than one log file by adding any number of :data_<alias>: settings inside your config.yml file, where alias is the name of your log file. So, for example, if your config.yml file contains the following:

:data_test: “testlog.yml”

You can load the “test” log by typing

:use test

(:use is a shorthand for :load_log). Similarly, another new keyword :dest has been introduced to be able to log a message to a different log file without loading it into memory, like this:

:log This message will be saved to testlog.yml :dest test

Finally, a :refresh keyword has been introduced as an alias to reloading the current log.

(Almost) automatic log of completed activities

Right when I was coding the :timecalc operation, I thought it would be nice to be able to log the start and end of a task without having to type it twice. Now this is possible using the :complete keyword:

:log Testing feature X in product Y

:complete

:complete will re-log the last message prepended with [COMPLETED]:

4 Mon Oct 08 2007 – 10:47:45 AM Testing feature X in product Y

5 Mon Oct 08 2007 – 10:54:31 AM [COMPLETED] Testing feature X in product Y

What if I start another task before completing the first one? No problem, it is sufficient to load the last activities using a :load command and then issuing :complete <number> where <number> is the index of the loaded activity. This nifty little feature will become more and more important when (starting from release 0.4) I’ll implement more time tracking functions, and it will be possible to track completed tasks in a specific timeframe and/or marked with a specific tag.

Easy integration with launchers like Launchy and QuickSilver

To conclude, as someone pointed out that it would be cool to use RedBook from launchers like Launchy or Quicksilver, I made another standalone script (redbooklet.rb or redbooklet.exe) which is just able to parse a log command and write a message to the specified log file. To use it with Launchy, for example, all you have to do is the following:

  1. Create a shortcut to redbooklet.exe (or to a way to execute the corresponding ruby script) named “log”.
  2. Copy the “log” shortcut anywhere in your start menu
  3. Bring up launchy (ALT+SPACE) and type in “log”
  4. Hit tab
  5. Type in your log message, optionally with the any :tags or :dest keywords.
  6. The message will be logged to your default log file or to the log you specified using the :dest keyword. If an error occurs, it will appear in a command line window for 15 seconds before the program is closed.

That’s all folks! As usual, if you have any comment or suggestion feel free to reply to this post or email me. For a list of the planned features and releases, check out the Milestones page.

DOWNLOAD HERE

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