disable terminal raw mode on cross term drop

This commit is contained in:
Denis-Cosmin Nutiu 2024-12-10 23:54:15 +02:00
parent a9d252f758
commit 9171b35025

View file

@ -1,5 +1,5 @@
use crossterm::event::{poll, read, Event, KeyCode};
use crossterm::terminal::enable_raw_mode;
use crossterm::terminal::{disable_raw_mode, enable_raw_mode};
use std::time::Duration;
/// InputModule retrieves the keys from the hardware or software input control module.
@ -89,3 +89,9 @@ impl InputModule for CrossTermInput {
None
}
}
impl Drop for CrossTermInput {
fn drop(&mut self) {
disable_raw_mode().expect("failed to disable terminal raw mode.");
}
}