Snippets!

By Dan | May 10, 2008

Awesome:

The basics are not too complicated. Slap a couple of Gtk::TextMarks around each tab stop to keep track of where they are, and monitor keystrokes to update mirrors and transformations.

The part that really flummoxed me was what to do when tab stops are right next to each other. Because they go to zero width all the time (you have to delete text inside a mirror before you can add new text) I was ending up with overlapping tab stops. For example:

<1>mirror one text</1><2>mirror two text</2>

would go to

<1><2>mirror one text</2></1>

Which is very wrong. If mirror 1 overlaps mirror 2 then you are never going to see text in mirror 2.

This kept me going for a good few days. I kept writing baroque solutions, and then discarding them thinking: there has got to be a simple way of doing this. And there was!

The solution was to give the textmarks an ordering and enforce that ordering after every text insertion. The final code is to fix this is about 40 lines, and crucially only required changing one part of the snippet inserter.

There are still things to fix. I fudged the Bundle support paths for now. That will all have to be revisited when I do Textmate commands anyway. And no doubt there will be more bastard edge cases to fix. But all the snippets I’ve tested so far work!

Topics: development | 1 Comment »

Nice new editing features

By Dan | April 3, 2008

  1. Smart indenting.
  2. Automatic indenting of pasted text.
  3. Smart paired characters like brackets.

The first and the last are demonstrated here:

Smart indenting and pairs video

I’m very happy at the speed I was able to develop these features. Automatic indenting of pasted text took 20 minutes to write (once the smart indenter had been written), and smart paired characters I implemented between 6am and 7am this morning. GTK is rich enough and Ruby is expressive enough that it’s just a dream when you combine the two.

Topics: development | No Comments »

Syntax Highlighting With Extra Awesome

By Dan | January 11, 2008

Since Christmas I have been rewriting the core of the syntax highlighting engine in C as Ruby just wasn’t fast enough. I was a bit apprehensive about this, but the Ruby-C interface is very nice to work with, and toss in Glib and it’s really not that painful. There’s something deeply satisfying about profiling, re-implementing a single method in C, and getting a 66% percent speedup immediately.

I’ve made a ton of fixes too and it feels much more solid. No more crashes and the speed is approaching usable. (It can do 500 lines in about 3 seconds 1 second - roughly.)

Anyway I leave you with a spot the difference competition :). Thanks to Ludvig Widman for the lovely theme.

Redcar:

redcar-2-trimmed.png

Textmate:

textmate.png

Topics: development | 2 Comments »

Freebase

By Dan | November 10, 2007

FreeBASE is a Ruby library that deserves to be better known.

FreeBASE is a plugin management system that automatically handles dependencies and plugin loading and starting. It has an internal databus that it uses, and that your application can use to store data and services. FreeBASE is part of the FreeRIDE project, but can be used independently.

I recently decided to port Redcar onto FreeBASE (ditching my own home-grown plugin system) and I must say that it was the right decision. I’ve been able to rip out an enormous amount of code from the Redcar libs.

For each plugin, you declare the relevant metadata in the plugin.yaml file:

--- !ruby/object:FreeBASE::PluginConfiguration
name: documents
version: 1.0
autoload: (true)
require_path: documents/documents
startup_module: Redcar::Plugins::Documents
load_dependencies:
  redcar-core: "*"
start_dependencies:
  redcar-core: "*"

FreeBASE can then calculate the dependencies between plugins (for plugin loading and for starting) and load them in the correct order.

The databus is a little like a filesystem. Here’s what the top two levels look like in Redcar:

  /system
  /system/properties
  /system/shutdown
  /system/state
  /log
  /log/debug
  /log/info
  /log/error
  /plugins
  /plugins/redcar_core
  /plugins/arrangements
  /plugins/textmate_support
  /plugins/ ...
  /redcar
  /redcar/menus
  /redcar/toolbars
  /redcar/gtk
  /redcar/commands
  /redcar/events
  /redcar/services
  /redcar/preferences

Using the FreeBASE databus simplifies things dramatically, because there’s always an obvious place to store information. Each ’slot’ in the databus can be data, a stack, a queue or a proc. The code to persist subtrees is built-in, and slots can have manager objects and arbitrary attributes.

If your Ruby project needs a plugin system, you should strongly consider FreeBASE. There are some useful docs about FreeBASE here and here.

Topics: development | No Comments »

Simple Milestone

By Dan | November 10, 2007

Yesterday I used Redcar for real work! Not realizing that emacs comes with Java-mode, I fired up Redcar to do some Java editing. And it worked just fine.

This is the first time that I’ve actually used Redcar, rather than just tested it. The next big milestone will be when I can develop Redcar from inside Redcar without returning to emacs at any point.

Topics: milestones | No Comments »

Redcar is coming.

By Dan | November 9, 2007

Welcome to RedcarIDE.com. My name is Daniel Lucraft and I’m writing a text-editor/IDE for Gnome in pure-Ruby. Sensible: no, fun: yes. More soon.

Topics: about | No Comments »