summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 20:05:20 -0300
committerGabriel Schneider <[email protected]>2026-11-05 22:03:21 -0300
commitd2b04b2a24a04b5de1416b33f37637f59dda71ee (patch)
tree727b5d4006d67b85c9decee7d708f5811cd16e68
parent12cb0a704075dea2512f77582635376fe967dee6 (diff)
downloadpardes-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
-rw-r--r--src/Layer.zig25
-rw-r--r--src/draw.zig2
-rw-r--r--src/gui/gui.zig4
-rw-r--r--src/look.zig5
-rw-r--r--src/macos.zig4
-rw-r--r--src/mouse.zig2
-rw-r--r--src/pardes.zig48
-rw-r--r--src/tagline.zig13
8 files changed, 48 insertions, 55 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));
+}
diff --git a/src/draw.zig b/src/draw.zig
index 910f4fef..136c57a8 100644
--- a/src/draw.zig
+++ b/src/draw.zig
@@ -29,7 +29,7 @@ const Rect = layout.Rect;
const Region = @import("surface.zig").Region;
const TagKind = @import("Layer.zig").Kind;
const pdf_enabled = panes.Pdf.enabled;
-const wordBoundsAtCol = pardes.wordBoundsAtCol;
+const wordBoundsAtCol = tagline.wordBoundsAtCol;
const BOX_H = pardes.BOX_H;
const TAG_TEXT_INSET = pardes.TAG_TEXT_INSET;
const MAX_PANES = pardes.MAX_PANES;
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index 7e60f0dc..c148c3fc 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -5726,7 +5726,7 @@ const ResolvedCell = struct {
role: pardes.FontRole,
};
-const taglineBandOffset = pardes.taglineBandOffset;
+const taglineBandOffset = pardes.Layer.taglineBandOffset;
/// The colours and atlas slot of `line[at]`. `cursor` is where the cursor sits
/// in `line`, block or bar: shaping breaks around it.
@@ -7996,7 +7996,7 @@ test "the rule between stacked panes stays in the tag band's slack, at any tagli
var groups: Groups = .{};
try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 800, 480, true);
const top = @as(f32, @floatFromInt(lower.rect.y)) * 20;
- const slack: f32 = @floatFromInt(@max(1, pardes.taglineBandOffset(lower.rect.y, 480, 20, tagline_h)));
+ const slack: f32 = @floatFromInt(@max(1, pardes.Layer.taglineBandOffset(lower.rect.y, 480, 20, tagline_h)));
var found = false;
for (g.decor.items) |item| {
const y0 = (1 - item.y0) / 2 * 480;
diff --git a/src/look.zig b/src/look.zig
index 7b39f113..25ec029d 100644
--- a/src/look.zig
+++ b/src/look.zig
@@ -866,7 +866,7 @@ pub fn lookWalk(p: *Pardes, delta: i32) void {
else
active_at;
var from = lookStand(p.panes[order[at]] orelse return);
- var budget: usize = Pardes.max_look_rows;
+ var budget: usize = max_look_rows;
var k: usize = 0;
while (k <= order.len) : (k += 1) {
// `+ 2 * len` only so the backward subtraction stays unsigned
@@ -2724,3 +2724,6 @@ test "Look on a diff line is the look of the address it names, selected by hand:
try std.testing.expect(std.mem.endsWith(u8, seen[0].active_path, "/entry/src/entry.rs"));
try std.testing.expectEqual(@as(i32, 1), seen[0].row);
}
+
+/// The rows n/N's walk over look-able text reads before it stops (look.zig).
+pub const max_look_rows = 8192;
diff --git a/src/macos.zig b/src/macos.zig
index 505aeb7f..9956d706 100644
--- a/src/macos.zig
+++ b/src/macos.zig
@@ -744,11 +744,11 @@ export fn pardes_gui_tagline_font_percent() u8 {
export fn pardes_tagline_band_offset(row: u16, canvas_h: f32, cell_h: u32, tagline_h: u32) u32 {
pardes.turn.wake();
defer pardes.turn.rest();
- return pardes.taglineBandOffset(row, canvas_h, cell_h, tagline_h);
+ return pardes.Layer.taglineBandOffset(row, canvas_h, cell_h, tagline_h);
}
export fn pardes_topbar_pane_border_px(cell_h: u32, tagline_h: u32) u32 {
- return pardes.topbarPaneBorderPixels(cell_h, tagline_h);
+ return pardes.Layer.topbarPaneBorderPixels(cell_h, tagline_h);
}
export fn pardes_tagline_origin_col(col: u16, row: u16) f32 {
diff --git a/src/mouse.zig b/src/mouse.zig
index 365ed560..5c3821e7 100644
--- a/src/mouse.zig
+++ b/src/mouse.zig
@@ -130,7 +130,7 @@ fn headerSweepRun(p: *Pardes, sweep: HeaderSweep) void {
const at = swept.lo - start;
const focused = p.header_focus and p.header_column == column;
const on = if (focused) tagline.headerSelection(t, text, line) else null;
- const under = if (pardes.wordBoundsAtCol(bar, at)) |b| bar[b.lo..b.hi] else "";
+ const under = if (tagline.wordBoundsAtCol(bar, at)) |b| bar[b.lo..b.hi] else "";
break :click if (on) |sp| (if (at >= sp.lo and at < sp.hi) bar[sp.lo..sp.hi] else under) else under;
};
const word = p.scratch.allocator().dupe(u8, selected) catch return;
diff --git a/src/pardes.zig b/src/pardes.zig
index 9e6a2d7f..153a07c9 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -156,21 +156,6 @@ pub const COLBAR_H: u16 = 1;
pub const BOX_H: u16 = 1;
pub const TAG_TEXT_INSET: u16 = config.GUTTER;
-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);
-}
-
pub fn taglineOriginCol(p: *const Pardes, col: u16, row: u16) f32 {
if (row < p.topBarHeight()) return 0;
if (row < p.topBarHeight() + layout.columnBarHeight(p)) {
@@ -1670,27 +1655,6 @@ comptime {
}
}
-const WordBounds = struct { lo: usize, hi: usize };
-
-/// The space-delimited word covering `col` in `str` (a header's click and
-/// hover), null on a space or past the end.
-pub fn wordBoundsAtCol(str: []const u8, col: usize) ?WordBounds {
- if (col >= str.len or str[col] == ' ') return null;
- var lo: usize = col;
- while (lo > 0 and str[lo - 1] != ' ') lo -= 1;
- var hi: usize = col;
- while (hi < str.len and str[hi] != ' ') hi += 1;
- return .{ .lo = lo, .hi = hi };
-}
-
-/// `a` IS `b` or lives under it — how Grep drops a pane's directory when
-/// another pane's directory already covers it
-pub fn pathUnder(a: []const u8, b: []const u8) bool {
- const root = std.mem.trimEnd(u8, b, "/");
- if (!std.mem.startsWith(u8, a, root)) return false;
- return a.len == root.len or a[root.len] == '/';
-}
-
test "Tab N draws every pane's tab N cells wide and clicks count past it; bare Tab says the width; the ctl read and a Dump keep it" {
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{ .cols = 60, .rows = 12 });
@@ -3657,9 +3621,6 @@ pub const Pardes = struct {
p.fs.late_failure_len = @intCast(kept.len);
}
- /// The rows n/N's walk over look-able text reads before it stops (look.zig).
- pub const max_look_rows = 8192;
-
/// The frontend drew a frame: a pointer resting on it follows what is
/// under it now, a drag's moving end and a look-hover's word.
pub fn presented(p: *Pardes) void {
@@ -4427,12 +4388,3 @@ test "every allocation failure during boot is a clean OutOfMemory" {
try std.testing.checkAllAllocationFailures(std.testing.allocator, bootAndTearDown, .{});
}
-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));
-}
diff --git a/src/tagline.zig b/src/tagline.zig
index 0bb0018b..3e7ebe52 100644
--- a/src/tagline.zig
+++ b/src/tagline.zig
@@ -518,3 +518,16 @@ test "a pane tag wraps a long line onto rows, and offsets map both ways" {
try std.testing.expectEqual(@as(usize, 10), shown.toReal(11)); // the 'e' of Del
try std.testing.expectEqual(@as(usize, 11), shown.fromReal(10));
}
+
+const WordBounds = struct { lo: usize, hi: usize };
+
+/// The space-delimited word covering `col` in `str` (a header's click and
+/// hover), null on a space or past the end.
+pub fn wordBoundsAtCol(str: []const u8, col: usize) ?WordBounds {
+ if (col >= str.len or str[col] == ' ') return null;
+ var lo: usize = col;
+ while (lo > 0 and str[lo - 1] != ' ') lo -= 1;
+ var hi: usize = col;
+ while (hi < str.len and str[hi] != ' ') hi += 1;
+ return .{ .lo = lo, .hi = hi };
+}