Skip to content

Double- and triple-click selection of whole words and lines - #84

Closed
osandov wants to merge 1 commit into
tmux:masterfrom
osandov:double-click-select
Closed

osandov wants to merge 1 commit into
tmux:masterfrom
osandov:double-click-select

Conversation

@osandov

@osandov osandov commented Aug 16, 2015

Copy link
Copy Markdown

The lack of this feature makes it more convenient to bypass copy-mode with Shift-click in many cases, but it'd be awesome to have this natively in tmux. Here's my go at implementing it.

@osandov
osandov force-pushed the double-click-select branch from b84cc57 to f453b3d Compare August 16, 2015 03:42
@nicm

nicm commented Aug 16, 2015

Copy link
Copy Markdown
Member

Thanks. This looks great but there is one problem:

When I double click, I don't want the command bound to Mouse1Down fired, I just want the Double click key fired, so there needs to be a way to achieve this.

I don't know what the best way is, if we wait for the timer to expire before figuring out what key to fire (Down, Up+Down, Double Click, Triple Click) then there will be a delay before anything happens. Maybe a delay would be acceptable, it's hard to tell without trying it. It works fine for Escape.

Perhaps a better option is to make Up/Down work as you have them (always fired as well as Double Click or Triple Click), but also add Single Click which is subject to the timer. So we fire Up/Down/etc as they happen, but also fire Single Click, Double Click, Triple Click if there are 1, 2 or 3 Down/Up pairs within 1 timer period for Single/Double or 2 timer periods (for Triple). So Down/Up is a direct mouse event, *Click is a count of Down/Up pairs using the timer.

I have some concerns about the actual copy mode bits but I think it would be better not to worry about that part until the mouse click behaviour is settled.

@osandov

osandov commented Aug 16, 2015

Copy link
Copy Markdown
Author

Thanks for taking a look! I threw something together to see how it this would feel with a timeout and put it here https://github.com/osandov/tmux/tree/double-click-select2. That doesn't wire up any actual events or anything, it justs logs when a click event would in theory be fired.

My opinion is that it feels too unresponsive, and it'd feel especially weird since other applications seem to trigger an event for all three clicks. As an example, I looked at Vim. Try doing a split then triple-clicking a line in the split that doesn't have focus. The first click changes the focus, the second click selects a word, and the third click selects the whole line. The same goes for Chrome. I think it'd be most natural to follow the existing convention and fire all three events, what do you think? And maybe it'd still be a good idea to separate single-, double-, and triple-click events from mouse down and mouse up events regardless?

@nicm

nicm commented Aug 16, 2015

Copy link
Copy Markdown
Member

Hmm. It is not very useful for users if they bind commands to single, double and triple click to have all three commands fired when they do a triple click. I don't think it matters what vim does, it is not a useful parallel to tmux.

I think the best thing would be if we did make it consistent and added a single click as well also using the timer, and also change it so that the down event is fired for every mouse down - so for a single click I get a mouse down, a mouse up and a single click once the timer expires; for a double click I get mouse down/mouse up/mouse down/mouse up and then a double click; and so on. That way if something is harmless when used with my triple click command (like select-pane) I can bind it to mouse down, if it is something that must be exclusive I can bind it to single click and put up with the timer. If I don't care about clicks, I can just unbind them and not have the timer interfere with my mouse down events.

The other thing you will need to do is remove the options, we do not need any new ones for this. For the timeout, pick a sensible default and add a #define KEYC_CLICK_TIMEOUT or something and for the separators please use the existing word-separators option.

I think your timeout of 300 is too long, 100 or 200 would be better.

@nicm

nicm commented Aug 16, 2015

Copy link
Copy Markdown
Member

I realise that you want double click selects word then one more click selects line - but you should be able to do that anyway, once double click selects a word it should be possible to arrange it so that another click (or mouse down) toggles to select the line.

I'm thinking of being able to do things like:

bind -n DoubleClick1Pane select-pane -Z
bind -n TripleClick1Pane rotate-window

Where it is more useful (and more obvious to the user) to have double and triple click entirely separate.

@osandov

osandov commented Aug 26, 2015

Copy link
Copy Markdown
Author

Okay, I see what you're getting at about generic double- and triple-click events, for those use cases what you describe is definitely more intuitive. I don't see a good way to resolve that, because I really want the instant behavior for selection. So, instead of adding generic double- and triple-click events, we can just do this at the copy mode level: copy-mode -M will handle MouseDown and do the selection from there. How does that sound?

@osandov
osandov force-pushed the double-click-select branch 2 times, most recently from c9a762c to 4ace229 Compare August 26, 2015 05:44
@nicm

nicm commented Aug 26, 2015

Copy link
Copy Markdown
Member

Sure you could make it so that one MouseDown moves the cursor or enters copy mode, and the next on the cursor selects word, and the next selects line, and so on, so it is not a double or triple click or a timer but just toggling the selection. I'm not sure we could bind it by default though because it would interfere with selecting a pane, I want one click to select a pane not to enter copy mode.

I think it'd be better in the long run to have click/double-click/triple-click separate from mouse up/down as I mentioned before (so you get down/up AND click).

@osandov
osandov force-pushed the double-click-select branch from 4ace229 to e007bd3 Compare September 13, 2015 05:59
@osandov

osandov commented Sep 13, 2015

Copy link
Copy Markdown
Author

Hi, sorry, just picking up on this again. Could you take a look at what I just pushed? I implemented what I described above. I used a timer because doing it any other way felt weird to use. The default select-pane behavior is not interfered with. Overall, I feel that this behavior feels the most natural, and it doesn't preclude adding generic double-/triple-click events in the future.

@nicm

nicm commented Sep 13, 2015

Copy link
Copy Markdown
Member

Can you send me a diff or give me a URL please? This issue is still
pointing to the old patch.

Thanks

On Sat, Sep 12, 2015 at 11:03:08PM -0700, Omar Sandoval wrote:

Hi, sorry, just picking up on this again. Could you take a look at what I
just pushed? I implemented what I described above. I used a timer because
doing it any other way felt weird to use. The default select-pane behavior
is not interfered with. Overall, I feel that this behavior feels the most
natural, and it doesn't preclude adding generic double-/triple-click
events in the future.

--
Reply to this email directly or [1]view it on GitHub.

Reverse link: [2]unknown

References

Visible links

  1. Double- and triple-click selection of whole words and lines #84 (comment)
  2. Double- and triple-click selection of whole words and lines #84 (comment)

@osandov

osandov commented Sep 14, 2015

Copy link
Copy Markdown
Author

It's the same branch as in the issue, I've just updated it (https://github.com/osandov/tmux/tree/double-click-select). If that doesn't work for you, I'm happy to send a patch instead.

@nicm

nicm commented Sep 14, 2015

Copy link
Copy Markdown
Member

Please send a patch, thanks

On Sun, Sep 13, 2015 at 10:36:01PM -0700, Omar Sandoval wrote:

It's the same branch as in the issue, I've just updated it
([1]https://github.com/osandov/tmux/tree/double-click-select). If that
doesn't work for you, I'm happy to send a patch instead.

--
Reply to this email directly or [2]view it on GitHub.

Reverse link: [3]unknown

References

Visible links

  1. https://github.com/osandov/tmux/tree/double-click-select
  2. Double- and triple-click selection of whole words and lines #84 (comment)
  3. Double- and triple-click selection of whole words and lines #84 (comment)

@nicm

nicm commented Sep 14, 2015

Copy link
Copy Markdown
Member

Never mind turns out I can do https://github.com/tmux/tmux/compare/master...osandov:double-click-select.patch

I'll look at it in a bit

Thanks

@nicm

nicm commented Sep 14, 2015

Copy link
Copy Markdown
Member

This diff is good as far as it goes but it sucks that we have double/triple clicks without letting people bind them, I need to think about it.

@nicm

nicm commented Sep 14, 2015

Copy link
Copy Markdown
Member

I think I would like this better if the timer was in window-copy.c and the flags in window_copy_mode_data. Can you do that instead?

@osandov
osandov force-pushed the double-click-select branch from e007bd3 to 97790be Compare September 29, 2015 07:39
@osandov
osandov force-pushed the double-click-select branch from 97790be to 7e9bf7b Compare January 27, 2016 09:56
@osandov

osandov commented Jan 27, 2016

Copy link
Copy Markdown
Author

Hey, I picked this back up and rebased on top of master. There were quite a few conflicts but it should all be cleaned up now. Let me know if there's anything else I can do, I'd still love to see this get in.

@nicm

nicm commented Jan 29, 2016

Copy link
Copy Markdown
Member

I'm busy at the moment but I'll try to look at it again at some point.

On Wed, Jan 27, 2016 at 02:00:57AM -0800, Omar Sandoval wrote:

Hey, I picked this back up and rebased on top of master. There were quite
a few conflicts but it should all be cleaned up now. Let me know if
there's anything else I can do, I'd still love to see this get in.

--
Reply to this email directly or [1]view it on GitHub.

Reverse link: [2]unknown

References

Visible links

  1. Double- and triple-click selection of whole words and lines #84 (comment)
  2. Double- and triple-click selection of whole words and lines #84 (comment)

Double-clicking selects the word under the mouse; dragging after that
will select whole words. Triple-clicking selects the line under the
mouse; dragging after that will select whole lines.

This is implemented by modifying "copy-mode -M" to handle mouse down
events directly rather than by adding generic double- or triple-click
events. We also add a default binding for MouseDown1Pane.
@osandov
osandov force-pushed the double-click-select branch from 7e9bf7b to 69da595 Compare June 17, 2016 23:33
@osandov

osandov commented Jun 17, 2016

Copy link
Copy Markdown
Author

Rebased again. I can send a patch to the mailing list instead if that's more convenient.

@nicm

nicm commented Oct 10, 2016

Copy link
Copy Markdown
Member

Hi. I don't like making this all part of copy mode, I think it is much better to have generic DoubleClick and TripleClick and bind them to select-word and select-line commands, even if it needs a few extra clicks to swap between different selections. I think I will go with this: tmux-clicks.diff.txt

@nicm

nicm commented Oct 10, 2016

Copy link
Copy Markdown
Member

Soon you will be able to bind full commands as keys in copy mode, so it will be possible to make these more sophisticated (check current selection perhaps).

@nicm

nicm commented Oct 11, 2016

Copy link
Copy Markdown
Member

Applied this now.

@nicm nicm closed this Oct 11, 2016
@osandov
osandov deleted the double-click-select branch December 3, 2016 00:13
@lock

lock Bot commented Feb 14, 2020

Copy link
Copy Markdown

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked and limited conversation to collaborators Feb 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants