richterm

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

commit 63461003fad32eae7f09cb45791065fedc4059a0
parent 81f4675ff9e021dd947ba4c145d5633f0cade50d
Author: Pavel Renev <an2qzavok@gmail.com>
Date:   Wed, 28 Jul 2021 15:01:21 +0000

implement qlocking, maybe

Diffstat:
Mrichterm.c | 20+++++++++++++++++++-
Mrichterm.h | 1+
2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/richterm.c b/richterm.c @@ -60,12 +60,18 @@ threadmain(int argc, char **argv) if (initdraw(0, 0, "richterm") < 0) sysfatal("%s: %r", argv0); + rich.l = mallocz(sizeof(QLock), 1); + + qlock(rich.l); + rich.obj = nil; rich.count = 0; rich.page.scroll = ZP; rich.page.view = nil; + qunlock(rich.l); + mmode = 0; Iscrollbar = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x888888FF); @@ -138,6 +144,8 @@ threadmain(int argc, char **argv) break; } if (rich.obj != nil) { + qlock(rich.l); + /* TODO: make this utf8-aware */ Faux *aux; olast = rich.obj + rich.count - 1; @@ -146,6 +154,8 @@ threadmain(int argc, char **argv) aux->data->p = realloc(aux->data->p, aux->data->n + 1); aux->data->p[aux->data->n - 1] = kv; aux->data->p[aux->data->n] = 0; + + qunlock(rich.l); } redraw(1); nbsend(dctl->rc, &kv); @@ -193,6 +203,8 @@ generatepage(Rich *rich) char *brkp; Faux *aux; + qlock(rich->l); + page = &rich->page; r = page->r; @@ -202,7 +214,10 @@ generatepage(Rich *rich) pt = r.min; ymax = 0; - if (rich->obj == nil) return; + if (rich->obj == nil) { + qunlock(rich->l); + return; + } obj = rich->obj; aux = obj->ftext->aux; @@ -280,6 +295,7 @@ generatepage(Rich *rich) rich->page.max.y = ymax - r.min.y; rich->page.max.x = 0; + qunlock(rich->l); } Font * @@ -342,10 +358,12 @@ Object * newobject(Rich *rich) { Object *obj; + qlock(rich->l); rich->count++; rich->obj = realloc(rich->obj, rich->count * sizeof(Object)); obj = &(rich->obj[rich->count - 1]); obj->id = smprint("%ld", rich->count); + qunlock(rich->l); return obj; } diff --git a/richterm.h b/richterm.h @@ -62,6 +62,7 @@ Point viewsize(View *); typedef struct Rich Rich; struct Rich { + QLock *l; Object *obj; long count; Page page;