From 3ebdbe26a14546f8e4ee06462850aad85f1c9646 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 5 Nov 2026 22:59:25 -0300 Subject: settings #3, the terminal's three go, each the value it had by default: Pager (a terminal's shell pages into a +Pager where the environment names no pager, so PAGER and GIT_PAGER set by the user are what an opt-out is; host_io's Paging.terminal_off goes), PagerColor (a +Pager keeps its program's colours; pager.parse loses its colour argument, its callers in Core.zig and ninep/ctl.zig with it) and TermImages (a new terminal draws its images as pixels where it can, Petscii still flips one; terminal.adoptSettings and its call in panes.zig go); deleted tests: "settings: Pager is pardes by default, off taken, anything else refused with its choices" and "PagerColor off: the same text, no spans, overstrike included" (the man page's overstrike case pins what stays); rewritten: TermImages' test as a new terminal drawing pixels, ctl's pager test with the second +Pager keeping its colours, host_io's environment test for the one terminal paging, process/tree's /commands row on Wrap; the reference, setup and changelog say an environment's PAGER is the way out; no golden changes; gates on tui: core-test 964/964, behaviour-test 241/241, unit-test 1480/1481, pane-test 171/172, snap all 105 scripts ok, process-test 0 of 37 failed; gui unit-test 1524/1525 Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/host_io.zig | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'src/host_io.zig') diff --git a/src/host_io.zig b/src/host_io.zig index b7e58506..86df754b 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -1841,8 +1841,8 @@ pub const ChildEnv = struct { /// Which pager a child is given where the user's environment names none: /// a command pane's one-shot shell `cat` (its output is a pane already), - /// a terminal's shell `pardes -` (a +Pager pane) unless `Pager off`. - pub const Paging = enum { command, terminal, terminal_off }; + /// a terminal's shell `pardes -` (a +Pager pane). + pub const Paging = enum { command, terminal }; pub fn build(slots: *Slots, paging: Paging) ?[*:null]const ?[*:0]const u8 { var n: usize = 0; @@ -1865,7 +1865,6 @@ pub const ChildEnv = struct { const defaults: []const [*:0]const u8 = switch (paging) { .command => &cat_pagers, .terminal => pardesPagers(), - .terminal_off => &.{}, }; for (defaults) |default| { const set = for (libc.environ[0..i]) |entry| { @@ -1962,28 +1961,26 @@ test "the child environment replaces the launcher's terminal identity exactly on var slots: ChildEnv.Slots = undefined; // Where the user named no pager: a terminal's shell pages into a - // +Pager pane (`pardes -`), or, Pager off, as the environment says; a - // command pane's through cat. A pager the user named is kept. - for ([_]ChildEnv.Paging{ .terminal, .terminal_off }) |paging| { - var shell_slots: ChildEnv.Slots = undefined; - const shell_envp = ChildEnv.build(&shell_slots, paging) orelse return error.EnvironmentTooLarge; - var said: usize = 0; - var systemd: usize = 0; - var j: usize = 0; - while (shell_envp[j]) |entry| : (j += 1) { - const line = std.mem.span(entry); - if (std.c.getenv("SYSTEMD_PAGER") == null and std.mem.startsWith(u8, line, "SYSTEMD_PAGER=")) systemd += 1; - if (std.c.getenv("SYSTEMD_PAGERSECURE") == null and std.mem.eql(u8, line, "SYSTEMD_PAGERSECURE=0")) systemd += 1; - if (std.mem.startsWith(u8, line, "PAGER=") and std.c.getenv("PAGER") == null) { - try std.testing.expect(paging == .terminal and std.mem.endsWith(u8, line, " -")); - said += 1; - } + // +Pager pane (`pardes -`); a command pane's through cat. A pager the + // user named is kept. + var shell_slots: ChildEnv.Slots = undefined; + const shell_envp = ChildEnv.build(&shell_slots, .terminal) orelse return error.EnvironmentTooLarge; + var said: usize = 0; + var systemd: usize = 0; + var j: usize = 0; + while (shell_envp[j]) |entry| : (j += 1) { + const line = std.mem.span(entry); + if (std.c.getenv("SYSTEMD_PAGER") == null and std.mem.startsWith(u8, line, "SYSTEMD_PAGER=")) systemd += 1; + if (std.c.getenv("SYSTEMD_PAGERSECURE") == null and std.mem.eql(u8, line, "SYSTEMD_PAGERSECURE=0")) systemd += 1; + if (std.mem.startsWith(u8, line, "PAGER=") and std.c.getenv("PAGER") == null) { + try std.testing.expect(std.mem.endsWith(u8, line, " -")); + said += 1; } - if (std.c.getenv("PAGER") == null) try std.testing.expectEqual(@as(usize, if (paging == .terminal) 1 else 0), said); - // systemd's pager and its secure mode off, with ours only. - if (std.c.getenv("SYSTEMD_PAGER") == null and std.c.getenv("SYSTEMD_PAGERSECURE") == null) - try std.testing.expectEqual(@as(usize, if (paging == .terminal) 2 else 0), systemd); } + if (std.c.getenv("PAGER") == null) try std.testing.expectEqual(@as(usize, 1), said); + // systemd's pager and its secure mode off, with ours only. + if (std.c.getenv("SYSTEMD_PAGER") == null and std.c.getenv("SYSTEMD_PAGERSECURE") == null) + try std.testing.expectEqual(@as(usize, 2), systemd); const envp = ChildEnv.build(&slots, .command) orelse return error.EnvironmentTooLarge; var terms: usize = 0; var colorterms: usize = 0; @@ -2126,7 +2123,8 @@ pub fn forkShell( const pages = if (core) |c| if (c.panes[pane]) |pn| pn.command_pages else false else false; const paging: ChildEnv.Paging = if (one_line != null and !pages) .command - else if (core) |c| (if (c.settings.pager == .off) .terminal_off else .terminal) else .terminal; + else + .terminal; const envp = ChildEnv.build(&env_slots, paging); const ws = ptyWinsize(core, cols, rows); // The child says here why it could not become the shell (its chdir or -- cgit v1.3