pub fn caret_item(
content_x: f32,
content_y: f32,
run: &EditorTextRun,
local_byte: usize,
style: EditorStyle,
) -> EditorPaintItemExpand description
Converts run-local caret geometry into a neutral paint item.
content_x and content_y are screen-space text origins in logical pixels;
local_byte is clamped by the underlying text layout.
ยงExamples
use ailloli_ui_core::{Color, FontId, TextStyle};
use ailloli_ui_editor::{layout::EditorTextRun, paint::{caret_painter::caret_item, EditorPaintItem}, EditorStyle};
use ailloli_ui_text::{TextLayoutParams, TextSystem};
let mut system = TextSystem::new();
let layout = system.layout_cached(TextLayoutParams::new("x", TextStyle::new(FontId::Mono, 13, Color::WHITE)));
let run = EditorTextRun { index: 0, byte_range: 0..1, baseline_y: 12.0, layout };
assert!(matches!(caret_item(10.0, 10.0, &run, 1, EditorStyle::default()), EditorPaintItem::Caret { .. }));