fix(screen): handle events directed at other tabs (#257)
This commit is contained in:
parent
1c71d16eb5
commit
e551bec538
2 changed files with 19 additions and 4 deletions
|
|
@ -561,6 +561,9 @@ impl Tab {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn has_terminal_pid(&self, pid: RawFd) -> bool {
|
||||||
|
self.panes.contains_key(&PaneId::Terminal(pid))
|
||||||
|
}
|
||||||
pub fn handle_pty_event(&mut self, pid: RawFd, event: VteEvent) {
|
pub fn handle_pty_event(&mut self, pid: RawFd, event: VteEvent) {
|
||||||
// if we don't have the terminal in self.terminals it's probably because
|
// if we don't have the terminal in self.terminals it's probably because
|
||||||
// of a race condition where the terminal was created in pty_bus but has not
|
// of a race condition where the terminal was created in pty_bus but has not
|
||||||
|
|
|
||||||
|
|
@ -276,10 +276,22 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
||||||
screen.send_pty_instructions.update(err_ctx);
|
screen.send_pty_instructions.update(err_ctx);
|
||||||
match event {
|
match event {
|
||||||
ScreenInstruction::Pty(pid, vte_event) => {
|
ScreenInstruction::Pty(pid, vte_event) => {
|
||||||
screen
|
let active_tab = screen.get_active_tab_mut().unwrap();
|
||||||
.get_active_tab_mut()
|
if active_tab.has_terminal_pid(pid) {
|
||||||
.unwrap()
|
// it's most likely that this event is directed at the active tab
|
||||||
.handle_pty_event(pid, vte_event);
|
// look there first
|
||||||
|
active_tab.handle_pty_event(pid, vte_event);
|
||||||
|
} else {
|
||||||
|
// if this event wasn't directed at the active tab, start looking
|
||||||
|
// in other tabs
|
||||||
|
let all_tabs = screen.get_tabs_mut();
|
||||||
|
for tab in all_tabs.values_mut() {
|
||||||
|
if tab.has_terminal_pid(pid) {
|
||||||
|
tab.handle_pty_event(pid, vte_event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ScreenInstruction::Render => {
|
ScreenInstruction::Render => {
|
||||||
screen.render();
|
screen.render();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue