summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorWormHeamer2025-12-27 23:26:28 -0500
committerWormHeamer2025-12-27 23:26:28 -0500
commitbf4535008a78ed84fe3e76a9ae262646b9a5f150 (patch)
tree86a0a199e15634c9fe6682de9e08593ef9237687 /main.c
basic piece table implementation
Diffstat (limited to 'main.c')
-rw-r--r--main.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..e367825
--- /dev/null
+++ b/main.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <stddef.h>
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+#define ARENA_IMPL
+
+#include "wrmr.h"
+#include "arena.h"
+#include "txt.h"
+
+int main(void) {
+ Arena a = arena_init(1L << 20);
+ Txt txt = { 0 };
+ txt_open(&txt, "test.txt");
+ txt_insert(&txt, txt.len, "wheeee", 6);
+ txt_delete(&txt, txt.len, 6);
+ for (u32 i = 0; i < txt.ptbl.n; i++) {
+ TxtPiece *p = &txt.ptbl.v[i];
+ printf("%u. %.*s\n", i, (int)p->n, txt.buf[p->buf].s + p->ofs);
+ }
+ arena_free(&a);
+ return 0;
+}