core: reset sgr on deinit, and at the end of prettyPrint

Reset SGR unilaterally when deiniting vaxis. Also reset it at the end of
a prettyPrint render.
This commit is contained in:
Tim Culverhouse 2024-09-30 10:52:30 -05:00
parent 1961712c1f
commit a1b43d2465

View file

@ -114,6 +114,7 @@ pub fn deinit(self: *Vaxis, alloc: ?std.mem.Allocator, tty: AnyWriter) void {
// always show the cursor on exit // always show the cursor on exit
tty.writeAll(ctlseqs.show_cursor) catch {}; tty.writeAll(ctlseqs.show_cursor) catch {};
tty.writeAll(ctlseqs.sgr_reset) catch {};
if (self.screen.cursor_shape != .default) { if (self.screen.cursor_shape != .default) {
// In many terminals, `.default` will set to the configured cursor shape. Others, it will // In many terminals, `.default` will set to the configured cursor shape. Others, it will
// change to a blinking block. // change to a blinking block.
@ -974,6 +975,7 @@ pub fn prettyPrint(self: *Vaxis, tty: AnyWriter) !void {
try tty.writeAll(ctlseqs.sync_set); try tty.writeAll(ctlseqs.sync_set);
defer tty.writeAll(ctlseqs.sync_reset) catch {}; defer tty.writeAll(ctlseqs.sync_reset) catch {};
try tty.writeAll(ctlseqs.sgr_reset); try tty.writeAll(ctlseqs.sgr_reset);
defer tty.writeAll(ctlseqs.sgr_reset) catch {};
var reposition: bool = false; var reposition: bool = false;
var row: usize = 0; var row: usize = 0;