Function zone_byte_at_point

Source
pub fn zone_byte_at_point(
    viewport: EditorViewport,
    runs: &[EditorTextRun],
    style: EditorStyle,
    buffer_len_bytes: usize,
    pos: Point,
) -> EditorZoneHitTest
Expand description

Classifies gutter/text/outside before resolving the nearest byte.

Gutter hits resolve at the text left edge on the same y coordinate. Padded content outside text_rect is still classified as text. Outside uses the supplied buffer length without consulting runs.

ยงExamples

use ailloli_ui_core::{Point, Rect};
use ailloli_ui_editor::{input::hit_test::zone_byte_at_point, EditorConfig, EditorHitZone, 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 hit = zone_byte_at_point(viewport, &[], EditorStyle::default(), 9, Point::new(100.0, 100.0));
assert_eq!((hit.zone, hit.byte), (EditorHitZone::Outside, 9));