From 9171b350256c799741cc36281f2e85dea3061a11 Mon Sep 17 00:00:00 2001 From: Denis Nutiu Date: Tue, 10 Dec 2024 23:54:15 +0200 Subject: [PATCH] disable terminal raw mode on cross term drop --- src/input.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/input.rs b/src/input.rs index 9c3e56c..33e41b7 100644 --- a/src/input.rs +++ b/src/input.rs @@ -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."); + } +} \ No newline at end of file