From f3f0e27372d8cf111269dde674d4581cf4cb0c41 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 3 Jul 2026 23:37:10 -0300 Subject: sdl: main + ui_sdl rework, build.zig updates --- term.zig | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'term.zig') diff --git a/term.zig b/term.zig index cb451b7c..7201c7c7 100644 --- a/term.zig +++ b/term.zig @@ -84,6 +84,8 @@ pub const EditSnap = struct { cur_off: u16, }; +pub const CwdOscState = enum { normal, esc, osc, osc7, collect, st_esc }; + /// Persistent per-terminal state: the pty handle, the ghostty emulator and its /// (stateful) VT parser, the background reader task, plus its layout weight and /// text selection. @@ -94,10 +96,15 @@ pub const EditSnap = struct { pub const Term = @This(); pty: std.Io.File, -pid: std.posix.pid_t, // the shell child; used to read /proc//cwd for the tag +pid: std.posix.pid_t, // shell child; Linux uses /proc//cwd for live cwd tags term: ghostty_vt.Terminal, stream: ghostty_vt.TerminalStream, reader: std.Io.Future(anyerror!void), +/// Last known shell cwd for platforms without Linux procfs. macOS updates this +/// from OSC 7 emitted by our shell rc; BSDs use the spawn cwd as a fallback. +cwd: ?[]u8 = null, +cwd_osc_state: CwdOscState = .normal, +cwd_osc: std.ArrayList(u8) = .empty, /// When set, this pane is a (read/editable) text FILE view, not a terminal: its /// body comes from `content` instead of the emulator, and all the tty-specific @@ -196,6 +203,8 @@ pub fn deinit(self: *Term, io: std.Io, gpa: std.mem.Allocator) void { self.pty.close(io); } self.tty_stream.deinit(gpa); + if (self.cwd) |cwd| gpa.free(cwd); + self.cwd_osc.deinit(gpa); self.ed_undo.deinit(gpa); self.ed_redo.deinit(gpa); self.tag_tail.deinit(gpa); -- cgit v1.3