mod.rs (781B)
1 use crate::tui_utils::TabsState; 2 pub mod ui; 3 4 pub struct App<'a> { 5 pub title: &'a str, 6 pub should_quit: bool, 7 pub tabs: TabsState<'a>, 8 pub enhanced_graphics: bool, 9 } 10 11 impl<'a> App<'a> { 12 pub fn new(title: &'a str, enhanced_graphics: bool) -> App<'a> { 13 App { 14 title, 15 should_quit: false, 16 tabs: TabsState::new(vec!["Tab0", "Tab1"]), 17 enhanced_graphics, 18 } 19 } 20 21 pub fn on_right(&mut self) { 22 self.tabs.next(); 23 } 24 25 pub fn on_left(&mut self) { 26 self.tabs.previous(); 27 } 28 29 pub fn on_key(&mut self, c: char) { 30 match c { 31 'q' => { 32 self.should_quit = true; 33 } 34 _ => {} 35 } 36 } 37 38 pub fn on_tick(&mut self) {} 39 }