repline/
raw.rs

1//! Sets the terminal to [`raw`] mode for the duration of the returned object's lifetime.
2
3/// Sets the terminal to raw mode for the duration of the returned object's lifetime.
4pub fn raw() -> impl Drop {
5    Raw::default()
6}
7struct Raw();
8impl Default for Raw {
9    fn default() -> Self {
10        std::thread::yield_now();
11        crossterm::terminal::enable_raw_mode()
12            .expect("should be able to transition into raw mode");
13        Raw()
14    }
15}
16impl Drop for Raw {
17    fn drop(&mut self) {
18        crossterm::terminal::disable_raw_mode()
19            .expect("should be able to transition out of raw mode");
20    }
21}