Skip to content

Commit

Permalink
fix: termion not enabling input on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Beastwick18 committed Aug 14, 2024
1 parent 5cb0fd8 commit c5fd7cd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use ratatui::{backend::CrosstermBackend, Terminal};
use sync::AppSync;

#[cfg(not(any(target_os = "linux", target_os = "windows", target_os = "macos")))]
use ratatui::termion::raw::IntoRawMode;
use ratatui::{
backend::TermionBackend, termion::raw::IntoRawMode, termion::screen::IntoAlternateScreen,
};

pub mod app;
pub mod client;
Expand Down Expand Up @@ -65,7 +67,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(any(target_os = "linux", target_os = "windows", target_os = "macos"))]
let backend = CrosstermBackend::new(stdout());
#[cfg(not(any(target_os = "linux", target_os = "windows", target_os = "macos")))]
let backend = CrosstermBackend::new(stdout().into_raw_mode()?);
let (backend, backend_termion) = (
CrosstermBackend::new(stdout().into_raw_mode()?.into_alternate_screen()?),
TermionBackend::new(stdout().into_raw_mode()?.into_alternate_screen()?),
);

let mut terminal = Terminal::new(backend)?;

Expand All @@ -79,6 +84,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
app.run_app::<_, _, AppConfig, false>(&mut terminal, sync, config)
.await?;

#[cfg(not(any(target_os = "linux", target_os = "windows", target_os = "macos")))]
drop(backend_termion);

util::term::reset_terminal()?;
terminal.show_cursor()?;

Expand Down

0 comments on commit c5fd7cd

Please sign in to comment.