summaryrefslogtreecommitdiff
path: root/src/tui.rs
diff options
context:
space:
mode:
authorJulian T. <julian@jtle.dk>2024-04-28 00:05:33 +0200
committerJulian T. <julian@jtle.dk>2024-04-28 00:05:33 +0200
commit0b29e9b14607f3226c46f75a20f11abd49c8f4a6 (patch)
treef35d4d8021fc018e7e04c4268b543b1971a9af66 /src/tui.rs
parentb27e72f5ac588506941b74c1f421235eb59e69d5 (diff)
Start with tui instead
Diffstat (limited to 'src/tui.rs')
-rw-r--r--src/tui.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/tui.rs b/src/tui.rs
new file mode 100644
index 0000000..7bae1ab
--- /dev/null
+++ b/src/tui.rs
@@ -0,0 +1,24 @@
+use crossterm::{execute, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}};
+
+use ratatui::{
+ prelude::CrosstermBackend,
+ Terminal,
+};
+
+use std::io::{self, stdout, Stdout};
+
+
+pub type Tui = Terminal<CrosstermBackend<Stdout>>;
+
+pub fn init() -> io::Result<Tui> {
+ execute!(stdout(), EnterAlternateScreen)?;
+ enable_raw_mode()?;
+ Terminal::new(CrosstermBackend::new(stdout()))
+}
+
+pub fn restore() -> io::Result<()> {
+ execute!(stdout(), LeaveAlternateScreen)?;
+ disable_raw_mode()?;
+
+ Ok(())
+}