diff --git a/CHANGELOG.md b/CHANGELOG.md index 813bc5fb20..01e0081265 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ## Unreleased +- Report focus change https://terminalguide.namepad.de/mode/p1004/. - Updated wgpu to 0.19.0. - Removed support to DX11. - Add basic touch support by @androw [#226](https://github.com/raphamorim/rio/pull/226) diff --git a/frontends/rioterm/src/screen/mod.rs b/frontends/rioterm/src/screen/mod.rs index 3506d99424..1b67c63cd1 100644 --- a/frontends/rioterm/src/screen/mod.rs +++ b/frontends/rioterm/src/screen/mod.rs @@ -1352,6 +1352,19 @@ impl Screen { self.ctx_mut().current_mut().messenger.send_bytes(msg); } + #[inline] + pub fn on_focus_change(&mut self, is_focused: bool) { + if self.get_mode().contains(Mode::FOCUS_IN_OUT) { + let chr = if is_focused { "I" } else { "O" }; + + let msg = format!("\x1b[{}", chr); + self.ctx_mut() + .current_mut() + .messenger + .send_bytes(msg.into_bytes()); + } + } + #[inline] pub fn scroll(&mut self, new_scroll_x_px: f64, new_scroll_y_px: f64) { let width = self.sugarloaf.layout.scaled_sugarwidth as f64; diff --git a/frontends/rioterm/src/sequencer.rs b/frontends/rioterm/src/sequencer.rs index 7af1791ae3..2f2c319820 100644 --- a/frontends/rioterm/src/sequencer.rs +++ b/frontends/rioterm/src/sequencer.rs @@ -922,6 +922,8 @@ impl Sequencer { if has_regained_focus { route.redraw(); } + + route.window.screen.on_focus_change(focused); } }