From d931b14863838a8dceed8cd95c71a75a271cca6b Mon Sep 17 00:00:00 2001 From: Albert Cervin Date: Thu, 15 Dec 2022 18:06:59 +0100 Subject: Make minibuffer use an actual buffer Also fix some issues with inserting multibyte chars. --- src/text.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index 952f4ce..97163a5 100644 --- a/src/text.c +++ b/src/text.c @@ -48,6 +48,16 @@ void text_destroy(struct text *text) { free(text->lines); } +void text_clear(struct text *text) { + for (uint32_t li = 0; li < text->nlines; ++li) { + text->lines[li].flags = 0; + text->lines[li].nbytes = 0; + text->lines[li].nchars = 0; + } + + text->nlines = 1; +} + // given `char_idx` as a character index, return the byte index uint32_t charidx_to_byteidx(struct line *line, uint32_t char_idx) { if (char_idx > line->nchars) { -- cgit v1.2.3