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 => {
|
MouseButton::Left => {
|
||||||
self.dispatch_action(Action::LeftClick(point));
|
self.dispatch_action(Action::LeftClick(point));
|
||||||
}
|
}
|
||||||
|
MouseButton::Right => {
|
||||||
|
self.dispatch_action(Action::RightClick(point));
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
MouseEvent::Release(point) => {
|
MouseEvent::Release(point) => {
|
||||||
|
|
|
||||||
|
|
@ -327,4 +327,12 @@ impl Pane for PluginPane {
|
||||||
fn borderless(&self) -> bool {
|
fn borderless(&self) -> bool {
|
||||||
self.borderless
|
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))
|
.send_to_screen(ScreenInstruction::LeftClick(point, client_id))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
Action::RightClick(point) => {
|
||||||
|
session
|
||||||
|
.senders
|
||||||
|
.send_to_screen(ScreenInstruction::RightClick(point, client_id))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
Action::MouseRelease(point) => {
|
Action::MouseRelease(point) => {
|
||||||
session
|
session
|
||||||
.senders
|
.senders
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ pub(crate) enum ScreenInstruction {
|
||||||
TerminalResize(Size),
|
TerminalResize(Size),
|
||||||
ChangeMode(ModeInfo, ClientId),
|
ChangeMode(ModeInfo, ClientId),
|
||||||
LeftClick(Position, ClientId),
|
LeftClick(Position, ClientId),
|
||||||
|
RightClick(Position, ClientId),
|
||||||
MouseRelease(Position, ClientId),
|
MouseRelease(Position, ClientId),
|
||||||
MouseHold(Position, ClientId),
|
MouseHold(Position, ClientId),
|
||||||
Copy(ClientId),
|
Copy(ClientId),
|
||||||
|
|
@ -138,6 +139,7 @@ impl From<&ScreenInstruction> for ScreenContext {
|
||||||
ScreenInstruction::ScrollUpAt(..) => ScreenContext::ScrollUpAt,
|
ScreenInstruction::ScrollUpAt(..) => ScreenContext::ScrollUpAt,
|
||||||
ScreenInstruction::ScrollDownAt(..) => ScreenContext::ScrollDownAt,
|
ScreenInstruction::ScrollDownAt(..) => ScreenContext::ScrollDownAt,
|
||||||
ScreenInstruction::LeftClick(..) => ScreenContext::LeftClick,
|
ScreenInstruction::LeftClick(..) => ScreenContext::LeftClick,
|
||||||
|
ScreenInstruction::RightClick(..) => ScreenContext::RightClick,
|
||||||
ScreenInstruction::MouseRelease(..) => ScreenContext::MouseRelease,
|
ScreenInstruction::MouseRelease(..) => ScreenContext::MouseRelease,
|
||||||
ScreenInstruction::MouseHold(..) => ScreenContext::MouseHold,
|
ScreenInstruction::MouseHold(..) => ScreenContext::MouseHold,
|
||||||
ScreenInstruction::Copy(..) => ScreenContext::Copy,
|
ScreenInstruction::Copy(..) => ScreenContext::Copy,
|
||||||
|
|
@ -973,6 +975,14 @@ pub(crate) fn screen_thread_main(
|
||||||
|
|
||||||
screen.render();
|
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) => {
|
ScreenInstruction::MouseRelease(point, client_id) => {
|
||||||
screen
|
screen
|
||||||
.get_active_tab_mut(client_id)
|
.get_active_tab_mut(client_id)
|
||||||
|
|
|
||||||
|
|
@ -269,6 +269,7 @@ pub trait Pane {
|
||||||
fn set_boundary_color(&mut self, _color: Option<PaletteColor>) {}
|
fn set_boundary_color(&mut self, _color: Option<PaletteColor>) {}
|
||||||
fn set_borderless(&mut self, borderless: bool);
|
fn set_borderless(&mut self, borderless: bool);
|
||||||
fn borderless(&self) -> bool;
|
fn borderless(&self) -> bool;
|
||||||
|
fn handle_right_click(&mut self, _to: &Position) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! resize_pty {
|
macro_rules! resize_pty {
|
||||||
|
|
@ -2586,6 +2587,14 @@ impl Tab {
|
||||||
pane.start_selection(&relative_position);
|
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) {
|
fn focus_pane_at(&mut self, point: &Position) {
|
||||||
if let Some(clicked_pane) = self.get_pane_id_at(point, true) {
|
if let Some(clicked_pane) = self.get_pane_id_at(point, true) {
|
||||||
self.active_terminal = Some(clicked_pane);
|
self.active_terminal = Some(clicked_pane);
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ pub enum Mouse {
|
||||||
ScrollUp(usize), // number of lines
|
ScrollUp(usize), // number of lines
|
||||||
ScrollDown(usize), // number of lines
|
ScrollDown(usize), // number of lines
|
||||||
LeftClick(isize, usize), // line and column
|
LeftClick(isize, usize), // line and column
|
||||||
|
RightClick(isize, usize), // line and column
|
||||||
Hold(isize, usize), // line and column
|
Hold(isize, usize), // line and column
|
||||||
Release(Option<(isize, usize)>), // line and column
|
Release(Option<(isize, usize)>), // line and column
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -258,6 +258,7 @@ pub enum ScreenContext {
|
||||||
TerminalResize,
|
TerminalResize,
|
||||||
ChangeMode,
|
ChangeMode,
|
||||||
LeftClick,
|
LeftClick,
|
||||||
|
RightClick,
|
||||||
MouseRelease,
|
MouseRelease,
|
||||||
MouseHold,
|
MouseHold,
|
||||||
Copy,
|
Copy,
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ pub enum Action {
|
||||||
/// Detach session and exit
|
/// Detach session and exit
|
||||||
Detach,
|
Detach,
|
||||||
LeftClick(Position),
|
LeftClick(Position),
|
||||||
|
RightClick(Position),
|
||||||
MouseRelease(Position),
|
MouseRelease(Position),
|
||||||
MouseHold(Position),
|
MouseHold(Position),
|
||||||
Copy,
|
Copy,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue