From e1e3c61cdfa35a68e747685d1a245aa1d81d88f4 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Fri, 30 Aug 2024 06:46:46 -0500 Subject: [PATCH] osc7: use std.Uri for percent encoding --- src/Vaxis.zig | 8 +++++++- src/ctlseqs.zig | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Vaxis.zig b/src/Vaxis.zig index 6fd294a..5d0d766 100644 --- a/src/Vaxis.zig +++ b/src/Vaxis.zig @@ -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}); } diff --git a/src/ctlseqs.zig b/src/ctlseqs.zig index ded4883..4e55448 100644 --- a/src/ctlseqs.zig +++ b/src/ctlseqs.zig @@ -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\\";