commit 89268a83ad9307fffe6d06bfa4ce3e45a203ccec
parent 999de2df33305dd15e04a4e9f3feb713a6715348
Author: Pavel Renev <an2qzavok@gmail.com>
Date: Tue, 15 Mar 2022 19:53:31 +0000
right-button menu is back online
Diffstat:
M | fs.c | | | 25 | ++++++++++++++++++++++++- |
M | richterm.c | | | 32 | ++++++++++++++------------------ |
2 files changed, 38 insertions(+), 19 deletions(-)
diff --git a/fs.c b/fs.c
@@ -44,6 +44,7 @@ initfs(char *srvname)
rq = reqqueuecreate();
menubuf = arraycreate(sizeof(char), 1024, nil);
consc = chancreate(sizeof(Array *), 1024);
+ ctlc = chancreate(sizeof(Array *), 1024);
srv.tree = alloctree("richterm", "richterm", DMDIR|0555, nil);
fsroot = srv.tree->root;
@@ -54,6 +55,9 @@ initfs(char *srvname)
consctl = createfile(fsroot, "consctl", "richterm", DMAPPEND|0666,
fauxalloc(nil, nil, nil, nil, nil, nil));
+ ctl = createfile(fsroot, "ctl", "richterm", DMAPPEND|0666,
+ fauxalloc(nil, nil, ctlread, ctlwrite, nil, nil));
+
text = createfile(fsroot, "text", "richterm", 0666,
fauxalloc(richdata, arrayopen, arrayread, arraywrite, nil, nil));
text->length = richdata->count;
@@ -81,7 +85,7 @@ fauxalloc(
}
void
-fs_destroyfid(Fid *fid)
+fs_destroyfid(Fid *)
{
}
@@ -220,6 +224,25 @@ conswrite(Req *r)
arraygrow(a, r->ifcall.count, r->ifcall.data);
nbsend(insertc, &a);
r->ofcall.count = r->ifcall.count;
+ respond(r, nil);
+}
+
+void
+ctlread(Req *r)
+{
+ Array *msg;
+
+ recv(ctlc, &msg);
+ r->ifcall.offset = 0;
+ readbuf(r, msg->p, msg->count);
+ arrayfree(msg);
+
+ respond(r, nil);
+}
+
+void
+ctlwrite(Req *r)
+{
respond(r, nil);
}
diff --git a/richterm.c b/richterm.c
@@ -574,41 +574,39 @@ rgen(int n)
}
void
-rfollow(void *)
+rfollow(void *v)
{
+ Elem *e = (Elem *)v;
-/*
Array *a;
a = arraycreate(sizeof(char), 1024, nil);
arraygrow(a, 5, "link ");
- arraygrow(a, obj->dlink->count, arrayget(obj->dlink, 0, nil));
+ arraygrow(a, strlen(e->link), e->link);
arraygrow(a, 1, "\n");
- nbsend(ctlc, &a);
-*/
+ fprint(2, "rfollow: sending %p link %s\n", a, e->str);
+
+ nbsend(ctlc, &a);
}
void
-rsnarf(void *)
+rsnarf(void *v)
{
+ Elem *e = (Elem *)v;
-/*
int fd;
long n;
if ((fd = open("/dev/snarf", OWRITE)) > 0) {
- n = write(fd, arrayget(obj->dlink, 0, nil),
- obj->dlink->count);
- if (n < obj->dlink->count) fprint(2, "rsnarf: %r\n");
+ n = write(fd, e->link, strlen(e->link));
+ if (n < strlen(e->link)) fprint(2, "rsnarf: %r\n");
close(fd);
}
-*/
-
}
void
-rplumb(void *)
+rplumb(void *v)
{
-/*
+ Elem *e = (Elem *)v;
char buf[1024];
int pd;
@@ -620,14 +618,12 @@ rplumb(void *)
getwd(buf, sizeof(buf)),
"text",
nil,
- obj->dlink->count,
- arrayget(obj->dlink, 0, nil)
+ strlen(e->link),
+ e->link
};
plumbsend(pd, &m);
close(pd);
}
-*/
-
}
void