ref: 95fa0cb9868e932653e84533fe41691ad4e1579e
parent: 4ae95680d7cf09182aa783cc934ca6c46e56a8b5
author: aap <[email protected]>
date: Tue Aug 20 06:39:58 EDT 2024
some cleanup; note handler
--- a/fs.c
+++ b/fs.c
@@ -1039,7 +1039,6 @@
snprint(srvpipe, sizeof(srvpipe), "lola.%s.%lud", user, (ulong)getpid());
post(srvpipe, fsysfd);
// chatty9p++;
-// srv(&fsys);
threadcreate(srvthread, nil, mainstacksize);
}
--- a/inc.h
+++ b/inc.h
@@ -174,7 +174,6 @@
enum
{
Resized,
- Moved,
Deleted,
Refresh,
Holdon,
@@ -271,7 +270,7 @@
void wraise(Window *w);
void wlower(Window *w);
void wfocus(Window *w);
-void wunfocus(Window *w);
+void wremove(Window *w);
int whide(Window *w);
int wunhide(Window *w);
void wsethold(Window *w, int hold);
--- a/main.c
+++ b/main.c
@@ -27,6 +27,29 @@
write(windows[i]->notefd, "hangup", 6);
}
+static char *oknotes[] ={
+ "delete",
+ "hangup",
+ "kill",
+ "exit",
+ nil, // for debugging
+ nil
+};
+
+int
+notehandler(void*, char *msg)
+{
+ int i;
+
+ killprocs();
+ for(i = 0; oknotes[i]; i++)
+ if(strncmp(oknotes[i], msg, strlen(oknotes[i])) == 0)
+ threadexitsall(msg);
+ fprint(2, "lola %d: abort: %s\n", getpid(), msg);
+ abort();
+ return 0;
+}
+
/*
* /dev/snarf updates when the file is closed, so we must open our own
* fd here rather than use snarffd
@@ -906,6 +929,7 @@
newwindow("-dx 1280 -dy 800");
scrolling = TRUE;
notitle = FALSE;
+oknotes[nelem(oknotes)-2] = "interrupt";
}
initstr = nil;
@@ -963,4 +987,6 @@
if(initstr)
proccreate(initcmd, initstr, mainstacksize);
+
+ threadnotify(notehandler, 1);
}
--- a/text.c
+++ b/text.c
@@ -499,7 +499,7 @@
int
iswordrune(Rune r)
{
- return isalpharune(r) || isdigitrune(r);
+ return r == '_' || isalpharune(r) || isdigitrune(r);
}
static int
--- a/wctl.c
+++ b/wctl.c
@@ -12,6 +12,7 @@
enum
{
Screenoffset,
+ Screenrefresh,
New,
Resize,
Move,
@@ -34,6 +35,7 @@
static char *cmds[] = {
[Screenoffset] = "screenoffset",
+ [Screenrefresh] = "refresh",
[New] = "new",
[Resize] = "resize",
[Move] = "move",
@@ -361,9 +363,6 @@
case Nosticky:
w->sticky = FALSE;
break;
- case Screenoffset:
- screenoffset(r.min.x, r.min.y);
- break;
default:
return "invalid wctl message";
}
@@ -423,6 +422,12 @@
return "command needs to be run within a window";
switch(cmd.cmd){
+ case Screenoffset:
+ screenoffset(r.min.x, r.min.y);
+ return nil;
+ case Screenrefresh:
+ refresh();
+ return nil;
case New:
return wctlnew(cmd);
case Set:
--- a/wind.c
+++ b/wind.c
@@ -7,6 +7,7 @@
Point screenoff;
+static void wrepaint(Window *w);
static void winthread(void *arg);
static void
@@ -67,12 +68,13 @@
w->contrect = r;
if(!w->noborder)
w->contrect = insetrect(w->contrect, bordersz);
+
+ w->titlerect = ZR;
if(!w->notitle){
w->titlerect = w->contrect;
w->titlerect.max.y = w->titlerect.min.y + titlesz;
w->contrect.min.y += titlesz;
- }else
- w->titlerect = ZR;
+ }
r = insetrect(w->contrect, 1);
w->scrollr = r;
@@ -128,6 +130,8 @@
assert(w->content);
draw(w->frame, w->frame->r, colors[BACK], nil, ZP);
xinit(&w->text, w->textr, w->scrollr, font, w->content, colors);
+
+ wrepaint(w);
}
static int id = 1;
@@ -147,7 +151,6 @@
w->scrolling = scrolling;
w->notitle = notitle; // TODO: argument?
wsetsize(w, r);
- wdecor(w);
wlistpushfront(w);
// TODO: could be more graceful here
assert(nwindows < MAXWINDOWS);
@@ -229,11 +232,11 @@
/* increment ref count temporarily
* so win thread doesn't exit too early */
incref(w);
- wunfocus(w);
+ wremove(w);
wclose(w);
+ decref(w);
if(!inwinthread(w))
wsendmsg(w, Wakeup);
- decref(w);
}else
assert(w->ref > 0);
}
@@ -326,11 +329,11 @@
void
wdelete(Window *w)
{
- wunfocus(w);
+ wremove(w);
wsendmsg(w, Deleted);
}
-void
+static void
wrepaint(Window *w)
{
wsetcolors(w);
@@ -361,25 +364,7 @@
void
wmove(Window *w, Point pos)
{
- Point delta;
- /* BUG: originwindow causes the old window rect to be drawn onto the new one
- * with backing store of allocscreen
- * happens in _freeimage1(*winp); in libdraw/init.c:gengetwindow
- * where *winp has the old rectangle
- *
- * We don't care if we're handling resizing ourselves though */
-
- if(1 || w->mouseopen){
- delta = subpt(pos, w->frame->r.min);
- wresize(w, rectaddpt(w->frame->r, delta));
- }else{
- originwindow(w->frame, pos, w->hidden ? screen->r.max : pos);
- if(w != topwin && !w->hidden)
- worder();
- wcalcrects(w, w->frame->r);
- xsetrects(&w->text, w->textr, w->scrollr);
- wsendmsg(w, Moved);
- }
+ wresize(w, rectaddpt(w->frame->r, subpt(pos, w->frame->r.min)));
}
void
@@ -439,7 +424,7 @@
/* Take away focus but also get rid of the window visually.
* For hiding/deleting */
void
-wunfocus(Window *w)
+wremove(Window *w)
{
if(!w->deleted)
originwindow(w->frame, w->frame->r.min, screen->r.max);
@@ -453,7 +438,7 @@
if(w->hidden)
return -1;
incref(w);
- wunfocus(w);
+ wremove(w);
w->hidden = TRUE;
w->wctlready = TRUE;
wsendmsg(w, Wakeup);
@@ -777,12 +762,10 @@
case Resized:
wsetname(w);
- case Moved:
w->resized = TRUE;
w->wctlready = TRUE;
w->mc.buttons = 0; /* avoid re-triggering clicks on resize */
w->mq.counter++; /* cause mouse to be re-read */
- wdecor(w);
break;
case Refresh:
@@ -790,7 +773,6 @@
if(w->deleted)
break;
draw(w->content, w->content->r, x->cols[BACK], nil, ZP);
- wdecor(w);
xfullredraw(&w->text);
break;