summaryrefslogtreecommitdiff
path: root/src/edit_cmd.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/edit_cmd.zig')
-rw-r--r--src/edit_cmd.zig34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/edit_cmd.zig b/src/edit_cmd.zig
index 99cac6ce..207dd7cc 100644
--- a/src/edit_cmd.zig
+++ b/src/edit_cmd.zig
@@ -96,11 +96,11 @@ const World = struct {
return said(sam.File, why, "B: {s} is a directory", .{path});
// A look opens it, or finds it open, where a look would; the
// keyboard stays where the Edit ran.
- const was = p.active;
+ const was = p.view().active;
p.look_text = true;
look.lookAt(p, w.from, path);
p.look_text = false;
- if (p.panes[was] != null) p.active = was;
+ if (p.panes[was] != null) p.view().active = was;
for (p.panes, 0..) |slot, id| {
const pane = slot orelse continue;
const f = ninep_pane.fileOf(pane) orelse continue;
@@ -310,7 +310,7 @@ pub fn finish(p: *Pardes, success: bool, outputs: []const []const u8, failure: ?
const pd = p.pipe.edit_run orelse return;
p.pipe.edit_run = null;
defer pd.deinit(p.gpa);
- const at = if (p.panes[pd.origin]) |pane| (if (pane.serial == pd.origin_serial) pd.origin else p.active) else p.active;
+ const at = if (p.panes[pd.origin]) |pane| (if (pane.serial == pd.origin_serial) pd.origin else p.view().active) else p.view().active;
// Whatever fails from here fails the 9P write that ran it too.
const failures = p.fs.failures;
defer answerHold(p, at, p.fs.failures != failures);
@@ -329,9 +329,9 @@ pub fn finish(p: *Pardes, success: bool, outputs: []const []const u8, failure: ?
Pipe.writeFailure(w, failure) catch break :report;
const why = std.mem.sliceTo(out.written()[why_at..], '\n');
const said = std.fmt.bufPrint(&line, "Edit: {c} {s}: {s}", .{ job.c, job.command[0..@min(job.command.len, 120)], why }) catch "Edit: a command failed";
- const was = p.active;
+ const was = p.view().active;
_ = ninep_pane.appendErrors(p, at, out.written());
- if (p.panes[was] != null) p.active = was;
+ if (p.panes[was] != null) p.view().active = was;
return p.reportFailure(at, said);
}
p.reportFailure(at, "Edit: a command failed");
@@ -341,7 +341,7 @@ pub fn finish(p: *Pardes, success: bool, outputs: []const []const u8, failure: ?
/// of it, if a pane it changes is not the one it read any more.
fn commit(p: *Pardes, pd: *Pending, outputs: []const []const u8) void {
const res = pd.res;
- const at = if (p.panes[pd.origin]) |pane| (if (pane.serial == pd.origin_serial) pd.origin else p.active) else p.active;
+ const at = if (p.panes[pd.origin]) |pane| (if (pane.serial == pd.origin_serial) pd.origin else p.view().active) else p.view().active;
var text: [320]u8 = undefined;
for (res.files, 0..) |f, i| {
if (f.ops.items.len == 0 and !f.close and !f.renamed and !f.moved and f.get == null) continue;
@@ -429,9 +429,9 @@ fn commit(p: *Pardes, pd: *Pending, outputs: []const []const u8) void {
out.appendSlice(p.gpa, res.printed[from..]) catch return;
// Printed, the keyboard stays where it was: a +Errors made for it
// does not take it, so the next Edit lands where this one did.
- const was = p.active;
+ const was = p.view().active;
if (out.items.len > 0) _ = ninep_pane.appendErrors(p, at, out.items);
- if (p.panes[was] != null) p.active = was;
+ if (p.panes[was] != null) p.view().active = was;
}
if (refused.written().len > 0) {
var said: [320]u8 = undefined;
@@ -572,7 +572,7 @@ test "Edit's < | and > with a real shell: a command per address, > printed to +E
try testing.expectEqual(tree.Status.ok, th.wr(p, ctl, "Edit , > wc -l\n").reply.status);
try runReal(p);
// The +Errors it opened did not take the keyboard.
- try testing.expectEqual(@as(usize, 0), p.active);
+ try testing.expectEqual(@as(usize, 0), p.view().active);
try testing.expectEqualStrings("ONE TWO\nnew", p.panes[0].?.file.?.content);
try testing.expectEqualStrings("1", std.mem.trim(u8, errorsText(p).?, " \n"));
}
@@ -621,9 +621,9 @@ test "X over open files, w, e, r, f, B and D on panes and the disk" {
defer p.deinit();
var path: [4200]u8 = undefined;
look.lookAt(p, 0, try std.fmt.bufPrint(&path, "{s}/a.c", .{dir}));
- const a = p.active;
+ const a = p.view().active;
look.lookAt(p, 0, try std.fmt.bufPrint(&path, "{s}/b.h", .{dir}));
- p.active = 0;
+ p.view().active = 0;
const ctl = tree.Node.of(th.serialOf(p), .ctl);
// X: every open file whose line matches, each from its own dot.
try testing.expectEqual(tree.Status.ok, th.wr(p, ctl, "Edit X/\\.[ch]$/ ,s/foo/FOO/g\n").reply.status);
@@ -637,7 +637,7 @@ test "X over open files, w, e, r, f, B and D on panes and the disk" {
// B opens a file, which a `"re"` address then edits, from pane 0.
var cmd: [4400]u8 = undefined;
try testing.expectEqual(tree.Status.ok, th.wr(p, ctl, try std.fmt.bufPrint(&cmd, "Edit B {s}/c.c\n", .{dir})).reply.status);
- try testing.expectEqual(@as(usize, 0), p.active);
+ try testing.expectEqual(@as(usize, 0), p.view().active);
try testing.expectEqual(tree.Status.ok, th.wr(p, ctl, "Edit \"c\\.c$\" 1 s/bar/BAR/\n").reply.status);
const c = for (p.panes, 0..) |slot, i| {
if (slot) |q| if (q.file) |f| if (std.mem.endsWith(u8, f.path, "/c.c")) break i;
@@ -694,10 +694,10 @@ test "an Edit's w to a file changed on disk is refused once, as Save is, and the
defer p.deinit();
var path: [4200]u8 = undefined;
look.lookAt(p, 0, try std.fmt.bufPrint(&path, "{s}/a.txt", .{dir}));
- const a = p.active;
+ const a = p.view().active;
look.lookAt(p, 0, try std.fmt.bufPrint(&path, "{s}/b.txt", .{dir}));
- const b = p.active;
- p.active = 0;
+ const b = p.view().active;
+ p.view().active = 0;
for ([_]usize{ a, b }) |i| try testing.expectEqual(tree.Status.ok, th.wr(p, tree.Node.of(p.panes[i].?.serial, .ctl), "Edit $a/more/\n").reply.status);
// a.txt changed on disk since it was read (the watch says so).
p.panes[a].?.file.?.disk_newer = 1;
@@ -729,8 +729,8 @@ test "an Edit with no command runs beside one whose commands run, unless it touc
defer p.deinit();
var path: [4200]u8 = undefined;
look.lookAt(p, 0, try std.fmt.bufPrint(&path, "{s}/other.txt", .{dir}));
- const other = p.active;
- p.active = 0;
+ const other = p.view().active;
+ p.view().active = 0;
const ctl = tree.Node.of(th.serialOf(p), .ctl);
const other_ctl = tree.Node.of(p.panes[other].?.serial, .ctl);
try testing.expectEqual(tree.Status.ok, th.wr(p, ctl, "Edit , | sort\n").reply.status);