terminal/new: set/gwd pwd

This commit is contained in:
Mitchell Hashimoto
2024-03-04 14:41:26 -08:00
parent ff4a0fce7f
commit 8d81754f17

View File

@ -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,