richterm

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

commit d9889e2c516ab8fc07294abe8d4eef0b93be773e
parent 3f4e42688356a5c67bfbea96219aa971dedd3a0d
Author: glenda <glenda@9front.local>
Date:   Tue,  8 Jun 2021 21:00:32 +0000

add directory createon to fs, remove ui.h

Diffstat:
Mdevfs.c | 1+
Mfs.c | 2++
Mmkfile | 2+-
Mrichterm.c | 25++++++++-----------------
Mrichterm.h | 48++++++++++++++++++++++++++++++++++++++++++++++--
Dui.h | 37-------------------------------------
6 files changed, 58 insertions(+), 57 deletions(-)

diff --git a/devfs.c b/devfs.c @@ -2,6 +2,7 @@ #include <libc.h> #include <fcall.h> #include <thread.h> +#include <draw.h> #include <9p.h> #include "richterm.h" diff --git a/fs.c b/fs.c @@ -2,6 +2,7 @@ #include <libc.h> #include <fcall.h> #include <thread.h> +#include <draw.h> #include <9p.h> #include "richterm.h" @@ -39,6 +40,7 @@ initfs(void) fsctl->c = chancreate(sizeof(int), 0); srv.tree = alloctree("richterm", "richterm", DMDIR|0555, nil); if (srv.tree == nil) return nil; + fsctl->tree = srv.tree; new = createfile(srv.tree->root, "new", "richterm", 0666, fsctl); if (new == nil) return nil; threadpostmountsrv(&srv, nil, "/mnt/richterm", MREPL); diff --git a/mkfile b/mkfile @@ -2,6 +2,6 @@ TARG=richterm OFILES=richterm.$O devfs.$O fs.$O -HFILES=richterm.h ui.h +HFILES=richterm.h </sys/src/cmd/mkone diff --git a/richterm.c b/richterm.c @@ -9,21 +9,6 @@ #include <9p.h> #include "richterm.h" -#include "ui.h" - -typedef struct Rich Rich; -struct Rich { - Object *obj; - long count; - Page page; -}; - -typedef struct Fonts Fonts; -struct Fonts { - Font **data; - int size; - int count; -}; int hostpid = -1; Channel *pidchan; @@ -35,8 +20,6 @@ Fsctl *fsctl; Fonts fonts; void generatepage(Rectangle, Rich *); -Font* getfont(Fonts *, char *); -void addfont(Fonts *, Font *); void shutdown(void); void send_interrupt(void); void runcmd(void *); @@ -129,6 +112,8 @@ threadmain(int argc, char **argv) rich.obj = malloc(sizeof(Object) * 2); rich.count = 2; rich.obj[0] = (Object){ + nil, + "1", "text", "font=/lib/font/bit/lucida/unicode.24.font", strdup("This is richterm\n"), @@ -136,6 +121,8 @@ threadmain(int argc, char **argv) strtodata(""), strtodata(""), strtodata(""), strtodata(""), }; rich.obj[1] = (Object){ + nil, + "2", "text", "font=/lib/font/bit/lucida/unicode.16.font", strdup("The future of textual interfacing\n"), @@ -212,6 +199,7 @@ threadmain(int argc, char **argv) break; case DEVFSWRITE: rich.count++; + obj->id = smprint("%ld", rich.count); rich.obj = realloc(rich.obj, rich.count * sizeof(Object)); obj = &(rich.obj[rich.count - 1]); obj->data = ov; @@ -219,6 +207,9 @@ threadmain(int argc, char **argv) obj->opts = ""; obj->count = strlen(ov); + obj->dir = createfile(fsctl->tree->root, obj->id, "richterm", DMDIR|0555, fsctl); + /* TODO: add file for every field inside dir */ + generatepage(screen->r, &rich); draw(screen, screen->r, display->white, nil, ZP); diff --git a/richterm.h b/richterm.h @@ -5,9 +5,13 @@ struct Data { long size; }; +Data strtodata(char *); + typedef struct Object Object; struct Object { + File *dir; + char *id; /* old fields */ char *type; char *opts; @@ -20,8 +24,48 @@ struct Object { Data image; }; -Data strtodata(char *); +typedef struct Fonts Fonts; + +struct Fonts { + Font **data; + int size; + int count; +}; + +Font* getfont(Fonts *, char *); +void addfont(Fonts *, Font *); + +typedef struct View View; + +typedef struct Page Page; + +struct View { + Object *obj; + char *dp; + long length; + Font *font; + Rectangle r; + Page *page; +}; + +struct Page { + View *view; + long count; + Point scroll; + Point max; +}; + +void drawview(Image *, View *); +void drawpage(Image *, Page *); +Point viewsize(View *); +typedef struct Rich Rich; + +struct Rich { + Object *obj; + long count; + Page page; +}; typedef struct Devfsctl Devfsctl; @@ -32,11 +76,11 @@ struct Devfsctl { Devfsctl * initdevfs(void); - typedef struct Fsctl Fsctl; struct Fsctl { Channel *c; + Tree *tree; }; Fsctl * initfs(void); diff --git a/ui.h b/ui.h @@ -1,36 +0,0 @@ -/* - * View is an atom of our main GUI screen. - * It represents a small "window" through which - * a part of object can be seen. - * dp points to obj->data+x, so we can display - * only a part of the object (used for wrapped - * lines and such). - * r holds data on where view fits on screen. - * page holds pointer to page view belongs to. - */ -typedef struct View View; - -/* - * Page is a collection of views. - */ -typedef struct Page Page; - -struct View { - Object *obj; - char *dp; - long length; - Font *font; - Rectangle r; - Page *page; -}; - -struct Page { - View *view; - long count; - Point scroll; - Point max; -}; - -void drawview(Image *, View *); -void drawpage(Image *, Page *); -Point viewsize(View *); -\ No newline at end of file