diff --git a/src/widgets/TextInput.zig b/src/widgets/TextInput.zig index 6e7f250..30e32a8 100644 --- a/src/widgets/TextInput.zig +++ b/src/widgets/TextInput.zig @@ -97,6 +97,18 @@ pub fn draw(self: *TextInput, win: Window) void { win.showCursor(cursor_idx, 0); } +pub fn clearAndFree(self: *TextInput) void { + self.buf.clearAndFree(); + self.cursor_idx = 0; + self.grapheme_count = 0; +} + +pub fn clearRetainingCapacity(self: *TextInput) void { + self.buf.clearRetainingCapacity(); + self.cursor_idx = 0; + self.grapheme_count = 0; +} + // returns the number of bytes before the cursor // (since GapBuffers are strictly speaking not contiguous, this is a number in 0..realLength() // which would need to be fed to realIndex() to get an actual offset into self.buf.items.ptr)