commit 922675fb154bde0363cf6b6e7fb8a0438262c88c
parent 6630d0d8aa1cf8154390766fe19dc8becd203b17
Author: Pavel Renev <an2qzavok@gmail.com>
Date: Sat, 15 May 2021 22:19:33 +0000
implement struct Data
Diffstat:
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/richterm.c b/richterm.c
@@ -129,14 +129,14 @@ threadmain(int argc, char **argv)
"font=/lib/font/bit/lucida/unicode.24.font",
strdup("This is richterm\n"),
strlen("This is richterm\n"),
- "", "", "", "",
+ strtodata(""), strtodata(""), strtodata(""), strtodata(""),
};
rich.obj[1] = (Object){
"text",
"font=/lib/font/bit/lucida/unicode.16.font",
strdup("The future of textual interfacing\n"),
strlen("The future of textual interfacing\n"),
- "", "", "", "",
+ strtodata(""), strtodata(""), strtodata(""), strtodata(""),
};
rich.page.scroll = ZP;
rich.page.view = nil;
@@ -395,3 +395,8 @@ scroll(Point p, Rich *r)
drawpage(screen, &r->page);
flushimage(display, 1);
}
+
+Data strtodata(char *str)
+{
+ return (Data){strdup(str), strlen(str)};
+}
diff --git a/richterm.h b/richterm.h
@@ -1,3 +1,9 @@
+typedef struct Data Data;
+struct Data {
+ char *p;
+ long size;
+};
+
typedef struct Devfsctl Devfsctl;
struct Devfsctl {
Channel *rc;
@@ -12,10 +18,11 @@ struct Object {
char *data;
long count;
/* future fields */
- char *text;
- char *font;
- char *link;
- char *image;
+ Data text;
+ Data font;
+ Data link;
+ Data image;
};
+Data strtodata(char *);
Devfsctl * initdevfs(void);