Skip to content
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

Add action to copy link at mouse cursor #527

Open
bew opened this issue Mar 9, 2021 · 3 comments
Open

Add action to copy link at mouse cursor #527

bew opened this issue Mar 9, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@bew
Copy link
Contributor

bew commented Mar 9, 2021

Is your feature request related to a problem? Please describe.
When working remotely, it's not always obvious how to open links (http but also others like file or custom ones) or how to copy one efficiently.

Describe the solution you'd like
I'm thinking about an action CopyLinkAtMouseCursorTo(clip) similar to OpenLinkAtMouseCursor that would instead copy the link to a clipboard.

Describe alternatives you've considered
Selecting the link manually with the mouse then copy it.
But this doesn't always work / is not always complete, like when the link is not contiguously displayed but has escape sequences that makes it a link.

@bew bew added the enhancement New feature or request label Mar 9, 2021
@bew
Copy link
Contributor Author

bew commented Mar 11, 2021

I think a smaller step could be to add basic lua functions to manipulate the clipboards, and I could use it to override open-uri event to always copy the uri in question. (which would be ok for me currently)

But I wouldn't be able to have one binding to open the uri, and another one to copy it, as I don't have access to pressed modifiers from lua code afaik, right?

@wez
Copy link
Owner

wez commented Mar 11, 2021

I've been thinking this over a bit in the background, and I was leaning towards exposing a couple of methods on the pane object in lua:

  • Get current link, word, char, line, logical line under mouse cursor
  • Get current link, word, char, line, logical line under text cursor

On the window object:

  • Get/set the clipboard contents

With those functions, you could define a custom event that you trigger from a mouse binding that does what you want; the example in the docs here uses a key assignment to trigger the custom event, but the same technique should work for a mouse assignment:
https://wezfurlong.org/wezterm/config/lua/wezterm/on.html#custom-events

I'm not opposed to also adding a shortcut for the action you described, but I do worry a little bit about having too many over-specialized actions built-in, which is why I think it would be great to build out this set of functions.

@bew
Copy link
Contributor Author

bew commented Mar 11, 2021

Oh yes, I forgot about custom events, that would be the best option indead! 😍

wez added a commit that referenced this issue Mar 26, 2021
wez added a commit that referenced this issue Mar 26, 2021
This might be all that is needed to make multiline implicit hyperlinks
function, but I need to transfer this commit to another machine to try
it.

refs: #527
refs: #408
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants