Plan 9 from Bell Labs’s /usr/web/sources/contrib/pdt/sky/cmd/skywatch/skywatch.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <u.h>
#include <libc.h>
#include <bio.h>
#include <thread.h>
#include <draw.h>
#include <mouse.h>

#include "lex.h"
#include "sky.h"
#include "gfx.h"

#include "dat.h"
#include "fns.h"

enum
{
	STACK = 512*1024+10000*sizeof(Cmd) + 10000*sizeof(struct Cmdnode),
};

Mousectl *mc;

void
resized(void)
{
	opresize(nil, 0);
	opdraw(nil, 0);
}

void
cleanup(void)
{
	closemouse(mc);
}

void
threadmain(int argc, char *argv[])
{
	int rm;
	Mouse mm;
	Alt a[] = {
		{nil, &rm, CHANRCV},
		{nil, &mm, CHANRCV},
		{nil, nil, CHANEND},
	};

	opinit();

	if(newwindow(nil) < 0 || initdraw(nil, nil, "skywatch") < 0 || gfxinit() < 0)
		sysfatal("failed to initialise draw: %r");

	if((mc = initmouse(nil, screen)) == nil)
		sysfatal("initmouse: %r");

	rm = 0;
	a[0].c = mc->resizec;
	a[1].c = mc->c;

	resized();

	proccreate(&cmdproc, cmdreg, STACK);

	for(;;) switch(alt(a)){
	case 0:
		print("mouse: resized\n");
		resized();
		break;
	case 1:
		print("mouse: mouse\n");
		break;
	default:
		sysfatal("shouldn't happen");
	}		
}



Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].