diff options
| author | Grace Yoder <grace_yoder@outlook.com> | 2026-06-30 10:02:29 -0600 |
|---|---|---|
| committer | Grace Yoder <grace_yoder@outlook.com> | 2026-06-30 16:33:26 -0600 |
| commit | 9a377fa209cfecf53343247d197dc8578d6c2a1d (patch) | |
| tree | 363b610d822ef6b855cf31873dfa097dd436d38f /src/main.zig | |
| parent | 565174c4b8c73e9e28524709060335a0b17ee3fb (diff) | |
feat(NSPasteboard): uses backend when not ssh and on MacOS
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/main.zig b/src/main.zig index 4f45742..0725ae7 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,4 +1,7 @@ const std = @import("std"); +const builtin = @import("builtin"); + +const os = builtin.target.os.tag; const File = std.Io.File; const Clip = @import("Clip.zig"); @@ -13,10 +16,30 @@ pub fn main(init: std.process.Init) !void { // We want to avoid doing as many allocations as possible so having raw // pages with it being larger should be totally fine - var clip = try Clip.OSC52.init(std.heap.page_allocator, init.io, std.heap.pageSize()); - defer clip.free(); + const alloc = std.heap.page_allocator; + const size = std.heap.pageSize(); + + const is_ssh = init.environ_map.get("SSH_CONNECTION") != null or + init.environ_map.get("SSH_CLIENT") != null or + init.environ_map.get("SSH_TTY") != null; - try run(io, &clip); + // This can be cleaned up + if (is_ssh) { + var clip = try Clip.OSC52.init(alloc, io, size); + defer clip.free(); + try run(io, &clip); + } else { + if (comptime os == .macos) { + var clip = try Clip.NSPasteboard.init(alloc, io, size); + defer clip.free(); + try run(io, &clip); + } else { + // No Linux Clipboards yet + var clip = try Clip.OSC52.init(alloc, io, size); + defer clip.free(); + try run(io, &clip); + } + } } pub fn run(io: std.Io, clip: anytype) !void { |
