summaryrefslogtreecommitdiff
path: root/src/views.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/views.zig')
-rw-r--r--src/views.zig23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/views.zig b/src/views.zig
index 0c96c792..354ae0d0 100644
--- a/src/views.zig
+++ b/src/views.zig
@@ -474,18 +474,11 @@ pub fn deinit(p: *Pardes) void {
pub const Present = struct { ctx: ?*anyopaque, f: ?*const fn (?*anyopaque, *const pardes.Surface) void };
-/// Each view but the live one drawn and presented, the live one put back
-/// after exactly as it was (`drawOne`). Before the live one's frame: the
-/// surface after the pump is its.
-pub fn drawOthers(p: *Pardes, h: pardes.Host) !void {
- for (0..max) |i| {
- const k: u8 = @intCast(i);
- if (k == p.live or !isOpen(p, k) or (p.undrawn | p.views_away) & bit(k) != 0) continue;
- // No post_present: what a shell acknowledges there moves the
- // session's pointer and hover, which are the live view's to move;
- // a view's panels are acknowledged when it is live and drawn.
- try drawOne(p, k, .{ .ctx = h.ctx, .f = h.vtable.present });
- }
+/// The view this process's frontend shows: the one open view that is no
+/// replica client's (`undrawn`) and kept for none (`away`), if there is one.
+pub fn shown(p: *const Pardes) ?u8 {
+ for (0..max) |i| if (isOpen(p, @intCast(i)) and (p.undrawn | p.views_away) & bit(i) == 0) return @intCast(i);
+ return null;
}
fn drawLive(present: Present, p: *Pardes) anyerror!void {
@@ -782,7 +775,7 @@ test "a client's view kept for its rejoin: through an Upgrade's dump, each clien
try testing.expect(!isAway(p, ks[0]) and isAway(p, ks[1]));
}
-test "drawing the other views leaves the live one as it was, to the digest" {
+test "drawing another view leaves the live one as it was, to the digest" {
const gpa = testing.allocator;
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 });
defer p.deinit();
@@ -796,7 +789,7 @@ test "drawing the other views leaves the live one as it was, to the digest" {
p.toView(0);
cursorTo(p, pane, 95);
const before = pardes.walk.digest(Pardes, p);
- try drawOthers(p, .{});
+ try drawOne(p, k, .{ .ctx = null, .f = null });
try testing.expectEqual(@as(u8, 0), p.live);
try testing.expectEqual(before, pardes.walk.digest(Pardes, p));
p.toView(k);
@@ -814,7 +807,7 @@ test "a view drawn while another is live keeps its own cursors" {
try testing.expectEqual(@as(u16, 1), pane.body.nsel);
p.toView(0);
const before = pardes.walk.digest(Pardes, p);
- try drawOthers(p, .{});
+ try drawOne(p, k, .{ .ctx = null, .f = null });
try testing.expectEqual(before, pardes.walk.digest(Pardes, p));
p.toView(k);
try testing.expectEqual(@as(u16, 1), pane.body.nsel);