-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Enable shift+select in mouse mode #974
Conversation
Thanks, works nicely. I find it a bit odd that I have to hold Shift when clicking to clear the selection, even if other terminals do the same - I can't imagine a scenario where I would shift-select something, then start clicking without shift and expecting the selection to stay. |
Yeah I have definitely thought about just setting it up so clicking always clears selection no matter if shift is held or not. However until now alacritty also hasn't cleared when the mouse modes were enabled so I decided to stick with this for now. If anyone has a reason why the selection shouldn't be cleared when mouse mode is enabled and left mouse is clicked, please tell me. Otherwise I'd be inclined to change it to always clear on left click. Maybe @jwilm knows more about this kind of stuff? I'd say the current state of the PR is the "safe" route, so I'm gonna stick with it for now. Also while termite doesn't clear the selection when clicking without shift, it also doesn't keep up the selection when the buffer changes. So when I change rooms in weechat with a left click after selecting something, the selection is cleared. Currently with alacritty the selection would stay and effectively something completely different would be selected. |
I have no preference and have found myself eventually mashing Esc to clear it when I couldn't figure it out. I could say that the terms I use (mostly iterm) do clear it on the next regular click... One thing I wanted to bring up is that I get really good use out of Shift+Alt+drag for selecting a block. Consider that a feature request. :) This is very useful in vim/tmux to omit line numbers and other vertically split panes while copying code or log output, for example. Indeed I use block select at least 80% of the time. The reason why block select isn't necessarily an essential feature for me is that zooming to maximize the pane with tmux lets me use regular select in a pinch. |
How does this compare with @gilbertw1's implementation? |
I did not see an open PR from him. But looking at his master it looks like the main difference is that he's passing only the shift mod and I'm passing all modifiers. And mine is not using the git version of glutin. If you want to wait from a PR of him and merge that, feel free. I don't really care as long as this feature is merged. There are probably a few things that could be improved in both implementations, but they look almost identical. |
I hadn't opened a PR for it yet. As @chrisduerr said this implementation does look nearly identical to my fork with the exception that he's passing through all of the modifiers, which I believe is probably a better choice. Looks good to me 👍 Edit: The only difference behavior wise with mine is that single clicking does clear out the selection, unless the mouse input is captured by an application, in which case only shift + click will clear the selection. |
The single-click behavior seems to be the same for our versions from what I can tell. I've updated this PR to use only the shift key. Now they seem to be pretty much identical, except for the test which @gilbertw1 didn't change. |
So is it settled that only Shift+Click clears the selection, and not the Click alone? Still find that odd 😛 |
Based on the current implementation that would be the "safe" choice. But I still am open to change this. Maybe @jwilm has an opinion on that? I don't think it's a big deal either way, but I'd love to get some more input on this. |
I prefer a simple click clearing the selection, but I'm not completely opposed to shift-click. This is a great feature overall! |
It seems like the common consensus is that even in mouse mode, the If there is any reason why this should not be the case, please let me Note that in the current behavior of master, the selection would not be cleared when the mouse is captured by an application. However I don't know of any way to make a selection in an application that captures the mouse without this PR. |
When an application takes control over the mouse, it usually disables selection completely. However the common way to still make selection possible is by allowing selection while the shift key is held down. This feature is implemented here by making use of the new `modifiers` field on mouse events with glutin/winit. This fixes alacritty#146.
The only mouse modifier required right now is the shift key, to prevent passing around unnecessary state, only the shift state is passed to the mouse processors now.
Three was still a test which passed the whole modifiers struct instead of just the shift bool, this has been fixed.
The tests were using a manually setup `ModifiersState`, to clean things up a bit the `ModifiersState::default` method has been used to replace this.
It seems like the common consensus is that even in mouse mode, the selection should be cleared with a normal click. If there is any reason why this should not be the case, please let me know.
b329698
to
6525d05
Compare
I noticed that doubleclicking with this makes the selection work word-wise. Very good! |
Double-clicking in general is used for semantic selection. And triple-clicking is used for line-selection. This PR didn't introduce this but the functionality should work when holding shift in mouse-mode now. |
Ah yes I remember it working from before, too. Being in tmux most of the time I had forgotten. |
BTW, I am used to how selecting copies what was selected to the system buffer right away. I wonder if a configuration can be added to make this happen? Uh, I can make a feature request for this. |
This should be the case for both normal selection and selection with shift when mouse-mode is enabled. Is this not working for you? |
It is implemented, just keep in mind that mouse selection puts contents to the "primary selection clipboard" (something you would paste in vim with |
I think he's talking about MacOS, not linux. I've talked to jwilm on IRC and he said If there is a convention how this should be done (I think @unphased has mentioned that iTerm2 supports this), then implementing this feature for MacOS too should be possible. |
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.
Thanks for the PR @chrisduerr! Excited to land this feature which people have been asking for as long as I can remember.
Everything looks good sans one minor change.
src/input.rs
Outdated
if let Event::WindowEvent { event: WindowEvent::MouseInput { state, button, .. }, .. } = $input { | ||
processor.mouse_input(state, button); | ||
if let Event::WindowEvent { event: WindowEvent::MouseInput { state, button, modifiers, .. }, .. } = $input { | ||
processor.mouse_input(state, button, modifiers.shift); |
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.
It seems to me that modifiers
should be passed through in its entirety. If we ever want to add some other mouse + modifier functionality, then all the mods are already being passed without bloating the method signature.
ModifiersState is now passed to the mouse methods in `input.rs` as a whole instead of just passing the `shift` state. This should make it a bit easier to do changes in the future.
Thanks for the clarifications guys! |
Am I supposed to be able to hold shift + mouse drag to select text in tmux now? Because it isn't working after a |
@lf94 Are you sure you are on the latest master? Usually in tmux you should be able to just select text by default as long as mouse mode is not enabled. After enabling mouse mode, you should now be able to select text with shift + mouse. At least this is the way it works on my X11 machine. Are you on macos? |
7b4ba80 is the first bit of the latest commit hash. I'm on Debian Stretch (9.0). I have mouse mode enabled in tmux, as it's always been :) (
|
I'm not quite sure what to tell you then. It seems to work just fine with tmux 2.6 on archlinux. What exactly happens when you try to shift-select? Do you still get the mouse selection from tmux? |
Yeah that is exactly what is happening still. |
My configuration:
|
I'm unable to reproduce even with your config. |
@lf94 is it possible that you use an unusual keyboard layout maybe? For the record, I can't reproduce the issue too. |
I'm using Dvorak, setup via Cinnamon's configuration tools. It works in xterm/urxvt/gnome-terminal though just fine. |
Is there a way to verify my alacritty binary? You guys have a SHA-1 we can compare? |
0edb8ba861... is the first bit of the hash. (I am not editing my posts in case lurkers are watching via email.) |
I wonder if this is somehow related or caused by #61, specifically:
To double check, try QWERTY maybe? My binary, compiled on Arch Linux: alacritty.zip |
If Dvorak should not be an issue, I'm using it myself and it works just fine. |
Yes, it gives me results. I'm now waiting for it to compile with Also, our hashes did not equal each other. Hm. |
It seems Mission complete. Thank you guys :) |
No problem. :) |
When an application takes control over the mouse, it usually disables
selection completely. However the common way to still make selection
possible is by allowing selection while the shift key is held down.
This feature is implemented here by making use of the new
modifiers
field on mouse events with glutin/winit.
This fixes #146.
I've thought about changing the cursor, but it seems like that would be kinda odd (you wouldn't want it changing every time when hitting shift). And other terminal emulators also do not seem to change the cursor with shift selection.
For clearing a selection you also need to hold shift and click, but this also seems consistent with my experience on other terminal emulators.
If you have any feedback on these two things, feel free to tell me about it.