From ad18f346eb10936c7ca059b2bc3445c72c189dbd Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Sat, 30 Mar 2024 07:40:08 -0500 Subject: [PATCH] textinput: make byteOffsetToCursor public --- src/widgets/TextInput.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/widgets/TextInput.zig b/src/widgets/TextInput.zig index 011a661..b0a0371 100644 --- a/src/widgets/TextInput.zig +++ b/src/widgets/TextInput.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const assert = std.debug.assert; const Key = @import("../Key.zig"); const Cell = @import("../Cell.zig"); const Window = @import("../Window.zig"); @@ -188,7 +189,7 @@ fn reset(self: *TextInput) void { // 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) -fn byteOffsetToCursor(self: TextInput) usize { +pub fn byteOffsetToCursor(self: TextInput) usize { // assumption! the gap is never in the middle of a grapheme // one way to _ensure_ this is to move the gap... but that's a cost we probably don't want to pay. var iter = GraphemeIterator.init(self.buf.items);