feat: add support for pasting from the native windows clipboard

This give us OSC52 equivalent support on windows.

closes #95
This commit is contained in:
CJ van den Berg 2024-12-24 14:44:12 +01:00
parent 750bed8a9c
commit 233e881f95
2 changed files with 29 additions and 2 deletions

View file

@ -571,8 +571,11 @@ const cmds = struct {
pub const open_previous_file_meta = .{ .description = "Open the previous file" };
pub fn system_paste(_: *Self, _: Ctx) Result {
if (builtin.os.tag == .windows)
return command.executeName("paste", .{}) catch {};
if (builtin.os.tag == .windows) {
const text = try tui.current().rdr.request_windows_clipboard();
defer tui.current().rdr.allocator.free(text);
return command.executeName("paste", command.fmt(.{text})) catch {};
}
tui.current().rdr.request_system_clipboard();
}
pub const system_paste_meta = .{ .description = "Paste from system clipboard" };