diff options
Diffstat (limited to 'src/tagline.zig')
| -rw-r--r-- | src/tagline.zig | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/tagline.zig b/src/tagline.zig index 5a9e2346..d13f3c5f 100644 --- a/src/tagline.zig +++ b/src/tagline.zig @@ -23,6 +23,7 @@ pub const context_pane_tail = file_pane_tail ++ " TreeContext"; pub const locations_pane_tail = file_pane_tail ++ " LocationsConfig"; pub const terminal_pane_tail = " " ++ config.terminal_pane_builtins_str; pub const command_pane_tail = " " ++ config.command_pane_builtins_str; +pub const dir_pane_tail = " " ++ config.dir_pane_builtins_str; /// A file with changes it has not saved. pub fn dirty(pane: *const panes.Pane) bool { const f = pane.file orelse return false; @@ -94,10 +95,11 @@ fn shownDir(arena: std.mem.Allocator, pane: *Pane) ![]const u8 { /// The computed start of a pane's tag -- its path and dirty marker, a /// PDF's page, a terminal's directory -- without the space that parts it /// from the tag's own text. It is never stored, and never edited. -pub fn pathPrefix(arena: std.mem.Allocator, pane: *Pane) ![]const u8 { +pub fn pathPrefix(p: *const Pardes, arena: std.mem.Allocator, pane: *Pane) ![]const u8 { if (comptime pdf_enabled) if (pane.pdf) |pv| return std.fmt.allocPrint(arena, "{s} [{d}/{d}]", .{ pv.path, pv.page + 1, pv.page_count }); - if (pane.image) |*state| return panes.Image.tagPrefix(arena, state); + // What is drawn: with no graphics, glyph art whatever `Petscii` says. + if (pane.image) |*state| return panes.Image.tagPrefix(arena, state, state.glyph_art or !p.native_images); // A command pane: its directory, the line it runs, and how that went. // Its first line only, cut to 48 bytes at a character's start: a tag's // first row is where the prefix ends, and a line that ran over to a @@ -127,18 +129,21 @@ pub fn pathPrefix(arena: std.mem.Allocator, pane: *Pane) ![]const u8 { if (pane.file) |f| return if (pane.prompt == .name) pane.input.own orelse f.path else f.path; // A terminal showing kitty graphics says how it draws them, as an image // pane does, and so does one drawing them as glyph art by choice. - if (panes.terminal.petscii(pane)) |on| if (on or panes.terminal.hasImages(pane)) - return std.fmt.allocPrint(arena, "{s} petscii:{s}", .{ (try shownDir(arena, pane)), if (on) "on" else "off" }); + if (panes.terminal.petscii(pane)) |chosen| { + const on = chosen or !p.native_images; + if (chosen or panes.terminal.hasImages(pane)) + return std.fmt.allocPrint(arena, "{s} petscii:{s}", .{ (try shownDir(arena, pane)), if (on) "on" else "off" }); + } return (try shownDir(arena, pane)); } pub fn tagPrefix(p: *Pardes, pane: *Pane) ![]u8 { - return prefixIn(p.scratch.allocator(), pane); + return prefixIn(p, p.scratch.allocator(), pane); } /// The prefix as the tag shows it, built in `arena`. -pub fn prefixIn(arena: std.mem.Allocator, pane: *Pane) ![]u8 { - const prefix = try pathPrefix(arena, pane); +pub fn prefixIn(p: *const Pardes, arena: std.mem.Allocator, pane: *Pane) ![]u8 { + const prefix = try pathPrefix(p, arena, pane); // The space between the prefix and the tag's own text is the text's // (every default starts with one), but the prefix is computed, so it // cannot trust the text to keep it: with it deleted, Look and Exec @@ -158,6 +163,7 @@ pub fn curTail(pane: *Pane) []const u8 { pub fn defaultTail(pane: *const Pane) []const u8 { if (comptime pdf_enabled) if (pane.pdf != null) return pdf_pane_tail; + if (pane.file) |file| if (file.listing != null) return dir_pane_tail; if (pane.file) |file| if (file.output) |out| if (panes.Output.usesLocationsConfig(out.from)) return locations_pane_tail; if (panes.File.supportsContext(pane)) return context_pane_tail; |
