osc7: use std.Uri for percent encoding

This commit is contained in:
Tim Culverhouse 2024-08-30 06:46:46 -05:00
parent 7dde40d346
commit e1e3c61cdf
2 changed files with 8 additions and 2 deletions

View file

@ -1232,5 +1232,11 @@ pub fn setTerminalWorkingDirectory(_: *Vaxis, tty: AnyWriter, path: []const u8)
.windows => null,
else => std.posix.getenv("HOSTNAME"),
} orelse "localhost";
try tty.print(ctlseqs.osc7, .{ hostname, path });
const uri: std.Uri = .{
.scheme = "file",
.host = .{ .raw = hostname },
.path = .{ .raw = path },
};
try tty.print(ctlseqs.osc7, .{uri});
}

View file

@ -113,7 +113,7 @@ pub const strikethrough_reset = "\x1b[29m";
// OSC sequences
pub const osc2_set_title = "\x1b]2;{s}\x1b\\";
pub const osc7 = "\x1b]7;file://{s}{s}\x1b\\";
pub const osc7 = "\x1b]7;{;+/}\x1b\\";
pub const osc8 = "\x1b]8;{s};{s}\x1b\\";
pub const osc8_clear = "\x1b]8;;\x1b\\";
pub const osc9_notify = "\x1b]9;{s}\x1b\\";