this repo has no description
13
fork

Configure Feed

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

vaxis: implement mouse shapes

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>

+36 -2
+1 -1
README.md
··· 22 22 | Bracketed Paste | ✅ | ✅ | ❌ | 23 23 | Kitty Keyboard | ✅ | ✅ | ✅ | 24 24 | Styled Underlines | ✅ | ✅ | ✅ | 25 - | Mouse Shapes (OSC 22) | ✅ | planned | ❌ | 25 + | Mouse Shapes (OSC 22) | ✅ | ✅ | ❌ | 26 26 | System Clipboard (OSC 52) | ✅ | planned | ❌ | 27 27 | System Notifications (OSC 9) | ✅ | ✅ | ❌ | 28 28 | System Notifications (OSC 777) | ✅ | ✅ | ❌ |
+3
src/InternalScreen.zig
··· 2 2 const assert = std.debug.assert; 3 3 const Style = @import("cell.zig").Style; 4 4 const Cell = @import("cell.zig").Cell; 5 + const Shape = @import("Mouse.zig").Shape; 5 6 6 7 const log = std.log.scoped(.internal_screen); 7 8 ··· 26 27 cursor_row: usize = 0, 27 28 cursor_col: usize = 0, 28 29 cursor_vis: bool = false, 30 + 31 + mouse_shape: Shape = .default, 29 32 30 33 /// sets each cell to the default cell 31 34 pub fn init(alloc: std.mem.Allocator, w: usize, h: usize) !InternalScreen {
+14
src/Mouse.zig
··· 1 + /// A mouse event 2 + pub const Mouse = @This(); 3 + 4 + pub const Shape = enum { 5 + default, 6 + text, 7 + pointer, 8 + help, 9 + progress, 10 + wait, 11 + @"ew-resize", 12 + @"ns-resize", 13 + cell, 14 + };
+3
src/Screen.zig
··· 2 2 const assert = std.debug.assert; 3 3 4 4 const Cell = @import("cell.zig").Cell; 5 + const Shape = @import("Mouse.zig").Shape; 5 6 6 7 const log = std.log.scoped(.screen); 7 8 ··· 17 18 cursor_vis: bool = false, 18 19 19 20 unicode: bool = false, 21 + 22 + mouse_shape: Shape = .default, 20 23 21 24 pub fn init(alloc: std.mem.Allocator, w: usize, h: usize) !Screen { 22 25 var self = Screen{
+1
src/ctlseqs.zig
··· 84 84 pub const osc8_clear = "\x1b]8;;\x1b\\"; 85 85 pub const osc9_notify = "\x1b]9;{s}\x1b\\"; 86 86 pub const osc777_notify = "\x1b]777;notify;{s};{s}\x1b\\"; 87 + pub const osc22_mouse_shape = "\x1b]22;{s}\x1b\\";
+1
src/main.zig
··· 18 18 test { 19 19 _ = @import("GraphemeCache.zig"); 20 20 _ = @import("Key.zig"); 21 + _ = @import("Mouse.zig"); 21 22 _ = @import("Options.zig"); 22 23 _ = @import("Parser.zig"); 23 24 _ = @import("Screen.zig");
+13 -1
src/vaxis.zig
··· 11 11 const Window = @import("Window.zig"); 12 12 const Options = @import("Options.zig"); 13 13 const Style = @import("cell.zig").Style; 14 - const strWidth = @import("ziglyph").display_width.strWidth; 15 14 const gwidth = @import("gwidth.zig"); 15 + const Shape = @import("Mouse.zig").Shape; 16 16 17 17 /// Vaxis is the entrypoint for a Vaxis application. The provided type T should 18 18 /// be a tagged union which contains all of the events the application will ··· 458 458 ); 459 459 _ = try tty.write(ctlseqs.show_cursor); 460 460 } 461 + if (self.screen.mouse_shape != self.screen_last.mouse_shape) { 462 + try std.fmt.format( 463 + tty.buffered_writer.writer(), 464 + ctlseqs.osc22_mouse_shape, 465 + .{@tagName(self.screen.mouse_shape)}, 466 + ); 467 + } 461 468 } 462 469 463 470 fn enableKittyKeyboard(self: *Self, flags: Key.KittyFlags) !void { ··· 509 516 const seq = if (enable) ctlseqs.bp_set else ctlseqs.bp_reset; 510 517 _ = try self.tty.?.write(seq); 511 518 try self.tty.?.flush(); 519 + } 520 + 521 + /// set the mouse shape 522 + pub fn setMouseShape(self: *Self, shape: Shape) void { 523 + self.screen.mouse_shape = shape; 512 524 } 513 525 }; 514 526 }