feat(ui): add right-click support to plugins
This commit is contained in:
parent
2904c04ab0
commit
9ea3dc0dbe
8 changed files with 40 additions and 0 deletions
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,6 +258,7 @@ pub enum ScreenContext {
|
|||
TerminalResize,
|
||||
ChangeMode,
|
||||
LeftClick,
|
||||
RightClick,
|
||||
MouseRelease,
|
||||
MouseHold,
|
||||
Copy,
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ pub enum Action {
|
|||
/// Detach session and exit
|
||||
Detach,
|
||||
LeftClick(Position),
|
||||
RightClick(Position),
|
||||
MouseRelease(Position),
|
||||
MouseHold(Position),
|
||||
Copy,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue