summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/config.md1
-rw-r--r--docs/themes.md3
-rw-r--r--src/config.zig2
-rw-r--r--src/pardes.zig24
4 files changed, 21 insertions, 9 deletions
diff --git a/docs/config.md b/docs/config.md
index 854b3140..9205539b 100644
--- a/docs/config.md
+++ b/docs/config.md
@@ -270,6 +270,7 @@ inheritance or partial override layer.
foreground on both normal and active tags. When omitted or `null`, it uses
the corresponding tag foreground. Directory text and tag commands retain
their regular colors; selecting filename text uses the selection colors.
+Terminal tags use this color for `Tty`, which comes immediately after the path.
`Filter` in a terminal's tag projects that pane's ANSI colors through the
active theme, and does it in two stages. The default foreground and background
diff --git a/docs/themes.md b/docs/themes.md
index 73da8dad..5c7da44b 100644
--- a/docs/themes.md
+++ b/docs/themes.md
@@ -113,7 +113,8 @@ so existing exported themes remain valid.
Native palettes give filenames a distinct hue at approximately the same
brightness as the surrounding tag text. This also applies to output names
-such as `+Search`; directories and commands retain the regular tag color.
+such as `+Search`. Terminal tags instead tint `Tty`, the first builtin after
+the path. Directory paths and the other commands retain the regular tag color.
These colors are shared by the GUI and TTY. Tags and their active tint retain
the same text, command execution, drag targets and focus behavior. Selection
diff --git a/src/config.zig b/src/config.zig
index 6e88475d..321e0caf 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -224,7 +224,7 @@ pub const topbar_str = "Newcol Joincol Find Grep Help Changelog Tutor Dump NextC
pub const pane_builtins_str = "Tty Del Collapse";
pub const pdf_pane_builtins_str = "Tty Del PdfSections PdfTint Collapse";
pub const file_pane_builtins_str = "Save Tty Del Collapse";
-pub const terminal_pane_builtins_str = "Save Tty Del Togglettymode Filter Collapse";
+pub const terminal_pane_builtins_str = "Tty Save Del Togglettymode Filter Collapse";
// Each mode badge is one codepoint.
pub const tag_normal = " ";
diff --git a/src/pardes.zig b/src/pardes.zig
index cd62eb3b..3965c200 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -281,6 +281,7 @@ const pre_collapse_pane_tail = " Tty Del";
const pre_collapse_file_pane_tail = " Save Tty Del";
const pre_collapse_pdf_pane_tail = " Tty Del PdfSections PdfTint";
const pre_collapse_terminal_pane_tail = " Save Tty Del Togglettymode Filter";
+const pre_tty_first_terminal_pane_tail = " Save Tty Del Togglettymode Filter Collapse";
const Builtin = builtins.registry.Builtin();
@@ -1275,14 +1276,14 @@ test "legacy default tag tails upgrade while custom tails remain owned" {
});
p.restoreTail(terminal, terminal_old);
try std.testing.expect(!terminal.tag_init);
- try std.testing.expectEqualStrings(" Save Tty Del Togglettymode Filter Collapse", Pardes.curTail(terminal));
+ try std.testing.expectEqualStrings(" Tty Save Del Togglettymode Filter Collapse", Pardes.curTail(terminal));
const terminal_previous = try std.fmt.allocPrint(p.scratch.allocator(), "{s} New Del", .{
try p.tagPrefix(terminal),
});
p.restoreTail(terminal, terminal_previous);
try std.testing.expect(!terminal.tag_init);
- try std.testing.expectEqualStrings(" Save Tty Del Togglettymode Filter Collapse", Pardes.curTail(terminal));
+ try std.testing.expectEqualStrings(" Tty Save Del Togglettymode Filter Collapse", Pardes.curTail(terminal));
const terminal_prefilter = try std.fmt.allocPrint(p.scratch.allocator(), "{s}{s}", .{
try p.tagPrefix(terminal),
@@ -1290,7 +1291,7 @@ test "legacy default tag tails upgrade while custom tails remain owned" {
});
p.restoreTail(terminal, terminal_prefilter);
try std.testing.expect(!terminal.tag_init);
- try std.testing.expectEqualStrings(" Save Tty Del Togglettymode Filter Collapse", Pardes.curTail(terminal));
+ try std.testing.expectEqualStrings(" Tty Save Del Togglettymode Filter Collapse", Pardes.curTail(terminal));
const terminal_custom = try std.fmt.allocPrint(p.scratch.allocator(), "{s} Keep Del", .{
try p.tagPrefix(terminal),
@@ -1319,7 +1320,7 @@ test "legacy default tag tails upgrade while custom tails remain owned" {
.terminal = .{ .cwd = "/historical/cwd" },
});
try std.testing.expect(!terminal.tag_init);
- try std.testing.expectEqualStrings(" Save Tty Del Togglettymode Filter Collapse", Pardes.curTail(terminal));
+ try std.testing.expectEqualStrings(" Tty Save Del Togglettymode Filter Collapse", Pardes.curTail(terminal));
// This happens to be the historical FILE default, but on a terminal it is
// user-owned text and must not be swallowed by migration.
@@ -7107,7 +7108,16 @@ pub const Pardes = struct {
return out;
}
- fn tagNameRange(pane: *const Pane, prefix_len: usize) ?struct { lo: usize, hi: usize } {
+ fn tagTintRange(pane: *const Pane, tag: []const u8, prefix_len: usize) ?struct { lo: usize, hi: usize } {
+ if (pane.isTerminal()) {
+ var words = std.mem.tokenizeAny(u8, tag[prefix_len..], " \t\r\n");
+ while (words.next()) |word| {
+ if (!std.mem.eql(u8, word, "Tty")) continue;
+ const lo = @intFromPtr(word.ptr) - @intFromPtr(tag.ptr);
+ return .{ .lo = lo, .hi = lo + word.len };
+ }
+ return null;
+ }
var start: usize = 0;
const name = if (pane.file) |file|
if (pane.tag_name_len) |len| pane.tag_name[0..len] else file.path
@@ -12459,7 +12469,7 @@ pub const Pardes = struct {
pre_collapse_file_pane_tail,
pre_collapse_pane_tail,
},
- .terminal => &.{ terminal_pane_tail, pre_collapse_terminal_pane_tail, pre_column_terminal_pane_tail, pre_tty_terminal_pane_tail, prev_terminal_pane_tail, legacy_terminal_pane_tail, pane_tail, pre_collapse_pane_tail, pre_column_pane_tail, prev_pane_tail, legacy_pane_tail },
+ .terminal => &.{ terminal_pane_tail, pre_tty_first_terminal_pane_tail, pre_collapse_terminal_pane_tail, pre_column_terminal_pane_tail, pre_tty_terminal_pane_tail, prev_terminal_pane_tail, legacy_terminal_pane_tail, pane_tail, pre_collapse_pane_tail, pre_column_pane_tail, prev_pane_tail, legacy_pane_tail },
};
for (defaults) |default|
if (std.mem.eql(u8, said, std.mem.trimStart(u8, default, " "))) return;
@@ -13253,7 +13263,7 @@ pub const Pardes = struct {
tag.len;
const tag_start = @min(tag_cut, panes.File.rawAtDisplay(tag, pane.tag_scroll));
_ = s.print(tx, tag_y, tw, tag[tag_start..tag_cut], tag_style);
- if (tagNameRange(pane, tag.len - curTail(pane).len)) |name| {
+ if (tagTintRange(pane, tag, tag.len - curTail(pane).len)) |name| {
const lo = @max(name.lo, tag_start);
const hi = @min(name.hi, tag_cut);
if (lo < hi) {