Tuesday, September 27, 2005

Surprising reduction in image size, and more outliner goodness

In Factor, each word has a word properties hashtable associated with it. Word properties can be read and written with the word-prop and set-word-prop words. When browsing around in the inspector, I noticed that a lot of word properties simply had the value f; denoting no value. So I tweaked set-word-prop to simply call remove-hash if the new value is f, thus removing a hashtable key instead of storing a key/value pair with f as the value. This elimination of redundant key/value pairs has reduced image size by a whopping 500Kb! So a full factor.image is only 3.1mb now. This is a 1.3Mb reduction since Factor 0.77, and a 700Kb reduction since Factor 0.78.

I wrote a couple of days ago about a new outliner gadget in the UI. I have cleaned it up, made it look better and decided on a protocol for calling it.

The new protocol for outputting outliners is decoupled from the UI itself and can be used in plain text streams (of course no outliner is displayed in that case). To output an outliner, you call the write-outliner ( string object quot -- ) word. When the outliner is expanded, the quotation is called with the default stream rebound to another stream; any output written to the stream is displayed in the outliner's expanded area. This quotation can therefore output more outliners, creating a nested tree.

Here is a example implementing a call hierarchy outliner; notice how simple it is, with no calls into the UI implementation, or event handling. First we have the utility object-outline word, which takes a sequence of objects, and a quotation that can expand an outline for each object. It prints a set of outliners, one for each object in the sequence, with the quotation as the callback. The quotation receives the object on the stack.

Here is what it looks like after a few nested outliners have been expanded. Note that each word in the outline is a live presentation that can be clicked to display a command menu:

I have similarly updated the inspector and stack display to use outlining. As previously mentioned, the new vocabs. displays an outliner for browsing vocabularies and word definitions.

As you can see in the screenshot, scroll bars look a bit nicer now, and have up/down arrows. There is a clipping flaw in the arrows; its either an sdl-gfx problem or with how I'm calling it, but in any case it should be easy to fix.

I have been studying the part of the CLIM spec for accepting presentations, input editing, and completion. This is a major omission from the Factor UI toolkit at this point. I'll probably implement something rather different from the CLIM way, however understanding how others have solved similar problems helps a lot.