diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/dump.zig | 8 | ||||
| -rw-r--r-- | src/image.zig | 2 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 16 |
3 files changed, 25 insertions, 1 deletions
diff --git a/src/dump.zig b/src/dump.zig index 1420ea8f..84321457 100644 --- a/src/dump.zig +++ b/src/dump.zig @@ -247,6 +247,10 @@ pub const Image = struct { petscii: bool = false, palette: ImagePalette = .commodore, ascii: bool = true, + /// A PDF's PdfFit and PdfTint, by their tag words (`width`, `filtered`); + /// empty, the defaults, as in dumps from before. + pdf_fit: []const u8 = "", + pdf_tint: []const u8 = "", }; pub const Pane = struct { @@ -961,6 +965,10 @@ fn initDump(gpa: std.mem.Allocator, opts: Options, zon_bytes: []const u8, previo if (pardes.panes.Pdf.openPane(p, i, im.path, src.scroll + 1, .last) catch null) |restored| { if (raw.len > 0) gpa.free(raw); raw = &.{}; + // Its fit and tint as they were (PdfFit, PdfTint). + const pv = &restored.pdf.?; + if (std.meta.stringToEnum(@TypeOf(pv.fit), im.pdf_fit)) |fit| if (fit != pv.fit) pardes.panes.Pdf.toggleFit(restored); + if (std.meta.stringToEnum(@TypeOf(pv.tint), im.pdf_tint)) |tint| while (pv.tint != tint) pardes.panes.Pdf.toggleTint(restored); restored.cols = @max(1, src.cols); restored.rows = @max(1, src.rows); break :restore_image restored; diff --git a/src/image.zig b/src/image.zig index 3a3f1932..9f635d1c 100644 --- a/src/image.zig +++ b/src/image.zig @@ -875,6 +875,8 @@ pub fn dumpPane( .terminal => .terminal, } else .commodore, .ascii = if (pane.image) |state| state.ascii else true, + .pdf_fit = if (comptime pardes.pdf_enabled) (if (pane.pdf) |pv| @tagName(pv.fit) else "") else "", + .pdf_tint = if (comptime pardes.pdf_enabled) (if (pane.pdf) |pv| @tagName(pv.tint) else "") else "", }, }; } diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index c5e47d5d..6c9ee2da 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -382,7 +382,7 @@ fn writeQuoted(w: *std.Io.Writer, s: []const u8) !void { try w.writeByte('\''); } -pub const pane_text_cap = 9 * 12 + 2 * 256 + 4 + "notcurrent ".len + 48; +pub const pane_text_cap = 9 * 12 + 2 * 256 + 4 + "notcurrent ".len + 48 + "collapsed fit:height tint:filtered ".len; /// acme's winctlprint (plan9port wind.c), field for field: serial, tag /// length, body length, isdir (0), the dirty flag, the width in cells, the @@ -412,6 +412,10 @@ pub fn paneText(p: *Pardes, pane: *Pane, buf: []u8) []const u8 { var idbuf: [48]u8 = undefined; const id = exec_line.replId(&idbuf, pane); if (id.len > 0) w.print("{s} ", .{id}) catch {}; + // Then what its tag does not say: Collapse, and a PDF's PdfFit and + // PdfTint, in the words they take. + if (pane.collapsed) w.writeAll("collapsed ") catch {}; + if (comptime pardes.pdf_enabled) if (pane.pdf) |pv| w.print("fit:{s} tint:{s} ", .{ @tagName(pv.fit), @tagName(pv.tint) }) catch {}; return w.buffered(); } @@ -4309,3 +4313,13 @@ test "Lspinfo's answer is the +Lsp pane it fills, as a Rename preview's is its + const shown = p.paneBySerial(p.fs.lsp_result.?).?; try testing.expect(std.mem.endsWith(u8, p.panes[shown].?.file.?.path, "+Lsp")); } + +test "a collapsed pane's ctl says so" { + const p = try withFile(testing.allocator, "x\n"); + defer p.deinit(); + _ = try th.newPane(p); + const id = p.paneBySerial(serialOf(p)).?; + layout.toggleCollapse(p, id); + try testing.expect(p.panes[id].?.collapsed); + try testing.expect(std.mem.endsWith(u8, rd(p, Node.of(serialOf(p), .ctl), 0, 4096).bytes, " collapsed ")); +} |
