From d286ed3eb877365c01f7a7ec56de9a0dc84bab2e Mon Sep 17 00:00:00 2001 From: sam-anthony Date: Sun, 6 Mar 2022 21:56:57 -0330 Subject: simplify/remove a lot of stuff --- src/app.rs | 90 +------------------------------------------------------------- 1 file changed, 1 insertion(+), 89 deletions(-) (limited to 'src/app.rs') diff --git a/src/app.rs b/src/app.rs index bc12812..dedb11e 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,82 +1,9 @@ -use crate::input::{InputMode, InputParam, Row}; - -#[derive(Copy, Clone)] -pub enum Tab { - Const = 0, - Input = 1, - Config = 2, -} - -impl Tab { - fn next(&self) -> Self { - match self { - Self::Const => Self::Input, - Self::Input => Self::Config, - Self::Config => Self::Const, - } - } - - fn previous(&self) -> Self { - match self { - Self::Const => Self::Config, - Self::Input => Self::Const, - Self::Config => Self::Input, - } - } - - fn string(&self) -> String { - match self { - Self::Const => "Const".to_string(), - Self::Input => "Input".to_string(), - Self::Config => "Config".to_string(), - } - } -} - -impl IntoIterator for Tab { - type Item = Tab; - type IntoIter = TabIter; - - fn into_iter(self) -> Self::IntoIter { - TabIter { tab: Some(self) } - } -} - -pub struct TabIter { - tab: Option, -} - -impl Iterator for TabIter { - type Item = Tab; - - fn next(&mut self) -> Option { - match self.tab { - Some(Tab::Const) => { - self.tab = Some(Tab::Input); - Some(Tab::Const) - } - Some(Tab::Input) => { - self.tab = Some(Tab::Config); - Some(Tab::Input) - } - Some(Tab::Config) => { - self.tab = None; - Some(Tab::Config) - } - None => None, - } - } -} +use crate::input::{InputParam, Row}; pub struct App { - pub tab: Tab, - tab_titles: Vec, - rows: Vec, selected_row: usize, selected_column: InputParam, - - pub input_mode: InputMode, } impl App { @@ -84,18 +11,6 @@ impl App { &self.rows } - pub fn tab_titles(&self) -> &Vec { - &self.tab_titles - } - - pub fn next_tab(&mut self) { - self.tab = self.tab.next(); - } - - pub fn previous_tab(&mut self) { - self.tab = self.tab.previous(); - } - pub fn next_row(&mut self) { if self.selected_row < self.rows.len() - 1 { self.selected_row += 1; @@ -155,12 +70,9 @@ impl App { impl Default for App { fn default() -> App { App { - tab: Tab::Const, - tab_titles: Tab::Const.into_iter().map(|t| t.string()).collect(), rows: vec![Row::default()], selected_row: 0, selected_column: InputParam::Rpm(String::new()), - input_mode: InputMode::Normal, } } } -- cgit v1.2.3