UI module

delete_selection

procedureextensionexperimentalsince 0.31.0Source

Delete the selection. Returns whether there was one.

Example↗
edit: Text_Edit;
defer free_text_edit(*edit);
set_contents(*edit, "hello world");
move_caret(*edit, 5);
move_caret(*edit, 11, extend = true);
assert(delete_selection(*edit));
assert(contents(*edit) == "hello");
assert(!delete_selection(*edit));
delete_selection :: (edit: *Text_Edit) -> bool

Delete the selection. Returns whether there was one.

Parameters

edit: *Text_Edit
the text being edited.

Returns

bool
Example↗
edit: Text_Edit;
defer free_text_edit(*edit);
set_contents(*edit, "hello world");
move_caret(*edit, 5);
move_caret(*edit, 11, extend = true);
assert(delete_selection(*edit));
assert(contents(*edit) == "hello");
assert(!delete_selection(*edit));

See also