summaryrefslogtreecommitdiff
path: root/txt.c
diff options
context:
space:
mode:
Diffstat (limited to 'txt.c')
-rw-r--r--txt.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/txt.c b/txt.c
index fd51bc4..a982cd2 100644
--- a/txt.c
+++ b/txt.c
@@ -314,6 +314,17 @@ Str txt_next_chunk(TxtLoc *l) {
return s;
}
+Str txt_prev_chunk(TxtLoc *l) {
+ while (!l->i && l->p > 0) {
+ l->p--;
+ l->i = l->t->ptbl.v[l->p].n;
+ }
+ TxtPiece *p = &l->t->ptbl.v[l->p];
+ Str s = { l->t->buf[p->buf].s + p->ofs, l->i };
+ l->i = 0;
+ return s;
+}
+
int txt_range_equal(TxtLoc lo, TxtLoc hi, Str cmp) {
u32 i = 0;
while (txt_before(lo, hi)) {