Skip to main content Module text_input Copy item path Source TextEditState Persistent text editing state per text input element.
Keyed by element u32 ID in PlyContext::text_edit_states. TextInputBuilder Builder for configuring a text input element via closure. TextInputConfig Configuration for a text input element’s visual appearance.
Stored per-frame in PlyContext::text_input_configs. UndoEntry A snapshot of text state for undo/redo. VisualLine A single visual line after word-wrapping. UndoActionKind Identifies what kind of edit an undo entry was, for grouping consecutive similar edits. char_index_to_byte Convert a character index to a byte index in the string. char_pos_from_line_col Convert a (line, column) pair to a character position.
If the column exceeds the line length, clamps to line end. compute_char_x_positions Compute x-positions for each character boundary in the display text.
Returns a Vec with len = char_count + 1.
Uses the provided measure function to measure substrings. cursor_to_visual_pos Given visual lines and a global cursor position, return (visual_line_index, column_in_visual_line). display_text Build the display text for rendering.
Returns the string that should be measured/drawn. find_nearest_char_boundary Find the nearest character boundary for a given pixel x-position.
char_x_positions has len = char_count + 1 (position 0 = left edge, position n = right edge). find_word_at Find the word boundaries (start, end) at the given character position.
Used for double-click word selection. find_word_boundary_left Find the word boundary to the left of pos (for Ctrl+Left / Ctrl+Backspace). find_word_boundary_right Find the word boundary to the right of pos (for Ctrl+Right / Ctrl+Delete).
Skips whitespace first, then stops at the end of the next word. find_word_delete_boundary_right Find the delete boundary to the right of pos (for Ctrl+Delete).
Deletes the current word AND trailing whitespace (skips word → skips spaces). line_and_column Returns (line_index, column) for a given char position.
Lines are 0-indexed, split by ‘\n’. line_end_char_pos Find the char index of the end of the line containing char_pos.
Returns the position just before the ‘\n’ or at text end. line_start_char_pos Find the char index of the start of the line containing char_pos.
A “line” is delimited by ‘\n’. Returns 0 for the first line. split_lines Split text into lines (by ‘\n’), returning each line’s text
and the global char index where it starts. visual_line_end Move to end of current visual line. Returns the new global cursor position. visual_line_home Move to start of current visual line. Returns the new global cursor position. visual_move_down Navigate cursor one visual line down. Returns the new global cursor position. visual_move_up Navigate cursor one visual line up. Returns the new global cursor position.
col is the desired column (preserved across up/down moves). wrap_lines Word-wrap text into visual lines that fit within max_width.
Splits on ‘\n’ first (hard breaks), then wraps long lines at word boundaries.
If max_width <= 0, no wrapping occurs (equivalent to split_lines).