diff options
Diffstat (limited to 'src/layout.zig')
| -rw-r--r-- | src/layout.zig | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/layout.zig b/src/layout.zig index fca4c846..7719af38 100644 --- a/src/layout.zig +++ b/src/layout.zig @@ -180,8 +180,8 @@ pub fn columnDrop(p: *const Pardes, source: usize, x: u16, grab: u16) ColumnDrop } /// Share out the width of columns `left` and `left + 1` so the left one is -/// `left_width` cells, neither below MINW. A border drag and a column grip -/// dropped inside its own place both end here. +/// `left_width` cells, neither below MINW. A column grip dropped inside its +/// own place ends here. pub fn setColumnPairWidth(p: *Pardes, left: usize, left_width: u64) void { const v = p.view(); if (left + 1 >= v.ncol) return; @@ -849,7 +849,7 @@ fn blankRows(p: *const Pardes, id: usize) u16 { // The empty line after a final newline shows nothing. (panes.File.nlines(p.gpa, f) -| @intFromBool(std.mem.endsWith(u8, f.content, "\n"))) -| f.scroll else if (pane.isTerminal()) - @as(usize, panes.terminal.gridCursor(pane).y) + 1 + @as(usize, panes.Term.grid(pane.terminal).cursor_y) + 1 else rows; return rows -| @as(u16, @intCast(@min(used, rows))); @@ -1090,7 +1090,7 @@ pub fn splitBelow(p: *Pardes, src_id: usize, nw: *Pane) void { // Its tag may wrap to more than one row: the rows under it are its body. const tag_h = @max(BOX_H, src.tag_rows); const body: u16 = if (src_h > tag_h) src_h - tag_h else 1; - const cur: u16 = if (!src.isTerminal()) body / 2 else panes.terminal.gridCursor(src).y + 1; + const cur: u16 = if (!src.isTerminal()) body / 2 else panes.Term.grid(src.terminal).cursor_y + 1; // cap keep so a content-full source still leaves the new pane a tag + // a few body rows (an Alt-n from a full shell was born 0 rows tall) // ...and the source min_body_rows of its own (placeNew), when it @@ -1650,6 +1650,7 @@ fn weightsOf(p: *const Pardes) [MAX_COLS]u64 { } test "collapse transfers height upward and restores the original layout" { + if (pardes.Term.ops == null) return error.SkipZigTest; // a shell const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 32 }); defer p.deinit(); _ = try p.newShell(1, ""); @@ -1674,6 +1675,7 @@ test "collapse transfers height upward and restores the original layout" { } test "collapse changes only one neighbor at the top middle and bottom" { + if (pardes.Term.ops == null) return error.SkipZigTest; // a shell for (0..4) |target| { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 58 }); defer p.deinit(); @@ -1698,6 +1700,7 @@ test "collapse changes only one neighbor at the top middle and bottom" { } test "collapse skips folded neighbors and expansion reclaims only its neighbor" { + if (pardes.Term.ops == null) return error.SkipZigTest; // a shell const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 62 }); defer p.deinit(); for (1..5) |id| { @@ -1725,6 +1728,7 @@ test "collapse skips folded neighbors and expansion reclaims only its neighbor" } test "collapse local transfers remain bounded through repeated tiny window resizes" { + if (pardes.Term.ops == null) return error.SkipZigTest; // a shell const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 58 }); defer p.deinit(); for (1..5) |id| { @@ -1772,6 +1776,7 @@ test "collapse expansion is limited to space available in one neighbor" { } test "collapse single and all panes leave unused column space" { + if (pardes.Term.ops == null) return error.SkipZigTest; // a shell const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 32 }); defer p.deinit(); toggleCollapse(p, 0); @@ -1788,6 +1793,7 @@ test "collapse single and all panes leave unused column space" { } test "collapse survives tiny resizes" { + if (pardes.Term.ops == null) return error.SkipZigTest; // a shell const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 32 }); defer p.deinit(); _ = try p.newShell(1, ""); @@ -1813,6 +1819,7 @@ test "collapse survives tiny resizes" { } test "collapse can be expanded by dragging its boundary" { + if (pardes.Term.ops == null) return error.SkipZigTest; // a shell const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 32 }); defer p.deinit(); _ = try p.newShell(1, ""); @@ -1998,6 +2005,7 @@ test "an attachment survives Dump and Restore, and one left away from its owner } test "a new column takes width only from the column that created it" { + if (pardes.Term.ops == null) return error.SkipZigTest; // a shell const p = try Pardes.init(std.testing.allocator, .{ .cols = 124, .rows = 24 }); defer p.deinit(); @@ -2061,6 +2069,7 @@ test "a new column takes width only from the column that created it" { } test "Newcol refuses an unsplittable restored weight before spawning" { + if (pardes.Term.ops == null) return error.SkipZigTest; // a shell const p = try Pardes.init(std.testing.allocator, .{ .cols = 200, .rows = 20 }); defer p.deinit(); @@ -2092,6 +2101,7 @@ test "Newcol refuses an unsplittable restored weight before spawning" { } test "repeated non-dyadic column splits preserve every unrelated boundary" { + if (pardes.Term.ops == null) return error.SkipZigTest; // a shell const p = try Pardes.init(std.testing.allocator, .{ .cols = 979, .rows = 20 }); defer p.deinit(); @@ -2099,15 +2109,7 @@ test "repeated non-dyadic column splits preserve every unrelated boundary" { try std.testing.expect(splitColumn(p, 0, 1, false)); p.sync(); - const handle = p.view().col_x[0] + p.view().col_w[0] - 1; - const untouched = weightsOf(p); - p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = handle, .row = TOPBAR_H + 1 } }); - p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = handle, .row = TOPBAR_H + 1 } }); - try std.testing.expectEqual(untouched, weightsOf(p)); - - p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = handle, .row = TOPBAR_H + 1 } }); - p.update(.{ .mouse = .{ .button = .left, .kind = .drag, .col = 417, .row = TOPBAR_H + 1 } }); - p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = 417, .row = TOPBAR_H + 1 } }); + setColumnPairWidth(p, 0, 418); p.sync(); try std.testing.expectEqual(@as(u16, 418), p.view().rects[0].w); |
