ref: 4ae95680d7cf09182aa783cc934ca6c46e56a8b5
parent: 386ed6ba96647167e1a230033b02398f1d2d7a45
author: aap <[email protected]>
date: Sun Jul 28 11:03:02 EDT 2024
implemented -i. updated text.c. fixed a few bugs.
--- /dev/null
+++ b/TODO
@@ -1,0 +1,20 @@
+rethink resizing and repainting
+rethink hiding/unhiding
+check for bad rects (what's left here?)
+top/bottom/current seems to work a bit different in rio
+make sure there are no deadlocks
+...
+
+ideas:
+ case-insensitive 'look'
+ virtual screen (like fvwm)
+ cursor movement
+ decorations (at least make them possible)
+ tabbed window
+
+problems:
+ Borderwidth hardcoded in gengetwindow
+ originwindow doesn't work with gengetwindow
+ non-origin screen breaks samterm scrollbars
+ raw mode where?
+ initkeyboard with /dev/kbd support (also fix leaks in old code)
--- a/fs.c
+++ b/fs.c
@@ -1020,8 +1020,15 @@
return 0;
}
+static void
+srvthread(void*)
+{
+ threadsetname("fs");
+ srv(&fsys);
+}
+
void
-fs(void)
+startfs(void)
{
io9p = ioproc();
@@ -1032,7 +1039,8 @@
snprint(srvpipe, sizeof(srvpipe), "lola.%s.%lud", user, (ulong)getpid());
post(srvpipe, fsysfd);
// chatty9p++;
- srv(&fsys);
+// srv(&fsys);
+ threadcreate(srvthread, nil, mainstacksize);
}
int
--- a/inc.h
+++ b/inc.h
@@ -89,7 +89,6 @@
void xpaste(Text *x);
void xsend(Text *x);
int xplumb(Text *w, char *src, char *dir, int maxsize);
-void freescrtemps(void);
enum
{
@@ -331,7 +330,7 @@
extern Srv fsys;
-void fs(void);
+void startfs(void);
int fsmount(int id);
#define runemalloc(n) malloc((n)*sizeof(Rune))
--- a/main.c
+++ b/main.c
@@ -15,6 +15,8 @@
Screen *wscreen;
Image *fakebg;
+Channel *pickchan;
+
void
killprocs(void)
{
@@ -598,7 +600,8 @@
i = screenoff.x/dx;
j = screenoff.y/dy;
Point ssel = dmenuhit(2, mctl, ndeskx, ndesky, Pt(i,j));
- if(ssel.x >= 0 && ssel.y >= 0)
+ if(ssel.x >= 0 && ssel.y >= 0 &&
+ (ssel.x*dx != screenoff.x || ssel.y*dy != screenoff.y))
screenoffset(ssel.x*dx, ssel.y*dy);
}
@@ -709,7 +712,6 @@
sysfatal("resize failed: %r");
nr = screen->clipr;
- freescrtemps();
freeimage(fakebg);
freescreen(wscreen);
wscreen = allocscreen(screen, background, 0);
@@ -863,12 +865,34 @@
}
}
-Channel *pickchan;
+void
+initcmd(void *arg)
+{
+ char *cmd;
+ char *wsys;
+ int fd;
+ cmd = arg;
+ rfork(RFENVG|RFFDG|RFNOTEG|RFNAMEG);
+ wsys = getenv("wsys");
+ fd = open(wsys, ORDWR);
+ if(fd < 0)
+ fprint(2, "lola: failed to open wsys: %r\n");
+ if(mount(fd, -1, "/mnt/wsys", MREPL, "none") < 0)
+ fprint(2, "lola: failed to mount wsys: %r\n");
+ if(bind("/mnt/wsys", "/dev/", MBEFORE) < 0)
+ fprint(2, "lola: failed to bind wsys: %r\n");
+ free(wsys);
+ close(fd);
+ procexecl(nil, "/bin/rc", "rc", "-c", cmd, nil);
+ fprint(2, "lola: exec failed: %r\n");
+ exits("exec");
+}
+
void
usage(void)
{
- fprint(2, "usage: lola [-s] [-t]\n");
+ fprint(2, "usage: lola [-i initcmd] [-s] [-t]\n");
exits("usage");
}
@@ -875,6 +899,7 @@
void
threadmain(int argc, char *argv[])
{
+ char *initstr;
char buf[256];
if(strcmp(argv[0]+1, ".out") == 0){
rfork(RFENVG);
@@ -883,12 +908,11 @@
notitle = FALSE;
}
+ initstr = nil;
ARGBEGIN{
-/*
case 'i':
initstr = EARGF(usage());
break;
-*/
case 's':
scrolling = TRUE;
break;
@@ -935,6 +959,8 @@
flushimage(display, 1);
- fs();
- // not reached
+ startfs();
+
+ if(initstr)
+ proccreate(initcmd, initstr, mainstacksize);
}
--- a/text.c
+++ b/text.c
@@ -111,6 +111,7 @@
w->org += n;
else if(q0 <= w->org+w->nchars)
frinsert(w, r, r+n, q0-w->org);
+ xscrdraw(w);
return q0;
}
@@ -271,29 +272,6 @@
* Scrolling
*/
-static Image *scrtmp;
-
-static Image*
-scrtemps(void)
-{
- int h;
-
- if(scrtmp == nil){
- h = BIG*Dy(screen->r);
- scrtmp = allocimage(display, Rect(0, 0, 32, h), screen->chan, 0, DNofill);
- }
- return scrtmp;
-}
-
-void
-freescrtemps(void)
-{
- if(scrtmp){
- freeimage(scrtmp);
- scrtmp = nil;
- }
-}
-
static Rectangle
scrpos(Rectangle r, uint p0, uint p1, uint tot)
{
@@ -325,27 +303,17 @@
void
xscrdraw(Text *w)
{
- Rectangle r, r1, r2;
- Image *b;
+ Rectangle r1, r2;
- b = scrtemps();
- if(b == nil || w->i == nil)
+ if(w->i == nil)
return;
- r = w->scrollr;
- r1 = r;
- r1.min.x = 0;
- r1.max.x = Dx(r);
+
+ r1 = w->scrollr;
r2 = scrpos(r1, w->org, w->org+w->nchars, w->nr);
if(!eqrect(r2, w->lastsr)){
w->lastsr = r2;
- /* move r1, r2 to (0,0) to avoid clipping */
- r2 = rectsubpt(r2, r1.min);
- r1 = rectsubpt(r1, r1.min);
- draw(b, r1, w->cols[BORD], nil, ZP);
- draw(b, r2, w->cols[BACK], nil, ZP);
- r2.min.x = r2.max.x-1;
- draw(b, r2, w->cols[BORD], nil, ZP);
- draw(w->i, r, b, nil, Pt(0, r1.min.y));
+ draw(w->i, r1, w->cols[BORD], nil, ZP);
+ draw(w->i, insetrect(r2,1), w->cols[BACK], nil, ZP);
}
}
--- a/wind.c
+++ b/wind.c
@@ -104,6 +104,7 @@
freeimage(w->frame);
w->frame = nil;
+ w->mc.image = nil;
}
static void
@@ -119,6 +120,7 @@
originwindow(w->frame, r.min, hr.min);
}else
w->frame = allocwindow(wscreen, r, Refbackup, DNofill);
+ w->mc.image = w->frame;
s = allocscreen(w->frame, colors[BACK], 0);
assert(s);
wcalcrects(w, r);