UI module

move_vertically

procedureextensionexperimentalsince 0.31.0Source

Move the caret lines lines up (negative) or down, keeping its horizontal position.

Example↗
edit: Text_Edit;
defer free_text_edit(*edit);
set_contents(*edit, "abcd\nef");
move_caret(*edit, 3);

ui := headless();
defer free_ui(*ui);
move_vertically(*ui, *edit, 1, .{});
line, column := caret_position(*edit);
assert(line == 1);
move_vertically :: (
    ui: *UI_State,
    edit: *Text_Edit,
    lines: int,
    style: Text_Style,
    extend: bool = false
)

Move the caret lines lines up (negative) or down, keeping its horizontal position.

Parameters

ui: *UI_State
the UI whose text system measures the lines.
edit: *Text_Edit
the text being edited.
lines: int
how many lines to move. Past either end the caret goes to the start or end of the text.
style: Text_Style
the style the lines are drawn in.
extend: bool = false
keep the anchor, so the selection grows or shrinks.
Example↗
edit: Text_Edit;
defer free_text_edit(*edit);
set_contents(*edit, "abcd\nef");
move_caret(*edit, 3);

ui := headless();
defer free_ui(*ui);
move_vertically(*ui, *edit, 1, .{});
line, column := caret_position(*edit);
assert(line == 1);

See also