-
Notifications
You must be signed in to change notification settings - Fork 689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Right click to copy support #5935
base: main
Are you sure you want to change the base?
Conversation
src/config/Config.zig
Outdated
.linux => .true, | ||
.macos => .true, | ||
else => .false, | ||
}, | ||
|
||
@"copy-on-right-click": CopyOnMouseAction = switch (builtin.os.tag) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs (also mention this is GTK only for now)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this will partially work on macOS, except that it will both copy the selection and open up the context menu. I can't test, but that's my intuition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, unfortunately I don't have a macbook at hand to test this on but the copy should work however the menu will still pop up. I will add the option to the docs
src/config/Config.zig
Outdated
.linux => .false, | ||
.macos => .false, | ||
else => .false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's just disabled everywhere then... just make it false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point
Before we start merging pull requests, we should really spend some more time thinking about the best config for this. I'd recommend something like this:
|
src/Surface.zig
Outdated
@@ -3103,14 +3109,15 @@ pub fn mouseButtonCallback( | |||
// If we already have a selection and the selection contains | |||
// where we clicked then we don't want to modify the selection. | |||
if (self.io.terminal.screen.selection) |prev_sel| { | |||
try self.copyOnMouseAction(prev_sel, self.config.copy_on_right_click); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you already have a selection and then right click outside the selection you get two "Copied to Clipboard" toasts (with --copy-on-right-click=clipboard
) so one of these calls to copyOnMouseAction
seems redundant or misplaced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are absolutely correct, I moved this inside the subsequent conditional, where you are clicking inside an existing selection.
src/Surface.zig
Outdated
// If copy on select is false then exit early. | ||
if (self.config.copy_on_select == .false) return; | ||
|
||
// clear the clipboard. If the selection is set, we only set the clipboard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Insanely minor but
// clear the clipboard. If the selection is set, we only set the clipboard | |
// Clear the clipboard. If the selection is set, we only set the clipboard |
src/config/Config.zig
Outdated
/// Whether to copy selected text to the clipboard on right mouse click. `true` | ||
/// will prefer to copy to the selection clipboard, otherwise it will copy to | ||
/// the system clipboard. | ||
/// | ||
/// The value `clipboard` will always copy text to the selection clipboard | ||
/// as well as the system clipboard. | ||
/// | ||
/// Middle-click paste will always use the selection clipboard. Middle-click | ||
/// paste is always enabled even if this is `false`. | ||
/// | ||
/// The default value is false for all systems. | ||
/// | ||
/// At present this will only disable the context menu on Linux in the future | ||
/// this shoul also disable the context menu on macOS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kept the copy of this identical to copy-on-select
Is the preference to reference the existing config for things like the behaviour of clipboard?
This is a reasonable enough ask, and I think it makes sense. I just read through @mitchellh's response on the original issue to this same suggestion Should I close this MR and re-open one with this behaviour or even close it on a permanent basis until there is a proposal for a more permanent solution? |
Adds right click to copy support to ghostty.
Only gtk context menu is currently being disabled.
Issue 4404