diff options
Diffstat (limited to 'txt.c')
| -rw-r--r-- | txt.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -132,6 +132,7 @@ loop: } TxtLoc txt_insert(TxtLoc l, const char *s, u32 n) { + if (l.t->readonly) return l; l = txt_add_piece(l); TxtPiece *p = &l.t->ptbl.v[l.p]; isize ext = txt_buf_dedup(l.t, p->buf, s, n); @@ -147,6 +148,7 @@ TxtLoc txt_insert(TxtLoc l, const char *s, u32 n) { } TxtLoc txt_delete(TxtLoc l, u32 n) { + if (l.t->readonly) return l; l = txt_split_piece(l); while (n > 0) { TxtPiece *p = &l.t->ptbl.v[l.p]; @@ -193,6 +195,7 @@ TxtLoc txt_delete_range(TxtLoc lo, TxtLoc hi) { } TxtLoc txt_delete_c(TxtLoc l) { + if (l.t->readonly) return l; while (!at_start(l) && (txt_byte(bprev(l)) & 0xc0) == 0x80) l = txt_delete(l, 1); l = txt_delete(l, 1); @@ -274,7 +277,7 @@ void txt_hist_push(Txt *t, TxtLoc cur) { return; } if (t->hist.i + 1 < t->hist.n) t->hist.n = t->hist.i + 1; - if (t->hist.n == TXT_HIST_MAX) { + if (t->hist.i + 1 == TXT_HIST_MAX) { free(t->hist.v[0].v); MOVE(&t->hist.v[0], &t->hist.v[1], TXT_HIST_MAX - 1); t->hist.i--; |
