diff options
| author | Albert Cervin <albert@acervin.com> | 2022-12-15 18:06:59 +0100 |
|---|---|---|
| committer | Albert Cervin <albert@acervin.com> | 2022-12-15 18:06:59 +0100 |
| commit | d931b14863838a8dceed8cd95c71a75a271cca6b (patch) | |
| tree | 64e1afa0b4849628f47f29d5cdb192fd0db63240 /src/text.c | |
| parent | a73225c9b45e110d315a3fc587a82040ce8c9a13 (diff) | |
| download | dged-d931b14863838a8dceed8cd95c71a75a271cca6b.tar.gz dged-d931b14863838a8dceed8cd95c71a75a271cca6b.tar.xz dged-d931b14863838a8dceed8cd95c71a75a271cca6b.zip | |
Make minibuffer use an actual buffer
Also fix some issues with inserting multibyte chars.
Diffstat (limited to 'src/text.c')
| -rw-r--r-- | src/text.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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) { |
