diff options
Diffstat (limited to 'src/tagline.zig')
| -rw-r--r-- | src/tagline.zig | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/tagline.zig b/src/tagline.zig index 1c060a66..59c51b4d 100644 --- a/src/tagline.zig +++ b/src/tagline.zig @@ -112,8 +112,15 @@ pub fn pathPrefix(arena: std.mem.Allocator, pane: *Pane) ![]const u8 { 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); // 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 + // second (acme runs a multi-line selection as one command) would move + // it (body_layer.zig tagTintRange). if (pane.command) |line| { - const shown = line[0..@min(line.len, 48)]; + const first = line[0 .. std.mem.indexOfAny(u8, line, "\r\n") orelse line.len]; + var cut = @min(first.len, 48); + while (cut < first.len and cut > 0 and first[cut] & 0xC0 == 0x80) cut -= 1; + const shown = first[0..cut]; const more = if (shown.len < line.len) "..." else ""; var idbuf: [48]u8 = undefined; const id = exec.replId(&idbuf, pane); @@ -409,8 +416,26 @@ pub fn restoreTailAt( }, .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, said, std.mem.trimStart(u8, default, " "))) return; + if (std.mem.eql(u8, plain, std.mem.trimStart(u8, default, " "))) return; pane.tag.own = p.gpa.dupe(u8, rest) catch return; } |
