Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,9 @@ For each paragraph:
- Calculates target visual line: `scroll_top + (row - text_area.y)`

2. **Find Nearest Position**:
- Calls `closest_pointer_near_line(visual_line, relative_column)`
- Searches `visual_positions` for entries on that line
- Finds closest position by column distance
- Calls `closest_pointer_near_line_visual(visual_line, relative_column)`
- Checks whether the click lands inside a reveal tag's visual width and, if so, selects that tag's pointer directly
- Otherwise searches `visual_positions` for entries on that line and finds the closest position by column distance
- If line empty, searches nearby lines (alternating above/below)
- Returns `CursorDisplay` with pointer and position

Expand Down Expand Up @@ -437,7 +437,7 @@ For each paragraph:

3. **Render with Tags**: `display.render_document(...)`
- Passes reveal tags to renderer
- Renderer inserts reveal tag fragments (e.g., `[Bold>`, `<Bold]`)
- Renderer inserts reveal tag fragments (e.g., `[Bold>`, `<Bold]`) and attaches marker events so hit-testing can target them
- Tags styled distinctly (yellow on blue background)
- Cursor can be positioned at tag boundaries
- Tags have zero `content_width` (don't affect content column tracking)
Expand Down
17 changes: 12 additions & 5 deletions benches/performance.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pure_tui::{
editor,
editor::{self, DocumentEditor},
render::{self, DirectCursorTracking},
theme::Theme,
};
Expand Down Expand Up @@ -287,12 +287,18 @@ fn bench_rendering_reveal_codes() {
println!("╚════════════════════════════════════════════════════════════════╝");

let doc = create_styled_document(MEDIUM_DOC_PARAGRAPHS);
let reveal_tags = {
let mut editor = DocumentEditor::new(doc.clone());
editor.set_reveal_codes(true);
let (_, _, tags, _) = editor.clone_with_markers('\u{F8FF}', None, '\u{F8FE}', '\u{F8FD}');
tags
};

let result_normal = benchmark("render_document - reveal_codes OFF", ITERATIONS, || {
let tracking = DirectCursorTracking {
cursor: None,
selection: None,
track_all_positions: false,
track_all_positions: true,
};
let theme = Theme::default();
let _ = render::render_document_direct(&doc, 80, 0, &[], tracking, &theme);
Expand All @@ -303,10 +309,10 @@ fn bench_rendering_reveal_codes() {
let tracking = DirectCursorTracking {
cursor: None,
selection: None,
track_all_positions: false,
track_all_positions: true,
};
let theme = Theme::default();
let _ = render::render_document_direct(&doc, 80, 0, &[], tracking, &theme);
let _ = render::render_document_direct(&doc, 80, 0, &reveal_tags, tracking, &theme);
});
result_reveal.print();

Expand Down Expand Up @@ -1395,7 +1401,8 @@ fn bench_mouse_cursor_positioning() {
println!("║ PERFORMANCE NOTES ║");
println!("╚════════════════════════════════════════════════════════════════╝");
println!("\nMouse positioning calls pointer_from_mouse which:");
println!(" 1. Calls closest_pointer_near_line");
println!(" 1. Calls closest_pointer_near_line_visual");
println!(" - Immediately handles reveal tag hit-testing based on rendered width");
println!(" 2. Which calls get_positions_for_line");
println!(" 3. Which calls ensure_paragraph_positions (lazy population)");
println!(" 4. Which calls layout_paragraph with track_all_positions=true");
Expand Down
Loading
Loading