vaxis: implement osc2 set title

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
This commit is contained in:
Tim Culverhouse 2024-01-24 13:18:24 -06:00
parent 33d43dc6d1
commit 400e2d5cac
2 changed files with 11 additions and 0 deletions

View file

@ -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\\";

View file

@ -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},
);
}
};
}