commit 647009a1d4276cc53b2b5ce59395ae06cece2f9b
parent 40b18ba4cb4e1dcc72bb62474b498b4cef9cd20c
Author: Pavel Renev <an2qzavok@gmail.com>
Date: Sun, 25 Apr 2021 17:03:37 +0000
richterm.c: stubfs for opts parsing
Diffstat:
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/richterm.c b/richterm.c
@@ -48,11 +48,15 @@ threadmain(int argc, char **argv)
//if (initview(&view) < 0) sysfatal("initview failed: %r);
rich.obj = malloc(sizeof(Object) * 4);
rich.count = 4;
- rich.obj[0] = (Object){"text", nil, "hello ", strlen("hello ")};
- rich.obj[1] = (Object){"text",
- "font=/lib/font/bit/terminusunicode.18.font", "world", strlen("world")};
- rich.obj[2] = (Object){"text", nil, "!", strlen("!")};
- rich.obj[3] = (Object){"text", nil, "\n", strlen("\n")};
+ rich.obj[0] = (Object){"text", "", "hello ", strlen("hello ")};
+ rich.obj[1] = (Object){
+ "text",
+ "font=/lib/font/bit/terminusunicode.18.font",
+ "world",
+ strlen("world")
+ };
+ rich.obj[2] = (Object){"text", "", "!", strlen("!")};
+ rich.obj[3] = (Object){"text", "", "\n", strlen("\n")};
rich.page = generatepage(screen->r, &rich);
@@ -105,22 +109,33 @@ drawview(Image *dst, View *v)
if (n >= 4096) break;
memcpy(buf, v->dp, n);
buf[n] = '\0';
- string(dst, v->r.min, display->black, ZP, font, buf);
+ string(dst, v->r.min, display->black, ZP, v->font, buf);
}
Page
generatepage(Rectangle r, Rich *rich)
{
- int i;
+ #define BSIZE 4096
+
+ char *bp, buf[BSIZE], *argc[2];
+ Object *obj;
+ View view;
+ int i, argv;
Point pt;
Page page;
page.view = nil;
page.count = 0;
pt = r.min;
for (i = 0; i < rich->count; i++) {
- Object *obj;
- View view;
obj = &rich->obj[i];
+ strncpy(buf, obj->opts, BSIZE);
+ for (bp = buf; (bp != nil) &&
+ (argv = tokenize(bp, argc, 2) > 0); bp = argc[1]){
+ if (strstr(argc[0], "font") == argc[0]) {
+ fprint(2, "we got a font\n");
+ }
+ if (argv == 1) break;
+ }
page.count++;
page.view = realloc(page.view, sizeof(View) * (page.count));
view.obj = obj;