Skip to content

Background and Motivation

stacksmith edited this page Jul 8, 2019 · 5 revisions

SubText...

Background and Motivation

Don't you often wish you could slap on an minimal user interface onto a project?

What I want is simple: Bind a few keys, and maybe make some text clickable.

The gap between a working piece of Lisp code and something that can stand on its own is enormous. And it does not help that a Lisp environment is a glovebox inside Emacs talking to a Lisp image across a Swank connection. Binding a key in Emacs (a whole other nightmare) does nothing for the Lisp project!

So, SubText. As the name implies, underneath text, there is some plumbing. Text is provided by GTK; plumbing is added on to GTK's management of buffers, marks and tags. Result: text that is connected to Lisp code, in both directions. Interaction with certain regions of text invoke Lisp methods; and the text displayed can be located in the buffer and modified by Lisp code.

This weekend project turned into a few months of (mostly) trying to figure out how to do this. After a few unsuccessful attempts to use external interval trees of various kinds, I decided to just build onto the existing GTK mark and tag functionality (far from ideal, but good enough to test the concepts). It was surprisingly hard to wrap my brain around some concepts, such as how to turn gtktextbuffer into a stream, deal with creating presentations and tagged areas before they actually exist in the buffer (promises!), dealing with adjoining tags and presentations (still problematic) etc.

Now that it sort of works - well enough for a simple demo - it's time to fix the really clunky parts...

Clone this wiki locally