Ported examples 00 and 01 to proc macro interface.

This commit is contained in:
2026-03-21 21:51:50 -04:00
parent 437b318ad9
commit c9966b79ef
8 changed files with 864 additions and 42 deletions

View File

@@ -585,6 +585,7 @@ impl SceneSnapshot {
mod tests {
use super::{Color, Point, PreparedText, Rect};
use crate::TextSelectionStyle;
use crate::{TextStyle, TextSystem, TextWrap};
#[test]
fn prepared_text_hit_testing_clamps_to_nearest_cluster_boundary() {
@@ -703,4 +704,22 @@ mod tests {
assert_eq!(text.line_start_offset(6), Some(4));
assert_eq!(text.line_end_offset(2), Some(4));
}
#[test]
fn prepared_text_multiline_selection_stays_on_target_line() {
let mut text_system = TextSystem::new();
let style = TextStyle::new(16.0, Color::rgb(0xFF, 0xFF, 0xFF)).with_wrap(TextWrap::None);
let text = text_system.prepare("ab\ncd\nef", Point::new(10.0, 20.0), &style);
assert_eq!(text.lines.len(), 3);
let target_line = &text.lines[1];
let y = target_line.rect.origin.y + target_line.rect.size.height * 0.5;
let start = text.byte_offset_for_position(Point::new(target_line.rect.origin.x, y));
let end = text.byte_offset_for_position(Point::new(target_line.rect.origin.x + 16.0, y));
let rects = text.selection_rects(start, end);
assert_eq!(rects.len(), 1);
assert_eq!(rects[0].origin.y, target_line.rect.origin.y);
}
}