summaryrefslogtreecommitdiff
path: root/src/Handover.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Handover.zig')
-rw-r--r--src/Handover.zig40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/Handover.zig b/src/Handover.zig
index 2233d228..2d47bb4e 100644
--- a/src/Handover.zig
+++ b/src/Handover.zig
@@ -94,14 +94,14 @@ pub fn begin(h: *Handover, p: *Pardes, carried: Kind, at: usize) void {
.pane => {
const f = layout.findPane(p, at) orelse return;
const end = if (layout.ownerOf(p, at) == null) layout.groupEnd(p, f.col, f.idx) else f.idx + 1;
- for (p.col_panes[f.col][f.idx..end]) |id| {
+ for (p.cols[f.col].panes[f.idx..end]) |id| {
ids[n] = id;
n += 1;
}
},
.column => {
- if (at >= p.ncol or p.col_n[at] == 0) return;
- for (p.col_panes[at][0..p.col_n[at]]) |id| {
+ if (at >= p.ncol or p.cols[at].n == 0) return;
+ for (p.cols[at].panes[0..p.cols[at].n]) |id| {
ids[n] = id;
n += 1;
}
@@ -172,7 +172,7 @@ pub fn finish(h: *Handover, p: *Pardes, seq: u32, to: []const u8, failure: ?[]co
};
}
if (h.carried == .column) if (layout.columnBySerial(p, h.column_serial)) |c| {
- if (p.col_n[c] == 0 and p.ncol > 1) layout.dropColumn(p, c);
+ if (p.cols[c].n == 0 and p.ncol > 1) layout.dropColumn(p, c);
};
layout.compute(p);
p.setMessage(p.active, if (kept == 0)
@@ -293,18 +293,18 @@ pub fn adopt(p: *Pardes, bytes: []const u8) !usize {
p.sync();
return slots[0];
}
- for (0..p.ncol) |c| for (p.col_panes[c][0..p.col_n[c]]) |id| {
+ for (0..p.ncol) |c| for (p.cols[c].panes[0..p.cols[c].n]) |id| {
heights[id] = p.rects[id].h;
};
// The group under the pointer (a pane with what is attached to it): the
// new panes go under all of it, out of its owner's rows.
- var after: usize = p.col_n[tc];
+ var after: usize = p.cols[tc].n;
var root: ?usize = null;
var k: usize = 0;
- while (k < p.col_n[tc]) {
+ while (k < p.cols[tc].n) {
const end = layout.groupEnd(p, tc, k);
- const first = p.col_panes[tc][k];
- const last = p.col_panes[tc][end - 1];
+ const first = p.cols[tc].panes[k];
+ const last = p.cols[tc].panes[end - 1];
root = first;
after = end;
if (y < p.rects[last].y + p.rects[last].h) break;
@@ -520,8 +520,8 @@ test "a grip let go past the window's edge dumps its pane alone, and closes it o
const p = try twoPanes(std.testing.allocator);
defer p.deinit();
const f = layout.findPane(p, 0).?;
- try std.testing.expect(p.col_n[f.col] == 2);
- const other = p.col_panes[f.col][1 - f.idx];
+ try std.testing.expect(p.cols[f.col].n == 2);
+ const other = p.cols[f.col].panes[1 - f.idx];
const before = p.rects[other];
releaseOutside(p, 0);
// Dumped and asked for; nothing moved yet.
@@ -552,7 +552,7 @@ test "a grip let go past the window's edge dumps its pane alone, and closes it o
// (Store.zig): Panes does not offer it back here.
try std.testing.expect(p.store.closedBySerial(serial) == null);
p.sync();
- try std.testing.expectEqual(@as(usize, 1), p.col_n[layout.findPane(p, other).?.col]);
+ try std.testing.expectEqual(@as(usize, 1), p.cols[layout.findPane(p, other).?.col].n);
}
test "a pane edited while it is on its way to another window stays here too" {
@@ -569,7 +569,7 @@ test "a terminal's grip let go past the edge stays: its shell is this window's"
const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 30, .shells = 3 });
defer p.deinit();
p.update(.{ .resize = .{ .cols = 100, .rows = 30 } });
- const id = p.col_panes[1][0];
+ const id = p.cols[1].panes[0];
try std.testing.expect(p.panes[id].?.isTerminal());
releaseOutside(p, id);
try std.testing.expect(!p.handover.flying);
@@ -587,8 +587,8 @@ test "a pane let go over another window goes under the pane the pointer is over,
to.sync();
const before = to.rects;
const c = layout.findPane(to, 0).?.col;
- const upper = to.col_panes[c][0];
- const lower = to.col_panes[c][1];
+ const upper = to.cols[c].panes[0];
+ const lower = to.cols[c].panes[1];
// The pointer over the upper pane, six rows into it.
to.pointer_inside = true;
to.hover_col = to.rects[upper].x + 5;
@@ -598,9 +598,9 @@ test "a pane let go over another window goes under the pane the pointer is over,
const pane = to.panes[id].?;
try std.testing.expectEqualStrings("unsaved alpha\nbeta\n", pane.file.?.content);
try std.testing.expect(tagline.dirty(pane));
- try std.testing.expectEqual(upper, to.col_panes[c][0]);
- try std.testing.expectEqual(id, to.col_panes[c][1]);
- try std.testing.expectEqual(lower, to.col_panes[c][2]);
+ try std.testing.expectEqual(upper, to.cols[c].panes[0]);
+ try std.testing.expectEqual(id, to.cols[c].panes[1]);
+ try std.testing.expectEqual(lower, to.cols[c].panes[2]);
// The pane under the pointer keeps its top and gives its rows below
// the pointer; the new one is just there; every other pane is where it was.
try std.testing.expectEqual(before[upper].y, to.rects[upper].y);
@@ -639,12 +639,12 @@ test "a column let go over another window goes beside the column the pointer is
to.sync();
try std.testing.expectEqual(ncol + 1, to.ncol);
try std.testing.expectEqual(ncol, layout.findPane(to, id).?.col);
- try std.testing.expectEqual(@as(usize, 2), to.col_n[ncol]);
+ try std.testing.expectEqual(@as(usize, 2), to.cols[ncol].n);
for (0..ncol - 1) |k| {
try std.testing.expectEqual(widths[k], to.col_w[k]);
try std.testing.expectEqual(xs[k], to.col_x[k]);
}
// The finish here: both panes and their column gone from the window.
from.update(.{ .handed = .{ .seq = from.handover.seq, .to = "pardes/2" } });
- try std.testing.expect(from.ncol == 1 or from.col_n[c] == 0 or layout.findPane(from, 0) == null);
+ try std.testing.expect(from.ncol == 1 or from.cols[c].n == 0 or layout.findPane(from, 0) == null);
}