From 4bdc504c87c5608918a8afe148dcd91efbf91346 Mon Sep 17 00:00:00 2001 From: kosay Date: Wed, 21 Jun 2023 00:35:01 +0900 Subject: [PATCH] feat: Enable capturing focus events. --- src/main.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5e1419a2..7bbc39be 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,7 @@ use crossbeam::channel::{bounded, Receiver, Sender}; use crossterm::{ cursor::Show, - event::{DisableMouseCapture, EnableMouseCapture}, + event::{DisableFocusChange, DisableMouseCapture, EnableFocusChange, EnableMouseCapture}, execute, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, }; @@ -36,8 +36,13 @@ use ratatui::{backend::CrosstermBackend, Terminal, TerminalOptions, Viewport}; macro_rules! enable_raw_mode { () => { enable_raw_mode().expect("failed to enable raw mode"); - execute!(io::stdout(), EnterAlternateScreen, EnableMouseCapture) - .expect("failed to enable raw mode"); + execute!( + io::stdout(), + EnterAlternateScreen, + EnableMouseCapture, + EnableFocusChange + ) + .expect("failed to enable raw mode"); }; } @@ -47,6 +52,7 @@ macro_rules! disable_raw_mode { io::stdout(), LeaveAlternateScreen, DisableMouseCapture, + DisableFocusChange, Show ) .expect("failed to restore terminal");