diff options
Diffstat (limited to 'core/panes.zig')
| -rw-r--r-- | core/panes.zig | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/core/panes.zig b/core/panes.zig index dd36839a..7ea479b9 100644 --- a/core/panes.zig +++ b/core/panes.zig @@ -716,7 +716,7 @@ pub const Pane = struct { // A replica's emulator is what the authority's deltas make it; what // pardes keeps over it moves as the authority's feed told it. if (tape.screenReplica()) { - if (has_positions and pane.followRows(state, bytes)) if (paneIdOf(p, pane)) |id| p.setMessage(id, positions_lost); + if (has_positions and pane.followRows(state, bytes)) if (paneIdOf(p, pane)) |id| p.setMessage(.at(id), positions_lost); return; } // Sticky bottom, as every other terminal does it: output drags the @@ -728,7 +728,7 @@ pub const Pane = struct { Term.cellPixels(state, p.view().cell_pixels.w, p.view().cell_pixels.h); if (!has_positions) { _ = Term.feed(state, bytes, &.{}, &.{}, &.{}); - } else if (pane.followRows(state, bytes)) if (paneIdOf(p, pane)) |id| p.setMessage(id, positions_lost); + } else if (pane.followRows(state, bytes)) if (paneIdOf(p, pane)) |id| p.setMessage(.at(id), positions_lost); p.shell_rows.markStale(pane); if (pane.body.mode == .tty and at_bottom) pane.followOutput(); } @@ -1078,7 +1078,7 @@ pub const Pane = struct { // failure is worth the pane. if (pane.command_pages) { pane.command_pages = false; - if (status == 0) return p.removePane(id, null) catch |err| p.reportError(id, "close", err); + if (status == 0) return p.removePane(id, null) catch |err| p.reportError(.at(id), "close", err); } var buf: [16]u8 = undefined; const code = if (status) |n| std.fmt.bufPrint(&buf, "{d}", .{n}) catch unreachable else "?"; // an exit status fits 16 @@ -1350,8 +1350,8 @@ pub fn newScratchBelow(p: *Pardes, from_id: usize) void { /// A scratch for New (`.scratch`) or 9P's pane/new (`.fs`). pub fn newScratchFor(p: *Pardes, from_id: usize, kind: layout.NewPane) void { - const free = p.freeSlot() orelse return p.reportError(from_id, "New", error.NoPaneSlots); - _ = newScratch(p, from_id, free, kind) catch |err| return p.reportError(from_id, "New", err); + const free = p.freeSlot() orelse return p.reportError(.at(from_id), "New", error.NoPaneSlots); + _ = newScratch(p, from_id, free, kind) catch |err| return p.reportError(.at(from_id), "New", err); layout.placeNew(p, from_id, from_id, free, kind); } @@ -1529,7 +1529,7 @@ pub fn startPrompt(p: *Pardes, pane: *Pane, t: *Text, request: union(enum) { // directory for the name to be typed onto. const dir = if (request == .save) paneDir(pane) else ""; const slash: []const u8 = if (request == .save and (dir.len == 0 or dir[dir.len - 1] != '/')) "/" else ""; - const answer = std.mem.concat(p.gpa, u8, &.{ marker, dir, slash }) catch |err| return p.reportError(p.view().active, "prompt", err); + const answer = std.mem.concat(p.gpa, u8, &.{ marker, dir, slash }) catch |err| return p.reportError(.at(p.view().active), "prompt", err); // The keyboard comes back to the text answered for; a prompt for // the body takes it out of a tag or header. switch (t.what) { @@ -1584,7 +1584,7 @@ test "owned cwd preserves long paths aliases and failed updates" { var path: [3072]u8 = @splat('d'); path[0] = '/'; for (1..12) |i| path[i * 256] = '/'; - p.setCwd(0, &path); + p.setCwd(.at(0), &path); try std.testing.expectEqualStrings(&path, pane.cwdSlice()); try std.testing.expect(pane.cwdSlice().ptr != &path); const original = pane.cwdSlice(); @@ -1609,15 +1609,15 @@ test "owned cwd preserves long paths aliases and failed updates" { const current = pane.cwdSlice(); allocator.fail_index = allocator.alloc_index; - p.setCwd(0, "/replacement"); + p.setCwd(.at(0), "/replacement"); try std.testing.expectEqual(current.ptr, pane.cwdSlice().ptr); try std.testing.expectEqualStrings(&path, pane.cwdSlice()); try std.testing.expect(std.mem.indexOf(u8, pane.msg[0..pane.msg_len], "out of memory") != null); allocator.fail_index = std.math.maxInt(usize); - p.setCwd(0, "/replacement"); + p.setCwd(.at(0), "/replacement"); try std.testing.expectEqualStrings("/replacement", pane.cwdSlice()); const allocations = allocator.allocations; - p.setCwd(0, "/replacement"); + p.setCwd(.at(0), "/replacement"); try std.testing.expectEqual(allocations, allocator.allocations); pane.clearCwd(); try std.testing.expect(pane.cwd == .none); @@ -1678,8 +1678,8 @@ test "owned cwd column close allocates every copy before removing any pane" { var allocator = std.testing.FailingAllocator.init(std.testing.allocator, .{}); const p = try Pardes.init(allocator.allocator(), .{ .shells = 3, .cols = 100, .rows = 30 }); defer p.deinit(); - p.setCwd(0, "/first"); - p.setCwd(1, "/second"); + p.setCwd(.at(0), "/first"); + p.setCwd(.at(1), "/second"); const first_child = try p.newDocPane(3); const second_child = try p.newDocPane(4); first_child.cwd = .{ .inherited = p.panes[0].? }; @@ -1706,7 +1706,7 @@ test "owned cwd EOF failure retains the pane and Del retries its close" { var allocator = std.testing.FailingAllocator.init(std.testing.allocator, .{}); const p = try Pardes.init(allocator.allocator(), .{ .tty_only = true }); defer p.deinit(); - p.setCwd(0, "/exited"); + p.setCwd(.at(0), "/exited"); const parent = p.panes[0].?; p.newScratchBelow(0); const child = p.panes[p.view().active].?; @@ -1800,7 +1800,7 @@ test "New opens an empty scratch below the caller, inheriting its directory" { while (p.nextEffect()) |_| {} const source: usize = 2; // the right column; active starts in the left - p.setCwd(source, "/tmp/pardes-scratch-dir"); + p.setCwd(.at(source), "/tmp/pardes-scratch-dir"); const source_col = layout.findPane(p, source).?.col; try std.testing.expect(p.executeBuiltinLine(source, "New")); @@ -1814,7 +1814,7 @@ test "New opens an empty scratch below the caller, inheriting its directory" { try std.testing.expectEqual(@as(usize, 0), np.file.?.content.len); // its directory is a LIVE link to the opener, not a snapshot taken at New try std.testing.expectEqualStrings("/tmp/pardes-scratch-dir", Pardes.paneDir(np)); - p.setCwd(source, "/tmp/pardes-moved"); + p.setCwd(.at(source), "/tmp/pardes-moved"); try std.testing.expectEqualStrings("/tmp/pardes-moved", Pardes.paneDir(np)); try p.removePane(source, null); p.sync(); |
