From 8d81754f1727b29874b349ce08185cfc90c754aa Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 4 Mar 2024 14:41:26 -0800 Subject: [PATCH] terminal/new: set/gwd pwd --- src/terminal/new/Terminal.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/terminal/new/Terminal.zig b/src/terminal/new/Terminal.zig index b444f4888..891355640 100644 --- a/src/terminal/new/Terminal.zig +++ b/src/terminal/new/Terminal.zig @@ -2070,6 +2070,19 @@ fn clearPromptForResize(self: *Terminal) void { _ = self; } +/// Set the pwd for the terminal. +pub fn setPwd(self: *Terminal, pwd: []const u8) !void { + self.pwd.clearRetainingCapacity(); + try self.pwd.appendSlice(pwd); +} + +/// Returns the pwd for the terminal, if any. The memory is owned by the +/// Terminal and is not copied. It is safe until a reset or setPwd. +pub fn getPwd(self: *const Terminal) ?[]const u8 { + if (self.pwd.items.len == 0) return null; + return self.pwd.items; +} + /// Options for switching to the alternate screen. pub const AlternateScreenOptions = struct { cursor_save: bool = false,