lab 59 - acme stand alone complex A project that has been on my mind for quite a while is to package inferno's acme as a stand alone editor. I only had Windows in mind as a target host, but the work should be quite easy to reproduce on other hosts.

I wanted the editor to blend well with the host system, and work as a substitute for other popular programmer editors such as vim, emacs, or jedit. There were a few things I felt needed to be in place for this to work.

This lab covers the code to do the acme resize with host windows.

I copied the code from /emu/port/devpointer.c and made devwmsz.c. The code is almost identical except for the name changes. This device holds a short queue of window resize events and serves a file /dev/wmsize that's the same format as /dev/pointer with x and y fields representing the width and height of the host window.

I modified acme directly to support this new device instead of modifying wm modules, which might be more appropriate, I'm not sure. I added a new thread to /acme/gui.b to listen for resize events and resize the acme window appropriately.

startwmsize(): chan of Rect
{
	rchan := chan of Rect;
	fd := sys->open("/dev/wmsize", Sys->OREAD);
	if(fd == nil)
		return rchan;
	sync := chan of int;
	spawn wmsizeproc(sync, fd, rchan);
	<-sync;
	return rchan;
}

wmsizeproc(sync: chan of int, 
	fd: ref Sys->FD, ptr: chan of Rect)
{
	sync <-= sys->pctl(0, nil);

	b:= array[Wmsize] of byte;
	while(sys->read(fd, b, len b) > 0){
		p := bytes2rect(b);
		if(p != nil)
			ptr <-= *p;
	}
}

/appl/acme/gui.b:/^eventproc/ responds to the new event on the channel from wmsizeproc,

eventproc()
{
	wmsize := startwmsize();
	for(;;) alt{
	wmsz := <-wmsize =>
		win.image = win.screen.newwindow(wmsz, 
			Draw->Refnone, Draw->Nofill);
		p := ref zpointer;
		mainwin = win.image;
		p.buttons = Acme->M_RESIZE;
		cmouse <-= p;
...

I copied similar code into /appl/wm/wm.b so the standard window manager (included in this lab's files). After using it a little I think I prefer it not resizing.

I use Acme:SAC as my main environment now, opening up another Inferno session when I want to do graphics work.

I've created a page for the Acme:SAC download where I'll post updates as I try to improve the packaging. The download is based on the emu from 20060227 Inferno release and my dried dung inferno tree. FILES caerwyn.com/lab/59
Acme: Stand Alone Complex