diff options
| -rw-r--r-- | docs/typ/builtins-gui.json | 3 | ||||
| -rw-r--r-- | docs/typ/builtins-tui.json | 3 | ||||
| -rw-r--r-- | docs/typ/reference.typ | 9 | ||||
| -rw-r--r-- | docs/typ/setup.typ | 6 | ||||
| -rw-r--r-- | src/CHANGELOG.md | 5 | ||||
| -rw-r--r-- | src/Core.zig | 2 | ||||
| -rw-r--r-- | src/TerminalImages.zig | 2 | ||||
| -rw-r--r-- | src/config.zig | 25 | ||||
| -rw-r--r-- | src/host_io.zig | 46 | ||||
| -rw-r--r-- | src/main.zig | 2 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 11 | ||||
| -rw-r--r-- | src/pager.zig | 22 | ||||
| -rw-r--r-- | src/panes.zig | 1 | ||||
| -rw-r--r-- | src/terminal.zig | 17 | ||||
| -rw-r--r-- | test/behaviour/settings.zig | 11 | ||||
| -rw-r--r-- | test/process/tree.zig | 2 | ||||
| -rw-r--r-- | test/snapshots/pagercolor.snap | 2 |
17 files changed, 54 insertions, 115 deletions
diff --git a/docs/typ/builtins-gui.json b/docs/typ/builtins-gui.json index db0a4c58..5faa326c 100644 --- a/docs/typ/builtins-gui.json +++ b/docs/typ/builtins-gui.json @@ -69,8 +69,6 @@ {"name": "New", "leader": "SPC f n", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Open an empty scratch pane, <dir>/+New, in this pane's directory."}, {"name": "Newcol", "leader": "SPC c n", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "An empty column right of the keyboard's, its tag taking the keyboard."}, {"name": "NextColor", "leader": "SPC t n", "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Switch to the next bundled theme."}, - {"name": "Pager", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "pardes, off", "doc": "What a terminal's commands page through: pardes, a +Pager pane (pardes -), or off, the environment's own; for terminals started after it."}, - {"name": "PagerColor", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A +Pager keeps its program's colours, on or off; for the next text paged."}, {"name": "Palette", "leader": "SPC t l", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "the C64 palette or the terminal's own 16"}, {"name": "Panes", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Pick an open pane by its name in a query pane under this one (SPC b b)."}, {"name": "PdfFit", "leader": "SPC t z", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Fit the PDF page to the pane by width or by height, flipping between them (or to the one named, `width|height`)."}, @@ -100,7 +98,6 @@ {"name": "Tab", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "A tab's width in cells, 1 through 16, in every pane; bare, it says the width."}, {"name": "TaglineSize", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "Scale the tag font, a percentage."}, {"name": "Term", "leader": "SPC n t", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "A shell in the calling pane's directory, raw from the first frame."}, - {"name": "TermImages", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "real, petscii", "doc": "How a new terminal draws its program's kitty graphics: real, as pixels where it can, or petscii, as glyph art."}, {"name": "Theme", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "Switch to the named theme."}, {"name": "ThemeFile", "leader": null, "also": [], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "Load a theme from a file."}, {"name": "Themes", "leader": "SPC t t", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "List the themes in a pane, each a word to click."}, diff --git a/docs/typ/builtins-tui.json b/docs/typ/builtins-tui.json index 182058c8..861ade79 100644 --- a/docs/typ/builtins-tui.json +++ b/docs/typ/builtins-tui.json @@ -65,8 +65,6 @@ {"name": "New", "leader": "SPC f n", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Open an empty scratch pane, <dir>/+New, in this pane's directory."}, {"name": "Newcol", "leader": "SPC c n", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "An empty column right of the keyboard's, its tag taking the keyboard."}, {"name": "NextColor", "leader": "SPC t n", "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Switch to the next bundled theme."}, - {"name": "Pager", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "pardes, off", "doc": "What a terminal's commands page through: pardes, a +Pager pane (pardes -), or off, the environment's own; for terminals started after it."}, - {"name": "PagerColor", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A +Pager keeps its program's colours, on or off; for the next text paged."}, {"name": "Palette", "leader": "SPC t l", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "the C64 palette or the terminal's own 16"}, {"name": "Panes", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Pick an open pane by its name in a query pane under this one (SPC b b)."}, {"name": "PdfFit", "leader": "SPC t z", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Fit the PDF page to the pane by width or by height, flipping between them (or to the one named, `width|height`)."}, @@ -94,7 +92,6 @@ {"name": "Symbols", "leader": "SPC l s", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the file's symbols from the language server."}, {"name": "Tab", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "A tab's width in cells, 1 through 16, in every pane; bare, it says the width."}, {"name": "Term", "leader": "SPC n t", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "A shell in the calling pane's directory, raw from the first frame."}, - {"name": "TermImages", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "real, petscii", "doc": "How a new terminal draws its program's kitty graphics: real, as pixels where it can, or petscii, as glyph art."}, {"name": "Theme", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "Switch to the named theme."}, {"name": "ThemeFile", "leader": null, "also": [], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "Load a theme from a file."}, {"name": "Themes", "leader": "SPC t t", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "List the themes in a pane, each a word to click."}, diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ index a0452e5b..c9e117e8 100644 --- a/docs/typ/reference.typ +++ b/docs/typ/reference.typ @@ -430,7 +430,7 @@ runs fails with the editor's words (`Mount: already mounted`, `Save /root/x: acc == Settings <settings> -A setting that chooses among words (`on`/`off` switches, #word("Pager")) +A setting that chooses among words (`on`/`off` switches, #word("Pet")) steps to its next value when given bare, as its word clicked in a tag does. The same lines go in the startup file (#doc("config")). @@ -440,11 +440,8 @@ word clicked in a tag does. The same lines go in the startup file [#word("ThemeFile") `<path>`], [a `.zon` theme, relative to the config directory; reloads live when saved], [#word("Verbose")], [on: a builtin announces its name on the message row], [#word("MessageLinger")], [800 milliseconds, at most 60000: how long a message stays after the key or click that dismisses it], - [#word("PagerColor")], [on: the next paged text keeps its colours], [#word("ProgramEsc")], [off: in a raw terminal #key("Esc") goes back a pane and #key("Shift-Esc") is the program's Esc; on swaps them, and #key("Esc") goes back only at an empty shell prompt], - [#word("Pager") `pardes|off`], [`pardes`: what a terminal's commands page through, `pardes -`; `off` leaves `PAGER`, `GIT_PAGER` and `SYSTEMD_PAGER` as the environment has them (#doc("fs", section: "pardes-stdin")). It applies to terminals started after it], [#word("JumpScope") `file|all`], [`file`: #word("Back") and #word("Forward") keep to the focused pane's file, that pane's places first, then the file's in another pane, and go to another file only when the file has no place left that way; from a terminal or a pane with no file they step through every place; `all`: every place, in the order it was jumped to], - [#word("TermImages") `real|petscii`], [`real`: a new terminal draws its program's kitty graphics (yazi's previews) as pixels where the shell can; #word("Petscii") flips one terminal; a tui under a terminal without kitty graphics draws them as glyph art either way], [#word("Shell") `<name or path>`], [`$SHELL` when it is executable, else `/bin/sh`: the shell the next terminal and command pane run; a bare name is searched for in the usual bin directories, not `$PATH`; bare #word("Shell"): `$SHELL` if it is executable, else `/bin/sh`], [#word("DumpDir") `<dir>`], [`$XDG_DATA_HOME/pardes`, else `~/.local/share/pardes`: the directory of the state file, `pardes.xitdb`, which keeps Recent and the dumps and which every session of the user shares (one that cannot be read as one is kept aside as `pardes.xitdb.broken` and a new one started); an absolute or `~` path to a directory that may be written (made if missing); a relative one, or one under a directory that may not be written, is refused; bare returns to the default], [#word("TreeContext")], [off: sticky declaration headers in a source pane, in the tagline style (per pane, dumped)], @@ -1091,7 +1088,7 @@ to its end before the write is answered, and one that finds nothing fails, the directory, left clean, opening at its top, with no line numbers; a `+Pager` already there keeps its page. The session parses the text with ghostty-vt: SGR colours become the `+Pager`'s own display, never part of -its body or any read (#word("PagerColor") `off` pages plain), mapped +its body or any read, mapped through the theme as a terminal's are until its #word("Filter") shows them as sent; every other escape is dropped; a carriage return keeps a progress line's last state, and CRLF becomes LF. Empty stdin shows nothing. Inside a pardes pane it returns at once; a text the session cannot @@ -1101,7 +1098,7 @@ directory's. Outside a pardes pane it starts a new editor whose first pane the text is. Stdin up to a file's limit (256 MiB) arrives whole; past that it is cut, with a note saying so. -With #word("Pager") `pardes`, a terminal's shell gets `PAGER`, `GIT_PAGER` and +A terminal's shell gets `PAGER`, `GIT_PAGER` and `SYSTEMD_PAGER` set to this pardes plus ` -` (the path quoted only when it needs it), and `SYSTEMD_PAGERSECURE=0` (it has no shell escape), each only where your environment does not set it. `man` pages through `MANPAGER` diff --git a/docs/typ/setup.typ b/docs/typ/setup.typ index c94751da..b25175b4 100644 --- a/docs/typ/setup.typ +++ b/docs/typ/setup.typ @@ -80,14 +80,12 @@ fi #cmd("ls --color=always | pardes - # into a new +Pager there, colours kept") -With #word("Pager") `pardes` (the default) a terminal's shell gets +A terminal's shell gets `PAGER`, `GIT_PAGER` and `SYSTEMD_PAGER` set to it (and `SYSTEMD_PAGERSECURE=0`) wherever your environment leaves them unset, so `git log`, `journalctl` and `man` arrive as a pane, a diff drawn as one; command panes page through `cat`. `man` reads `MANPAGER` first, which -pardes never sets. #word("Pager") `off` in the startup file leaves them all -yours, for terminals started after it; #word("PagerColor") `off` makes the -text plain. +pardes never sets. Set them in your environment to keep your own pager. = yazi in a terminal pane <yazi> diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md index 88482e92..3869aa07 100644 --- a/src/CHANGELOG.md +++ b/src/CHANGELOG.md @@ -11,6 +11,11 @@ - FocusTint: the focused pane's and column's tags are tinted. - SyntaxBold: keywords are not bold. - Ligatures: the window draws a font's ligatures. + - Pager: a terminal's shell pages into a +Pager (`pardes -`) where your + environment names no pager; set `PAGER` and `GIT_PAGER` to keep yours. + - PagerColor: a +Pager keeps its program's colours. + - TermImages: a new terminal draws its program's images as pixels where + the shell can; Petscii still flips one terminal to glyph art. - What pardes keeps on disk is in xitdb databases now (a pinned commit of github.com/xit-vcs/xitdb, pure Zig). The state file, `pardes.xitdb` in diff --git a/src/Core.zig b/src/Core.zig index a455cf1c..0f90f4cb 100644 --- a/src/Core.zig +++ b/src/Core.zig @@ -545,7 +545,7 @@ fn initSession(gpa: std.mem.Allocator, opts: Options) !*Pardes { p.oneColumn(); }, .stdin => { - const page = try pager.parse(gpa, opts.stdin_text.?, p.settings.pager_color); + const page = try pager.parse(gpa, opts.stdin_text.?); errdefer gpa.free(page.spans); const content = page.text; errdefer gpa.free(content); diff --git a/src/TerminalImages.zig b/src/TerminalImages.zig index 86c20d2c..9c44ec40 100644 --- a/src/TerminalImages.zig +++ b/src/TerminalImages.zig @@ -21,7 +21,7 @@ const PixelRect = image.PixelRect; pub const storage_limit = 64 * 1024 * 1024; /// This pane asks for its images as glyph art even where pixels could be -/// drawn (the Petscii builtin; TermImages sets it for a new pane). +/// drawn (the Petscii builtin). petscii: bool = false, /// Pixels in RGBA for images ghostty-vt holds in another format (RGB, /// grey): only for images on screen, dropped the frame they are not. diff --git a/src/config.zig b/src/config.zig index edfaf3ed..3d5de631 100644 --- a/src/config.zig +++ b/src/config.zig @@ -117,9 +117,6 @@ pub const leader_path = paths: { .Search = null, .Panes = null, .More = null, - .Pager = null, - .PagerColor = null, - .TermImages = null, .JumpScope = null, .Debug = "td", .Msg = null, @@ -740,17 +737,6 @@ pub const Runtime = struct { tagline_percent: u8 = 100, } = .{}, - /// What a terminal's shell pages through (host_io.ChildEnv): `pardes`, - /// PAGER and GIT_PAGER set to `pardes -`, a +Pager pane, where the - /// user's environment set neither; `off`, the environment as it is. - pager: Pager = .pardes, - /// A +Pager keeps its program's colours (SGR, as spans over the text, - /// pager.zig), or is plain; for the next text paged. - pager_color: bool = true, - /// How a new terminal pane draws the kitty graphics its program sends - /// (yazi's previews): `real`, as pixels where the shell can, or - /// `petscii`, as glyph art. The Petscii builtin flips one pane. - term_images: TermImages = .real, /// What Back and Forward keep to (Jump.jumpBy): `file`, the places in /// the focused pane's file first, other files only once those run out /// that way; `all`, every place in the order it was jumped to. @@ -769,13 +755,11 @@ pub const Runtime = struct { /// +Preview with): it never resizes itself after. search_rows: u16 = 8, - pub const Pager = enum { pardes, off }; - pub const TermImages = enum { real, petscii }; pub const JumpScope = enum { file, all }; pub const SearchPlace = enum { attached, column }; pub const SearchPane = enum { reuse, new }; /// A setting that is one of a few words, each an enum field of Runtime. - pub const Choice = enum { pager, term_images, jump_scope, search_place, search_pane, pet }; + pub const Choice = enum { jump_scope, search_place, search_pane, pet }; pub const Pet = enum { off, cat, frog }; pub const tagline_percent_min: u8 = 1; @@ -845,7 +829,7 @@ pub const Runtime = struct { pub const Capability = std.meta.FieldEnum(Capabilities); - pub const Toggle = enum { wrap, debug, pager_color, verbose, cursor_blink, jump_trail, program_esc }; + pub const Toggle = enum { wrap, debug, verbose, cursor_blink, jump_trail, program_esc }; pub const Action = union(enum) { toggle: Toggle, @@ -917,9 +901,6 @@ pub const Runtime = struct { .{ .word = "TaglineSize", .action = .tagline_size, .doc = "Scale the tag font, a percentage." }, .{ .word = "WindowOpacity", .action = .window_opacity, .doc = "The window's opacity, a percentage." }, .{ .word = "WindowBlur", .action = .window_blur, .doc = "The blur behind a translucent window, a radius." }, - .{ .word = "Pager", .action = .{ .choice = .pager }, .doc = "What a terminal's commands page through: pardes, a +Pager pane (pardes -), or off, the environment's own; for terminals started after it." }, - .{ .word = "PagerColor", .action = .{ .toggle = .pager_color }, .doc = "A +Pager keeps its program's colours, on or off; for the next text paged." }, - .{ .word = "TermImages", .action = .{ .choice = .term_images }, .doc = "How a new terminal draws its program's kitty graphics: real, as pixels where it can, or petscii, as glyph art." }, .{ .word = "JumpScope", .action = .{ .choice = .jump_scope }, .doc = "What Back and Forward keep to: file, the focused pane's file until it runs out that way, or all, every place in order." }, .{ .word = "CallstackDepth", .action = .callstack_depth, .doc = "Caller levels collected by Callstack, 1 through 64; default 8. Bare, it says the current limit." }, .{ .word = "Tab", .action = .tab, .doc = "A tab's width in cells, 1 through 16, in every pane; bare, it says the width." }, @@ -1332,7 +1313,7 @@ pub const Runtime = struct { }; const values = [_][2][]const u8{ .{ "TaglineSize", "73" }, .{ "WindowOpacity", "85" }, .{ "WindowBlur", "40" }, - .{ "MessageLinger", "1500" }, .{ "DumpDir", "~/dumps" }, .{ "TermImages", "petscii" }, + .{ "MessageLinger", "1500" }, .{ "DumpDir", "~/dumps" }, .{ "JumpScope", "all" }, .{ "SearchPlace", "column" }, .{ "SearchPane", "new" }, .{ "GripWidth", "200" }, .{ "InactiveDim", "35" }, .{ "CallstackDepth", "16" }, .{ "Tab", "8" }, .{ "SearchRows", "12" }, 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 diff --git a/src/main.zig b/src/main.zig index afa72881..be66e8e2 100644 --- a/src/main.zig +++ b/src/main.zig @@ -61,7 +61,7 @@ const help_text = \\With no arguments the shell pane starts in tty mode. A FILE argument \\(optionally file:LINE) opens it alone, filling the window; a DIRECTORY \\argument becomes the cwd shells spawn in. `-` reads stdin into a +Pager - \\pane, its colours kept (PagerColor) and every other escape dropped: + \\pane, its colours kept and every other escape dropped: \\inside a pardes pane the outer session's, returning at once (a \\terminal's PAGER), else a new editor's. \\ diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index f8cda59a..3784cf41 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -690,7 +690,7 @@ pub fn writePager(p: *Pardes, req: Req) Reply { /// The text a /pager open wrote after its directory (`held`), a program's /// output for a terminal, put in the +Pager `serial` as `pardes -` once /// wrote it to the body: through ghostty-vt (pager.zig), its colours kept -/// as the pane's spans unless PagerColor is off, one undo step, and left +/// as the pane's spans, one undo step, and left /// clean. Reads of the pane are its plain text. The held bytes go either way. pub fn fillPager(p: *Pardes, serial: u32, held: *std.ArrayList(u8)) error{OutOfMemory}!void { if (held.items.len == 0) return; @@ -698,7 +698,7 @@ pub fn fillPager(p: *Pardes, serial: u32, held: *std.ArrayList(u8)) error{OutOfM const id = p.paneBySerial(serial) orelse return; const pane = p.panes[id].?; const f = if (pane.file) |*file| file else return; - const page = try pardes.pager.parse(p.gpa, held.items, p.settings.pager_color); + const page = try pardes.pager.parse(p.gpa, held.items); held.clearAndFree(p.gpa); if (page.text.len == 0 and f.content.len == 0) return page.deinit(p.gpa); if (!pane.fs.nomark) panes.File.pushUndo(p, pane); @@ -2715,9 +2715,8 @@ test "what a /pager open writes after its directory is the text: plain in the bo try testing.expectEqualStrings("red /a\nNext\n", f.content); try testing.expectEqual(@as(usize, 0), f.pager_spans.len); - // PagerColor off, and an open closed with no read: the same text, plain, - // in at the editor's next step (a close through a mount never waits). - p.settings.pager_color = false; + // An open closed with no read: the text in at the editor's next step + // (a close through a mount never waits), its colours kept. const kept = try testing.allocator.dupe(u8, f.content); defer testing.allocator.free(kept); const shut = call(p, .{ .tag = 7, .op = .open, .node = pager, .omode = 1 }).reply.handle; @@ -2734,7 +2733,7 @@ test "what a /pager open writes after its directory is the text: plain in the bo try testing.expectEqualStrings("", next.content); fillClosedPagers(p); try testing.expectEqualStrings("green\n", next.content); - try testing.expectEqual(@as(usize, 0), next.pager_spans.len); + try testing.expectEqual(@as(usize, 1), next.pager_spans.len); try testing.expectEqual(next.revision, next.saved_revision); } diff --git a/src/pager.zig b/src/pager.zig index 9102fb84..e4ccbab4 100644 --- a/src/pager.zig +++ b/src/pager.zig @@ -28,10 +28,10 @@ pub const Page = struct { } }; -/// `raw`, a program's output for a terminal, as text and, `colour` on -/// (PagerColor), its spans. Both are `gpa`'s. -pub fn parse(gpa: std.mem.Allocator, raw: []const u8, colour: bool) !Page { - var h: Handler = .{ .gpa = gpa, .colour = colour }; +/// `raw`, a program's output for a terminal, as text and its spans. Both +/// are `gpa`'s. +pub fn parse(gpa: std.mem.Allocator, raw: []const u8) !Page { + var h: Handler = .{ .gpa = gpa }; errdefer h.text.deinit(gpa); errdefer h.spans.deinit(gpa); try h.text.ensureTotalCapacity(gpa, raw.len); @@ -46,7 +46,6 @@ pub fn parse(gpa: std.mem.Allocator, raw: []const u8, colour: bool) !Page { const Handler = struct { gpa: std.mem.Allocator, - colour: bool, text: std.ArrayList(u8) = .empty, spans: std.ArrayList(Span) = .empty, /// What SGR has set so far. @@ -74,7 +73,7 @@ const Handler = struct { const cp = std.unicode.utf8Decode(h.text.items[h.last..]) catch return; for (0..@min(value, 1024)) |_| h.print(cp); }, - .set_attribute => if (h.colour) h.attribute(value), + .set_attribute => h.attribute(value), .linefeed => { h.append("\n"); h.line_start = h.text.items.len; @@ -178,7 +177,7 @@ const Handler = struct { /// `from` to the text's end drawn in `style`: the span before it goes /// on when it ends there in the same style. fn span(h: *Handler, from: usize, style: CellStyle) void { - if (!h.colour or std.meta.eql(style, CellStyle{})) return; + if (std.meta.eql(style, CellStyle{})) return; const end: u32 = @intCast(h.text.items.len); if (h.spans.items.len > 0) { const tail = &h.spans.items[h.spans.items.len - 1]; @@ -249,7 +248,7 @@ const testing = std.testing; /// The text `raw` pages to, and its spans as `text[start..end]=style` lines. fn expectPage(raw: []const u8, text: []const u8, spans: []const struct { []const u8, CellStyle }) !void { - const page = try parse(testing.allocator, raw, true); + const page = try parse(testing.allocator, raw); defer page.deinit(testing.allocator); try testing.expectEqualStrings(text, page.text); for (spans, 0..) |want, i| { @@ -350,13 +349,6 @@ test "bytes that are not UTF-8 page as U+FFFD, the text around them kept" { try expectPage("caf\xe9 \xff\xfe ok\n", "caf\u{fffd} \u{fffd}\u{fffd} ok\n", &.{}); } -test "PagerColor off: the same text, no spans, overstrike included" { - const page = try parse(testing.allocator, "\x1b[31mred\x1b[m N\x08N\n", false); - defer page.deinit(testing.allocator); - try testing.expectEqualStrings("red N\n", page.text); - try testing.expectEqual(@as(usize, 0), page.spans.len); -} - test "a carriage return's rewrite takes the spans of what it rewrote with it" { try expectPage("\x1b[31m10%\r\x1b[32m100%\x1b[m\n", "100%\n", &.{.{ "100%", .{ .fg = .{ .index = 2 } } }}); } diff --git a/src/panes.zig b/src/panes.zig index c0783ac7..2e1e9262 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -845,7 +845,6 @@ pub fn installPane(p: *Pardes, id: usize, pane: *Pane) void { p.rects[id] = .{}; p.panes[id] = pane; views.installed(p, pane); - panes.terminal.adoptSettings(p, pane); // /log hears of it once the update that made it ends, when it has // its file, name and place (`ctlfs.events.announce`). pane.fs.unannounced = true; diff --git a/src/terminal.zig b/src/terminal.zig index 4cde89a4..c9c60b5b 100644 --- a/src/terminal.zig +++ b/src/terminal.zig @@ -3088,13 +3088,6 @@ pub fn petscii(pane: *const Pane) ?bool { return state.images.petscii; } -/// A new terminal takes TermImages: pixels, or glyph art. -pub fn adoptSettings(p: *const Pardes, pane: *Pane) void { - if (comptime !images_enabled) return; - const state = pane.terminal orelse return; - state.images.petscii = p.settings.term_images == .petscii; -} - /// Whether the screen showing holds any kitty graphics image. pub fn hasImages(pane: *const Pane) bool { if (comptime !images_enabled) return false; @@ -3399,23 +3392,17 @@ test "a terminal's image is a placement whatever the frontend draws, and the Pet try std.testing.expect(!imagePlaces(s)[0].art.glyph); } -test "TermImages is real by default, and petscii makes new terminals draw glyph art" { +test "a new terminal draws its program's images as pixels, and one without images says nothing of them" { if (comptime !images_enabled) return error.SkipZigTest; const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .shells = 1 }); defer p.deinit(); - try std.testing.expectEqual(config.Runtime.TermImages.real, p.settings.term_images); try std.testing.expectEqual(false, petscii(p.panes[0].?).?); // A pane without images says nothing of them. try std.testing.expect(std.mem.indexOf(u8, try tagline.tagPrefix(p, p.panes[0].?), "petscii") == null); - try std.testing.expect(p.executeBuiltinLine(0, "TermImages petscii")); - try std.testing.expectEqual(config.Runtime.TermImages.petscii, p.settings.term_images); - // The setting is for new panes: the one there keeps its choice. - try std.testing.expectEqual(false, petscii(p.panes[0].?).?); const id = p.freeSlot().?; const fresh = try p.newShell(id, ""); - try std.testing.expectEqual(true, petscii(fresh).?); - try std.testing.expect(std.mem.indexOf(u8, try tagline.tagPrefix(p, fresh), " petscii:on") != null); + try std.testing.expectEqual(false, petscii(fresh).?); } test "a program asking the cell size in pixels (CSI 16 t) is told the shell's" { diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig index fdb37fa3..113a423b 100644 --- a/test/behaviour/settings.zig +++ b/test/behaviour/settings.zig @@ -14,17 +14,6 @@ fn setting(s: *Session, word: []const u8) ![]const u8 { return error.NoSuchSetting; } -test "settings: Pager is pardes by default, off taken, anything else refused with its choices" { - var s = try Session.initFile(std.testing.allocator, "x\n"); - defer s.deinit(); - try std.testing.expectEqualStrings("Pager pardes", try setting(&s, "Pager")); - try s.write("/ctl", "Pager off\n"); - try std.testing.expectEqualStrings("Pager off", try setting(&s, "Pager")); - try std.testing.expectEqual(@as(u16, 22), try s.refused("/ctl", "Pager less\n")); - try std.testing.expectEqualStrings("bad value in control message; takes pardes, off \"less\"", s.said); - try std.testing.expectEqualStrings("Pager off", try setting(&s, "Pager")); -} - test "settings: Shell refuses a path that is no executable, and bare it goes back to the default" { var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); diff --git a/test/process/tree.zig b/test/process/tree.zig index 0136cc80..8a0a8e13 100644 --- a/test/process/tree.zig +++ b/test/process/tree.zig @@ -258,7 +258,7 @@ fn discovery(gpa: std.mem.Allocator, exe: [:0]const u8) !void { if (std.mem.eql(u8, which, "arg")) which = w.next().?; try expect(contains(&.{ "root", "pane", "both" }, which)); } - try expect(row(commands, "Pager arg root pardes,off")); + try expect(row(commands, "Wrap arg root on,off")); try expect(std.mem.endsWith(u8, commands, "\n")); try expectEqual(commands.len, (try c.stat("/commands")).length); try c.write(f.at("/pane/{d}/ctl", .{first}), "Msg said through ctl\n"); diff --git a/test/snapshots/pagercolor.snap b/test/snapshots/pagercolor.snap index 650792b3..70630b0d 100644 --- a/test/snapshots/pagercolor.snap +++ b/test/snapshots/pagercolor.snap @@ -1,4 +1,4 @@ -# `pardes -` keeps a program's colours (PagerColor, on by default): its SGR +# `pardes -` keeps a program's colours: its SGR # becomes the +Pager's own colours over the plain text (red through the # theme's palette, truecolor as given, bold and underline, a man page's # overstrike), and every other escape (the OSC title) is dropped. The |
