diff options
Diffstat (limited to 'src/ninep/cols.zig')
| -rw-r--r-- | src/ninep/cols.zig | 24 |
1 files changed, 12 insertions, 12 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"); |
