diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 01:07:58 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 01:40:44 -0300 |
| commit | 4f06c3ba5f985267ef589289b2b5e60220eeb4bf (patch) | |
| tree | 1500f2d82cfcc914f177db7da05ab021c430a589 /src/Layer.zig | |
| parent | 813527001b1c9a87fa807c9e22c934b7d71acd05 (diff) | |
| download | pardes-4f06c3ba5f985267ef589289b2b5e60220eeb4bf.tar.gz pardes-4f06c3ba5f985267ef589289b2b5e60220eeb4bf.zip | |
draw, gui: a tag caret's span is one Layer.caretSpan (past a full row's end it sits at the tag's right edge, where the grid's is clamped), which the core's focused cursor box and the window's caret both take, in place of the rule written in each with a comment pointing at the other
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/Layer.zig')
| -rw-r--r-- | src/Layer.zig | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Layer.zig b/src/Layer.zig index c43cab03..96250ce4 100644 --- a/src/Layer.zig +++ b/src/Layer.zig @@ -267,3 +267,13 @@ pub fn columnAt(p: *const pardes.Pardes, kind: Kind, id: usize, supplied: ?TagHi } return if (p.reprojectTagHit(point)) |mapped| mapped.col else null; } + +/// A tag caret `w` wide at glyph `x`, its left and right edges in the unit +/// `cell` (a grid cell's width) is in, glyphs `pitch` apart: past a full +/// row's end it sits at the tag's right edge, where the grid's is clamped. +pub fn caretSpan(layer: *const Layer, x: u16, cell: f32, pitch: f32, w: f32) [2]f32 { + const left = @as(f32, @floatFromInt(layer.viewport.x)) * cell; + const right = left + @as(f32, @floatFromInt(layer.viewport.w)) * cell; + const x0 = @min(left + @as(f32, @floatFromInt(x)) * pitch, right - w); + return .{ x0, @min(right, x0 + w) }; +} |
