summaryrefslogtreecommitdiff
path: root/src/draw.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 19:53:53 -0300
committerGabriel Schneider <[email protected]>2026-11-05 22:03:21 -0300
commit12cb0a704075dea2512f77582635376fe967dee6 (patch)
tree0f498bf581e3f8ece31f8a5eaa06accba7aa7415 /src/draw.zig
parent1a1ce29051ea6aa3be4754074f6a00b905d6b208 (diff)
downloadpardes-12cb0a704075dea2512f77582635376fe967dee6.tar.gz
pardes-12cb0a704075dea2512f77582635376fe967dee6.zip
split pardes.zig by noun, layout: the session's columns and the rows its chrome takes move into src/layout.zig: newColumn, setActiveColumn, activeColumn, noteTyped, newScratchIn, keyboardColumn, removeColumn, besideColumn, topBarHeight, columnBarHeight, wantedTagRows, bodyTop, tagTop, tagCapacity and reprojectTagHit; the session keeps four as declaration aliases (topBarHeight and bodyTop, called from everywhere; tagTop and setActiveColumn, which Store.zig and Handover.zig call, so the persistence agent's files are untouched), the rest are layout.x(p, ...) in their callers (draw.zig, mouse.zig, ninep/cols.zig, tagline.zig and seven more; gui.zig, whose locals are named layout, through pardes.layout); layout's own placement helper bodyTop, a pane's top past its tag as heights go, is bodyFrom now, the name going to the session's; tests moved with them, by name: a new column takes width only from the column that created it; Newcol refuses an unsplittable restored weight before spawning; repeated non-dyadic column splits preserve every unrelated boundary; dragging a column's only pane to another leaves that column in place, empty; tiny screens keep pane space before adding a column tag; a pure move, no field touched, a dump and the wire as they were; gates: tui core-test 960/960, behaviour-test 238/238, pane-test 171/172 (1 skipped), 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/draw.zig')
-rw-r--r--src/draw.zig20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/draw.zig b/src/draw.zig
index 75d6378b..910f4fef 100644
--- a/src/draw.zig
+++ b/src/draw.zig
@@ -105,7 +105,7 @@ pub fn place(p: *Pardes, s: *Surface) void {
s.addRegion(.{ .kind = .notice, .owner = owner, .serial = pane.serial, .active = active, .notice = @intCast(i), .rect = .{ .x = tx + tw - chip, .y = body_y + @as(u16, pane.notices.row[i]), .w = chip, .h = BOX_H } });
}
}
- const column_rows = p.columnBarHeight();
+ const column_rows = layout.columnBarHeight(p);
if (column_rows > 0) for (0..p.ncol) |c| {
if (p.col_w[c] == 0) continue;
const active = if (layout.findPane(p, p.active)) |found| found.col == c else false;
@@ -221,7 +221,7 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface {
// Separators have their own role; a scrollbar need not frame the page.
const whole = s.regions[0].rect;
s.fill(whole.x, whole.y, whole.w, whole.h, .{ .bg = .{ .rgb = chrome.border } });
- for (0..p.ncol) |c| if (p.col_n[c] == 0) s.fill(p.col_x[c], p.topBarHeight() + p.columnBarHeight(), p.col_w[c], s.rows -| (p.topBarHeight() + p.columnBarHeight()), .{ .bg = .{ .rgb = chrome.empty_col } });
+ for (0..p.ncol) |c| if (p.col_n[c] == 0) s.fill(p.col_x[c], p.topBarHeight() + layout.columnBarHeight(p), p.col_w[c], s.rows -| (p.topBarHeight() + layout.columnBarHeight(p)), .{ .bg = .{ .rgb = chrome.empty_col } });
for (&p.panes, 0..) |*slot, id| {
const pane = slot.* orelse continue;
@@ -481,7 +481,7 @@ fn paintHeaders(p: *Pardes, s: *Surface) !void {
try renderHeaderLayer(p, layer, .workspace, 0, viewport, tagline.topbar(p), top, chrome.tag_bg, chrome.tag_fg);
joinHeaderRows(s, layer, chrome.tag_fg);
}
- const column_rows = p.columnBarHeight();
+ const column_rows = layout.columnBarHeight(p);
if (column_rows > 0) for (0..p.ncol) |c| {
const region = s.region(.column_tag, c) orelse continue;
const active = if (layout.findPane(p, p.active)) |found| found.col == c and p.settings.focus_tint else false;
@@ -582,7 +582,7 @@ fn renderHeaderLayer(p: *Pardes, layer: *pardes.Layer, kind: TagKind, id: u16, v
}
var widest: usize = 0;
for (0..viewport.h) |line| widest = @max(widest, panes.File.displayWidth(modal.lineSlice(text, line + top)));
- const columns: u16 = @intCast(@min(std.math.maxInt(u16), @max(p.tagCapacity(viewport.w), widest + 1)));
+ const columns: u16 = @intCast(@min(std.math.maxInt(u16), @max(layout.tagCapacity(p, viewport.w), widest + 1)));
const count = @as(usize, columns) * viewport.h;
if (layer.cells.len != count) layer.cells = try p.gpa.realloc(layer.cells, count);
layer.kind = kind;
@@ -673,7 +673,7 @@ fn renderHeaderLayer(p: *Pardes, layer: *pardes.Layer, kind: TagKind, id: u16, v
/// A pane's tag rows, painted once into their layer, a row to a line, and
/// copied into the grid; the grid's caret where the layer has it.
fn joinPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool) !void {
- const capacity = p.tagCapacity(r.w -| TAG_TEXT_INSET);
+ const capacity = layout.tagCapacity(p, r.w -| TAG_TEXT_INSET);
// Too narrow for a layer: only the grid's gap cell.
if (r.w <= TAG_TEXT_INSET) return paintPaneTag(p, s, arena, pane, r, id, active);
const chrome = p.chromeTheme();
@@ -758,7 +758,7 @@ fn joinNotice(p: *Pardes, s: *Surface, arena: std.mem.Allocator, region: Region)
// flush right would put it past the pane and off the grid. Wider than
// the chip, the text loses its head: the end is the part that says
// something.
- const capacity = p.tagCapacity(chip);
+ const capacity = layout.tagCapacity(p, chip);
const room = capacity -| 1;
const shown = panes.File.displayWidth(text);
var kept = text;
@@ -1067,8 +1067,8 @@ test "place puts every part where the painters and layers put it, in every layou
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 });
defer p.deinit();
_ = try p.setTestFile(std.mem.asBytes(&@as([80][7]u8, @splat("placed\n".*))));
- p.newColumn(0);
- p.newScratchIn(0, p.activeColumn().?);
+ layout.newColumn(p, 0);
+ layout.newScratchIn(p, 0, layout.activeColumn(p).?);
p.newScratchBelow(0);
p.sync();
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
@@ -1129,11 +1129,11 @@ test "place puts every part where the painters and layers put it, in every layou
}
for (0..p.ncol) |c| {
const region = s.region(.column_tag, c);
- if (p.columnBarHeight() == 0) {
+ if (layout.columnBarHeight(p) == 0) {
try std.testing.expect(region == null);
continue;
}
- try std.testing.expectEqual(Rect{ .x = p.col_x[c] + TAG_TEXT_INSET, .y = p.topBarHeight(), .w = p.col_w[c] - TAG_TEXT_INSET, .h = p.columnBarHeight() }, region.?.rect);
+ try std.testing.expectEqual(Rect{ .x = p.col_x[c] + TAG_TEXT_INSET, .y = p.topBarHeight(), .w = p.col_w[c] - TAG_TEXT_INSET, .h = layout.columnBarHeight(p) }, region.?.rect);
}
}
}