diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.zig | 7 | ||||
| -rw-r--r-- | src/pardes.zig | 41 |
2 files changed, 33 insertions, 15 deletions
diff --git a/src/main.zig b/src/main.zig index abf9b22d..a3e7f862 100644 --- a/src/main.zig +++ b/src/main.zig @@ -66,12 +66,13 @@ const help_text = \\Usage: pardes [options] [file|dir] \\ \\With no arguments the shell pane starts in tty mode. A FILE argument - \\(optionally file:LINE) opens it focused beside a terminal on the launch - \\directory; a DIRECTORY argument becomes the cwd shells spawn in. + \\(optionally file:LINE) opens it alone, filling the window; a DIRECTORY + \\argument becomes the cwd shells spawn in. \\ \\Options: \\ --tty start as one shell pane already in tty mode - \\ -n <count> initial shell panes: 1 (default) or 3 (classic) + \\ -n <count> initial shell panes: 1 (default) or 3 (classic). + \\ A FILE argument boots just that file instead. \\ --tty-toggle <key> use Ctrl-<key> to enter/leave tty mode \\ -l <dump.zon> load a dump of another instance (see Dump) \\ -h, --help show this help and exit diff --git a/src/pardes.zig b/src/pardes.zig index aa2ec398..ad530319 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -553,8 +553,12 @@ test "PdfTint cycles pane-local state and exposes it in the live PDF tag" { const full_tag = try p.tagText(p.scratch.allocator(), pane); try std.testing.expect(std.mem.indexOf(u8, full_tag, "full PdfTint") != null); - // The launch companion is a terminal. Running the same pane-scoped word - // there cannot mutate the PDF next to it. + // Running the same pane-scoped word in a terminal cannot mutate the PDF + // next to it. A FILE boot is one pane now, so that terminal is asked for + // here rather than inherited from init. + _ = try p.newPane(1); + p.layoutAppendColumn(1); + p.sync(); // rects for the new column, exactly as the two-pane boot did try std.testing.expect(!hasPdf(p.panes[1].?)); p.runBuiltin(tint_builtin, 1, "", null); try std.testing.expectEqual(PdfTintMode.full, pv.tint); @@ -773,6 +777,11 @@ test "PDF pane geometry change preserves its page-relative position" { .rows = 24, }); defer p.deinit(); + // A FILE boot is one pane now and a lone column always fills the window, + // so the divider drag below needs a second column to take the width from. + _ = try p.newPane(1); + p.layoutAppendColumn(1); + p.sync(); // rects for the new column, exactly as the two-pane boot did const pane = p.panes[0].?; const pv = &pane.pdf.?; p.native_images = true; @@ -1345,6 +1354,14 @@ test "PdfSections output, Look, and n/N share exact cached outline destinations" const p = try Pardes.init(gpa, .{ .file = path, .cols = 80, .rows = 28 }); defer p.deinit(); + // A FILE boot is one pane now, so the launch shell this leans on twice has + // to be asked for: an empty slot 1 would satisfy the inertness check below + // for the wrong reason (runBuiltin drops a null pane before any builtin + // runs) AND would then be handed to the +PdfSections output, which is the + // one pane the look at the end must NOT come from. + _ = try p.newPane(1); + p.layoutAppendColumn(1); + p.sync(); // rects for the new column, exactly as the two-pane boot did while (p.nextEffect()) |_| {} const pdf_pane = p.panes[0].?; const sections = std.meta.stringToEnum(Builtin, "PdfSections") orelse @@ -3741,10 +3758,12 @@ pub const Rect = struct { x: u16, y: u16, w: u16, h: u16 }; pub const Options = struct { tty_only: bool = false, - /// initial shell panes: 1 (default) or 3 for the classic two-column boot + /// initial shell panes: 1 (default) or 3 for the classic two-column boot. + /// A `file` outranks this — see there. shells: u8 = 1, - /// argv FILE (resolved absolute): boot with it focused as a doc pane in - /// the left column, a terminal on the launch directory in the right + /// argv FILE (resolved absolute): boot with it as the ONLY pane, focused + /// and filling the window. It names the whole boot layout, so `shells` is + /// not consulted at all (it never was — the file arm always won). file: ?[]const u8 = null, file_line: usize = 0, tty_toggle: u21 = config.tty_toggle_default, @@ -3932,8 +3951,10 @@ pub const Pardes = struct { const p = try gpa.create(Pardes); p.* = .{ .gpa = gpa, .opts = opts, .screen_w = opts.cols, .screen_h = opts.rows, .scratch = .init(gpa) }; if (opts.file) |path| { - // FILE argv boot: the doc focused in the left column, a terminal - // on the launch directory in the right (files left, shells right) + // FILE argv boot: the doc alone, filling the window. Naming a file + // is asking to READ it, not to be handed a shell you did not ask + // for and have to close — and the launch directory is one Newcol + // away when it is wanted. Doc, PDF and image all boot the same way. _ = initial_doc: { if (comptime pdf_enabled) if (look.isPdfPath(path)) break :initial_doc try p.openPdfView(0, path, opts.file_line); @@ -3941,13 +3962,9 @@ pub const Pardes = struct { break :initial_doc try p.openImageView(0, path); break :initial_doc try file_pane.open(p, 0, path, opts.file_line); }; - const sh = try p.newPane(1); - sh.greet = true; - p.ncol = 2; + p.ncol = 1; p.col_n[0] = 1; p.col_terms[0][0] = 0; - p.col_n[1] = 1; - p.col_terms[1][0] = 1; } else if (opts.tty_only) { _ = try p.newPane(0); p.panes[0].?.mode = .tty; |
