ref: 50aa3d1310d678ed8ff37791240c48d6c5045f65
parent: c9133834024f6fd08a9c0410f67885c2382427ec
author: spew <spew@palas>
date: Wed Jan 29 20:24:20 EST 2025
make another window, draw to it
--- a/guitest.c
+++ b/guitest.c
@@ -77,7 +77,7 @@
Rectangle scrollr;
void
-drawtext(Chan *chan, int resize)
+drawtext(Chan *chan, int resize, Image *screen)
{
Rectangle scrollcur, bodyr;
@@ -118,8 +118,10 @@
Rune r, *rs;
Mouse m;
Chan *chan;
- char *s;
- int len;
+ char *s, *wsys;
+ int len, fd;
+ Screen *_screennicks;
+ Image *screennicks;
len = readn(0, buf, sizeof(buf));
buf[len] = '\0';
@@ -142,6 +144,17 @@
chan->bodylen = runestrlen(chan->body);
chan->totlines = lines(chan->body);
+ if((wsys = getenv("wsys")) == nil)
+ sysfatal("cannot find $wsys: %r");
+ if((fd = open(wsys, ORDWR)) < 0)
+ sysfatal("cannot open $wsys: %r");
+ if(mount(fd, -1, "/mnt/wsysnicks", MREPL, "new") < 0)
+ sysfatal("cannot create new window: %r");
+ screennicks = nil;
+ _screennicks = nil;
+ if(gengetwindow(display, "/mnt/wsysnicks/winname", &screennicks, &_screennicks, Refnone) < 0)
+ sysfatal("cannot get window: %r");
+
Alt a[NCHAN+1] = {
[MOUSE] = {mc->c, &m, CHANRCV},
[RESIZE] = {mc->resizec, nil, CHANRCV},
@@ -148,32 +161,33 @@
[KEYBD] = {kc->c, &r, CHANRCV},
[NCHAN] = {nil, nil, CHANEND},
};
- drawtext(chan, 1);
- for(;;){
- switch(alt(a)){
- default:
+ drawtext(chan, 1, screen);
+ draw(screennicks, screennicks->r, cols[BACK], nil, ZP);
+ flushimage(display, 1);
+ for(;;)switch(alt(a)){
+ default:
+ break;
+ case KEYBD:
+ if(r == Kdel)
+ goto end;
+ break;
+ case MOUSE:
+ if(!ptinrect(m.xy, scrollr))
break;
- case KEYBD:
- if(r == Kdel)
- goto end;
- break;
- case MOUSE:
- if(!ptinrect(m.xy, scrollr))
- break;
- while(m.buttons == 2){
- setcurline(m.xy.y, chan);
- drawtext(chan, 0);
- readmouse(mc);
- m = *mc;
- }
- break;
- case RESIZE:
- if(getwindow(display, Refnone) < 0)
- sysfatal("%s: %r", argv0);
- drawtext(chan, 1);
- break;
+ while(m.buttons == 2){
+ setcurline(m.xy.y, chan);
+ drawtext(chan, 0, screen);
+ readmouse(mc);
+ m = *mc;
}
+ break;
+ case RESIZE:
+ if(getwindow(display, Refnone) < 0)
+ sysfatal("%s: %r", argv0);
+ drawtext(chan, 1, screen);
+ break;
}
end:
+ unmount(nil, "/mnt/wsysnicks");
threadexitsall(0);
}