diff options
Diffstat (limited to 'core/exec.zig')
| -rw-r--r-- | core/exec.zig | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/core/exec.zig b/core/exec.zig index 0e09e175..6a8ef6d8 100644 --- a/core/exec.zig +++ b/core/exec.zig @@ -329,14 +329,14 @@ pub fn saveTo(p: *Pardes, id: usize, path: []const u8) void { const pane = p.panes[id] orelse return; if (path.len == 0 or path[path.len - 1] == '/' or std.mem.indexOfScalar(u8, path, '\n') != null) - return p.reportError(id, "save", error.NoFilename); + return p.reportError(.at(id), "save", error.NoFilename); var home_buf: [4096]u8 = undefined; const full = std.Io.Dir.path.resolvePosix( p.scratch.allocator(), &.{ Pardes.paneDir(pane), p.expandHome(path, &home_buf) }, - ) catch |err| return p.reportError(id, "save", err); - if (!std.Io.Dir.path.isAbsolute(full)) return p.reportError(id, "save", error.NoDirectory); - if (full.len > Pardes.SavePath.cap) return p.reportError(id, "save", error.PathTooLong); + ) catch |err| return p.reportError(.at(id), "save", err); + if (!std.Io.Dir.path.isAbsolute(full)) return p.reportError(.at(id), "save", error.NoDirectory); + if (full.len > Pardes.SavePath.cap) return p.reportError(.at(id), "save", error.PathTooLong); const f = if (pane.file) |*file| file else { // a terminal writes its scrollback; an image and a PDF have nothing // of their own that is unwritten, so they have nothing to write @@ -382,7 +382,7 @@ pub fn spawnTty(p: *Pardes, from: usize) ?*Pane { return null; } const free = p.freeSlot() orelse { - p.reportError(from, "Term", error.NoPaneSlots); + p.reportError(.at(from), "Term", error.NoPaneSlots); return null; }; const nt = p.newShell(free, dir) catch |err| { @@ -390,14 +390,14 @@ pub fn spawnTty(p: *Pardes, from: usize) ?*Pane { p.reportFailure(from, std.fmt.comptimePrint("Term: its directory is longer than a path may be ({d} bytes)", .{pardes.memory.limits.host_path_cap})); return null; } - p.reportError(from, "Term", err); + p.reportError(.at(from), "Term", err); return null; }; nt.greet = true; nt.body.mode = .tty; layout.placeNew(p, from, from, free, .shell); if (refusedPlacement(p, free)) { - p.reportError(from, "Term", error.NoPaneRoom); + p.reportError(.at(from), "Term", error.NoPaneRoom); return null; } return nt; @@ -411,7 +411,7 @@ fn refusedPlacement(p: *Pardes, id: usize) bool { p.unplaced.unset(id); // It held no weight (layout.placeNew put every pane's rows back as they // were): nothing else moves, a pane dragged short included. - p.removePane(id, null) catch |err| p.reportError(id, "open", err); + p.removePane(id, null) catch |err| p.reportError(.at(id), "open", err); return true; } @@ -471,7 +471,7 @@ const Routed = union(enum) { none, sent: usize, asked }; pub fn replGone(p: *Pardes, from: usize, repl: *const Pane) Routed { var idbuf: [48]u8 = undefined; var said: pardes.Kind.Buf(128) = .{}; - p.setMessage(from, said.print("Repl: {s} has no program running; nothing sent", .{replId(&idbuf, repl)})); + p.setMessage(.at(from), said.print("Repl: {s} has no program running; nothing sent", .{replId(&idbuf, repl)})); return .asked; } @@ -572,7 +572,7 @@ pub fn sendToRepl(p: *Pardes, from: usize, to: usize, text: []const u8) void { // Lines end in \n alone (a \r\n would give Python a blank line that // ends its block), and no ESC or other control byte but a tab goes: an // ESC[201~ in the text would end a bracketed paste early. - const clean = p.scratch.allocator().alloc(u8, text.len) catch |err| return p.reportError(from, "Repl", err); + const clean = p.scratch.allocator().alloc(u8, text.len) catch |err| return p.reportError(.at(from), "Repl", err); var n: usize = 0; for (text, 0..) |c, i| { if (c == '\r') { @@ -585,7 +585,7 @@ pub fn sendToRepl(p: *Pardes, from: usize, to: usize, text: []const u8) void { // paste, or with half a block. if (n + 16 > p.writeRoom(to)) { var said: pardes.Kind.Buf(128) = .{}; - return p.setMessage(from, said.print("Repl: {d} bytes is more than can be sent at once; send less", .{n})); + return p.setMessage(.at(from), said.print("Repl: {d} bytes is more than can be sent at once; send less", .{n})); } const pasted = panes.Term.modes(dst.terminal).bracketed_paste; edit.typeToTty(p, to, dst, clean[0..n]); @@ -615,10 +615,10 @@ pub fn sendToRepl(p: *Pardes, from: usize, to: usize, text: []const u8) void { { dst.repl_warned = true; var warn: pardes.Kind.Buf(128) = .{}; - p.setMessage(from, warn.print("Repl: {s} takes no bracketed paste; a blank line in a block ends it", .{id})); + p.setMessage(.at(from), warn.print("Repl: {s} takes no bracketed paste; a blank line in a block ends it", .{id})); } var said: pardes.Kind.Buf(64) = .{}; - p.setMessage(from, said.print("\u{2192} {s}", .{id})); + p.setMessage(.at(from), said.print("\u{2192} {s}", .{id})); src.msg_sent = true; var rec: [96]u8 = undefined; pardes.ctlfs.events.notePath(p, "send", std.fmt.bufPrint(&rec, "{d} {d} {s}", .{ src.serial, dst.serial, id }) catch return); @@ -710,7 +710,7 @@ pub fn executeFrom(p: *Pardes, id: usize, txt: []const u8, from_body: bool) ?usi }; pane.noteCommand(cmd); if (pane.queuePendingCommand(cmd) catch |err| { - p.reportError(id, "queue command", err); + p.reportError(.at(id), "queue command", err); return id; }) return id; p.emitWrite(id, cmd); @@ -754,7 +754,7 @@ pub fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize { if (reuse) |id| { const pane = p.panes[id].?; const owned = p.gpa.dupe(u8, line) catch |err| { - p.reportError(from, "exec", err); + p.reportError(.at(from), "exec", err); return null; }; p.gpa.free(pane.command.?); @@ -778,18 +778,18 @@ pub fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize { return id; } const free = p.freeSlot() orelse { - p.reportError(from, "exec", error.NoPaneSlots); + p.reportError(.at(from), "exec", error.NoPaneSlots); return null; }; const pane = panes.newCommand(p, free, dir, line) catch |err| { - p.reportError(from, "exec", err); + p.reportError(.at(from), "exec", err); return null; }; pane.command_from = winid(p, src); echoCommand(p, pane, line); layout.placeNew(p, from, from, free, .command); if (refusedPlacement(p, free)) { - p.reportError(from, "exec", error.NoPaneRoom); + p.reportError(.at(from), "exec", error.NoPaneRoom); return null; } pane.noteRun(p, "run", line); @@ -982,7 +982,7 @@ pub fn runBuiltinFrom(p: *Pardes, b: Builtin, id: usize, txt: []const u8, arg: ? // row's only, never /log's: a msg record is something said. if (p.announce and p.settings.verbose and builtins.registry.announces(b)) { p.fs.unlogged = true; - p.setMessage(id, @tagName(b)); + p.setMessage(.at(id), @tagName(b)); p.fs.unlogged = false; pane.msg_announcement = true; } @@ -1032,7 +1032,7 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[] p.settings.shell.pending = true; if (!p.announce) return; var said: pardes.Kind.Buf(320) = .{}; - return p.setMessage(v.active, said.print("Shell: the default again, {s} ($SHELL, else /bin/sh)", .{p.sessionShell()[0..@min(p.sessionShell().len, 256)]})); + return p.setMessage(.at(v.active), said.print("Shell: the default again, {s} ($SHELL, else /bin/sh)", .{p.sessionShell()[0..@min(p.sessionShell().len, 256)]})); } var why: [320]u8 = undefined; if (pardes.tape.site(.shell, null, @import("dev").host_io.Shell.refusal, .{ want[0..@min(want.len, 200)], &why })) |refused| { @@ -1044,7 +1044,7 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[] // Bare, each says its value, as acme's Tab says the width. inline .tab, .callstack_depth => |_, tag| if (arg == null) { var said: pardes.Kind.Buf(40) = .{}; - return p.setMessage(v.active, said.print("{s} {d}", .{ setting.word, @field(p.settings, @tagName(tag)) })); + return p.setMessage(.at(v.active), said.print("{s} {d}", .{ setting.word, @field(p.settings, @tagName(tag)) })); } else if (!p.settings.apply(p.tape, setting, arg, p.sessionHome())) { var said: pardes.Kind.Buf(96) = .{}; p.reportFailure(v.active, said.print("{s}{s}: takes {s}", .{ setting.word, if (tag == .tab) ": invalid tab width" else "", comptime config.Runtime.takes(tag).? })); @@ -1090,10 +1090,10 @@ pub fn runWord(p: *Pardes, id: usize, w: *const pardes.Kind.Word, line: []const if (w.arg == pardes.Kind.c.PA_ARG_NONE and arg.len > 0) return p.reportFailure(id, std.fmt.bufPrint(&said, "{s} takes no argument", .{name}) catch name); if (w.arg == pardes.Kind.c.PA_ARG_REQUIRED and arg.len == 0) return p.reportFailure(id, std.fmt.bufPrint(&said, "{s} needs an argument", .{name}) catch name); if (w.opens != 0) { - const free = p.freeSlot() orelse return p.reportError(id, name, error.NoPaneSlots); + const free = p.freeSlot() orelse return p.reportError(.at(id), name, error.NoPaneSlots); var path_buf: [4096]u8 = undefined; const path = if (arg.len == 0 or std.Io.Dir.path.isAbsolute(arg)) arg else std.fmt.bufPrint(&path_buf, "{s}/{s}", .{ std.mem.trimEnd(u8, if (p.panes[id]) |pane| Pardes.paneDir(pane) else p.sessionDir(), "/"), arg }) catch arg; - const made = (if (path.len > 0) pardes.Kind.openFile(p, free, w.kind, path) else pardes.Kind.open(p, free, w.kind, null, null)) catch |err| return p.reportError(id, name, err); + const made = (if (path.len > 0) pardes.Kind.openFile(p, free, w.kind, path) else pardes.Kind.open(p, free, w.kind, null, null)) catch |err| return p.reportError(.at(id), name, err); if (made.addon.?.refused.len > 0) { made.vweight = 0; p.unplaced.set(free); |
