diff options
Diffstat (limited to 'txt.h')
| -rw-r--r-- | txt.h | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -0,0 +1,43 @@ +#ifndef TXT_H +#define TXT_H + +#include "dynarr.h" + +typedef enum : u8 { + TXT_SRC, + TXT_ADD +} TxtBufIdx; + +typedef struct TxtPiece { + TxtBufIdx buf; + u32 ofs, n; +} TxtPiece; + +typedef struct { + char *s; + u32 n, c; +} TxtBuf; + +typedef struct { + u32 p, i; +} TxtLoc; + +typedef struct { + DYNARR(TxtPiece) ptbl; + TxtBuf buf[2]; + u32 len; +} Txt; + +TxtLoc txt_at(Txt *b, u32 cur); + +u32 txt_split_piece(Txt *b, u32 pi, u32 i); +void txt_remove_piece(Txt *b, u32 pi); +void txt_insert_piece(Txt *b, u32 pi, TxtBufIdx buf, u32 ofs, u32 n); +void txt_buf_append(Txt *b, TxtBufIdx bi, const char *s, u32 n); + +u32 txt_insert(Txt *b, u32 cur, const char *s, u32 n); +u32 txt_insert_c(Txt *b, u32 cur, char ch); +u32 txt_delete(Txt *b, u32 cur, u32 n); +int txt_open(Txt *b, const char *path); + +#endif |
