xref: /Held/src/utils/ui/mod.rs (revision 5dacf00fa267a9ac7a4794894f9162d71b69c2b8)
1*984a200eSGnoCiYeH use std::io;
2*984a200eSGnoCiYeH 
3*984a200eSGnoCiYeH use crossterm::style::Color;
4*984a200eSGnoCiYeH 
5*984a200eSGnoCiYeH use super::style::StyleManager;
6*984a200eSGnoCiYeH 
7*984a200eSGnoCiYeH pub mod event;
8*984a200eSGnoCiYeH pub mod mode;
9*984a200eSGnoCiYeH pub mod uicore;
10*984a200eSGnoCiYeH 
11*984a200eSGnoCiYeH #[derive(Debug)]
12*984a200eSGnoCiYeH pub struct AppInfo {
13*984a200eSGnoCiYeH     pub level: InfoLevel,
14*984a200eSGnoCiYeH     pub info: String,
15*984a200eSGnoCiYeH }
16*984a200eSGnoCiYeH 
17*984a200eSGnoCiYeH impl AppInfo {
reset(&mut self)18*984a200eSGnoCiYeH     pub fn reset(&mut self) {
19*984a200eSGnoCiYeH         self.level = InfoLevel::Info;
20*984a200eSGnoCiYeH         self.info = String::new();
21*984a200eSGnoCiYeH     }
22*984a200eSGnoCiYeH }
23*984a200eSGnoCiYeH 
24*984a200eSGnoCiYeH #[allow(dead_code)]
25*984a200eSGnoCiYeH #[derive(Debug)]
26*984a200eSGnoCiYeH pub enum InfoLevel {
27*984a200eSGnoCiYeH     Info,
28*984a200eSGnoCiYeH     Warn,
29*984a200eSGnoCiYeH     Error,
30*984a200eSGnoCiYeH }
31*984a200eSGnoCiYeH 
32*984a200eSGnoCiYeH impl InfoLevel {
set_style(&self) -> io::Result<()>33*984a200eSGnoCiYeH     pub fn set_style(&self) -> io::Result<()> {
34*984a200eSGnoCiYeH         match self {
35*984a200eSGnoCiYeH             InfoLevel::Info => {}
36*984a200eSGnoCiYeH             InfoLevel::Warn => {
37*984a200eSGnoCiYeH                 StyleManager::set_background_color(Color::DarkYellow)?;
38*984a200eSGnoCiYeH             }
39*984a200eSGnoCiYeH             InfoLevel::Error => {
40*984a200eSGnoCiYeH                 StyleManager::set_background_color(Color::DarkRed)?;
41*984a200eSGnoCiYeH             }
42*984a200eSGnoCiYeH         }
43*984a200eSGnoCiYeH 
44*984a200eSGnoCiYeH         Ok(())
45*984a200eSGnoCiYeH     }
46*984a200eSGnoCiYeH }
47