Skip to main content

justerm_core/
logical.rs

1//! Viewport logical lines (#113, ADR-0017): soft-wrap-joined text plus a
2//! per-char map back to viewport cells. This is the buffer-wide *mechanism* a
3//! frame-mode consumer needs for URL detection — the regex and `new URL()`
4//! validation stay consumer-side (policy). It also serves the a11y screen-reader
5//! mirror (#119). The cell-aware assembly lives in `term/logical.rs` — the `Term` half
6//! of this model, moved out of `term.rs` in #601; this module is just the returned shape.
7
8/// One soft-wrap-joined logical line touching the viewport.
9#[derive(Clone, PartialEq, Eq, Debug)]
10pub struct LogicalLine {
11    /// The line text: wrap-joined across soft-wrapped rows, wide-char spacers
12    /// skipped, trailing blanks trimmed. This is **not** the equivalence to xterm.js's
13    /// `BufferLine.translateToString(true)` an earlier version of this comment claimed. The
14    /// spacer skip matches; the wrap join does not (that method spans one `BufferLine` —
15    /// xterm pairs it with `Buffer.getWrappedRangeForLine`); and the trim differs on a line
16    /// ending in *printed* spaces, which xterm keeps and `trim_end` drops. Pinned in
17    /// `docs/agents/reference-facts.md` § "Logical-line assembly".
18    pub text: String,
19    /// Per `text` char, the viewport cell `(row, col)` it came from. A `row`
20    /// outside `0..rows` is off-screen wrapped context (a line that wraps in from
21    /// above the top / out past the bottom) — present so a URL spanning the edge
22    /// still matches; the consumer highlights only the in-range cells.
23    pub cells: Vec<(i32, usize)>,
24}