pub fn caret_rect_for_runs(
viewport: EditorViewport,
runs: &[EditorTextRun],
caret_byte: usize,
style: EditorStyle,
) -> RectExpand description
Finds the containing run or returns a fallback caret after the final run.
With no runs, the caret starts at the viewport text origin and has height
px_size + 2. Boundary bytes may select the first matching adjacent run.
ยงExamples
use ailloli_ui_core::Rect;
use ailloli_ui_editor::{input::caret::caret_rect_for_runs, EditorConfig, EditorStyle, EditorViewport};
use ailloli_ui_text::TextEditState;
let viewport = EditorViewport::new(Rect::new(0.0, 0.0, 80.0, 40.0), EditorConfig::default(), &TextEditState::new());
let rect = caret_rect_for_runs(viewport, &[], 0, EditorStyle::default());
assert_eq!((rect.x, rect.y, rect.w, rect.h), (10.0, 10.0, 1.0, 15.0));