richterm

"terminal emulator" with support for text fonts and images for plan9
git clone git://nsmpr.xyz/richterm.git
Log | Files | Refs | README

commit d0235849a0e7d158e3dda34323858ae2cc6a8803
parent cdf8e7d64f8817208d96403ffa712588b816da41
Author: Pavel Renev <an2qzavok@gmail.com>
Date:   Thu, 29 Jul 2021 20:28:53 +0000

some code massaging

Diffstat:
Mdevfs.c | 10++--------
Mrichterm.c | 28+++++++++++-----------------
Mrichterm.h | 2++
3 files changed, 15 insertions(+), 25 deletions(-)

diff --git a/devfs.c b/devfs.c @@ -32,19 +32,13 @@ void devfs_write(Req *r) { File *f; - Devfsctl *dctl; f = r->fid->file; - dctl = f->aux; if (f == cons){ char *buf; buf = mallocz(r->ifcall.count + 1, 1); - /* TODO: - * + 1 is a hack to make sure string is \0 terminated - * we should send a struct that includes both data and size - * instead of simple char pointer. - */ memcpy(buf, r->ifcall.data, r->ifcall.count); - send(dctl->wc, &buf); + mkobjectftree(newobject(&rich), fsctl->tree->root, buf); + redraw(1); r->ofcall.count = r->ifcall.count; respond(r, nil); } else if (f == consctl) { diff --git a/richterm.c b/richterm.c @@ -35,7 +35,6 @@ void threadmain(int argc, char **argv) { Object *olast; - char *ov; Mousectl *mctl; Keyboardctl *kctl; int rv[2], mmode; @@ -49,17 +48,6 @@ threadmain(int argc, char **argv) usage(); } ARGEND - if(rfork(RFENVG) < 0) - sysfatal("rfork: %r"); - atexit(shutdown); - - pidchan = chancreate(sizeof(int), 0); - proccreate(runcmd, argv, 16 * 1024); - hostpid = recvul(pidchan); - - if (initdraw(0, 0, "richterm") < 0) - sysfatal("%s: %r", argv0); - rich.l = mallocz(sizeof(QLock), 1); qlock(rich.l); @@ -72,6 +60,17 @@ threadmain(int argc, char **argv) qunlock(rich.l); + if(rfork(RFENVG) < 0) + sysfatal("rfork: %r"); + atexit(shutdown); + + pidchan = chancreate(sizeof(int), 0); + proccreate(runcmd, argv, 16 * 1024); + hostpid = recvul(pidchan); + + if (initdraw(0, 0, "richterm") < 0) + sysfatal("%s: %r", argv0); + mmode = 0; Iscrollbar = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x888888FF); @@ -90,7 +89,6 @@ threadmain(int argc, char **argv) {mctl->c, &mv, CHANRCV}, {mctl->resizec, rv, CHANRCV}, {kctl->c, &kv, CHANRCV}, - {dctl->wc, &ov, CHANRCV}, {nil, nil, CHANEND}, }; for (;;) { @@ -161,10 +159,6 @@ threadmain(int argc, char **argv) redraw(1); nbsend(dctl->rc, &kv); break; - case DEVFSWRITE: - mkobjectftree(newobject(&rich), fsctl->tree->root, ov); - redraw(1); - break; case NONE: break; } diff --git a/richterm.h b/richterm.h @@ -89,6 +89,8 @@ struct Fsctl { Tree *tree; }; +extern Fsctl *fsctl; + Fsctl * initfs(void); typedef struct Faux Faux;