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

Feature: pass the mouse click event to pty #1013

Closed
jaeheonji opened this issue Jan 18, 2022 · 5 comments
Closed

Feature: pass the mouse click event to pty #1013

jaeheonji opened this issue Jan 18, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@jaeheonji
Copy link
Member

jaeheonji commented Jan 18, 2022

This feature related to #1011

In the tab, mouse click events are only used for pane selection (focus)

pub fn handle_left_click(&mut self, position: &Position, client_id: ClientId) {
self.focus_pane_at(position, client_id);
if let Some(pane) = self.get_pane_at(position, false) {
let relative_position = pane.relative_position(position);
pane.start_selection(&relative_position, client_id);
self.selecting_with_mouse = true;
};
}
pub fn handle_right_click(&mut self, position: &Position, client_id: ClientId) {
self.focus_pane_at(position, client_id);
if let Some(pane) = self.get_pane_at(position, false) {
let relative_position = pane.relative_position(position);
pane.handle_right_click(&relative_position, client_id);
};
}

This means that programs that use a mouse in the TUI environment (eg neovim) will ignore mouse event.

It looks like we need to some logic to pass the mouse click event to pty after selecting the pane.

@jaeheonji jaeheonji added the enhancement New feature or request label Jan 18, 2022
@a-kenji
Copy link
Contributor

a-kenji commented Jan 19, 2022

Here is some prior work, that could potentially be a good starting point for anyone wanting / having the ability to work on it:

Sending mouse events to the terminal #624 .

@tlinford
Copy link
Contributor

#624 looks like a great start, the major thing i think it's missing is only sending mouse events to panes that have themselves enabled mouse mode. Info on that can be found here: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking.

Another thing that needs some thought is what modes should be supported, as far as I can tell SGR (1006) should be preferred.

@ghost
Copy link

ghost commented Jan 24, 2022

Another thing that needs some thought is what modes should be supported, as far as I can tell SGR (1006) should be preferred.

SGR is the best for today, as it has no upper limit on coordinates and can distinguish between each button for all events.

UTF-8 (1005) is also good because it has a large range, but the button release event is a single event for any number of buttons. If you do SGR or UTF-8 first, doing the next one might look confusing because there is a behavior difference in addition to an encoding difference.

Note that applications will often ask for several things at once like CSI ? 1002;1003;1005;1006h --> give me SGR any-event, if you don't have SGR make it UTF-8, if you don't have any-event make it button-event.

@imsnif
Copy link
Member

imsnif commented May 3, 2022

I think this can be closed, right @tlinford ?

@tlinford
Copy link
Contributor

tlinford commented May 3, 2022

Yep, support for SGR was added in #1191, I'd say that if we want to add support for other encodings we can open new, specific, issues for that.

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

4 participants