feat: report focus in and out events
This commit is contained in:
parent
a5acc057af
commit
042c915990
1 changed files with 18 additions and 2 deletions
|
|
@ -190,7 +190,7 @@ impl TerminalPaneGrid {
|
|||
let entity = tab_model.active();
|
||||
if let Some(terminal) = tab_model.data::<Mutex<Terminal>>(entity) {
|
||||
let mut terminal = terminal.lock().unwrap();
|
||||
terminal.is_focused = self.focus == *pane;
|
||||
terminal.set_focused(self.focus == *pane);
|
||||
terminal.update();
|
||||
}
|
||||
}
|
||||
|
|
@ -200,7 +200,7 @@ impl TerminalPaneGrid {
|
|||
let entity = tab_model.active();
|
||||
if let Some(terminal) = tab_model.data::<Mutex<Terminal>>(entity) {
|
||||
let mut terminal = terminal.lock().unwrap();
|
||||
terminal.is_focused = false;
|
||||
terminal.set_focused(false);
|
||||
terminal.update();
|
||||
}
|
||||
}
|
||||
|
|
@ -402,6 +402,22 @@ impl Terminal {
|
|||
self.zoom_adj = value;
|
||||
}
|
||||
|
||||
fn set_focused(&mut self, is_focused: bool) {
|
||||
let focus_changed = self.is_focused != is_focused;
|
||||
self.is_focused = is_focused;
|
||||
|
||||
if focus_changed {
|
||||
let report_focus = self.term.lock().mode().contains(TermMode::FOCUS_IN_OUT);
|
||||
if report_focus {
|
||||
const FOCUS_IN: &[u8] = b"\x1b[I";
|
||||
const FOCUS_OUT: &[u8] = b"\x1b[O";
|
||||
|
||||
let input = if is_focused { FOCUS_IN } else { FOCUS_OUT };
|
||||
self.input_no_scroll(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn redraw(&self) -> bool {
|
||||
self.buffer.redraw()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue