diff options
Diffstat (limited to 'src/app.rs')
| -rw-r--r-- | src/app.rs | 90 |
1 files changed, 1 insertions, 89 deletions
@@ -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<Tab>, -} - -impl Iterator for TabIter { - type Item = Tab; - - fn next(&mut self) -> Option<Self::Item> { - 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<String>, - rows: Vec<Row>, 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<String> { - &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, } } } |