Wednesday, 12 May 2010

Coordinate prompts in gschem

Way back when I was a kid I learned a bit of AutoCAD, having spent some time at a naval architect firm on Friday afternoons while my stepdad was having a beer with his mates. I wasn't big into beer, rather into computers, so Christo put me in front of their CAD station and showed me a few basics. Somewhere along the line I also had AutoCAD at home (probably a bootleg copy), and there I learned about AutoLISP, probably even programmed a few simple macros in it.

The possibility of giving gschem a similar capability has been haunting me for quite a while, knowing that it couldn't possibly be that hard, since it already uses Guile for its scheme magic. And now, recently I've taught gschem to let a scheme expression ask for coordinates:

Here I'm getting the REPL to trigger a prompt for a place to put a NAND gate. Actually running this script is a little less in-your-face, and you might not notice it in the screenshot, so I'll apply my magic red marker:

I won't show you a screenshot of the NAND gate once it's on the schematic, because that'd just be boring. Also this function exposes a bug in gschem: the drawing area doesn't refresh after the call to (add-component-at-xy ...)

I'm still tying up some loose ends in the interface related to keyboard focus going to the wrong widget, and I'm not convinced the combobox is the right affordance. Alternatives?