diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2020-06-12 12:33:38 -0700 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2020-06-12 12:33:38 -0700 |
commit | a79d1edc9ef2e29597faa723a05088a5d19ea8aa (patch) | |
tree | 0ca99e37b46750316b5db2ea3e6a2cdeb4aec5fd /sys/cmd/dvtm/window.c | |
parent | e41eb5691417ecacade402759231f64778e3147f (diff) |
checkin: going to flesh out your own api
Diffstat (limited to 'sys/cmd/dvtm/window.c')
-rw-r--r-- | sys/cmd/dvtm/window.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/sys/cmd/dvtm/window.c b/sys/cmd/dvtm/window.c index 44690c9..fec3997 100644 --- a/sys/cmd/dvtm/window.c +++ b/sys/cmd/dvtm/window.c @@ -1,15 +1,13 @@ #include <u.h> #include <libn.h> -#include "buffer.h" +#include "term.h" typedef struct Rect Rect; -typedef struct Window Window; -/* origin upper left corner */ struct Rect { - int r0, c0, rows, cols; + int top, left, rows, cols; }; struct Window @@ -17,26 +15,30 @@ struct Window Buffer buffer[2], *buf; Rect area; /* on screen */ Pen pen, spen; /* current and saved pen */ - struct { - uint visible : 1; - int row, col; /* saved cursor row/colmn (zero based) */ - int srow, scol; /* saved cursor row/colmn (zero based) */ - } c; -} + uint curvis : 1; + uint damage : 1; +}; /* functions */ Window * -makewindow( +makewindow(Window *root, Rect area, int history) +{ + Window *w; + w = calloc(1, sizeof(*w)); + if (!w) + panicf("out of memory"); - t->pen = (Pen) { + w->pen = (Pen) { .state = PenNormal, .col = {-1, -1}, }; - t->buffer = &t->buf[0]; - if (!binit(&t->buf[0], rows, cols, size) || - !binit(&t->buf[1], rows, cols, 0)) { - free(t); + if (!binit(w->buffer+0, area.rows, area.cols, history) || + !binit(w->buffer+1, area.rows, area.cols, 0)) { + free(w); return nil; } + w->buf = w->buffer; + return w; +} |