this repo has no description
13
fork

Configure Feed

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

vaxis: add support for color scheme updates

+89 -4
+1 -1
README.md
··· 30 30 | System Notifications (OSC 777) | ✅ | ✅ | ❌ | 31 31 | Synchronized Output (DEC 2026) | ✅ | ✅ | ✅ | 32 32 | Unicode Core (DEC 2027) | ✅ | ✅ | ❌ | 33 - | Color Mode Updates (DEC 2031) | ✅ | planned | ❌ | 33 + | Color Mode Updates (DEC 2031) | ✅ | ✅ | ❌ | 34 34 | Images (full/space) | ✅ | planned | ✅ | 35 35 | Images (half block) | ✅ | planned | ✅ | 36 36 | Images (quadrant) | ✅ | planned | ✅ |
+5
src/Cell.zig
··· 118 118 value: [3]u8, 119 119 }; 120 120 121 + pub const Scheme = enum { 122 + dark, 123 + light, 124 + }; 125 + 121 126 pub fn eql(a: Color, b: Color) bool { 122 127 switch (a) { 123 128 .default => return b == .default,
+47 -1
src/Parser.zig
··· 341 341 }, 342 342 } 343 343 }, 344 + 'n' => { 345 + switch (seq.params[0]) { 346 + 5 => { 347 + // "Ok" response 348 + return .{ 349 + .event = null, 350 + .n = i + 1, 351 + }; 352 + }, 353 + 997 => { 354 + switch (seq.params[1]) { 355 + 1 => { 356 + return .{ 357 + .event = .{ .color_scheme = .dark }, 358 + .n = i + 1, 359 + }; 360 + }, 361 + 2 => { 362 + return .{ 363 + .event = .{ .color_scheme = .dark }, 364 + .n = i + 1, 365 + }; 366 + }, 367 + else => { 368 + log.warn("unhandled csi: CSI {s}", .{input[start + 1 .. i + 1]}); 369 + return .{ 370 + .event = null, 371 + .n = i + 1, 372 + }; 373 + }, 374 + } 375 + }, 376 + else => { 377 + log.warn("unhandled csi: CSI {s}", .{input[start + 1 .. i + 1]}); 378 + return .{ 379 + .event = null, 380 + .n = i + 1, 381 + }; 382 + }, 383 + } 384 + }, 344 385 'u' => blk: { 345 386 if (seq.private_indicator) |priv| { 346 387 // response to our kitty query ··· 417 458 else => return .{ .event = .cap_unicode, .n = i + 1 }, 418 459 } 419 460 }, 420 - 2031 => {}, 461 + 2031 => { 462 + switch (seq.params[1]) { 463 + 0, 4 => return .{ .event = null, .n = i + 1 }, 464 + else => return .{ .event = .cap_color_scheme_updates, .n = i + 1 }, 465 + } 466 + }, 421 467 else => { 422 468 log.warn("unhandled DECRPM: CSI {s}", .{input[start + 1 .. i + 1]}); 423 469 return .{ .event = null, .n = i + 1 };
+13
src/Tty.zig
··· 32 32 bracketed_paste: bool = false, 33 33 mouse: bool = false, 34 34 pixel_mouse: bool = false, 35 + color_scheme_updates: bool = false, 35 36 cursor: struct { 36 37 row: usize = 0, 37 38 col: usize = 0, ··· 66 67 } 67 68 if (self.state.alt_screen) { 68 69 _ = self.write(ctlseqs.rmcup) catch {}; 70 + } 71 + if (self.state.color_scheme_updates) { 72 + _ = self.write(ctlseqs.color_scheme_reset) catch {}; 69 73 } 70 74 // always show the cursor on exit 71 75 _ = self.write(ctlseqs.show_cursor) catch {}; ··· 224 228 loop.postEvent(.{ .color_report = report }); 225 229 } 226 230 }, 231 + .color_scheme => |scheme| { 232 + if (@hasField(Event, "color_scheme")) { 233 + loop.postEvent(.{ .color_scheme = scheme }); 234 + } 235 + }, 227 236 .cap_kitty_keyboard => { 228 237 log.info("kitty keyboard capability detected", .{}); 229 238 loop.vaxis.caps.kitty_keyboard = true; ··· 246 255 .cap_sgr_pixels => { 247 256 log.info("pixel mouse capability detected", .{}); 248 257 loop.vaxis.caps.sgr_pixels = true; 258 + }, 259 + .cap_color_scheme_updates => { 260 + log.info("color_scheme_updates capability detected", .{}); 261 + loop.vaxis.caps.color_scheme_updates = true; 249 262 }, 250 263 .cap_da1 => { 251 264 std.Thread.Futex.wake(&loop.vaxis.query_futex, 10);
+15 -1
src/Vaxis.zig
··· 32 32 rgb: bool = false, 33 33 unicode: gwidth.Method = .wcwidth, 34 34 sgr_pixels: bool = false, 35 + color_scheme_updates: bool = false, 35 36 }; 36 37 37 38 pub const Options = struct { ··· 202 203 // _ = try tty.write(ctlseqs.decrqm_sync); 203 204 _ = try tty.write(ctlseqs.decrqm_sgr_pixels); 204 205 _ = try tty.write(ctlseqs.decrqm_unicode); 205 - _ = try tty.write(ctlseqs.decrqm_color_theme); 206 + _ = try tty.write(ctlseqs.decrqm_color_scheme); 206 207 // TODO: XTVERSION has a DCS response. uncomment when we can parse 207 208 // that 208 209 // _ = try tty.write(ctlseqs.xtversion); ··· 872 873 } 873 874 try tty.flush(); 874 875 } 876 + 877 + /// Subscribe to color theme updates. A `color_scheme: Color.Scheme` tag must 878 + /// exist on your Event type to receive the response. This is a queried 879 + /// capability. Support can be detected by checking the value of 880 + /// vaxis.caps.color_scheme_updates. The initial scheme will be reported when 881 + /// subscribing. 882 + pub fn subscribeToColorSchemeUpdates(self: Vaxis) !void { 883 + var tty = self.tty orelse return; 884 + _ = try tty.write(ctlseqs.color_scheme_request); 885 + _ = try tty.write(ctlseqs.color_scheme_set); 886 + try tty.flush(); 887 + tty.state.color_scheme_updates = true; 888 + }
+6 -1
src/ctlseqs.zig
··· 7 7 pub const decrqm_sgr_pixels = "\x1b[?1016$p"; 8 8 pub const decrqm_sync = "\x1b[?2026$p"; 9 9 pub const decrqm_unicode = "\x1b[?2027$p"; 10 - pub const decrqm_color_theme = "\x1b[?2031$p"; 10 + pub const decrqm_color_scheme = "\x1b[?2031$p"; 11 11 pub const csi_u_query = "\x1b[?u"; 12 12 pub const kitty_graphics_query = "\x1b_Gi=1,a=q\x1b\\"; 13 13 pub const sixel_geometry_query = "\x1b[?2;1;0S"; ··· 28 28 // bracketed paste 29 29 pub const bp_set = "\x1b[?2004h"; 30 30 pub const bp_reset = "\x1b[?2004l"; 31 + 32 + // color scheme updates 33 + pub const color_scheme_request = "\x1b[?996n"; 34 + pub const color_scheme_set = "\x1b[?2031h"; 35 + pub const color_scheme_reset = "\x1b[?2031l"; 31 36 32 37 // Key encoding 33 38 pub const csi_u_push = "\x1b[>{d}u";
+2
src/event.zig
··· 13 13 paste_end, // bracketed paste end 14 14 paste: []const u8, // osc 52 paste, caller must free 15 15 color_report: Color.Report, // osc 4, 10, 11, 12 response 16 + color_scheme: Color.Scheme, 16 17 17 18 // these are delivered as discovered terminal capabilities 18 19 cap_kitty_keyboard, ··· 21 22 cap_sgr_pixels, 22 23 cap_unicode, 23 24 cap_da1, 25 + cap_color_scheme_updates, 24 26 };