lab 29 - embedded graphs


lab 29 - embedded graphs


Taking inspiration from Mathematica's notebook user interface, I tried implementing graphs embedded within the shell window, wm/sh. The idea being that a scrolling page of graphs, text and images is easier to manage than many overlapping windows. I feel this especially while I'm iteratively running commands, generating data and viewing graphs.

The shell window provides a history of activity. By including other windows in that history I can look back at the graphs I generated, what data generated them, what command was used to generate the data, and so on. With overlapping windows this context can be lost.

Wm/sh used in this way now behaves as a rudimentary window manager. It is easy to imagine ways in which it becomes inconvient to use. Such as interacting with two windows separated by a large block of text. But it still might add a useful alternative to the wm/wm and acme window manager styles.


The graphs are Tk windows embedded within the text of the shell window. The graph can respond to events, and in this case clicking inside the graph updates the displayed coordinates.

I didn't know how to do any of this, or even that Tk made it possible, until I looked at the editor wm/brutus. Brutus seems to be a forgotten application within Inferno and not very stable. It supports embedding of images, tables, and excerpts of code within the text and simple formatting. It is still useful to trawl through such programs for snippets of code. Finding the code to embed Tk windows within text was enlightening.

I used the brutus extension interface brutusext.m to implement the graph module. The graph module itself was adapted from /appl/math/gr.b.

The shell already comes with a file system inteface /chan/shctl to communicate with external programs. I added to wm/sh two commands to be recognized by this file.

          % echo graph filename > /chan/shctl

where filename contains a set of coordinates. Wm/sh displays a graph within the shell window. embedgraph

I also added a command to display images. For example,

          % echo bitmap /icons/coin.bit > /chan/shctl

To clear memory from all the Tk objects created,

          % echo clear >/chan/shctl


By adding this feature many other possibilities and questions quickly arise. How can we collapse individual embedded windows? Can we cut and paste the embeds? What about saving the whole contents of the shell window, including embeds, and restoring them later for browsing. Wm/brutus again points the way to doing some of this, by creating a simple markup using SGML or sexprs to store the contents as an expression.


graph.b sh.b


Popular posts from this blog

lab 110 - inferno archive edition

lab 107 - midiplay

lab 111 - wavloop