From ae8aafed5bad8edd594556bce079b1545aea9bec Mon Sep 17 00:00:00 2001 From: Joris Date: Mon, 21 Nov 2022 14:47:36 +0100 Subject: Show errors in TUI instead of nothing Once the terminal was setup, errors were not shown in case the application stopped because of an error. So, show errors explicitely in TUI to be able to debug easily the deck for example. --- src/gui/mod.rs | 2 +- src/gui/question.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/mod.rs b/src/gui/mod.rs index b39cbcf..719f39a 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -11,7 +11,7 @@ use std::{fs, io, time::Duration}; use termion::{raw::IntoRawMode, raw::RawTerminal, screen::AlternateScreen}; use tui::{backend::TermionBackend, Terminal}; -type Term = Terminal>>>; +pub type Term = Terminal>>>; pub fn terminal() -> Result { let stdout = io::stdout().into_raw_mode()?; diff --git a/src/gui/question.rs b/src/gui/question.rs index 2060cb7..426daa9 100644 --- a/src/gui/question.rs +++ b/src/gui/question.rs @@ -203,7 +203,11 @@ pub fn ask( fn is_correct(input: &str, responses: &[String]) -> bool { // Remove whitespaces - let input = input.split_whitespace().map(|word| word.trim()).collect::>().join(" "); + let input = input + .split_whitespace() + .map(|word| word.trim()) + .collect::>() + .join(" "); responses .iter() -- cgit v1.2.3