From ffffee2ac77c88ea0219b1b0e39e3988ed918319 Mon Sep 17 00:00:00 2001 From: sam-anthony Date: Sat, 5 Feb 2022 21:42:28 -0330 Subject: impl Iterator for Row for building input table --- src/app.rs | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src/app.rs') diff --git a/src/app.rs b/src/app.rs index 25002bd..92f89c0 100644 --- a/src/app.rs +++ b/src/app.rs @@ -7,14 +7,18 @@ pub struct App { pub tab_index: usize, tab_titles: [&'static str; 2], - pub rows: Vec, - pub selected_row: usize, - pub selected_column: InputParam, + rows: Vec, + selected_row: usize, + selected_column: InputParam, pub input_mode: InputMode, } impl App { + pub fn rows(&self) -> &Vec { + &self.rows + } + pub fn tab_titles(&self) -> &[&str] { &self.tab_titles } @@ -68,6 +72,22 @@ impl App { } } } + + pub fn selected_input_param(&self) -> &InputParam { + match self.selected_column { + InputParam::Rpm(_) => &self.rows[self.selected_row].rpm, + InputParam::Ve(_) => &self.rows[self.selected_row].ve, + InputParam::Map(_) => &self.rows[self.selected_row].map, + } + } + + pub fn selected_input_param_mut(&mut self) -> &mut InputParam { + match self.selected_column { + InputParam::Rpm(_) => &mut self.rows[self.selected_row].rpm, + InputParam::Ve(_) => &mut self.rows[self.selected_row].ve, + InputParam::Map(_) => &mut self.rows[self.selected_row].map, + } + } } impl Default for App { -- cgit v1.2.3