Skip to content

Commit

Permalink
Use alternate screen in TUI
Browse files Browse the repository at this point in the history
  • Loading branch information
mhovd committed Jan 7, 2024
1 parent a531a99 commit bca7e98
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/tui/ui.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Defines the Terminal User Interface (TUI) for NPcore
use crossterm::execute;
use eyre::Result;
use ratatui::{
backend::CrosstermBackend,
Expand Down Expand Up @@ -31,7 +32,8 @@ use crate::prelude::{output::NPCycle, settings::run::Settings};
use crate::tui::components::*;

pub fn start_ui(mut rx: UnboundedReceiver<Comm>, settings: Settings) -> Result<()> {
let stdout = stdout();
let mut stdout = stdout();
execute!(stdout, crossterm::terminal::EnterAlternateScreen)?;
crossterm::terminal::enable_raw_mode()?;
let backend = CrosstermBackend::new(stdout);
let mut terminal = Terminal::new(backend)?;
Expand Down Expand Up @@ -106,7 +108,13 @@ pub fn start_ui(mut rx: UnboundedReceiver<Comm>, settings: Settings) -> Result<(
}
}

// Draw one last image
// Exit alternate screen, and print one last frame

terminal.clear()?;
execute!(
terminal.backend_mut(),
crossterm::terminal::LeaveAlternateScreen
)?;
terminal
.draw(|rect| {
draw(
Expand Down

0 comments on commit bca7e98

Please sign in to comment.