term: enable DECSET 1004 Focus Reporting
This is enabled only for local terminals for now; the multiplexer protocol will need to be extended to carry this signal.
This commit is contained in:
1 parent
e4fb68bb22
commit
4e6357b218
5 files changed
+37
-4
No files matched your search
@@ -10,7 +10,8 @@ daily) from the master branch. It may not be usable and
|
||||
the feature set may change. As features stabilize some
|
||||
brief notes about them may accumulate here.
|
||||
|
||||
* Not yet
|
||||
* Added support for DECSET 1004 Focus Reporting to local
|
||||
(not multiplexer) terminal sessions.
|
||||
|
||||
### 20200620-160318-e00b076c
|
||||
|
||||
|
||||
@@ -320,6 +320,10 @@ impl WindowCallbacks for TermWindow {
|
||||
|
||||
// force cursor to be repainted
|
||||
self.window.as_ref().unwrap().invalidate();
|
||||
|
||||
if let Some(tab) = self.get_active_tab_or_overlay() {
|
||||
tab.focus_changed(focused);
|
||||
}
|
||||
}
|
||||
|
||||
fn mouse_event(&mut self, event: &MouseEvent, context: &dyn WindowOps) {
|
||||
@@ -1216,10 +1220,19 @@ impl TermWindow {
|
||||
tab_idx as usize
|
||||
};
|
||||
|
||||
if let Some(tab) = self.get_active_tab_or_overlay() {
|
||||
tab.focus_changed(false);
|
||||
}
|
||||
|
||||
if tab_idx < max {
|
||||
window.set_active(tab_idx);
|
||||
|
||||
drop(window);
|
||||
|
||||
if let Some(tab) = self.get_active_tab_or_overlay() {
|
||||
tab.focus_changed(false);
|
||||
}
|
||||
|
||||
self.update_title();
|
||||
self.update_scrollbar();
|
||||
}
|
||||
|
||||
@@ -94,6 +94,10 @@ impl Tab for LocalTab {
|
||||
self.terminal.borrow_mut().erase_scrollback();
|
||||
}
|
||||
|
||||
fn focus_changed(&self, focused: bool) {
|
||||
self.terminal.borrow_mut().focus_changed(focused);
|
||||
}
|
||||
|
||||
fn is_mouse_grabbed(&self) -> bool {
|
||||
self.terminal.borrow().is_mouse_grabbed()
|
||||
}
|
||||
|
||||
@@ -102,6 +102,9 @@ pub trait Tab: Downcast {
|
||||
|
||||
fn erase_scrollback(&self) {}
|
||||
|
||||
/// Called to advise on whether this tab has focus
|
||||
fn focus_changed(&self, _focused: bool) {}
|
||||
|
||||
/// Performs a search.
|
||||
/// If the result is empty then there are no matches.
|
||||
/// Otherwise, the result shall contain all possible matches.
|
||||
|
||||
@@ -261,6 +261,7 @@ pub struct TerminalState {
|
||||
|
||||
/// Movement events enabled
|
||||
any_event_mouse: bool,
|
||||
focus_tracking: bool,
|
||||
/// SGR style mouse tracking and reporting is enabled
|
||||
sgr_mouse: bool,
|
||||
mouse_tracking: bool,
|
||||
@@ -360,6 +361,7 @@ impl TerminalState {
|
||||
color_map,
|
||||
application_keypad: false,
|
||||
bracketed_paste: false,
|
||||
focus_tracking: false,
|
||||
sgr_mouse: false,
|
||||
any_event_mouse: false,
|
||||
button_event_mouse: false,
|
||||
@@ -659,6 +661,13 @@ impl TerminalState {
|
||||
self.bracketed_paste
|
||||
}
|
||||
|
||||
/// Advise the terminal about a change in its focus state
|
||||
pub fn focus_changed(&mut self, focused: bool) {
|
||||
if self.focus_tracking {
|
||||
write!(self.writer, "{}{}", CSI, if focused { "I" } else { "O" }).ok();
|
||||
}
|
||||
}
|
||||
|
||||
/// Send text to the terminal that is the result of pasting.
|
||||
/// If bracketed paste mode is enabled, the paste is enclosed
|
||||
/// in the bracketing, otherwise it is fed to the writer as-is.
|
||||
@@ -1666,9 +1675,11 @@ impl TerminalState {
|
||||
self.any_event_mouse = false;
|
||||
}
|
||||
|
||||
Mode::SetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::FocusTracking))
|
||||
| Mode::ResetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::FocusTracking)) => {
|
||||
// FocusTracking is not supported
|
||||
Mode::SetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::FocusTracking)) => {
|
||||
self.focus_tracking = true;
|
||||
}
|
||||
Mode::ResetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::FocusTracking)) => {
|
||||
self.focus_tracking = false;
|
||||
}
|
||||
|
||||
Mode::SetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::SGRMouse)) => {
|
||||
@@ -2739,6 +2750,7 @@ impl<'a> Performer<'a> {
|
||||
self.dec_ansi_mode = false;
|
||||
self.application_keypad = false;
|
||||
self.bracketed_paste = false;
|
||||
self.focus_tracking = false;
|
||||
self.sgr_mouse = false;
|
||||
self.any_event_mouse = false;
|
||||
self.button_event_mouse = false;
|
||||
|
||||
Reference in new issue
Block a user