From 400e2d5cace35aacf8d169cbb9f1eeaea8e5bdfe Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Wed, 24 Jan 2024 13:18:24 -0600 Subject: [PATCH] vaxis: implement osc2 set title Signed-off-by: Tim Culverhouse --- src/ctlseqs.zig | 1 + src/vaxis.zig | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/ctlseqs.zig b/src/ctlseqs.zig index f4e6cea..0cc2cd5 100644 --- a/src/ctlseqs.zig +++ b/src/ctlseqs.zig @@ -74,6 +74,7 @@ pub const invisible_reset = "\x1b[28m"; pub const strikethrough_reset = "\x1b[29m"; // OSC sequences +pub const osc2_set_title = "\x1b]2;{s}\x1b\\"; pub const osc8 = "\x1b]8;{s};{s}\x1b\\"; pub const osc8_clear = "\x1b]8;;\x1b\\"; pub const osc9_notify = "\x1b]9;{s}\x1b\\"; diff --git a/src/vaxis.zig b/src/vaxis.zig index 915a2be..abafc86 100644 --- a/src/vaxis.zig +++ b/src/vaxis.zig @@ -490,6 +490,16 @@ pub fn Vaxis(comptime T: type) type { ); } } + + /// sets the window title + pub fn setTitle(self: *Self, title: []const u8) !void { + if (self.tty == null) return; + try std.fmt.format( + self.tty.?.buffered_writer.writer(), + ctlseqs.osc2_set_title, + .{title}, + ); + } }; }