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

[SelectionManager] Select the word underneath the cursor on contextmenu #778

Closed
mofux opened this issue Jul 11, 2017 · 8 comments
Closed
Assignees
Labels
area/selection help wanted type/enhancement Features or improvements to existing features
Milestone

Comments

@mofux
Copy link
Contributor

mofux commented Jul 11, 2017

If a user right clicks on a word or url in the terminal, the word should be automatically selected, so it can be copied without having to select it first. This would mimic the default behaviour of Terminal.app, Chrome and most other UIs that allow text selection. I can try to create a PR with this feature if desired.

@Tyriar
Copy link
Member

Tyriar commented Jul 11, 2017

I think it would be good to support this for macOS only, a PR would be awesome! One thing to keep in mind is that it generally doesn't seem to select whitespace in the programs I tested, currently SelectionManager._selectWordAt will select whitespace so you'll need to add an extra parameter to that function or something.

@mofux
Copy link
Contributor Author

mofux commented Jul 11, 2017

I was under the assumption that this would be the default behaviour for Windows and Linux too. How about making it platform dependant by default, but configurable through a config flag?

@Tyriar
Copy link
Member

Tyriar commented Jul 11, 2017

@mofux sounds good if it's default on macOS only. It would be cool to have opt-in support on other platforms.

@mofux
Copy link
Contributor Author

mofux commented Jul 11, 2017

This is currently blocked by #780

@Tyriar
Copy link
Member

Tyriar commented Jul 12, 2017

Is it really blocked? I would have thought you'd check MouseEvent for whether it was a right click and/or listen to contextmenu?

@mofux
Copy link
Contributor Author

mofux commented Jul 12, 2017

@Tyriar I thought I would just hook into the mousedown handler of the selection manager (the part that is changed by #780), check if options.rightClickSelectsWord is true, selection is currently empty and evt.button is 2 (right mouse button) and basically trigger the same action that is done for double-click (which should select the word underneath the cursor). Then, term.defaults.rightClickSelectsWord would only be true if Browser.isMac

@Tyriar
Copy link
Member

Tyriar commented Jul 12, 2017

Right now the right click logic is contained within Clipboard.ts which is called by listening to contextmenu or mousedown depending on the browser. This should probably go inside rightClickHandler which already has the SelectionManager passed in.

bmf-ribeiro added a commit to bmf-ribeiro/xterm.js that referenced this issue Nov 6, 2017
bmf-ribeiro added a commit to bmf-ribeiro/xterm.js that referenced this issue Nov 6, 2017
@Tyriar Tyriar added this to the 3.1.0 milestone Feb 2, 2018
@Tyriar
Copy link
Member

Tyriar commented Feb 5, 2018

Fixed with #1114

@Tyriar Tyriar closed this as completed Feb 5, 2018
@Tyriar Tyriar added type/enhancement Features or improvements to existing features and removed type/feature labels Apr 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/selection help wanted type/enhancement Features or improvements to existing features
Projects
None yet
Development

No branches or pull requests

2 participants