repline/
raw.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//! Sets the terminal to [`raw`] mode for the duration of the returned object's lifetime.

/// Sets the terminal to raw mode for the duration of the returned object's lifetime.
pub fn raw() -> impl Drop {
    Raw::default()
}
struct Raw();
impl Default for Raw {
    fn default() -> Self {
        std::thread::yield_now();
        crossterm::terminal::enable_raw_mode()
            .expect("should be able to transition into raw mode");
        Raw()
    }
}
impl Drop for Raw {
    fn drop(&mut self) {
        crossterm::terminal::disable_raw_mode()
            .expect("should be able to transition out of raw mode");
    }
}