this repo has no description
13
fork

Configure Feed

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

vxfw: add copy_to_clipboard command

Add a command to copy text to the clipboard via OSC 52

+16
+8
src/vxfw/App.zig
··· 195 195 .tick => |tick| try self.addTick(tick), 196 196 .set_mouse_shape => |shape| self.vx.setMouseShape(shape), 197 197 .request_focus => |widget| self.wants_focus = widget, 198 + .copy_to_clipboard => |content| { 199 + self.vx.copyToSystemClipboard(self.tty.anyWriter(), content, self.allocator) catch |err| { 200 + switch (err) { 201 + error.OutOfMemory => return Allocator.Error.OutOfMemory, 202 + else => std.log.err("copy error: {}", .{err}), 203 + } 204 + }; 205 + }, 198 206 } 199 207 } 200 208 }
+8
src/vxfw/vxfw.zig
··· 74 74 set_mouse_shape: vaxis.Mouse.Shape, 75 75 /// Request that this widget receives focus 76 76 request_focus: Widget, 77 + 78 + /// Try to copy the provided text to the host clipboard. Uses OSC 52. Silently fails if terminal 79 + /// doesn't support OSC 52 80 + copy_to_clipboard: []const u8, 77 81 }; 78 82 79 83 pub const EventContext = struct { ··· 117 121 118 122 pub fn requestFocus(self: *EventContext, widget: Widget) Allocator.Error!void { 119 123 try self.addCmd(.{ .request_focus = widget }); 124 + } 125 + 126 + pub fn copyToClipboard(self: *EventContext, content: []const u8) Allocator.Error!void { 127 + try self.addCmd(.{ .copy_to_clipboard = content }); 120 128 } 121 129 }; 122 130