summaryrefslogtreecommitdiff
path: root/src/tagline.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 22:48:21 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commitf0e162d287f44a562ff79e7c1d2cf81ace00c836 (patch)
tree098428d08600eef0a8eb28939cad955315dd3d95 /src/tagline.zig
parent6f42f51cd652e189408eace598f99ec25b9542f8 (diff)
downloadpardes-f0e162d287f44a562ff79e7c1d2cf81ace00c836.tar.gz
pardes-f0e162d287f44a562ff79e7c1d2cf81ace00c836.zip
Dumps and init files from before 0.0.4 load no more of their old tag formats, and three orphan test scripts go
A2: a restored pane's tag tail comes from the dump's tag_tail, which every dump since 0.0.4 writes; the 27 earlier default tails that were recognised to upgrade, restoreTail, tailClass, savedPrefix and restoreTailAt, pdf_view's and image's legacySavedPrefix, a terminal's TTY tag prefix and its raw output tail replay, and the ThemeSel, FontSel and ColumnTags words (init lines and dumped output names) go, with their tests; the CHANGELOG says so. A4: test/fs_soak.py, referenced nowhere (monkey9p.py does its work). A6: test/column_grip.py and test/look_placement.py, referenced nowhere; the six review scripts docs/ui-review.md names stay. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/tagline.zig')
-rw-r--r--src/tagline.zig135
1 files changed, 4 insertions, 131 deletions
diff --git a/src/tagline.zig b/src/tagline.zig
index df093925..1923871a 100644
--- a/src/tagline.zig
+++ b/src/tagline.zig
@@ -23,43 +23,11 @@ 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;
-/// The mark a tag carried after an unsaved file's name before the grip
-/// showed it; a dump from then still has it in its saved tags.
-const dirty_marker = " *";
-
/// A file with changes it has not saved.
pub fn dirty(pane: *const panes.Pane) bool {
const f = pane.file orelse return false;
return panes.Output.fileTraits(f.output).saves and (f.revision != f.saved_revision or f.disk_gone);
}
-pub const legacy_pane_tail = " Del";
-pub const legacy_file_pane_tail = " Save Del";
-// The defaults from the release before Newtty joined every tagline. Recognized
-// so a dump written then upgrades instead of keeping the old word as a tail.
-const prev_pane_tail = " New Del";
-pub const prev_file_pane_tail = " Save New Del";
-const legacy_terminal_pane_tail = " New Del Filter";
-// ...and the terminal default from the release before Save reached it, when a
-// scrollback was not yet something you could write to a path.
-pub const prev_terminal_pane_tail = " New Newtty Del Filter";
-const pre_tty_terminal_pane_tail = " Save New Newtty Del Filter";
-const pre_column_pane_tail = " New Newtty Del";
-pub const pre_column_file_pane_tail = " Save New Newtty Del";
-const pre_column_pdf_pane_tail = " New Newtty Del PdfSections PdfTint";
-pub const pre_column_terminal_pane_tail = " Save New Newtty Del Tty Filter";
-const pre_collapse_pane_tail = " Tty Del";
-pub const pre_collapse_file_pane_tail = " Save Tty Del";
-const pre_collapse_pdf_pane_tail = " Tty Del PdfSections PdfTint";
-pub const pre_collapse_terminal_pane_tail = " Save Tty Del Togglettymode Filter";
-pub const pre_tty_first_terminal_pane_tail = " Save Tty Del Togglettymode Filter Collapse";
-pub const pre_mode_terminal_pane_tail = " Tty Save Del Togglettymode Filter Collapse";
-// ...and the defaults from before the closing word moved to the end of every
-// tagline, where a click cannot land on it by overshooting the one before.
-const pre_close_last_pane_tail = " Tty Del Collapse";
-const pre_close_last_file_pane_tail = " Save Tty Del Collapse";
-const pre_close_last_pdf_pane_tail = " Tty Del PdfSections PdfTint Collapse";
-const pre_close_last_terminal_pane_tail = " Tty Save Del Mode Filter Collapse";
-
/// What a column's tag says until someone edits it.
pub const column_tag_default = "New Tty Find Grep Joincol Delcol";
@@ -420,106 +388,11 @@ pub fn enterHeader(p: *Pardes, column: ?usize) void {
t.normal.clear();
}
+/// A dump's tag tail, what was typed after the name: a dump from 0.0.4 on
+/// writes it, and an older one's saved tag is not read.
pub fn restoreDumpTail(p: *Pardes, pane: *Pane, src: dump.Pane) void {
- if (src.tag_tail) |tail| {
- pane.tag.own = p.gpa.dupe(u8, tail) catch return;
- return;
- }
- const tail_class = tailClass(pane);
- if (src.kind == .image and panes.Pdf.isPath(src.image.?.path)) {
- if (panes.Pdf.legacySavedPrefix(src.image.?.path, src.tag)) |prefix|
- return restoreTailAt(p, pane, src.tag, prefix, .generic);
- }
- if (src.kind == .terminal and std.mem.startsWith(u8, src.tag, "TTY ")) {
- const legacy = std.fmt.allocPrint(p.scratch.allocator(), "TTY {s}", .{src.terminal.?.cwd}) catch return;
- if (std.mem.startsWith(u8, src.tag, legacy))
- return restoreTailAt(p, pane, src.tag, legacy, .terminal);
- }
- const current = tagPrefix(p, pane) catch return;
- if (std.mem.startsWith(u8, src.tag, current))
- return restoreTailAt(p, pane, src.tag, savedPrefix(src.tag, current, tail_class), tail_class);
- if (src.kind != .image) return;
- const saved = src.image.?;
- if (pane.image) |*state| if (panes.Image.legacySavedPrefix(state, src.tag)) |legacy|
- return restoreTailAt(p, pane, src.tag, legacy, .generic);
- if (panes.Pdf.isPath(saved.path)) if (panes.Pdf.legacySavedPrefix(saved.path, src.tag)) |legacy|
- restoreTailAt(p, pane, src.tag, legacy, .generic);
-}
-
-pub fn restoreTail(p: *Pardes, pane: *Pane, saved_tag: []const u8) void {
- const pfx = tagPrefix(p, pane) catch return;
- const class = tailClass(pane);
- restoreTailAt(p, pane, saved_tag, savedPrefix(saved_tag, pfx, class), class);
-}
-
-const TailClass = enum { generic, file, output, terminal };
-
-fn tailClass(pane: *const Pane) TailClass {
- if (pane.file) |f| return if (f.output == null) .file else .output;
- if (pane.isTerminal()) return .terminal;
- return .generic;
-}
-
-fn savedPrefix(saved_tag: []const u8, live: []const u8, class: TailClass) []const u8 {
- if (class == .generic or class == .terminal) return live;
- if (!std.mem.startsWith(u8, saved_tag, live)) return live;
- const marked_len = live.len + dirty_marker.len;
- if (saved_tag.len >= marked_len and std.mem.eql(u8, saved_tag[live.len..marked_len], dirty_marker))
- return saved_tag[0..marked_len];
- return live;
-}
-
-pub fn restoreTailAt(
- p: *Pardes,
- pane: *Pane,
- saved_tag: []const u8,
- pfx: []const u8,
- class: TailClass,
-) void {
- if (!std.mem.startsWith(u8, saved_tag, pfx)) return;
- const rest = saved_tag[pfx.len..];
- const said = std.mem.trimStart(u8, rest, " ");
- const defaults: []const []const u8 = switch (class) {
- .generic => &.{ pdf_pane_tail, pane_tail, pre_close_last_pdf_pane_tail, pre_close_last_pane_tail, pre_collapse_pdf_pane_tail, pre_collapse_pane_tail, pre_column_pdf_pane_tail, pre_column_pane_tail, prev_pane_tail, legacy_pane_tail },
- .file => &.{ context_pane_tail, file_pane_tail, pre_close_last_file_pane_tail, pre_collapse_file_pane_tail, pre_column_file_pane_tail, prev_file_pane_tail, legacy_file_pane_tail },
- .output => &.{
- locations_pane_tail,
- file_pane_tail,
- pre_close_last_file_pane_tail,
- pre_close_last_pane_tail,
- prev_file_pane_tail,
- legacy_file_pane_tail,
- pane_tail,
- prev_pane_tail,
- legacy_pane_tail,
- pre_column_file_pane_tail,
- pre_column_pane_tail,
- pre_collapse_file_pane_tail,
- pre_collapse_pane_tail,
- },
- .terminal => &.{ terminal_pane_tail, pre_close_last_terminal_pane_tail, pre_close_last_pane_tail, pre_mode_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 },
- };
- // A terminal's saved tag carries what was live about it -- the REPL id
- // after its directory, the shell in its Tty word -- which is neither
- // dumped nor true of the new shell: its tail is still the default.
- var plain = said;
- var plain_buf: [256]u8 = undefined;
- if (class == .terminal) {
- const first = plain[0 .. std.mem.indexOfScalar(u8, plain, ' ') orelse plain.len];
- if (std.mem.lastIndexOfScalar(u8, first, '-')) |dash| if (dash + 2 == first.len and first[dash + 1] >= 'a' and first[dash + 1] <= 'z') {
- for (@import("grammar_manifest.zig").all) |g| if (std.mem.eql(u8, g.name, first[0..dash])) {
- plain = std.mem.trimStart(u8, plain[first.len..], " ");
- break;
- };
- };
- if (std.mem.startsWith(u8, plain, "Tty+")) {
- const word_end = std.mem.indexOfScalar(u8, plain, ' ') orelse plain.len;
- plain = std.fmt.bufPrint(&plain_buf, "Tty{s}", .{plain[word_end..]}) catch plain;
- }
- }
- for (defaults) |default|
- if (std.mem.eql(u8, plain, std.mem.trimStart(u8, default, " "))) return;
- pane.tag.own = p.gpa.dupe(u8, rest) catch return;
+ const tail = src.tag_tail orelse return;
+ pane.tag.own = p.gpa.dupe(u8, tail) catch return;
}
/// The span a header's selection covers on line `row` of its text, in