Avoid updating the link highlight while the context menu is shown
This commit is contained in:
parent
e7e47d5bac
commit
27e4d722bf
2 changed files with 19 additions and 14 deletions
|
|
@ -400,7 +400,7 @@ pub enum Message {
|
||||||
TabActivateJump(usize),
|
TabActivateJump(usize),
|
||||||
TabClose(Option<segmented_button::Entity>),
|
TabClose(Option<segmented_button::Entity>),
|
||||||
TabContextAction(segmented_button::Entity, Action),
|
TabContextAction(segmented_button::Entity, Action),
|
||||||
TabContextMenu(pane_grid::Pane, MenuState),
|
TabContextMenu(pane_grid::Pane, Option<MenuState>),
|
||||||
TabNew,
|
TabNew,
|
||||||
TabNewNoProfile,
|
TabNewNoProfile,
|
||||||
TabNext,
|
TabNext,
|
||||||
|
|
@ -2469,7 +2469,7 @@ impl Application for App {
|
||||||
if let Some(terminal) = tab_model.data::<Mutex<Terminal>>(entity) {
|
if let Some(terminal) = tab_model.data::<Mutex<Terminal>>(entity) {
|
||||||
// Update context menu position
|
// Update context menu position
|
||||||
let mut terminal = terminal.lock().unwrap();
|
let mut terminal = terminal.lock().unwrap();
|
||||||
terminal.context_menu = Some(menu_state);
|
terminal.context_menu = menu_state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ pub struct TerminalBox<'a, Message> {
|
||||||
show_headerbar: bool,
|
show_headerbar: bool,
|
||||||
click_timing: Duration,
|
click_timing: Duration,
|
||||||
context_menu: Option<Point>,
|
context_menu: Option<Point>,
|
||||||
on_context_menu: Option<Box<dyn Fn(MenuState) -> Message + 'a>>,
|
on_context_menu: Option<Box<dyn Fn(Option<MenuState>) -> Message + 'a>>,
|
||||||
on_mouse_enter: Option<Box<dyn Fn() -> Message + 'a>>,
|
on_mouse_enter: Option<Box<dyn Fn() -> Message + 'a>>,
|
||||||
opacity: Option<f32>,
|
opacity: Option<f32>,
|
||||||
mouse_inside_boundary: Option<bool>,
|
mouse_inside_boundary: Option<bool>,
|
||||||
|
|
@ -124,7 +124,10 @@ where
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_context_menu(mut self, on_context_menu: impl Fn(MenuState) -> Message + 'a) -> Self {
|
pub fn on_context_menu(
|
||||||
|
mut self,
|
||||||
|
on_context_menu: impl Fn(Option<MenuState>) -> Message + 'a,
|
||||||
|
) -> Self {
|
||||||
self.on_context_menu = Some(Box::new(on_context_menu));
|
self.on_context_menu = Some(Box::new(on_context_menu));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -1098,10 +1101,7 @@ where
|
||||||
// Update context menu state
|
// Update context menu state
|
||||||
if let Some(on_context_menu) = &self.on_context_menu {
|
if let Some(on_context_menu) = &self.on_context_menu {
|
||||||
shell.publish((on_context_menu)(match self.context_menu {
|
shell.publish((on_context_menu)(match self.context_menu {
|
||||||
Some(_) => MenuState {
|
Some(_) => None,
|
||||||
position: None,
|
|
||||||
link: None,
|
|
||||||
},
|
|
||||||
None => match button {
|
None => match button {
|
||||||
Button::Right => {
|
Button::Right => {
|
||||||
let x = p.x - self.padding.left;
|
let x = p.x - self.padding.left;
|
||||||
|
|
@ -1120,15 +1120,12 @@ where
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
let link = get_hyperlink(&terminal, location);
|
let link = get_hyperlink(&terminal, location);
|
||||||
MenuState {
|
Some(MenuState {
|
||||||
position: Some(p),
|
position: Some(p),
|
||||||
link,
|
link,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
_ => MenuState {
|
_ => None,
|
||||||
position: None,
|
|
||||||
link: None,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
@ -1340,6 +1337,14 @@ fn update_active_regex_match(
|
||||||
location: Option<TermPoint>,
|
location: Option<TermPoint>,
|
||||||
modifiers: Option<&Modifiers>,
|
modifiers: Option<&Modifiers>,
|
||||||
) {
|
) {
|
||||||
|
//Do not update any highlights if
|
||||||
|
//there is a context_menu shown
|
||||||
|
//to the user
|
||||||
|
if terminal.context_menu.is_some() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Require CTRL for keyboard and mouse interaction
|
||||||
if let Some(modifiers) = modifiers {
|
if let Some(modifiers) = modifiers {
|
||||||
if !modifiers.contains(Modifiers::CTRL) {
|
if !modifiers.contains(Modifiers::CTRL) {
|
||||||
if terminal.active_regex_match.is_some() {
|
if terminal.active_regex_match.is_some() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue