mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-19 18:26:13 +03:00
Merge 11ba929d5df65f480f0b6831787cef207ba2aa2a into 50a88dcfe7c35c8b21bcfb7011787a0270f3d7db
This commit is contained in:
@ -4480,19 +4480,32 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
|||||||
|
|
||||||
const pos = try self.rt_surface.getCursorPos();
|
const pos = try self.rt_surface.getCursorPos();
|
||||||
if (try self.linkAtPos(pos)) |link_info| {
|
if (try self.linkAtPos(pos)) |link_info| {
|
||||||
// Get the URL text from selection
|
const url_text = switch (link_info[0]) {
|
||||||
const url_text = (self.io.terminal.screen.selectionString(self.alloc, .{
|
._open_osc8 => url_text: {
|
||||||
.sel = link_info[1],
|
// For OSC8 links, get the URI directly from hyperlink data
|
||||||
.trim = self.config.clipboard_trim_trailing_spaces,
|
const uri = self.osc8URI(link_info[1].start()) orelse {
|
||||||
})) catch |err| {
|
log.warn("failed to get URI for OSC8 hyperlink", .{});
|
||||||
log.err("error reading url string err={}", .{err});
|
return false;
|
||||||
return false;
|
};
|
||||||
|
break :url_text try self.alloc.dupeZ(u8, uri);
|
||||||
|
},
|
||||||
|
.open => url_text: {
|
||||||
|
// For regex links, get the text from selection
|
||||||
|
break :url_text (self.io.terminal.screen.selectionString(self.alloc, .{
|
||||||
|
.sel = link_info[1],
|
||||||
|
.trim = self.config.clipboard_trim_trailing_spaces,
|
||||||
|
})) catch |err| {
|
||||||
|
log.err("error reading url string err={}", .{err});
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
defer self.alloc.free(url_text);
|
defer self.alloc.free(url_text);
|
||||||
|
|
||||||
self.rt_surface.setClipboardString(url_text, .standard, false) catch |err| {
|
self.rt_surface.setClipboardString(url_text, .standard, false) catch |err| {
|
||||||
log.err("error copying url to clipboard err={}", .{err});
|
log.err("error copying url to clipboard err={}", .{err});
|
||||||
return true;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user