1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//! macOS layout helper for [`crate::TextDisplay`].
//!
//! Painting moved to the shared [`crate::primitives::text_display::paint`]
//! (#810, PaintSurface Phase 2c) — see that fn's doc for the divergence
//! (Windows's bold-span support, dropped since `PaintSurface` has no
//! weight parameter) resolved while unifying
//! `gtk::text_display::draw_text_display`,
//! `macos::text_display::draw_text_display` and
//! `win::text_display::draw_text_display` into one implementation. This
//! module now only carries [`mac_text_display_layout`], the pixel-unit
//! layout query used for both hit-testing
//! (`MacBackend::text_display_layout`) and painting
//! (`MacBackend::draw_text_display`, via `Backend::text_display_layout`).
//!
//! The deleted `macos::text_display::draw_text_display` free function
//! had zero call sites in `coord-tui`/`vimcode` (`grep -rn
//! draw_text_display ~/src/coord-tui/src ~/src/vimcode/src` — both only
//! call `Backend::draw_text_display`, whose signature is unchanged), so
//! it needed no deprecation shim (CLAUDE.md rule 1).
use crateRect as QRect;
use crate;
/// Scrollbar gutter width in points. Matches the GTK rasteriser's
/// 12-pt gutter so the body width — and therefore the resolved
/// layout — stays parity-equivalent across the two pixel backends.
const SCROLLBAR_GUTTER_PT: f32 = 12.0;
/// Minimum scrollbar thumb length in points.
const SCROLLBAR_MIN_THUMB_PT: f32 = 8.0;
/// Compute the layout the macOS rasteriser would produce for
/// `display` at `rect` with the supplied `line_height` (font's
/// typographic line height in points). Hosts call this to drive
/// hit-testing for scrollbar drag interaction without re-deriving
/// metrics.
///
/// The returned layout's coordinates are **body-local** (y=0 at the
/// top of the body region). Title-bar painting consumes one
/// `line_height` strip above; the body height passed to the
/// primitive shrinks by that strip when `title` is present. This
/// matches the GTK helper's contract.
///
/// `char_width` is the backend's approximate average character width
/// (`Backend::char_width`) — see quadraui#905: this pure function has no
/// live `CTFont`/`CGContext` to measure real glyph widths with, so it
/// approximates the wrap column budget from pixels the same way the
/// shared `paint` (`MacBackend::draw_text_display`) does, so a click
/// always resolves against the same row boundaries that were actually
/// painted.