diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 20:54:21 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-04 21:12:33 -0300 |
| commit | 0ff1fc99eb870f8a1e714a71c1a853066737c822 (patch) | |
| tree | 2c8b4720e2ed190e6f9062cfe8586c3da22aeb42 /src/ninep | |
| parent | 3b082687c7da1c5d8cc52c71fdf4ddd38d860cd8 (diff) | |
| download | pardes-0ff1fc99eb870f8a1e714a71c1a853066737c822.tar.gz pardes-0ff1fc99eb870f8a1e714a71c1a853066737c822.zip | |
rename: the terminal frontend is the tui (-Dplatform=tui, src/tui/tui.zig, --tui with --tty kept as its old spelling, the process tests' backend .tui and --backend=tui, docs/typ/builtins-tui.json, the Settings report's platform), and the builtin Tty is Term (its registry entry, SPC n t, every default tag, the docs, tests and snap scripts), Tty still run as Term through exec.acme_words, Tty+fish too on a tag and a ctl; tty as a pane's raw mode and as the OS's terminal unchanged
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/ninep')
| -rw-r--r-- | src/ninep/cols.zig | 24 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 53 | ||||
| -rw-r--r-- | src/ninep/pane.zig | 2 | ||||
| -rw-r--r-- | src/ninep/pty.zig | 2 | ||||
| -rw-r--r-- | src/ninep/tree.zig | 4 |
5 files changed, 47 insertions, 38 deletions
diff --git a/src/ninep/cols.zig b/src/ninep/cols.zig index 6f5bee23..0ee25345 100644 --- a/src/ninep/cols.zig +++ b/src/ninep/cols.zig @@ -150,7 +150,7 @@ pub fn released(p: *Pardes, serial: ?u32) void { } /// A column's ctl: the words that act on a column, as its tag's clicks do -- -/// Delcol, Joincol, New, Tty -- one a line, each run as from that tag. What +/// Delcol, Joincol, New, Term -- one a line, each run as from that tag. What /// they say is the session's in the log (`msg -`), not the focused pane's. pub fn writeCtl(p: *Pardes, req: Req, serial: u32) Reply { // What this write touched, alone, reads back (runBuiltin notes it). @@ -162,14 +162,14 @@ pub fn writeCtl(p: *Pardes, req: Req, serial: u32) Reply { const line = std.mem.trim(u8, raw, " \t\r"); if (line.len == 0 or pardes.exec.isComment(line)) continue; const word = line[0 .. std.mem.indexOfAny(u8, line, " \t") orelse line.len]; - const takes = for ([_][]const u8{ "Delcol", "Joincol", "New", "Tty" }) |w| { + const takes = for ([_][]const u8{ "Delcol", "Joincol", "New", "Term" }) |w| { if (std.mem.eql(u8, w, word)) break true; } else false; // Plan 9's words for it, so a mount's errno is EINVAL as the root's // and a pane's ctl give (9ns reads "control message"). - if (!takes) return tree.failText(req.tag, E.INVAL, std.fmt.bufPrint(&p.fs.ename, "unknown control message \"{s}\": a column's ctl takes Delcol, Joincol, New or Tty", .{pardes.ctlfs.ctl.firstWord(line)[0..@min(pardes.ctlfs.ctl.firstWord(line).len, 64)]}) catch "unknown control message"); - // Only Tty takes a word (its shell); `New extra` is no New. - if (!std.mem.eql(u8, word, "Tty") and word.len != line.len) + if (!takes) return tree.failText(req.tag, E.INVAL, std.fmt.bufPrint(&p.fs.ename, "unknown control message \"{s}\": a column's ctl takes Delcol, Joincol, New or Term", .{pardes.ctlfs.ctl.firstWord(line)[0..@min(pardes.ctlfs.ctl.firstWord(line).len, 64)]}) catch "unknown control message"); + // Only Term takes a word (its shell); `New extra` is no New. + if (!std.mem.eql(u8, word, "Term") and word.len != line.len) return tree.failText(req.tag, E.INVAL, std.fmt.bufPrint(&p.fs.ename, "wrong #args in control message \"{s}\"", .{pardes.ctlfs.ctl.firstWord(line)[0..@min(pardes.ctlfs.ctl.firstWord(line).len, 64)]}) catch "wrong #args in control message"); const col = layout.columnBySerial(p, serial) orelse return Reply.fail(req.tag, E.NOENT); p.exec_column = col; @@ -197,7 +197,7 @@ pub fn writeExec(p: *Pardes, req: Req, serial: ?u32) Reply { if (pardes.ctlfs.ctl.tooLong(req, line)) |refusal| return refusal; // A pane's word (Undo, Msg, Save) is no word of a tag no pane owns: // refused as the root's ctl refuses it, never done at whichever - // pane has the keyboard. The tag's own words (New, Tty, Find, Grep + // pane has the keyboard. The tag's own words (New, Term, Find, Grep // in a column's) are its to run. if (paneWord(line, if (serial == null) pardes.config.topbar_str else tagline.column_tag_default)) return pardes.ctlfs.ctl.refuseTo(p, req, "not a session control message", line, "pane/<n>/ctl"); @@ -380,7 +380,7 @@ fn paneWord(line: []const u8, own: []const u8) bool { const b = std.meta.stringToEnum(pardes.builtins.registry.Builtin(), word) orelse return false; if (pardes.builtins.registry.scope(b) == .session) return false; // A new pane is every tag's to make, in the session's directory. - if (b == .New or b == .Tty) return false; + if (b == .New or b == .Term) return false; var words = std.mem.tokenizeScalar(u8, own, ' '); while (words.next()) |w| if (std.mem.eql(u8, w, word)) return false; return true; @@ -440,18 +440,18 @@ test "a shell command at /tagexec or a column's exec is a command pane in the se } } -test "New and Tty run at /tagexec and a column's exec, with no pane at all too" { +test "New and Term run at /tagexec and a column's exec, with no pane at all too" { const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); const tagexec = @backingInt(tree.TopFile.tagexec); const col_exec = tree.Node.ofCol(layout.columnSerial(p, 0), .exec); - for ([_]u64{ tagexec, col_exec }) |node| for ([_][]const u8{ "New\n", "Tty\n" }) |line| { + for ([_]u64{ tagexec, col_exec }) |node| for ([_][]const u8{ "New\n", "Term\n" }) |line| { const before = p.next_serial; try testing.expectEqual(tree.Status.ok, th.wr(p, node, line).reply.status); try testing.expectEqual(before + 1, p.next_serial); }; // Every pane gone: the workspace tag makes one all the same. - for ([_][]const u8{ "New\n", "Tty\n" }) |line| { + for ([_][]const u8{ "New\n", "Term\n" }) |line| { while (p.ncol > 0) { const first = p.panes[p.col_panes[0][0]].?.serial; _ = th.wr(p, tree.Node.of(first, .ctl), "delete\n"); @@ -475,7 +475,7 @@ test "every pane word a tag no pane owns does not hold is refused there, Edit in var checked: usize = 0; for (std.enums.values(Builtin)) |b| { if (pardes.builtins.registry.scope(b) == .session) continue; - if (b == .New or b == .Tty) continue; // every tag's + if (b == .New or b == .Term) continue; // every tag's var owned = false; var words = std.mem.tokenizeScalar(u8, tag_file.own, ' '); while (words.next()) |w| owned = owned or std.mem.eql(u8, w, @tagName(b)); @@ -548,7 +548,7 @@ test "a column's tag and the workspace's read, replace and append as a pane tag try testing.expectEqual(E.NOENT, th.look_up(p, col_dir, "777").errno()); const tag = Node.ofCol(serial, .tag); try testing.expectEqual(tree.Status.ok, th.look_up(p, Node.ofCol(serial, .dir), "tag").reply.status); - try testing.expectEqualStrings("New Tty Find Grep Joincol Delcol", th.rd(p, tag, 0, 4096).bytes); + try testing.expectEqualStrings("New Term Find Grep Joincol Delcol", th.rd(p, tag, 0, 4096).bytes); // `echo Make > tag`: cleared, then the newline ending the write dropped. _ = th.call(p, .{ .tag = 1, .op = .setattr, .node = tag, .truncate = true }); _ = th.wr(p, tag, "Make\n"); diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 89549933..4749fc94 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -515,9 +515,15 @@ fn blanked(line: []const u8, buf: []u8) []const u8 { /// as on a tag; acme's lowercase verbs are the pane ctl's and alias none. fn checkBuiltin(p: *Pardes, req: Req, line: []const u8, scope: builtins.Scope) ?Reply { var sp = std.mem.indexOfAny(u8, line, " \t"); - // `Word+arg` for a word that takes one so (`Tty+bash`), as exec does. - if (sp == null) if (std.mem.indexOfScalar(u8, line, '+')) |at| if (std.meta.stringToEnum(Builtin, line[0..at])) |head| { - if (builtins.registry.plusArg(head)) sp = at; + // `Word+arg` for a word that takes one so (`Term+bash`), as exec does; + // an old name's too (`Tty+bash`). + if (sp == null) if (std.mem.indexOfScalar(u8, line, '+')) |at| { + const head = for (pardes.exec.acme_words) |w| { + if (std.mem.eql(u8, line[0..at], w.acme)) break w.pardes orelse ""; + } else line[0..at]; + if (std.meta.stringToEnum(Builtin, head)) |b| if (builtins.registry.plusArg(b)) { + sp = at; + }; }; const typed = line[0 .. sp orelse line.len]; // acme's words: checked as the pardes word they run as, or refused. @@ -592,7 +598,7 @@ pub fn runBuiltin(p: *Pardes, req: Req, id: usize, line: []const u8) ?Reply { p.fs.failure_len = 0; defer p.fs.no_prompt = false; // What a ctl write touched reads back from /look and /exec as a click's - // does (`run`), so a script that made a pane with `Tty` finds it there. + // does (`run`), so a script that made a pane with `Term` finds it there. const context = if (p.panes[id]) |pane| pane.serial else 0; const before = Serials.snapshot(p); _ = exec_line.executeBuiltinLine(p, id, line); @@ -1768,7 +1774,7 @@ test "DumpConfig's whole report writes back to the root ctl, line by line, with } else return error.NoDumpConfigPane; defer testing.allocator.free(report); // What this shell cannot show is a comment, never a value it refuses. - if (pardes.platform == .tty) try testing.expect(std.mem.indexOf(u8, report, "# GripWidth unsupported\n") != null); + if (pardes.platform == .tui) try testing.expect(std.mem.indexOf(u8, report, "# GripWidth unsupported\n") != null); var lines = std.mem.splitScalar(u8, report, '\n'); while (lines.next()) |line| { if (line.len == 0) continue; @@ -1967,7 +1973,7 @@ test "Mount dials its peer and fails, mounting nothing, when none answers; a loo try testing.expect(th.logHas(p, "look: /n/gone/f.txt: dial failed: no answer")); } -test "Tty in a directory that is not there fails and makes no pane; a shell that never started answers a run" { +test "Term in a directory that is not there fails and makes no pane; a shell that never started answers a run" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); const serial = serialOf(p); @@ -1981,15 +1987,15 @@ test "Tty in a directory that is not there fails and makes no pane; a shell that defer p.host = .{}; var count: usize = 0; for (p.panes) |slot| count += @intFromBool(slot != null); - const refused = wr(p, Node.of(serial, .ctl), "Tty\n"); + const refused = wr(p, Node.of(serial, .ctl), "Term\n"); try testing.expectEqual(E.NOENT, refused.errno()); - try testing.expectStringStartsWith(refused.reply.ename, "Tty: /tmp/pardes-no-such-dir-zz: no such directory"); + try testing.expectStringStartsWith(refused.reply.ename, "Term: /tmp/pardes-no-such-dir-zz: no such directory"); var after: usize = 0; for (p.panes) |slot| after += @intFromBool(slot != null); try testing.expectEqual(count, after); // A terminal whose shell the host could not start. _ = wr(p, Node.of(serial, .name), "/tmp/f.txt\n"); - try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .ctl), "Tty\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .ctl), "Term\n").reply.status); const term = p.active; p.shellFailed(@intCast(term), error.FileNotFound); const run_node = Node.of(p.panes[term].?.serial, .pty_run); @@ -2066,7 +2072,7 @@ test "a terminal told the directory it already goes by logs no rename" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); _ = wr(p, Node.of(serialOf(p), .name), "/tmp/f.txt\n"); - try testing.expectEqual(Status.ok, wr(p, Node.of(serialOf(p), .ctl), "Tty\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, Node.of(serialOf(p), .ctl), "Term\n").reply.status); p.update(.tick); // announced const term = p.active; // The host says where its shell started: where it was already named. @@ -2161,7 +2167,7 @@ test "pty/ctl exec in a directory that is gone fails ENOENT; a shell that cannot try testing.expectEqualStrings("shell: permission denied", p.fs.late_failure[0..p.fs.late_failure_len]); } -test "a script whose interpreter is not there: Tty refuses it up front, only an err logged, and pty/ctl exec keeps the running shell" { +test "a script whose interpreter is not there: Term refuses it up front, only an err logged, and pty/ctl exec keeps the running shell" { const p = try th.withTerm(testing.allocator); defer p.deinit(); const Starting = struct { @@ -2178,14 +2184,14 @@ test "a script whose interpreter is not there: Tty refuses it up front, only an const serial = serialOf(p); var count: usize = 0; for (p.panes) |slot| count += @intFromBool(slot != null); - const refused = wr(p, Node.of(serial, .ctl), try std.fmt.bufPrint(&line, "Tty {s}/bad\n", .{dir})); + const refused = wr(p, Node.of(serial, .ctl), try std.fmt.bufPrint(&line, "Term {s}/bad\n", .{dir})); try testing.expectEqual(E.NOENT, refused.errno()); - try testing.expectEqualStrings("Tty: interpreter /no/such/interp not found", refused.reply.ename); + try testing.expectEqualStrings("Term: interpreter /no/such/interp not found", refused.reply.ename); var after: usize = 0; for (p.panes) |slot| after += @intFromBool(slot != null); try testing.expectEqual(count, after); // The log gained the err and nothing else: no new, msg or del. - try testing.expect(th.logHas(p, "Tty: interpreter /no/such/interp not found\n")); + try testing.expect(th.logHas(p, "Term: interpreter /no/such/interp not found\n")); try testing.expect(!th.logHas(p, "\nmsg ")); try testing.expect(!th.logHas(p, "\ndel ")); // The shell to start again is that script: refused before the running @@ -2407,7 +2413,7 @@ test "a focus moved over 9P tells the programs that asked for focus reports, as const first = for (p.panes) |slot| { if (slot) |pane| if (pane.isTerminal()) break pane.serial; } else return error.NoShell; - try testing.expectEqual(Status.ok, wr(p, Node.of(first, .exec), "Tty\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, Node.of(first, .exec), "Term\n").reply.status); var shells: [2]usize = undefined; var n: usize = 0; for (p.panes, 0..) |slot, id| if (slot) |pane| if (pane.isTerminal() and n < 2) { @@ -2536,11 +2542,11 @@ test "size is monotonic: growing is never refused, and a size once taken is take p.unattended = true; const root_ctl = @backingInt(tree.TopFile.ctl); const new = @backingInt(tree.TopFile.new); - // The dogfood's repro: Newcol, three pane/new, a Tty, then pane/new + // The dogfood's repro: Newcol, three pane/new, a Term, then pane/new // until a column has no room (ENOSPC). try testing.expectEqual(Status.ok, wr(p, root_ctl, "Newcol\n").reply.status); for (0..3) |_| try testing.expectEqual(Status.ok, call(p, .{ .tag = 1, .op = .open, .node = new }).reply.status); - try testing.expectEqual(Status.ok, wr(p, Node.of(p.panes[p.active].?.serial, .ctl), "Tty\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, Node.of(p.panes[p.active].?.serial, .ctl), "Term\n").reply.status); p.sync(); while (call(p, .{ .tag = 1, .op = .open, .node = new }).reply.status == .ok) p.sync(); p.sync(); @@ -2875,12 +2881,15 @@ test "a body write to an image pane says its body takes none, not that terminals try testing.expectEqualStrings(pane_files.e_no_body, wr(p, Node.of(doc.serial, .body), "x").reply.ename); } -test "Tty+bash on a pane ctl is Tty with its argument, as exec and the tag take it" { +test "Term+bash on a pane ctl is Term with its argument, as exec and the tag take it" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - const r = call(p, .{ .tag = 1, .op = .write, .node = Node.of(serialOf(p), .ctl), .data = "Tty+sh\n" }); - try testing.expectEqual(Status.ok, r.reply.status); - try testing.expect(r.spawned); + // Tty+sh too: Term's old name, as a saved tag holds it. + for ([_][]const u8{ "Term+sh\n", "Tty+sh\n" }) |data| { + const r = call(p, .{ .tag = 1, .op = .write, .node = Node.of(serialOf(p), .ctl), .data = data }); + try testing.expectEqual(Status.ok, r.reply.status); + try testing.expect(r.spawned); + } } test "a Rename that reaches other files previews them, says so, and is the pane a waiting write answers" { @@ -3003,7 +3012,7 @@ test "a command or a terminal refused for room is refused before anything is log defer p.deinit(); const exec = Node.of(serialOf(p), .exec); var buf: [32]u8 = undefined; - for ([_][]const u8{ "ls\n", "Tty\n" }) |line| { + for ([_][]const u8{ "ls\n", "Term\n" }) |line| { // Each a pane of its own until the column has no room for one more. var before = p.next_serial; var tries: usize = 0; diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index 28f1882d..d0b368ea 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -883,7 +883,7 @@ fn nameFault(name: []const u8) ?[]const u8 { fn unnamed(pane: *const Pane) []const u8 { return if (pane.isTerminal()) - "invalid rename: a terminal is named by its shell's directory; cd there, or Tty in another" + "invalid rename: a terminal is named by its shell's directory; cd there, or Term in another" else "invalid rename: an image or PDF is named by the file it shows"; } diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig index ee8c618e..5c9a6289 100644 --- a/src/ninep/pty.zig +++ b/src/ninep/pty.zig @@ -76,7 +76,7 @@ pub fn writeCtl(p: *Pardes, req: Req, id: usize) Reply { if (!apply and std.mem.eql(u8, line, "exec")) if (p.panes[id]) |pane| if (pane.command != null) return tree.failText(req.tag, E.INVAL, "invalid exec: a command pane does not restart"); // A shell restarted where the directory is gone would not start: - // refused before anything runs, as Tty there is. + // refused before anything runs, as Term there is. if (!apply and std.mem.eql(u8, line, "exec")) if (p.panes[id]) |pane| if (pardes.exec.missingDir(p, pane.cwdSlice())) { const dir = pane.cwdSlice(); return tree.failText(req.tag, E.NOENT, std.fmt.bufPrint(&p.fs.ename, "exec: {s}: no such directory", .{dir[0..@min(dir.len, 256)]}) catch "exec: no such directory"); diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index 6bf14243..bd53b6a9 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -1843,7 +1843,7 @@ test "random placements, refused or not, leave no pane under its tag and two row 1 => _ = call(p, .{ .tag = 1, .op = .open, .node = @backingInt(TopFile.new) }), 2 => _ = th.wr(p, Node.of(at, .exec), "Newcol\n"), 3 => _ = th.wr(p, Node.of(at, .exec), "Edit =\n"), - 4 => _ = th.wr(p, Node.of(at, .exec), "Tty\n"), + 4 => _ = th.wr(p, Node.of(at, .exec), "Term\n"), 5 => _ = th.wr(p, Node.of(at, .look), looked), 6 => _ = th.wr(p, Node.of(at, .exec), "Delcol\n"), else => _ = th.wr(p, Node.of(at, .ctl), "delete\n"), @@ -2005,7 +2005,7 @@ test "look and exec read back what their own open's write touched; a fresh open const first = p.panes[0].?.serial; const mine = call(p, .{ .tag = 1, .op = .open, .node = exec, .omode = 2 }).reply.handle; const theirs = call(p, .{ .tag = 2, .op = .open, .node = exec, .omode = 2 }).reply.handle; - _ = call(p, .{ .tag = 3, .op = .write, .node = exec, .handle = mine, .data = "Tty\n" }); + _ = call(p, .{ .tag = 3, .op = .write, .node = exec, .handle = mine, .data = "Term\n" }); const made = p.panes[p.active].?.serial; try testing.expect(made != first); _ = call(p, .{ .tag = 4, .op = .write, .node = exec, .handle = theirs, .data = "Msg hi\n" }); |
