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().expect("should be able to transition into raw mode");
12 Raw()
13 }
14}
15impl Drop for Raw {
16 fn drop(&mut self) {
17 crossterm::terminal::disable_raw_mode()
18 .expect("should be able to transition out of raw mode");
19 }
20}