summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-09-13 15:19:46 -0400
committerJesse Luehrs <doy@tozt.net>2014-09-13 15:19:46 -0400
commite1e7aea55beae31fd0ab067f087401012236cd96 (patch)
treedf299c8fe7ab2f7df5d4499cadf9acf26bb027a8 /examples
parentaef24a4d43598bd1f65951611e6338a597fc7bc0 (diff)
downloadlibvt100-e1e7aea55beae31fd0ab067f087401012236cd96.tar.gz
libvt100-e1e7aea55beae31fd0ab067f087401012236cd96.zip
add functions to allocate memory for the screen too
Diffstat (limited to 'examples')
-rw-r--r--examples/test1.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/examples/test1.c b/examples/test1.c
index bad0023..5531fbd 100644
--- a/examples/test1.c
+++ b/examples/test1.c
@@ -6,14 +6,13 @@
int main(int argc, char *argv[])
{
- VT100Screen vt;
+ VT100Screen *vt;
char buf[4096];
size_t offset = 0;
int i, j, skip;
- memset(&vt, 0, sizeof(VT100Screen));
- vt100_screen_init(&vt);
- vt100_screen_set_window_size(&vt);
+ vt = vt100_screen_new();
+ vt100_screen_set_window_size(vt);
for (;;) {
size_t bytes, parsed;
@@ -22,7 +21,7 @@ int main(int argc, char *argv[])
if (bytes < 1)
break;
- parsed = vt100_screen_process_string(&vt, buf, bytes + offset);
+ parsed = vt100_screen_process_string(vt, buf, bytes + offset);
if (parsed < bytes + offset) {
memcpy(buf, buf + parsed, bytes - parsed);
offset = bytes - parsed;
@@ -30,13 +29,13 @@ int main(int argc, char *argv[])
}
skip = 0;
- for (i = vt.grid->row_top; i < vt.grid->row_top + vt.grid->max.row; ++i) {
- for (j = 0; j < vt.grid->max.col; ++j) {
+ for (i = vt->grid->row_top; i < vt->grid->row_top + vt->grid->max.row; ++i) {
+ for (j = 0; j < vt->grid->max.col; ++j) {
if (skip) {
skip = 0;
continue;
}
- struct vt100_cell *cell = &vt.grid->rows[i].cells[j];
+ struct vt100_cell *cell = &vt->grid->rows[i].cells[j];
printf("%*s", cell->len, cell->contents);
if (cell->is_wide)
skip = 1;
@@ -44,7 +43,7 @@ int main(int argc, char *argv[])
printf("\n");
}
- vt100_screen_cleanup(&vt);
+ vt100_screen_delete(vt);
return 0;
}