diff options
Diffstat (limited to 'src/layout.zig')
| -rw-r--r-- | src/layout.zig | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/src/layout.zig b/src/layout.zig index 10bed438..38841f59 100644 --- a/src/layout.zig +++ b/src/layout.zig @@ -407,7 +407,7 @@ pub fn applyRowSplit(p: *Pardes, cc: usize, k: usize, cur_y: u16) void { const ra = p.rects[p.cols[cc].panes[k]]; const rb = p.rects[p.cols[cc].panes[k + 1]]; const combined: f32 = @floatFromInt(ra.h + rb.h); - var nt: f32 = @floatFromInt(if (p.settings.tag_bottom) cur_y -| ra.y else (cur_y + 1) -| ra.y); + var nt: f32 = @floatFromInt((cur_y + 1) -| ra.y); // A terminal keeps its tag and two body rows (floorRows); a text pane // gives up all but its tag, as acme's do. const lo: f32 = @floatFromInt(@max(BOX_H, floorRows(p, p.cols[cc].panes[k]))); @@ -828,9 +828,7 @@ fn splitAt(p: *Pardes, c: usize, id: usize, y: u16) void { } /// A pane's top plus its tag's rows, as heights go: a split this far down -/// leaves the pane its tag and that much of its body, whichever end the tag -/// is on (Tagbottom's is at its foot, the height the same; behaviour test -/// "placement: under Tagbottom..."). +/// leaves the pane its tag and that much of its body. fn bodyFrom(p: *const Pardes, id: usize) u16 { return p.rects[id].y + p.panes[id].?.tag_rows; } @@ -1429,7 +1427,6 @@ test "collapse local transfers remain bounded through repeated tiny window resiz } for (0..180) |step| { p.screen_h = @intCast((step * 17) % 81); - p.settings.tag_bottom = step % 3 == 0; compute(p); toggleCollapse(p, step % 5); var used: u16 = 0; @@ -1484,7 +1481,7 @@ test "collapse single and all panes leave unused column space" { try std.testing.expectEqual(p.screen_h - 1, p.rects[1].y); } -test "collapse survives tiny resizes and TagBottom" { +test "collapse survives tiny resizes" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 32 }); defer p.deinit(); _ = try p.newShell(1, ""); @@ -1492,22 +1489,17 @@ test "collapse survives tiny resizes and TagBottom" { insert(p, 0, 1, 1); insert(p, 0, 2, 2); p.panes[1].?.collapsed = true; - for ([_]bool{ false, true }) |bottom| { - p.settings.tag_bottom = bottom; - { - for (0..50) |height| { - p.screen_h = @intCast(height); - compute(p); - var used: u16 = 0; - for (p.cols[0].panes[0..p.cols[0].n]) |id| { - const rect = p.rects[id]; - try std.testing.expect(rect.h <= p.screen_h -| rect.y); - used += rect.h; - } - try std.testing.expect(used <= p.screen_h); - if (height >= 5) try std.testing.expectEqual(@as(u16, 1), p.rects[1].h); - } + for (0..50) |height| { + p.screen_h = @intCast(height); + compute(p); + var used: u16 = 0; + for (p.cols[0].panes[0..p.cols[0].n]) |id| { + const rect = p.rects[id]; + try std.testing.expect(rect.h <= p.screen_h -| rect.y); + used += rect.h; } + try std.testing.expect(used <= p.screen_h); + if (height >= 5) try std.testing.expectEqual(@as(u16, 1), p.rects[1].h); } p.screen_h = 32; compute(p); @@ -1525,8 +1517,7 @@ test "collapse can be expanded by dragging its boundary" { try std.testing.expect(!p.panes[0].?.collapsed); try std.testing.expectEqual(@as(u16, 6), p.rects[0].h); toggleCollapse(p, 1); - p.settings.tag_bottom = true; - applyRowSplit(p, 0, 0, p.rects[1].y - 5); + applyRowSplit(p, 0, 0, p.rects[1].y - 6); compute(p); try std.testing.expect(!p.panes[1].?.collapsed); try std.testing.expectEqual(@as(u16, 6), p.rects[1].h); @@ -1849,16 +1840,15 @@ pub fn wantedTagRows(p: *Pardes, id: usize) u16 { return @intCast(@max(BOX_H, @min(shown.rows(), MAX_TAG_ROWS))); } -/// The pane's first body row: under the tag when it is on top, over it -/// when it is at the bottom. Notice bands do NOT move it -- they are an -/// overlay, drawn over the top rows rather than taking them. -pub fn bodyTop(p: *const Pardes, pane: *const Pane, r: Rect) u16 { - return if (p.settings.tag_bottom) r.y else r.y + pane.tag_rows; +/// The pane's first body row, under its tag. Notice bands do NOT move it +/// -- they are an overlay, drawn over the top rows rather than taking them. +pub fn bodyTop(_: *const Pardes, pane: *const Pane, r: Rect) u16 { + return r.y + pane.tag_rows; } -/// The tag's first row: the pane's top, or its last rows with Tagbottom. -pub fn tagTop(p: *const Pardes, pane: *const Pane, r: Rect) u16 { - return if (p.settings.tag_bottom) r.y + r.h -| pane.tag_rows else r.y; +/// The tag's first row: the pane's top. +pub fn tagTop(_: *const Pardes, _: *const Pane, r: Rect) u16 { + return r.y; } pub fn tagCapacity(p: *const Pardes, physical_width: u16) u16 { |
