summaryrefslogtreecommitdiff
path: root/txt.h
diff options
context:
space:
mode:
Diffstat (limited to 'txt.h')
-rw-r--r--txt.h47
1 files changed, 34 insertions, 13 deletions
diff --git a/txt.h b/txt.h
index 3af9970..b33599b 100644
--- a/txt.h
+++ b/txt.h
@@ -29,29 +29,50 @@ typedef struct {
u32 p, i;
} TxtLoc;
+/* text buffer manipulation */
+
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);
-u32 txt_insert(Txt *b, u32 cur, const char *s, u32 n);
-u32 txt_delete(Txt *b, u32 cur, u32 n);
-u32 txt_insert_c(Txt *b, u32 cur, u32 ch);
-u32 txt_delete_c(Txt *b, u32 cur);
int txt_load(Txt *b, const char *path);
int txt_save(Txt *b, const char *path);
void txt_free(Txt *b);
-TxtLoc txt_at(Txt *b, u32 cur);
-u32 txt_ofs(Txt *b, TxtLoc l);
-TxtLoc txt_next(Txt *b, TxtLoc l);
-TxtLoc txt_prev(Txt *b, TxtLoc l);
-int txt_at_start(Txt *b, TxtLoc l);
-int txt_at_end(Txt *b, TxtLoc l);
+/* insertion & deletion */
+
+TxtLoc txt_insert(TxtLoc l, const char *s, u32 n);
+TxtLoc txt_delete(TxtLoc l, u32 n);
+TxtLoc txt_insert_c(TxtLoc l, u32 ch);
+TxtLoc txt_delete_c(TxtLoc l);
+
+/* navigation */
+
+TxtLoc txt_at(Txt *b, u32 ofs);
+u32 txt_ofs(TxtLoc l);
int txt_before(TxtLoc a, TxtLoc b);
int txt_after(TxtLoc a, TxtLoc b);
-u32 txt_chr(Txt *b, TxtLoc l);
-u8 txt_byte(Txt *b, TxtLoc l);
-u32 txt_chr_next(Txt *b, TxtLoc *l);
+TxtLoc bnext(TxtLoc l);
+TxtLoc bprev(TxtLoc l);
+TxtLoc cnext(TxtLoc l);
+TxtLoc cprev(TxtLoc l);
+int at_start(TxtLoc l);
+int at_end(TxtLoc l);
+
+TxtLoc next_newline(TxtLoc l);
+TxtLoc prev_newline(TxtLoc l);
+TxtLoc start_of_line(TxtLoc l);
+TxtLoc end_of_line(TxtLoc l);
+TxtLoc prev_line(TxtLoc l);
+TxtLoc next_line(TxtLoc l);
+TxtLoc at_col(TxtLoc l, u32 col);
+u32 get_col(TxtLoc l);
+
+/* reading */
+
+u32 txt_chr(TxtLoc l);
+u8 txt_byte(TxtLoc l);
+u32 txt_chr_next(TxtLoc *l);
#endif