mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
copy_or_interrupt action
This commit is contained in:
@ -3870,22 +3870,35 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
|||||||
},
|
},
|
||||||
|
|
||||||
.copy_to_clipboard => {
|
.copy_to_clipboard => {
|
||||||
// We can read from the renderer state without holding
|
if (copyToClipboard(self)) {
|
||||||
// the lock because only we will write to this field.
|
return true;
|
||||||
if (self.io.terminal.screen.selection) |sel| {
|
}
|
||||||
const buf = self.io.terminal.screen.selectionString(self.alloc, .{
|
},
|
||||||
.sel = sel,
|
|
||||||
.trim = self.config.clipboard_trim_trailing_spaces,
|
.copy_or_interrupt => {
|
||||||
}) catch |err| {
|
if (copyToClipboard(self)) {
|
||||||
log.err("error reading selection string err={}", .{err});
|
return true;
|
||||||
return true;
|
} else {
|
||||||
};
|
const buf = try self.alloc.alloc(u8, 1);
|
||||||
defer self.alloc.free(buf);
|
defer self.alloc.free(buf);
|
||||||
|
|
||||||
self.rt_surface.setClipboardString(buf, .standard, false) catch |err| {
|
buf[0] = 3;
|
||||||
log.err("error setting clipboard string err={}", .{err});
|
|
||||||
return true;
|
self.io.queueMessage(try termio.Message.writeReq(
|
||||||
};
|
self.alloc,
|
||||||
|
buf,
|
||||||
|
), .unlocked);
|
||||||
|
|
||||||
|
// Text triggers a scroll.
|
||||||
|
{
|
||||||
|
self.renderer_state.mutex.lock();
|
||||||
|
defer self.renderer_state.mutex.unlock();
|
||||||
|
self.scrollToBottom() catch |err| {
|
||||||
|
log.warn("error scrolling to bottom err={}", .{err});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -4206,6 +4219,30 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn copyToClipboard(self: *Surface) bool {
|
||||||
|
// We can read from the renderer state without holding
|
||||||
|
// the lock because only we will write to this field.
|
||||||
|
if (self.io.terminal.screen.selection) |sel| {
|
||||||
|
const buf = self.io.terminal.screen.selectionString(self.alloc, .{
|
||||||
|
.sel = sel,
|
||||||
|
.trim = self.config.clipboard_trim_trailing_spaces,
|
||||||
|
}) catch |err| {
|
||||||
|
log.err("error reading selection string err={}", .{err});
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
defer self.alloc.free(buf);
|
||||||
|
|
||||||
|
self.rt_surface.setClipboardString(buf, .standard, false) catch |err| {
|
||||||
|
log.err("error setting clipboard string err={}", .{err});
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns true if performing the given action result in closing
|
/// Returns true if performing the given action result in closing
|
||||||
/// the surface. This is used to determine if our self pointer is
|
/// the surface. This is used to determine if our self pointer is
|
||||||
/// still valid after performing some binding action.
|
/// still valid after performing some binding action.
|
||||||
|
@ -229,6 +229,7 @@ pub const Action = union(enum) {
|
|||||||
|
|
||||||
/// Copy and paste.
|
/// Copy and paste.
|
||||||
copy_to_clipboard: void,
|
copy_to_clipboard: void,
|
||||||
|
copy_or_interrupt: void,
|
||||||
paste_from_clipboard: void,
|
paste_from_clipboard: void,
|
||||||
paste_from_selection: void,
|
paste_from_selection: void,
|
||||||
|
|
||||||
@ -638,6 +639,7 @@ pub const Action = union(enum) {
|
|||||||
.cursor_key,
|
.cursor_key,
|
||||||
.reset,
|
.reset,
|
||||||
.copy_to_clipboard,
|
.copy_to_clipboard,
|
||||||
|
.copy_or_interrupt,
|
||||||
.paste_from_clipboard,
|
.paste_from_clipboard,
|
||||||
.paste_from_selection,
|
.paste_from_selection,
|
||||||
.increase_font_size,
|
.increase_font_size,
|
||||||
@ -889,6 +891,7 @@ pub const Action = union(enum) {
|
|||||||
// with include/ghostty.h.
|
// with include/ghostty.h.
|
||||||
pub const Key = enum(c_int) {
|
pub const Key = enum(c_int) {
|
||||||
copy_to_clipboard,
|
copy_to_clipboard,
|
||||||
|
copy_or_interrupt,
|
||||||
paste_from_clipboard,
|
paste_from_clipboard,
|
||||||
new_tab,
|
new_tab,
|
||||||
new_window,
|
new_window,
|
||||||
|
Reference in New Issue
Block a user