Quick
index
main
eev
eepitch
maths
angg
blogme
dednat6
littlelangs
PURO
(C2,C3,C4,
 λ,ES,
 GA,MD,
 Caepro,
 textos,
 Chapa 1)

emacs
lua
(la)tex
maxima
 qdraw
git
lean4
agda
forth
squeak
icon
tcl
tikz
fvwm
debian
irc
contact

diaglib - an editor for commutative diagrams in Tcl/Tk

(This page is very old - probably from 1999. See this.)

Hey. Do you want an editor for commutative diagrams that is intuitive and easy to use?

If you do then you'd better look elsewhere. Try xfig or tkdraw.

I wrote diaglib.014 because I needed something that I could hack easily to add more features, and that would let me write the diagrams in a real programming language. And I wanted to be able to edit the diagrams in Emacs, not just by pointing and clicking; the graphical interface was to be used only to drag some reference points until the final result looked reasonably pretty.

<blurb>
...experience shows ( :-) that editing diagrams in ASCII-art in Emacs is always much funnier than editing them using graphical tools, and coding them after that in diaglib code is very quick and funny enough (especially when you're diaglib's author, of course).
</blurb>


Quick and messy description:

Diagrams are made of text objects (see "TEXT ITEMS" in the manpage (3tk)canvas) and arrow objects ("LINE ITEMS" in (3tk)canvas). Arrow objects always go from a corner of a text object to a corner of another; they're generally straight but there are tricks to get curves. For the arrow objects we can specify line width, stipple, arrow shape and which ends get arrows. Text objects can be dragged with the mouse; when one of them is dragged all other text objects whose coordinates depended on it are dragged together with it and the diagram is redrawn; some arrows may move because their control points moved.

Diagrams are written as Tcl code that is executed after sourcing diaglib.014. The code creates two strings, $OnCreate and $OnUpdate, that are in fact Tk scripts; these scripts can be inspected by pressing buttons on the main window. OnCreate is only eval'ed once and OnUpdate is eval'ed every time a drag is done. A third array, OnDump, has Tcl code to show the present coordinates of the text objects in a format that can be incorporated in the diagram code.

Some text objects may be marked as auxiliaries. There's a button that deletes all auxiliary objects. Another button makes all objects black. Another one exports the current figure as encapsulated postscript to ~/LATEX/eps/<epsfilename>.eps, where <epsfilename> is set with the command "epsfile". The path ~/LATEX/eps/ is hardcoded but trivial to change.

The contents of the variables OnCreate, OnUpdate and OnDump (and the result of eval'ing OnDump) can be sent to stdout or to ~/o; again the path is hardcoded but easy to change. A button toggles if the output goes to stdout or to ~/o.