widgets(textinput): add toOwnedSlice
Add a way to get the contents of the TextInput
This commit is contained in:
parent
d40fb7cbdb
commit
b0944234c6
1 changed files with 6 additions and 0 deletions
|
@ -147,6 +147,12 @@ pub fn clearRetainingCapacity(self: *TextInput) void {
|
||||||
self.grapheme_count = 0;
|
self.grapheme_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn toOwnedSlice(self: *TextInput) ![]const u8 {
|
||||||
|
self.cursor_idx = 0;
|
||||||
|
self.grapheme_count = 0;
|
||||||
|
return self.buf.toOwnedSlice();
|
||||||
|
}
|
||||||
|
|
||||||
// returns the number of bytes before the cursor
|
// returns the number of bytes before the cursor
|
||||||
// (since GapBuffers are strictly speaking not contiguous, this is a number in 0..realLength()
|
// (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)
|
// which would need to be fed to realIndex() to get an actual offset into self.buf.items.ptr)
|
||||||
|
|
Loading…
Reference in a new issue