Struct imgui::TextCallbackData [−][src]
pub struct TextCallbackData<'a>(_);
Expand description
This struct provides methods to edit the underlying text buffer that Dear ImGui manipulates. Primarily, it gives remove_chars, insert_chars, and mutable access to what text is selected.
Implementations
Gives access to the underlying byte array MUTABLY.
Safety
This is very unsafe, and the following invariants must be upheld:
- Keep the data utf8 valid.
- After editing the string, call set_dirty.
To truncate the string, please use remove_chars. To extend the string, please use insert_chars and push_str.
This function should have highly limited usage, but could be for editing certain characters in the buffer based on some external condition.
Sets the dirty flag on the text to imgui, indicating that it should reapply this string to its internal state.
NB: You only need to use this method if you’re using [str_as_bytes_mut]
.
If you use the helper methods remove_chars and insert_chars,
this will be set for you. However, this is no downside to setting
the dirty flag spuriously except the minor CPU time imgui will spend.
Gets a range of the selected text. See selection_start_mut and selection_end_mut to mutably edit these values.
This Range is given in usize
so that it might be used in indexing
operations more easily. To quickly grab the selected text, use selected.
Returns the selected text directly. Note that if no text is selected, an empty str slice will be returned.
Sets the cursor to select all.
Clears the selection.
Checks if there is a selection within the text.
Pushes the given str to the end of this buffer. If this would require the String to resize, it will be resized. This is automatically handled.
Inserts the given string at the given position. If this would require the String to resize, it will be resized automatically.
Panics
Panics if the pos
is not a char_boundary.
Inserts the given string at the given position, unsafely. If this would require the String to resize, it will be resized automatically.
Safety
It is up to the caller to confirm that the pos
is a valid byte
position, or use insert_chars which will panic
if it isn’t.
Removes the given number of characters from the string starting at some byte pos.
Panics
Panics if the pos
is not a char boundary.
Removes the given number of bytes from the string starting at some byte pos, without checking for utf8 validity. Use remove_chars for a safe variant.
Safety
It is up to the caller to ensure that the position is at a valid utf8 char_boundary and that there are enough bytes within the string remaining.
Get a reference to the text callback buffer’s cursor pos.
Set the text callback buffer’s cursor pos.
Get a mutable reference to the text callback buffer’s selection start.
Get a mutable reference to the text callback buffer’s selection end..