Raxol.UI.Components.Input.MultiLineInput.TextHelper (Raxol v0.4.0)

View Source

Helper functions for text and line manipulation in MultiLineInput.

Summary

Functions

Deletes the currently selected text in the state, updating lines and value.

Inserts a character or codepoint at the current cursor position in the state, updating lines and value.

Converts a {row, col} tuple to a flat string index based on the provided lines.

Replaces text within a range (from start_pos_tuple to end_pos_tuple) with the given replacement string. Returns {new_full_text, replaced_text}.

Splits the given text into lines and applies the provided wrapping function to each line.

Splits the given text into lines, applying the specified wrapping mode (:none, :char, or :word).

Functions

calculate_new_position(row, col, inserted_text)

clamp(value, min, max)

delete_selection(state)

Deletes the currently selected text in the state, updating lines and value.

handle_backspace_no_selection(state)

handle_delete_no_selection(state)

insert_char(state, char_or_codepoint)

Inserts a character or codepoint at the current cursor position in the state, updating lines and value.

pos_to_index(text_lines, arg)

Converts a {row, col} tuple to a flat string index based on the provided lines.

replace_text_range(lines_list, start_pos_tuple, end_pos_tuple, replacement)

Replaces text within a range (from start_pos_tuple to end_pos_tuple) with the given replacement string. Returns {new_full_text, replaced_text}.

split_and_wrap(text, width, wrap_fun)

Splits the given text into lines and applies the provided wrapping function to each line.

split_into_lines(text, width, wrap_mode)

Splits the given text into lines, applying the specified wrapping mode (:none, :char, or :word).