summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 20:54:21 -0300
committerGabriel Schneider <[email protected]>2026-11-04 21:12:33 -0300
commit0ff1fc99eb870f8a1e714a71c1a853066737c822 (patch)
tree2c8b4720e2ed190e6f9062cfe8586c3da22aeb42 /src/pardes.zig
parent3b082687c7da1c5d8cc52c71fdf4ddd38d860cd8 (diff)
downloadpardes-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/pardes.zig')
-rw-r--r--src/pardes.zig84
1 files changed, 48 insertions, 36 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index 4c1d0a10..89e99a9b 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -75,7 +75,7 @@ const host_io = @import("host_io.zig");
pub const Host = host_io.Host;
pub const frameMark = tracy.frameMark;
-pub const Platform = enum { tty, gui, web, macos, esp32p4 };
+pub const Platform = enum { tui, gui, web, macos, esp32p4 };
pub const platform: Platform = @field(Platform, @tagName(@import("pardes_config").platform));
pub const theme_animation = @import("pardes_config").theme_animation;
@@ -87,7 +87,7 @@ pub const isolated = @import("pardes_isolation").isolated;
pub const font_picker = platform == .gui or platform == .macos;
-pub const hosted = platform == .tty or platform == .gui or platform == .macos;
+pub const hosted = platform == .tui or platform == .gui or platform == .macos;
/// Whose turn it is with the core. The core is single-threaded: the editor's
/// thread has it, and lets go of it in two kinds of gap -- while it waits for
@@ -174,7 +174,7 @@ pub const Turn = struct {
pub fn yield(t: *Turn) void {
// A replica makes no syscall: each is a site of the tape's. One that
// is none stops a speculation and diverges a replay (it joins
- // again), never the process (a window client's `Tty fish`, H17).
+ // again), never the process (a window client's `Term fish`, H17).
if (tape.replaying()) tape.stray();
const io = t.io orelse return;
yield_depth += 1;
@@ -234,7 +234,7 @@ pub const Turn = struct {
}
};
-pub const can_attach = platform == .tty or platform == .gui;
+pub const can_attach = platform == .tui or platform == .gui;
pub const terminal_panes = platform != .esp32p4;
@@ -253,7 +253,7 @@ pub const sdl_pdf_raster_policy: PdfRasterPolicy = .{
.match_viewport = true,
};
pub const pdf_raster_policy: PdfRasterPolicy = switch (platform) {
- .tty => kitty_pdf_raster_policy,
+ .tui => kitty_pdf_raster_policy,
// Both pixel shells rasterize for a real display and can afford it; the
// wire-bandwidth argument that shapes the Kitty policy does not apply.
.gui, .macos => sdl_pdf_raster_policy,
@@ -638,21 +638,21 @@ test "topbar hover highlights exactly the executable word" {
try std.testing.expectEqual(Color{ .rgb = p.chromeTheme().tag_bg }, left.at(TAG_TEXT_INSET + 1, 0).style.bg);
}
-test "pane-tag Exec prefers Tty and argument builtins before shell fallback" {
+test "pane-tag Exec prefers Term and argument builtins before shell fallback" {
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{ .cols = 100, .rows = 30 });
defer p.deinit();
while (p.nextEffect()) |_| {} // initial shell spawn/geometry
p.acknowledgeShell(0, "/bin/sh", false);
- // The Tty word names the shell the host ran, and opens another of it.
+ // The Term word names the shell the host ran, and opens another of it.
const pane = p.panes[0].?;
- try std.testing.expectEqualStrings(" Tty+sh" ++ tagline.terminal_pane_tail[" Tty".len..], tagline.curTail(pane));
+ try std.testing.expectEqualStrings(" Term+sh" ++ tagline.terminal_pane_tail[" Term".len..], tagline.curTail(pane));
const tag_x = p.rects[0].x + TAG_TEXT_INSET;
const tag_y = p.rects[0].y;
const rendered = try tagline.tagText(p, p.scratch.allocator(), pane);
- const new_x = tag_x + @as(u16, @intCast(std.mem.indexOf(u8, rendered, "Tty").?)) + 1;
+ const new_x = tag_x + @as(u16, @intCast(std.mem.indexOf(u8, rendered, "Term").?)) + 1;
var panes_before: usize = 0;
for (p.panes) |s| if (s != null) {
panes_before += 1;
@@ -914,14 +914,14 @@ test "compact tag commands stay beside their own prefix across layout changes" {
try std.testing.expectEqualStrings(above_tag, try tagline.tagText(p, p.scratch.allocator(), above));
}
-test "Tty spawns a raw shell in the caller's directory" {
+test "Term spawns a raw shell in the caller's directory" {
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 });
defer p.deinit();
while (p.nextEffect()) |_| {}
p.setCwd(0, "/tmp/newtty-dir");
- try std.testing.expect(p.executeBuiltinLine(0, "Tty"));
+ try std.testing.expect(p.executeBuiltinLine(0, "Term"));
const free = p.active;
try std.testing.expect(free != 0);
const nt = p.panes[free] orelse return error.NoNewPane;
@@ -944,11 +944,11 @@ test "a terminal respawned into a closed pane's slot hangs the old shell up firs
// end the new shell and leave the old one running.
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 });
defer p.deinit();
- try std.testing.expect(p.executeBuiltinLine(0, "Tty"));
+ try std.testing.expect(p.executeBuiltinLine(0, "Term"));
const slot = p.active;
while (p.nextEffect()) |_| {}
try p.removePane(slot, null);
- try std.testing.expect(p.executeBuiltinLine(0, "Tty"));
+ try std.testing.expect(p.executeBuiltinLine(0, "Term"));
try std.testing.expectEqual(slot, p.active);
var closed = false;
var spawned = false;
@@ -965,7 +965,7 @@ test "a terminal respawned into a closed pane's slot hangs the old shell up firs
try std.testing.expect(closed and spawned);
}
-test "first document fallback splits like Tty from the originating pane" {
+test "first document fallback splits like Term from the originating pane" {
for ([_]u16{ 100, 198 }) |width| for (0..3) |from| {
for ([_]bool{ false, true }) |collapsed| {
const p = try Pardes.init(std.testing.allocator, .{ .cols = width, .rows = 62, .shells = 3 });
@@ -1608,43 +1608,55 @@ test "a restored terminal's tag names neither the REPL it was nor the shell it h
try std.testing.expect(pane.repl == null and pane.tag.own == null);
const shown = try tagline.tagText(restored, restored.scratch.allocator(), pane);
try std.testing.expect(std.mem.indexOf(u8, shown, "python-a") == null);
- try std.testing.expect(std.mem.indexOf(u8, shown, "Tty+fish") == null);
+ try std.testing.expect(std.mem.indexOf(u8, shown, "Term+fish") == null);
}
-test "a Tty started by a shell's path keeps the path in its Tty+ word" {
+test "a Term started by a shell's path keeps the path in its Term+ word" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
defer p.deinit();
while (p.nextEffect()) |_| {}
- try std.testing.expect(p.executeBuiltinLine(0, "Tty /bin/sh"));
+ try std.testing.expect(p.executeBuiltinLine(0, "Term /bin/sh"));
try std.testing.expect(p.active != 0);
p.acknowledgeShell(p.active, "/bin/sh", false);
- try std.testing.expect(std.mem.startsWith(u8, tagline.curTail(p.panes[p.active].?), " Tty+/bin/sh "));
+ try std.testing.expect(std.mem.startsWith(u8, tagline.curTail(p.panes[p.active].?), " Term+/bin/sh "));
}
-test "Tty+fish, one word a tag can hold, opens a terminal on that shell" {
+test "Tty, Term's old name in saved tags, runs as Term, bare and with its +shell" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
defer p.deinit();
while (p.nextEffect()) |_| {}
- // sh, the one shell every host has.
try std.testing.expect(p.executeBuiltinLine(0, "Tty+sh"));
+ try std.testing.expectEqualStrings("sh", p.panes[p.active].?.shell.?);
+ const first = p.active;
+ p.active = 0;
+ try std.testing.expect(p.executeBuiltinLine(0, "Tty"));
+ try std.testing.expect(p.active != 0 and p.active != first);
+}
+
+test "Term+fish, one word a tag can hold, opens a terminal on that shell" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
+ defer p.deinit();
+ while (p.nextEffect()) |_| {}
+ // sh, the one shell every host has.
+ try std.testing.expect(p.executeBuiltinLine(0, "Term+sh"));
try std.testing.expect(p.active != 0);
try std.testing.expectEqualStrings("sh", p.panes[p.active].?.shell.?);
p.acknowledgeShell(p.active, "/bin/sh", false);
- try std.testing.expect(std.mem.startsWith(u8, tagline.curTail(p.panes[p.active].?), " Tty+sh "));
+ try std.testing.expect(std.mem.startsWith(u8, tagline.curTail(p.panes[p.active].?), " Term+sh "));
p.active = 0;
// A shell that is not there is said, not quietly replaced, and the
// pane that asked gets no shell of its own.
const before = p.active;
const caller = p.panes[0].?;
- try std.testing.expect(p.executeBuiltinLine(0, "Tty /nonexistent"));
+ try std.testing.expect(p.executeBuiltinLine(0, "Term /nonexistent"));
try std.testing.expect(p.active == before and caller.shell == null);
try std.testing.expect(std.mem.indexOf(u8, caller.msg[0..caller.msg_len], "shell \"/nonexistent\" not found") != null);
- try std.testing.expect(p.executeBuiltinLine(0, "Tty fsh-not-a-shell"));
+ try std.testing.expect(p.executeBuiltinLine(0, "Term fsh-not-a-shell"));
try std.testing.expect(caller.shell == null);
// A directory passes access(X_OK); it is no shell either.
- try std.testing.expect(p.executeBuiltinLine(0, "Tty /etc"));
+ try std.testing.expect(p.executeBuiltinLine(0, "Term /etc"));
try std.testing.expect(p.active == before);
- try std.testing.expect(std.mem.indexOf(u8, caller.msg[0..caller.msg_len], "Tty: not a shell: /etc is a directory") != null);
+ try std.testing.expect(std.mem.indexOf(u8, caller.msg[0..caller.msg_len], "Term: not a shell: /etc is a directory") != null);
// Only a word that says so splits at `+`: `Dump+x.zon` is no Dump.
try std.testing.expect(!p.executeBuiltinLine(0, "Dump+x.zon"));
try std.testing.expect(!p.executeBuiltinLine(0, "Msg+hello"));
@@ -2417,13 +2429,13 @@ test "Save reaches every tagline with text behind it and no other" {
// A scratch is an output buffer that wears the FILE tails.
out.file.?.output = .{ .from = .{ .cmd = std.meta.stringToEnum(Builtin, "New").? } };
- try std.testing.expectEqualStrings(" Save Tty Collapse Del", tagline.curTail(out));
+ try std.testing.expectEqualStrings(" Save Term Collapse Del", tagline.curTail(out));
// An image's bytes on disk already are what they are: nothing of the
// pane's own is unwritten, so the word is absent and inert.
const img_id = p.freeSlot().?;
const img = try panes.Image.create(p, img_id, "/tmp/pardes-tag.ppm", &.{});
- try std.testing.expectEqualStrings(" Tty Collapse Del", tagline.curTail(img));
+ try std.testing.expectEqualStrings(" Term Collapse Del", tagline.curTail(img));
try std.testing.expect(p.executeBuiltinLine(img_id, "Save"));
try std.testing.expect(img.prompt != .save);
var buf: [256]u8 = undefined;
@@ -3804,7 +3816,7 @@ pub const Options = struct {
/// window's build replaying a terminal's session starts as it did.
windowed: bool = platform == .gui,
/// The layout to boot, when a host means one outright rather than leaving
- /// it to be read off the options below. `--tty` names `.tty`; a core
+ /// it to be read off the options below. `--tui` names `.tty`; a core
/// booted for a test names nothing and gets `.tty_shell`.
boot: ?Boot = null,
/// initial shell panes: 1 (default) or 3 for the classic two-column boot.
@@ -5024,7 +5036,7 @@ pub const Pardes = struct {
}
/// A shell a dead session left, taken in (Adopt): a terminal pane made
- /// for it as the Tty word makes one, its greeting off (the shell is up
+ /// for it as the Term word makes one, its greeting off (the shell is up
/// already), whose spawn the host answers with that shell's pty. Its id,
/// or null with no room. An input, as every host write into the core
/// is: a replica of the session makes the same pane.
@@ -5035,7 +5047,7 @@ pub const Pardes = struct {
for (p.panes) |slot| if (slot) |pn| {
newest = @max(newest, pn.serial);
};
- _ = p.executeBuiltinLine(p.active, "Tty");
+ _ = p.executeBuiltinLine(p.active, "Term");
for (p.panes, 0..) |slot, id| if (slot) |pn| if (pn.serial > newest and pn.isTerminal()) {
pn.greet = false;
return @intCast(id);
@@ -5061,14 +5073,14 @@ pub const Pardes = struct {
pane.shell_failed = false;
pane.had_shell = true;
pane.fs.unmarked = !prompt_marks;
- // The tag's Tty word names the shell the host ran, and a click
- // on it (`Tty+fish`) opens another of the same.
+ // The tag's Term word names the shell the host ran, and a click
+ // on it (`Term+fish`) opens another of the same.
if (pane.command == null) {
// A shell given as a path keeps it: its bare name would find
// nothing, or another program, on the usual paths.
const base = if (pane.shell) |given| (if (std.mem.indexOfScalar(u8, given, '/') != null) given else std.fs.path.basename(executable)) else std.fs.path.basename(executable);
- const rest = tagline.terminal_pane_tail[" Tty".len..];
- if (std.fmt.bufPrint(&pane.shell_tail, " Tty+{s}{s}", .{ base, rest })) |tail| {
+ const rest = tagline.terminal_pane_tail[" Term".len..];
+ if (std.fmt.bufPrint(&pane.shell_tail, " Term+{s}{s}", .{ base, rest })) |tail| {
pane.shell_tail_len = @intCast(tail.len);
} else |_| {}
}
@@ -5416,7 +5428,7 @@ pub const Pardes = struct {
pane.command_pty = false;
exec.commandDone(p, id, 127);
} else if (pane.command == null and !pane.had_shell) {
- // A Tty whose shell never ran: no dead pane left behind; the
+ // A Term whose shell never ran: no dead pane left behind; the
// write that asked for it has failed with why. A terminal whose
// shell was started again (pty/ctl exec) keeps its pane.
p.unplaced.set(id);
@@ -6244,7 +6256,7 @@ pub const Pardes = struct {
// global window ops (any mode): Alt-n new terminal below, Alt-c move
// the active terminal into a fresh column
if (hit(key, config.new_shell_below)) {
- const free = p.freeSlot() orelse return p.reportError(p.active, "Tty", error.NoPaneSlots);
+ const free = p.freeSlot() orelse return p.reportError(p.active, "Term", error.NoPaneSlots);
const nt = p.newShell(free, "") catch return;
nt.greet = true;
// From a tag, as a 9P new is: acme's t->w == nil.