this repo has no description
13
fork

Configure Feed

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

feat: add functions to set the default terminal background/foreground

And reset to default on cleanup.

authored by

CJ van den Berg and committed by
Tim Culverhouse
7190fde1 a8baf9ce

+24
+22
src/Vaxis.zig
··· 86 86 pixel_mouse: bool = false, 87 87 color_scheme_updates: bool = false, 88 88 in_band_resize: bool = false, 89 + changed_default_fg: bool = false, 90 + changed_default_bg: bool = false, 89 91 cursor: struct { 90 92 row: usize = 0, 91 93 col: usize = 0, ··· 155 157 if (self.state.in_band_resize) { 156 158 try tty.writeAll(ctlseqs.in_band_resize_reset); 157 159 self.state.in_band_resize = false; 160 + } 161 + if (self.state.changed_default_fg) { 162 + try tty.writeAll(ctlseqs.osc10_reset); 163 + self.state.changed_default_fg = false; 164 + } 165 + if (self.state.changed_default_bg) { 166 + try tty.writeAll(ctlseqs.osc11_reset); 167 + self.state.changed_default_bg = false; 158 168 } 159 169 } 160 170 ··· 903 913 ctlseqs.osc52_clipboard_request, 904 914 .{}, 905 915 ); 916 + } 917 + 918 + /// Set the default terminal foreground color 919 + pub fn setTerminalForegroundColor(self: *Vaxis, tty: AnyWriter, rgb: [3]u8) !void { 920 + try tty.print(ctlseqs.osc10_set, .{ rgb[0], rgb[0], rgb[1], rgb[1], rgb[2], rgb[2] }); 921 + self.state.changed_default_fg = true; 922 + } 923 + 924 + /// Set the default terminal background color 925 + pub fn setTerminalBackgroundColor(self: *Vaxis, tty: AnyWriter, rgb: [3]u8) !void { 926 + try tty.print(ctlseqs.osc11_set, .{ rgb[0], rgb[0], rgb[1], rgb[1], rgb[2], rgb[2] }); 927 + self.state.changed_default_bg = true; 906 928 } 907 929 908 930 /// Request a color report from the terminal. Note: not all terminals support
+2
src/ctlseqs.zig
··· 130 130 pub const osc4_query = "\x1b]4;{d};?\x1b\\"; // color index {d} 131 131 pub const osc4_reset = "\x1b]104\x1b\\"; // this resets _all_ color indexes 132 132 pub const osc10_query = "\x1b]10;?\x1b\\"; // fg 133 + pub const osc10_set = "\x1b]10;rgb:{x:0>2}{x:0>2}/{x:0>2}{x:0>2}/{x:0>2}{x:0>2}\x1b\\"; // set default terminal fg 133 134 pub const osc10_reset = "\x1b]110\x1b\\"; // reset fg to terminal default 134 135 pub const osc11_query = "\x1b]11;?\x1b\\"; // bg 136 + 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 135 137 pub const osc11_reset = "\x1b]111\x1b\\"; // reset bg to terminal default 136 138 pub const osc12_query = "\x1b]12;?\x1b\\"; // cursor color 137 139 pub const osc12_reset = "\x1b]112\x1b\\"; // reset cursor to terminal default