this repo has no description
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

osc12: add function to set the terminal cursor color

authored by

CJ van den Berg and committed by
Tim Culverhouse
22dcdb6b dc0a228a

+12
+11
src/Vaxis.zig
··· 85 85 in_band_resize: bool = false, 86 86 changed_default_fg: bool = false, 87 87 changed_default_bg: bool = false, 88 + changed_cursor_color: bool = false, 88 89 cursor: struct { 89 90 row: u16 = 0, 90 91 col: u16 = 0, ··· 162 163 if (self.state.changed_default_bg) { 163 164 try tty.writeAll(ctlseqs.osc11_reset); 164 165 self.state.changed_default_bg = false; 166 + } 167 + if (self.state.changed_cursor_color) { 168 + try tty.writeAll(ctlseqs.osc12_reset); 169 + self.state.changed_cursor_color = false; 165 170 } 166 171 } 167 172 ··· 927 932 pub fn setTerminalBackgroundColor(self: *Vaxis, tty: AnyWriter, rgb: [3]u8) !void { 928 933 try tty.print(ctlseqs.osc11_set, .{ rgb[0], rgb[0], rgb[1], rgb[1], rgb[2], rgb[2] }); 929 934 self.state.changed_default_bg = true; 935 + } 936 + 937 + /// Set the terminal cursor color 938 + pub fn setTerminalCursorColor(self: *Vaxis, tty: AnyWriter, rgb: [3]u8) !void { 939 + try tty.print(ctlseqs.osc12_set, .{ rgb[0], rgb[0], rgb[1], rgb[1], rgb[2], rgb[2] }); 940 + self.state.changed_cursor_color = true; 930 941 } 931 942 932 943 /// Request a color report from the terminal. Note: not all terminals support
+1
src/ctlseqs.zig
··· 137 137 pub const osc11_set = "\x1b]11;rgb:{x:0>2}{x:0>2}/{x:0>2}{x:0>2}/{x:0>2}{x:0>2}\x1b\\"; // set default terminal bg 138 138 pub const osc11_reset = "\x1b]111\x1b\\"; // reset bg to terminal default 139 139 pub const osc12_query = "\x1b]12;?\x1b\\"; // cursor color 140 + pub const osc12_set = "\x1b]12;rgb:{x:0>2}{x:0>2}/{x:0>2}{x:0>2}/{x:0>2}{x:0>2}\x1b\\"; // set terminal cursor color 140 141 pub const osc12_reset = "\x1b]112\x1b\\"; // reset cursor to terminal default