Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(console): don't enable crossterm mouse capture #222

Merged
merged 2 commits into from
Dec 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions console/src/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@ pub use tui::{backend::CrosstermBackend, Terminal};

pub fn init_crossterm() -> color_eyre::Result<(Terminal<CrosstermBackend<io::Stdout>>, OnShutdown)>
{
use crossterm::{
event::{DisableMouseCapture, EnableMouseCapture},
terminal::{self, EnterAlternateScreen, LeaveAlternateScreen},
};
use crossterm::terminal::{self, EnterAlternateScreen, LeaveAlternateScreen};
terminal::enable_raw_mode().wrap_err("Failed to enable crossterm raw mode")?;

let mut stdout = std::io::stdout();
crossterm::execute!(stdout, EnterAlternateScreen, EnableMouseCapture)
.wrap_err("Failed to enable crossterm alternate screen and mouse capture")?;
crossterm::execute!(stdout, EnterAlternateScreen)
.wrap_err("Failed to enable crossterm alternate screen")?;
let backend = CrosstermBackend::new(io::stdout());
let term = Terminal::new(backend).wrap_err("Failed to create crossterm terminal")?;

let cleanup = OnShutdown::new(|| {
// Be a good terminal citizen...
let mut stdout = std::io::stdout();
crossterm::execute!(stdout, LeaveAlternateScreen, DisableMouseCapture)
.wrap_err("Failed to disable crossterm alternate screen and mouse capture")?;
crossterm::execute!(stdout, LeaveAlternateScreen)
.wrap_err("Failed to disable crossterm alternate screen")?;
terminal::disable_raw_mode().wrap_err("Failed to enable crossterm raw mode")?;
Ok(())
});
Expand Down