diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 20:05:20 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 22:03:21 -0300 |
| commit | d2b04b2a24a04b5de1416b33f37637f59dda71ee (patch) | |
| tree | 727b5d4006d67b85c9decee7d708f5811cd16e68 /src/Layer.zig | |
| parent | 12cb0a704075dea2512f77582635376fe967dee6 (diff) | |
| download | pardes-d2b04b2a24a04b5de1416b33f37637f59dda71ee.tar.gz pardes-d2b04b2a24a04b5de1416b33f37637f59dda71ee.zip | |
split pardes.zig by noun, the small moves: a header's word under a column (WordBounds, wordBoundsAtCol) goes to tagline.zig, the two frontend pixel helpers for tag bands (taglineBandOffset, topbarPaneBorderPixels) to Layer.zig with their test, the look walk's row budget (max_look_rows) to look.zig, its only reader; their callers name them there (draw.zig, mouse.zig, gui.zig, and macos.zig's two by text, built nowhere here); pathUnder goes, called from nowhere; the help index stays in the root, as builtins.zig's registry walks that file's own declarations and the index's rows depend on the registry (a dependency loop), and the theme's three accessors stay with the session, as colors.zig's locals are named theme; test moved, by name: tagline bands center in their cells and Tagbottom faces the window edge (to Layer.zig); a pure move, no field touched, a dump and the wire as they were; gates: tui core-test 960/960, behaviour-test 238/238, snap all 108 scripts ok, gui unit-test 1518/1519 (1 skipped)
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 | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/Layer.zig b/src/Layer.zig index 66f8b9c0..deca3466 100644 --- a/src/Layer.zig +++ b/src/Layer.zig @@ -270,3 +270,28 @@ pub fn caretSpan(layer: *const Layer, x: u16, cell: f32, pitch: f32, w: f32) [2] const x0 = @min(left + @as(f32, @floatFromInt(x)) * pitch, right - w); return .{ x0, @min(right, x0 + w) }; } + +pub fn taglineBandOffset(row: u16, canvas_h: f32, cell_h: u32, tagline_h: u32) u32 { + const spare = cell_h -| tagline_h; + const rows: u32 = @max(1, @as(u32, @intFromFloat(@floor(canvas_h / @as(f32, @floatFromInt(cell_h)))))); + // Every band centers in its cell, so text and anchors sit at the same + // height in the workspace, column and pane tags alike. Only the last row + // faces the window edge (Tagbottom). + if (@as(u32, row) + 1 >= rows) return spare; + return spare / 2; +} + +pub fn topbarPaneBorderPixels(cell_h: u32, tagline_h: u32) u32 { + const spare = cell_h -| tagline_h; + return @min(@as(u32, config.gui_topbar_pane_border_px), spare * 2); +} + +test "tagline bands center in their cells and Tagbottom faces the window edge" { + const cell_h: u32 = 20; + const tagline_h: u32 = 16; + const canvas_h: f32 = 200; + // Workspace, column and pane rows alike: text lines up across bands. + for ([_]u16{ 0, 1, 2, 5, 8 }) |row| + try std.testing.expectEqual(@as(u32, 2), taglineBandOffset(row, canvas_h, cell_h, tagline_h)); + try std.testing.expectEqual(@as(u32, 4), taglineBandOffset(9, canvas_h, cell_h, tagline_h)); +} |
