Skip to content

Commit

Permalink
feat: Enable capturing focus events.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarub0b0 committed Jun 25, 2023
1 parent 7bdfb9b commit 4bdc504
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};
Expand Down Expand Up @@ -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");
};
}

Expand All @@ -47,6 +52,7 @@ macro_rules! disable_raw_mode {
io::stdout(),
LeaveAlternateScreen,
DisableMouseCapture,
DisableFocusChange,
Show
)
.expect("failed to restore terminal");
Expand Down

0 comments on commit 4bdc504

Please sign in to comment.