diff options
Diffstat (limited to 'core/layout.zig')
| -rw-r--r-- | core/layout.zig | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/core/layout.zig b/core/layout.zig index 7fa57ee9..ff14a789 100644 --- a/core/layout.zig +++ b/core/layout.zig @@ -613,7 +613,7 @@ pub fn minRows(p: *Pardes, id: usize) u16 { pub fn minimaFit(p: *Pardes) bool { const v = p.view(); compute(p); - const avail = v.screen_h -| (p.topBarHeight() + columnBarHeight(p)); + const avail = v.screen_h -| (p.topBarHeight() + columnBarHeight(p) + noticeRowHeight(p)); for (0..p.view().ncol) |c| { if (v.cols[c].n < 2) continue; var need: u32 = 0; @@ -647,7 +647,7 @@ pub fn shareColumn(p: *Pardes, c: usize) bool { compute(p); const n = v.cols[c].n; if (n == 0) return false; - const avail = v.screen_h -| (p.topBarHeight() + columnBarHeight(p)); + const avail = v.screen_h -| (p.topBarHeight() + columnBarHeight(p) + noticeRowHeight(p)); var mins: [MAX_PANES]u16 = undefined; var need: u32 = 0; for (v.cols[c].panes[0..n], 0..) |k, i| { @@ -1333,7 +1333,8 @@ pub fn expandedNeighbor(p: *const Pardes, col: usize, index: usize, side: enum { fn computeCollapsedColumn(p: *Pardes, c: usize, x: u16, width: u16, folded: usize) void { const v = p.view(); var y: u16 = p.topBarHeight() + columnBarHeight(p); - const available = v.screen_h -| y; + const bottom = v.screen_h -| noticeRowHeight(p); + const available = bottom -| y; var expanded_left: usize = 0; var weight: f32 = 0; for (v.cols[c].panes[0..p.view().cols[c].n]) |id| if (p.panes[id]) |pane| { @@ -1347,7 +1348,7 @@ fn computeCollapsedColumn(p: *Pardes, c: usize, x: u16, width: u16, folded: usiz var folded_left = folded; for (v.cols[c].panes[0..p.view().cols[c].n]) |id| { const pane = p.panes[id] orelse continue; - const room = v.screen_h -| y; + const room = bottom -| y; const height: u16 = if (pane.collapsed) blk: { folded_left -= 1; break :blk @min(room, BOX_H); @@ -1401,7 +1402,8 @@ pub fn compute(p: *Pardes) void { var y: u16 = p.topBarHeight() + columnBarHeight(p); const top = y; - const avail_h = v.screen_h -| y; + const bottom = v.screen_h -| noticeRowHeight(p); + const avail_h = bottom -| y; var hs: [MAX_PANES]u16 = undefined; const n = v.cols[c].n; for (0..n) |k| { @@ -1412,7 +1414,7 @@ pub fn compute(p: *Pardes) void { }; const lastk = k + 1 == n; const fh = @as(f32, @floatFromInt(avail_h)) * pane.vweight / vsum; - const room = v.screen_h -| y; + const room = bottom -| y; hs[k] = if (lastk) room else @min(room, @max(1, @as(u16, @intFromFloat(@round(fh))))); y +|= hs[k]; } @@ -1471,6 +1473,14 @@ pub fn topBarHeight(p: *const Pardes) u16 { return TOPBAR_H; } +/// The notice row's height: one row at the window's foot (pick-ui SPEC +/// ยง10.3), the index of the live messages, under every column; none on a +/// screen too short for it, as the column tags have none. +pub fn noticeRowHeight(p: *const Pardes) u16 { + if (p.view().screen_h < 3) return 0; + return 1; +} + /// The column tags' height: one row, as acme's (cols.c:244, colresize, /// gives a column tag one font height); a newline in one is a space /// (tagline.flattenHeaders). @@ -1668,14 +1678,14 @@ test "collapse transfers height upward and restores the original layout" { toggleCollapse(p, 1); try std.testing.expectEqual(@as(u16, 1), p.view().rects[1].h); try std.testing.expectEqual(@as(f32, @floatFromInt(original[1].h)), p.panes[1].?.vweight); - try std.testing.expectEqual(p.view().screen_h, p.view().rects[2].y + p.view().rects[2].h); + try std.testing.expectEqual(p.view().screen_h - noticeRowHeight(p), p.view().rects[2].y + p.view().rects[2].h); try std.testing.expect(p.view().rects[0].h > original[0].h); try std.testing.expectEqualDeep(original[2], p.view().rects[2]); toggleCollapse(p, 1); try std.testing.expectEqualDeep(original, p.view().rects); toggleCollapse(p, 2); try std.testing.expectEqual(@as(u16, 1), p.view().rects[2].h); - try std.testing.expectEqual(p.view().screen_h, p.view().rects[2].y + p.view().rects[2].h); + try std.testing.expectEqual(p.view().screen_h - noticeRowHeight(p), p.view().rects[2].y + p.view().rects[2].h); } test "collapse changes only one neighbor at the top middle and bottom" { @@ -1793,7 +1803,7 @@ test "collapse single and all panes leave unused column space" { try std.testing.expectEqual(p.view().rects[0].y + 1, p.view().rects[1].y); try std.testing.expect(p.view().rects[1].y + 1 < p.view().screen_h); toggleCollapse(p, 0); - try std.testing.expectEqual(p.view().screen_h - 1, p.view().rects[1].y); + try std.testing.expectEqual(p.view().screen_h - noticeRowHeight(p) - 1, p.view().rects[1].y); } test "collapse survives tiny resizes" { @@ -1854,7 +1864,7 @@ test "collapse dump restores folded state and retained expansion weight" { try std.testing.expectEqual(@as(f32, @floatFromInt(original_height)), restored.panes[0].?.vweight); try std.testing.expectEqual(@as(u16, 1), restored.view().rects[0].h); toggleCollapse(restored, 0); - try std.testing.expectEqual(restored.view().screen_h - restored.view().rects[0].y, restored.view().rects[0].h); + try std.testing.expectEqual(restored.view().screen_h - noticeRowHeight(restored) - restored.view().rects[0].y, restored.view().rects[0].h); } test "column reorder moves only crossed state and preserves weights" { |
