mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
feat: implement copy_url_to_clipboard keybinding action functionality
This commit is contained in:
@ -3932,6 +3932,27 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
.copy_url_to_clipboard => {
|
||||||
|
const pos = try self.rt_surface.getCursorPos();
|
||||||
|
|
||||||
|
if (!self.mouse.over_link) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (try self.linkAtPos(pos)) |link| {
|
||||||
|
const str = try self.io.terminal.screen.selectionString(self.alloc, .{
|
||||||
|
.sel = link[1],
|
||||||
|
.trim = false,
|
||||||
|
});
|
||||||
|
defer self.alloc.free(str);
|
||||||
|
|
||||||
|
try self.rt_surface.setClipboardString(str, .standard, false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
.paste_from_clipboard => try self.startClipboardRequest(
|
.paste_from_clipboard => try self.startClipboardRequest(
|
||||||
.standard,
|
.standard,
|
||||||
.{ .paste = {} },
|
.{ .paste = {} },
|
||||||
|
@ -256,6 +256,8 @@ pub const Action = union(enum) {
|
|||||||
|
|
||||||
/// Copy and paste.
|
/// Copy and paste.
|
||||||
copy_to_clipboard: void,
|
copy_to_clipboard: void,
|
||||||
|
/// Copy the URL under cursor to the clipboard.
|
||||||
|
copy_url_to_clipboard: void,
|
||||||
paste_from_clipboard: void,
|
paste_from_clipboard: void,
|
||||||
paste_from_selection: void,
|
paste_from_selection: void,
|
||||||
|
|
||||||
@ -707,6 +709,7 @@ pub const Action = union(enum) {
|
|||||||
.cursor_key,
|
.cursor_key,
|
||||||
.reset,
|
.reset,
|
||||||
.copy_to_clipboard,
|
.copy_to_clipboard,
|
||||||
|
.copy_url_to_clipboard,
|
||||||
.paste_from_clipboard,
|
.paste_from_clipboard,
|
||||||
.paste_from_selection,
|
.paste_from_selection,
|
||||||
.increase_font_size,
|
.increase_font_size,
|
||||||
|
Reference in New Issue
Block a user