diff options
-rw-r--r-- | zellij-client/src/input_handler.rs | 3 | ||||
-rw-r--r-- | zellij-server/src/panes/plugin_pane.rs | 8 | ||||
-rw-r--r-- | zellij-server/src/route.rs | 7 | ||||
-rw-r--r-- | zellij-server/src/screen.rs | 10 | ||||
-rw-r--r-- | zellij-server/src/tab.rs | 9 | ||||
-rw-r--r-- | zellij-tile/src/data.rs | 1 | ||||
-rw-r--r-- | zellij-utils/src/errors.rs | 1 | ||||
-rw-r--r-- | zellij-utils/src/input/actions.rs | 1 |
8 files changed, 40 insertions, 0 deletions
diff --git a/zellij-client/src/input_handler.rs b/zellij-client/src/input_handler.rs index 2b89741e0..d07c2caa8 100644 --- a/zellij-client/src/input_handler.rs +++ b/zellij-client/src/input_handler.rs @@ -135,6 +135,9 @@ impl InputHandler { MouseButton::Left => { self.dispatch_action(Action::LeftClick(point)); } + MouseButton::Right => { + self.dispatch_action(Action::RightClick(point)); + } _ => {} }, MouseEvent::Release(point) => { diff --git a/zellij-server/src/panes/plugin_pane.rs b/zellij-server/src/panes/plugin_pane.rs index 8659ae155..6b1cb4168 100644 --- a/zellij-server/src/panes/plugin_pane.rs +++ b/zellij-server/src/panes/plugin_pane.rs @@ -327,4 +327,12 @@ impl Pane for PluginPane { fn borderless(&self) -> bool { self.borderless } + fn handle_right_click(&mut self, to: &Position) { + self.send_plugin_instructions + .send(PluginInstruction::Update( + Some(self.pid), + Event::Mouse(Mouse::RightClick(to.line.0, to.column.0)), + )) + .unwrap(); + } } diff --git a/zellij-server/src/route.rs b/zellij-server/src/route.rs index bb9e733dc..57fea1247 100644 --- a/zellij-server/src/route.rs +++ b/zellij-server/src/route.rs @@ -296,6 +296,13 @@ fn route_action( .send_to_screen(ScreenInstruction::LeftClick(point, client_id)) .unwrap(); } + Action::RightClick(point) => { + session + .senders + .send_to_screen(ScreenInstruction::RightClick(point, client_id)) + .unwrap(); + } + Action::MouseRelease(point) => { session .senders diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs index 72c681c97..4852b305b 100644 --- a/zellij-server/src/screen.rs +++ b/zellij-server/src/screen.rs @@ -74,6 +74,7 @@ pub(crate) enum ScreenInstruction { TerminalResize(Size), ChangeMode(ModeInfo, ClientId), LeftClick(Position, ClientId), + RightClick(Position, ClientId), MouseRelease(Position, ClientId), MouseHold(Position, ClientId), Copy(ClientId), @@ -138,6 +139,7 @@ impl From<&ScreenInstruction> for ScreenContext { ScreenInstruction::ScrollUpAt(..) => ScreenContext::ScrollUpAt, ScreenInstruction::ScrollDownAt(..) => ScreenContext::ScrollDownAt, ScreenInstruction::LeftClick(..) => ScreenContext::LeftClick, + ScreenInstruction::RightClick(..) => ScreenContext::RightClick, ScreenInstruction::MouseRelease(..) => ScreenContext::MouseRelease, ScreenInstruction::MouseHold(..) => ScreenContext::MouseHold, ScreenInstruction::Copy(..) => ScreenContext::Copy, @@ -973,6 +975,14 @@ pub(crate) fn screen_thread_main( screen.render(); } + ScreenInstruction::RightClick(point, client_id) => { + screen + .get_active_tab_mut(client_id) + .unwrap() + .handle_right_click(&point); + + screen.render(); + } ScreenInstruction::MouseRelease(point, client_id) => { screen .get_active_tab_mut(client_id) diff --git a/zellij-server/src/tab.rs b/zellij-server/src/tab.rs index d50aba42c..5c81b9c6e 100644 --- a/zellij-server/src/tab.rs +++ b/zellij-server/src/tab.rs @@ -269,6 +269,7 @@ pub trait Pane { fn set_boundary_color(&mut self, _color: Option<PaletteColor>) {} fn set_borderless(&mut self, borderless: bool); fn borderless(&self) -> bool; + fn handle_right_click(&mut self, _to: &Position) {} } macro_rules! resize_pty { @@ -2586,6 +2587,14 @@ impl Tab { pane.start_selection(&relative_position); }; } + pub fn handle_right_click(&mut self, position: &Position) { + self.focus_pane_at(position); + + if let Some(pane) = self.get_pane_at(position, false) { + let relative_position = pane.relative_position(position); + pane.handle_right_click(&relative_position); + }; + } fn focus_pane_at(&mut self, point: &Position) { if let Some(clicked_pane) = self.get_pane_id_at(point, true) { self.active_terminal = Some(clicked_pane); diff --git a/zellij-tile/src/data.rs b/zellij-tile/src/data.rs index 9696b3563..872a78f9f 100644 --- a/zellij-tile/src/data.rs +++ b/zellij-tile/src/data.rs @@ -34,6 +34,7 @@ pub enum Mouse { ScrollUp(usize), // number of lines ScrollDown(usize), // number of lines LeftClick(isize, usize), // line and column + RightClick(isize, usize), // line and column Hold(isize, usize), // line and column Release(Option<(isize, usize)>), // line and column } diff --git a/zellij-utils/src/errors.rs b/zellij-utils/src/errors.rs index be75e4add..401cdc10b 100644 --- a/zellij-utils/src/errors.rs +++ b/zellij-utils/src/errors.rs @@ -258,6 +258,7 @@ pub enum ScreenContext { TerminalResize, ChangeMode, LeftClick, + RightClick, MouseRelease, MouseHold, Copy, diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs index c1277db1f..9dd259580 100644 --- a/zellij-utils/src/input/actions.rs +++ b/zellij-utils/src/input/actions.rs @@ -87,6 +87,7 @@ pub enum Action { /// Detach session and exit Detach, LeftClick(Position), + RightClick(Position), MouseRelease(Position), MouseHold(Position), Copy, |