UI module

insert_text

procedureextensionexperimentalsince 0.31.0Source

Replace the selection (or insert at the caret) with text.

Example↗
edit: Text_Edit;
defer free_text_edit(*edit);
set_contents(*edit, "hello");
select_all(*edit);
insert_text(*edit, "bye");  // replaces the selection
assert(contents(*edit) == "bye");
insert_text :: (edit: *Text_Edit, text: string)

Replace the selection (or insert at the caret) with text.

Parameters

edit: *Text_Edit
the text being edited.
text: string
the text to insert. Line breaks are removed in a single-line edit.
Example↗
edit: Text_Edit;
defer free_text_edit(*edit);
set_contents(*edit, "hello");
select_all(*edit);
insert_text(*edit, "bye");  // replaces the selection
assert(contents(*edit) == "bye");

See also