diff options
Diffstat (limited to 'src/tagline.zig')
| -rw-r--r-- | src/tagline.zig | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/tagline.zig b/src/tagline.zig index d13f3c5f..b6601d61 100644 --- a/src/tagline.zig +++ b/src/tagline.zig @@ -19,8 +19,19 @@ const Pardes = pardes.Pardes; pub const pane_tail = " " ++ config.pane_builtins_str; pub const pdf_pane_tail = " " ++ config.pdf_pane_builtins_str; pub const file_pane_tail = " " ++ config.file_pane_builtins_str; -pub const context_pane_tail = file_pane_tail ++ " TreeContext"; -pub const locations_pane_tail = file_pane_tail ++ " LocationsConfig"; +fn withFileCommands(comptime tail: []const u8, comptime words: []const u8) []const u8 { + std.debug.assert(std.mem.endsWith(u8, tail, " Del")); + return tail[0 .. tail.len - " Del".len] ++ " " ++ words ++ " Del"; +} +pub const context_pane_tail = withFileCommands(file_pane_tail, "TreeContext"); +pub const locations_pane_tail = withFileCommands(file_pane_tail, "LocationsConfig"); +/// Language commands precede the final Del, like other file-pane commands. +pub const lsp_pane_tail = withFileCommands(file_pane_tail, config.lsp_pane_builtins_str); +pub const lsp_context_pane_tail = withFileCommands(context_pane_tail, config.lsp_pane_builtins_str); +pub const pager_pane_tail = " " ++ config.pager_pane_builtins_str; +pub const diff_pane_tail = " " ++ config.diff_pane_builtins_str; +pub const pager_diff_pane_tail = " " ++ config.pager_diff_pane_builtins_str; +pub const diff_view_tail = withFileCommands(" " ++ config.diff_view_builtins_str, "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; @@ -69,7 +80,7 @@ pub fn revealHeader(p: *Pardes) void { if (cur < p.header_top) p.header_top = cur; if (rows > 0 and cur >= p.header_top + rows) p.header_top = cur + 1 - rows; const line = modal.lineSlice(text, cur); - const width = p.tagCapacity(if (p.header_column) |c| p.col_w[c] -| TAG_TEXT_INSET else p.screen_w); + const width = p.tagCapacity(if (p.header_column) |c| p.col_w[c] -| TAG_TEXT_INSET else p.screen_w -| TAG_TEXT_INSET); const col = panes.File.rawDisplayCol(line, @min(@as(usize, @intCast(@max(0, t.cur_col))), line.len)); if (col < p.header_scroll) p.header_scroll = col; if (col >= p.header_scroll + width) p.header_scroll = col -| (width -| 1); @@ -164,10 +175,15 @@ 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 (pane.file) |file| if (file.pager) return if (file.pager_diff) pager_diff_pane_tail else pager_pane_tail; + if (pane.file != null and pane.colorAlgo() == .diff) return diff_pane_tail; + if (pane.file) |file| if (file.output) |out| { + if (std.meta.eql(out.from, panes.Output.Origin{ .cmd = .Diff })) return diff_view_tail; if (panes.Output.usesLocationsConfig(out.from)) return locations_pane_tail; - if (panes.File.supportsContext(pane)) return context_pane_tail; - if (pane.file != null) return file_pane_tail; + }; + const speaks = if (pane.file) |file| file.output == null and file.mini == null and pardes.lsp.speaks(file.path) else false; + if (panes.File.supportsContext(pane)) return if (speaks) lsp_context_pane_tail else context_pane_tail; + if (pane.file != null) return if (speaks) lsp_pane_tail else file_pane_tail; if (pane.command != null) return command_pane_tail; if (pane.isTerminal()) return if (pane.shell_tail_len > 0) pane.shell_tail[0..pane.shell_tail_len] else terminal_pane_tail; return pane_tail; @@ -468,4 +484,3 @@ test "a pane tag wraps a long line onto rows, and offsets map both ways" { try std.testing.expectEqual(@as(usize, 10), shown.toReal(11)); // the 'e' of Del try std.testing.expectEqual(@as(usize, 11), shown.fromReal(10)); } - |
