diff options
| author | Tw <tw19881113@gmail.com> | 2021-11-03 02:49:10 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-02 18:49:10 +0000 |
| commit | 9ea3dc0dbe61a749c8ccf3f03a8331db47f150a6 (patch) | |
| tree | 9c7abd3f3335031b0f28e6baeb1d818025a4ef6a /zellij-server/src | |
| parent | docs(changelog): `colors_transform` to `colorsys` (diff) | |
| download | sl0ppij-9ea3dc0dbe61a749c8ccf3f03a8331db47f150a6.tar.gz sl0ppij-9ea3dc0dbe61a749c8ccf3f03a8331db47f150a6.tar.xz sl0ppij-9ea3dc0dbe61a749c8ccf3f03a8331db47f150a6.zip | |
feat(ui): add right-click support to plugins
Diffstat (limited to 'zellij-server/src')
| -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 |
4 files changed, 34 insertions, 0 deletions
diff --git a/zellij-server/src/panes/plugin_pane.rs b/zellij-server/src/panes/plugin_pane.rs index 8659ae15..6b1cb416 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 bb9e733d..57fea124 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 72c681c9..4852b305 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 d50aba42..5c81b9c6 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); |
