feat(win32 gui): add clipboard paste support
This commit is contained in:
parent
5bc3cd6a6d
commit
5ac80f0b6f
3 changed files with 8 additions and 9 deletions
|
@ -354,7 +354,7 @@ pub fn request_system_clipboard(self: *Self) void {
|
||||||
self.vx.requestSystemClipboard(self.tty.anyWriter()) catch |e| log.logger(log_name).err("request_system_clipboard", e);
|
self.vx.requestSystemClipboard(self.tty.anyWriter()) catch |e| log.logger(log_name).err("request_system_clipboard", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn request_windows_clipboard(self: *Self) ![]u8 {
|
pub fn request_windows_clipboard(allocator: std.mem.Allocator) ![]u8 {
|
||||||
const windows = std.os.windows;
|
const windows = std.os.windows;
|
||||||
const win32 = struct {
|
const win32 = struct {
|
||||||
pub extern "user32" fn OpenClipboard(hWndNewOwner: ?windows.HWND) callconv(windows.WINAPI) windows.BOOL;
|
pub extern "user32" fn OpenClipboard(hWndNewOwner: ?windows.HWND) callconv(windows.WINAPI) windows.BOOL;
|
||||||
|
@ -375,7 +375,7 @@ pub fn request_windows_clipboard(self: *Self) ![]u8 {
|
||||||
const text = std.mem.span(data);
|
const text = std.mem.span(data);
|
||||||
defer _ = win32.GlobalUnlock(mem);
|
defer _ = win32.GlobalUnlock(mem);
|
||||||
|
|
||||||
return self.allocator.dupe(u8, text);
|
return allocator.dupe(u8, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn request_mouse_cursor_text(self: *Self, push_or_pop: bool) void {
|
pub fn request_mouse_cursor_text(self: *Self, push_or_pop: bool) void {
|
||||||
|
|
|
@ -383,10 +383,9 @@ pub fn request_system_clipboard(self: *Self) void {
|
||||||
_ = self;
|
_ = self;
|
||||||
@panic("todo");
|
@panic("todo");
|
||||||
}
|
}
|
||||||
pub fn request_windows_clipboard(self: *Self) ![]u8 {
|
|
||||||
_ = self;
|
pub const request_windows_clipboard = @import("tuirenderer").request_windows_clipboard;
|
||||||
@panic("todo");
|
|
||||||
}
|
|
||||||
pub fn request_mouse_cursor_text(self: *Self, push_or_pop: bool) void {
|
pub fn request_mouse_cursor_text(self: *Self, push_or_pop: bool) void {
|
||||||
_ = self;
|
_ = self;
|
||||||
_ = push_or_pop;
|
_ = push_or_pop;
|
||||||
|
|
|
@ -570,10 +570,10 @@ const cmds = struct {
|
||||||
}
|
}
|
||||||
pub const open_previous_file_meta = .{ .description = "Open the previous file" };
|
pub const open_previous_file_meta = .{ .description = "Open the previous file" };
|
||||||
|
|
||||||
pub fn system_paste(_: *Self, _: Ctx) Result {
|
pub fn system_paste(self: *Self, _: Ctx) Result {
|
||||||
if (builtin.os.tag == .windows) {
|
if (builtin.os.tag == .windows) {
|
||||||
const text = try tui.current().rdr.request_windows_clipboard();
|
const text = try @import("renderer").request_windows_clipboard(self.allocator);
|
||||||
defer tui.current().rdr.allocator.free(text);
|
defer self.allocator.free(text);
|
||||||
return command.executeName("paste", command.fmt(.{text})) catch {};
|
return command.executeName("paste", command.fmt(.{text})) catch {};
|
||||||
}
|
}
|
||||||
tui.current().rdr.request_system_clipboard();
|
tui.current().rdr.request_system_clipboard();
|
||||||
|
|
Loading…
Add table
Reference in a new issue