diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-19 20:31:32 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-19 20:31:32 -0300 |
| commit | 0db34fbf28e70c8c6a3c6025c0888fc5ec75201c (patch) | |
| tree | f2e288668decded9276ebc45907f16d651b06f9e /core/exec.zig | |
| parent | 2ab05b536bc3b063666b5aaab497157adc2a9120 (diff) | |
| parent | bf351b62e8843a3d173cedeefa2dd0b8ef4b4392 (diff) | |
| download | pardes-0db34fbf28e70c8c6a3c6025c0888fc5ec75201c.tar.gz pardes-0db34fbf28e70c8c6a3c6025c0888fc5ec75201c.zip | |
integration: a pane's and a view's slot as types, with the regular-expression fixes and the fixes the real loops asked for: pardes-ids (Pane.Id and View.Id through the entries, the events, the effects, the Host table and the device messages) and pardes-merge21, merged without a textual conflict; one call site written since on the old type follows (core/draw.zig: the twin test's file_changed event, .pane = .at(0)); tui core-test 848/991 (143 skipped), shell-test 1027/1030, the window builds; gates in the coordinator's ledger
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/exec.zig')
| -rw-r--r-- | core/exec.zig | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/core/exec.zig b/core/exec.zig index 0e09e175..687faa98 100644 --- a/core/exec.zig +++ b/core/exec.zig @@ -322,21 +322,21 @@ pub fn saveFile(p: *Pardes, id: usize) void { } f.disk_newer = null; } - p.emit(.{ .save_file = .{ .pane = @intCast(id) } }); + p.emit(.{ .save_file = .{ .pane = .at(id) } }); } 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 @@ -347,7 +347,7 @@ pub fn saveTo(p: *Pardes, id: usize, path: []const u8) void { // Save that fails changes nothing, the name included. if (f.output != null and panes.Output.fileTraits(f.output).saves) { p.emit(.{ .save_text = .{ - .pane = @intCast(id), + .pane = .at(id), .serial = pane.serial, .path = Pardes.SavePath.from(full), .promote = true, @@ -361,7 +361,7 @@ pub fn saveTo(p: *Pardes, id: usize, path: []const u8) void { fn askWrite(p: *Pardes, id: usize, serial: u32, path: []const u8) void { p.emit(.{ .save_text = .{ - .pane = @intCast(id), + .pane = .at(id), .serial = serial, .path = Pardes.SavePath.from(path), } }); @@ -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); |
