refactor: remove dead config screen code

This code was never used and might as well be removed for clarity's
sake.
This commit is contained in:
ClementTsang 2022-04-27 04:22:36 -04:00
parent f68acc5c9d
commit 1f731358ba
4 changed files with 5 additions and 67 deletions

View File

@ -126,9 +126,6 @@ pub struct App {
#[builder(default = false, setter(skip))]
pub basic_mode_use_percent: bool,
#[builder(default = false, setter(skip))]
pub is_config_open: bool,
#[builder(default = false, setter(skip))]
pub did_config_fail_to_save: bool,
@ -217,8 +214,6 @@ impl App {
}
self.is_force_redraw = true;
} else if self.is_config_open {
self.close_config_screen();
} else {
match self.current_widget.widget_type {
BottomWidgetType::Proc => {
@ -296,7 +291,7 @@ impl App {
}
fn ignore_normal_keybinds(&self) -> bool {
self.is_config_open || self.is_in_dialog()
self.is_in_dialog()
}
pub fn on_tab(&mut self) {
@ -909,8 +904,7 @@ impl App {
}
pub fn on_up_key(&mut self) {
if self.is_config_open {
} else if !self.is_in_dialog() {
if !self.is_in_dialog() {
self.decrement_position_count();
} else if self.help_dialog_state.is_showing_help {
self.help_scroll_up();
@ -931,8 +925,7 @@ impl App {
}
pub fn on_down_key(&mut self) {
if self.is_config_open {
} else if !self.is_in_dialog() {
if !self.is_in_dialog() {
self.increment_position_count();
} else if self.help_dialog_state.is_showing_help {
self.help_scroll_down();
@ -953,8 +946,7 @@ impl App {
}
pub fn on_left_key(&mut self) {
if self.is_config_open {
} else if !self.is_in_dialog() {
if !self.is_in_dialog() {
match self.current_widget.widget_type {
BottomWidgetType::ProcSearch => {
let is_in_search_widget = self.is_in_search_widget();
@ -1025,8 +1017,7 @@ impl App {
}
pub fn on_right_key(&mut self) {
if self.is_config_open {
} else if !self.is_in_dialog() {
if !self.is_in_dialog() {
match self.current_widget.widget_type {
BottomWidgetType::ProcSearch => {
let is_in_search_widget = self.is_in_search_widget();
@ -1190,7 +1181,6 @@ impl App {
}
}
}
} else if self.is_config_open {
}
}
@ -1237,7 +1227,6 @@ impl App {
}
}
}
} else if self.is_config_open {
}
}
@ -1489,7 +1478,6 @@ impl App {
'G' => self.skip_to_last(),
_ => {}
}
} else if self.is_config_open {
}
}
@ -1672,16 +1660,6 @@ impl App {
pub fn on_space(&mut self) {}
pub fn open_config_screen(&mut self) {
self.is_config_open = true;
self.is_force_redraw = true;
}
pub fn close_config_screen(&mut self) {
self.is_config_open = false;
self.is_force_redraw = true;
}
/// TODO: Disabled.
/// Call this whenever the config value is updated!
// fn update_config_file(&mut self) -> anyhow::Result<()> {
@ -2263,7 +2241,6 @@ impl App {
_ => {}
}
self.reset_multi_tap_keys();
} else if self.is_config_open {
} else if self.help_dialog_state.is_showing_help {
self.help_dialog_state.scroll_state.current_scroll_index = 0;
} else if self.delete_dialog_state.is_showing_dd {
@ -2342,7 +2319,6 @@ impl App {
_ => {}
}
self.reset_multi_tap_keys();
} else if self.is_config_open {
} else if self.help_dialog_state.is_showing_help {
self.help_dialog_state.scroll_state.current_scroll_index = self
.help_dialog_state

View File

@ -28,7 +28,6 @@ use crate::{
mod canvas_colours;
mod dialogs;
mod drawing_utils;
mod screens;
mod widgets;
/// Point is of time, data
@ -508,13 +507,6 @@ impl Painter {
),
_ => {}
}
} else if app_state.is_config_open {
let rect = Layout::default()
.margin(0)
.constraints([Constraint::Percentage(100)])
.split(f.size())[0];
self.draw_config_screen(f, app_state, rect)
} else if app_state.app_config_fields.use_basic_mode {
// Basic mode. This basically removes all graphs but otherwise
// the same info.

View File

@ -1,3 +0,0 @@
pub mod config_screen;
pub use config_screen::*;

View File

@ -1,27 +0,0 @@
#![allow(unused_variables)] //FIXME: Remove this
#![allow(unused_imports)] //FIXME: Remove this
use crate::{app::App, canvas::Painter, constants};
use tui::{
backend::Backend,
layout::Constraint,
layout::Direction,
layout::Layout,
layout::{Alignment, Rect},
terminal::Frame,
text::Span,
widgets::{Block, Borders, Paragraph},
};
impl Painter {
pub fn draw_config_screen<B: Backend>(
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect,
) {
let config_block = Block::default()
.title(Span::styled(" Config ", self.colours.widget_title_style))
.style(self.colours.border_style)
.borders(Borders::ALL)
.border_style(self.colours.border_style);
f.render_widget(config_block, draw_loc);
}
}