diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-29 09:01:46 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:16 -0300 |
| commit | 039ae6aa70d963f942d8a5747060c67599664af9 (patch) | |
| tree | 3f6448c9a7b3db81a076edeefce081990a9eea24 | |
| parent | e0a2fd56777cf0f571125650ec74e75c3f6a8c44 (diff) | |
| download | pardes-039ae6aa70d963f942d8a5747060c67599664af9.tar.gz pardes-039ae6aa70d963f942d8a5747060c67599664af9.zip | |
A terminal is typed into only when idle at an empty prompt
A look at a directory, or an exec at a terminal, typed its line after
whatever sat unsent at the prompt and ran the two joined (`echo TYPEDls`).
A terminal with text at its prompt now takes no line; a look at its
directory opens a new terminal, an exec runs as a command pane.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
| -rw-r--r-- | docs/fs.md | 14 | ||||
| -rw-r--r-- | src/exec.zig | 8 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 26 |
3 files changed, 42 insertions, 6 deletions
@@ -350,7 +350,8 @@ same tree without leaving the process. `/look` and `/exec` are the editor's two clicks, one per line of a write: - a line written to `look` is a right click on it: a path opens a file, - `file:12` jumps to a line, a directory opens a terminal there that runs + `file:12` jumps to a line, a directory types `ls` into a terminal idle + at an empty prompt there, else opens a terminal there that runs `ls` once (pardes has no directory listing pane of acme's kind; a shell in it is where one goes on from a directory), a URL opens in the browser, and a plain word, as acme's look3 does, selects its next @@ -371,10 +372,13 @@ same tree without leaving the process. acme's makenewwindow puts a new window (util.c:456-467: the active column first, then the pane's own), under the text with room or halving the tallest, never shorter than its tag and 2 rows), - or anything else, a command line. Written at a terminal at its prompt it - is typed into that shell (and a terminal whose shell exits, `exit` typed - or run, closes its pane). From anywhere else -- a file, a scratch, a tag, - a terminal whose tty a program holds -- it runs as a command pane: a + or anything else, a command line. Written at a terminal idle at an EMPTY + prompt it is typed into that shell -- any line that is no builtin, so + `Delcol x` at a terminal goes to the shell -- (and a terminal whose shell + exits, `exit` typed or run, closes its pane). Nothing is ever typed over + text someone typed at a prompt and did not send. From anywhere else -- a + file, a scratch, a tag, a terminal with a line typed at its prompt or + whose tty a program holds -- it runs as a command pane: a terminal whose child is the root ctl's `Shell` ($SHELL, else /bin/sh, unless set) run with `-c` and the line, in the pane's directory, with job control on (bash, sh, dash, zsh, ksh `-m`; fish `status job-control full`), diff --git a/src/exec.zig b/src/exec.zig index 6e437093..ebe90b98 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -37,6 +37,12 @@ pub fn takesCommandLine(p: *const Pardes, id: usize) bool { const pane = p.panes[id] orelse return false; // A command pane's child is its command, never a shell to type at. if (!pane.isTerminal() or pane.command != null) return false; + // Someone's line at the shell's prompt, typed and not sent: typing a + // command there would run it joined to theirs (`echo TYPEDls`). Only an + // idle, EMPTY prompt is typed at; otherwise a new pane runs the line. + // (Text in pardes's own edit buffer is not the shell's yet: an exec of + // it, or of anything, types only what it runs.) + if (panes.Terminal.promptInputReady(pane) and !panes.Terminal.promptInputEmpty(pane)) return false; // A mounted shell sits behind sudo's process supervisor. Its OSC 133 // prompt marks identify input readiness; the launcher's executable is // not the shell executable used by the ordinary process heuristic. @@ -371,7 +377,7 @@ fn spawnTtyWithMount(p: *Pardes, from: usize, v9fs: bool) ?*Pane { /// Whether `path` is a directory on this host, the turn out while it asks /// (it may be inside a mount this editor serves). -fn isDirectory(path: []const u8) bool { +pub fn isDirectory(path: []const u8) bool { var buf: [4096]u8 = undefined; const z = std.fmt.bufPrintSentinel(&buf, "{s}", .{path}, 0) catch return false; pardes.turn.yield(); diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index d1f920a2..95d81e3b 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -1886,6 +1886,32 @@ test "a terminal told the directory it already goes by logs no rename" { try testing.expect(th.logHas(p, try std.fmt.bufPrint(&rec, "rename {d} /usr", .{p.panes[term].?.serial}))); } +test "a terminal with text typed at its prompt is never typed into: a look at its directory opens another" { + const p = try th.withTerm(testing.allocator); + defer p.deinit(); + const term = p.paneBySerial(serialOf(p)).?; + p.setCwd(term, "/tmp"); + p.update(.{ .output = .{ .pane = @intCast(term), .bytes = "\x1b]133;A;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07TYPED" } }); + while (p.nextEffect()) |_| {} + var count: usize = 0; + for (p.panes) |slot| count += @intFromBool(slot != null); + try testing.expectEqual(Status.ok, wr(p, @intFromEnum(tree.TopFile.look), "/tmp\n").reply.status); + var typed_into = false; + while (p.nextEffect()) |effect| if (effect == .write and effect.write.pane == term) { + typed_into = true; + }; + try testing.expect(!typed_into); + var after: usize = 0; + for (p.panes) |slot| after += @intFromBool(slot != null); + try testing.expectEqual(count + 1, after); + // An exec at it runs in a pane of its own, not typed after TYPED. + _ = wr(p, Node.of(serialOf(p), .exec), "echo hi\n"); + while (p.nextEffect()) |effect| if (effect == .write and effect.write.pane == term) { + typed_into = true; + }; + try testing.expect(!typed_into); +} + test "size is monotonic: growing is never refused, and a size once taken is taken again" { const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 60 }); defer p.deinit(); |
