diff options
| author | Grace Yoder <grace_yoder@outlook.com> | 2026-07-03 19:43:26 -0600 |
|---|---|---|
| committer | Grace Yoder <grace_yoder@outlook.com> | 2026-07-03 20:40:06 -0600 |
| commit | c228995f20e16a97ad6baff05a0d46d3fffe3295 (patch) | |
| tree | 005d5c1f517398df287269da59deeb2c35924171 /src/Clip | |
| parent | 43c454a08c7c169df5c3d3ebcd2abded8bf5fa4b (diff) | |
feat: added ForkOut backend and now forks out to `xclip` and `wl-copy` on linux0.1.1
Diffstat (limited to 'src/Clip')
| -rw-r--r-- | src/Clip/ForkOut.zig | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Clip/ForkOut.zig b/src/Clip/ForkOut.zig new file mode 100644 index 0000000..97c5377 --- /dev/null +++ b/src/Clip/ForkOut.zig @@ -0,0 +1,24 @@ +/// ForkOut Clipboard backend +/// Fulfills `Clip` interface +pub const ForkOut = @This(); + +const std = @import("std"); + +extern fn sendPB(text: [*:0]const u8) void; +extern fn initPB() void; + +io: std.Io, + +child: std.process.Child, + +pub fn init(io: std.Io, argv: []const []const u8) !ForkOut { + return .{ .child = try std.process.spawn(io, .{ .argv = argv, .stdin = .pipe }), .io = io }; +} + +pub fn writeCopyBuffer(self: *ForkOut, buf: []const u8) anyerror!void { + try self.child.stdin.?.writeStreamingAll(self.io, buf); +} + +pub fn writePasteboard(self: *ForkOut) anyerror!void { + self.child.stdin.?.close(self.io); +} |
