UI module

caret_position

procedureextensionexperimentalsince 0.31.0Source

Where the caret is, as a zero-based line and a byte column within it.

Example↗
edit: Text_Edit;
defer free_text_edit(*edit);
set_contents(*edit, "ab\ncd");
move_caret(*edit, 4);
line, column := caret_position(*edit);
assert(line == 1 && column == 1);
caret_position :: (edit: *Text_Edit) -> (line: int, column: int)

Where the caret is, as a zero-based line and a byte column within it.

Parameters

edit: *Text_Edit
the text being edited.

Returns

line: int
column: int
Example↗
edit: Text_Edit;
defer free_text_edit(*edit);
set_contents(*edit, "ab\ncd");
move_caret(*edit, 4);
line, column := caret_position(*edit);
assert(line == 1 && column == 1);

See also