summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2023-05-28 00:46:13 -0400
committerGitHub <noreply@github.com>2023-05-28 00:46:13 -0400
commit635e82a8a2603a0862b5e9c791170720a39df25a (patch)
treed230014570f13d38098c876b179b9558418f92c3
parent9cea3e1a8d922af4ff255ebabbd896fc7fb28908 (diff)
refactor: remove typed builder from App struct (#1176)
Another one on the chopping block. This also moves out the app widget logic to a separate struct.
-rw-r--r--src/app.rs268
-rw-r--r--src/app/states.rs11
-rw-r--r--src/bin/main.rs6
-rw-r--r--src/canvas.rs4
-rw-r--r--src/canvas/dialogs/dd_dialog.rs1
-rw-r--r--src/canvas/widgets/basic_table_arrows.rs2
-rw-r--r--src/canvas/widgets/battery_display.rs7
-rw-r--r--src/canvas/widgets/cpu_graph.rs13
-rw-r--r--src/canvas/widgets/disk_table.rs7
-rw-r--r--src/canvas/widgets/mem_graph.rs3
-rw-r--r--src/canvas/widgets/network_graph.rs4
-rw-r--r--src/canvas/widgets/process_table.rs30
-rw-r--r--src/canvas/widgets/temperature_table.rs7
-rw-r--r--src/lib.rs20
-rw-r--r--src/options.rs53
15 files changed, 289 insertions, 147 deletions
diff --git a/src/app.rs b/src/app.rs
index 789329ef..a65d0e20 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -10,7 +10,6 @@ use filter::*;
use hashbrown::HashMap;
use layout_manager::*;
pub use states::*;
-use typed_builder::*;
use unicode_segmentation::{GraphemeCursor, UnicodeSegmentation};
use crate::widgets::{ProcWidgetColumn, ProcWidgetMode};
@@ -79,63 +78,45 @@ pub struct DataFilters {
pub net_filter: Option<Filter>,
}
-#[derive(TypedBuilder)]
+cfg_if::cfg_if! {
+ if #[cfg(target_os = "linux")] {
+ /// The max signal we can send to a process on Linux.
+ pub const MAX_PROCESS_SIGNAL: usize = 64;
+ } else if #[cfg(target_os = "macos")] {
+ /// The max signal we can send to a process on macOS.
+ pub const MAX_PROCESS_SIGNAL: usize = 31;
+ } else if #[cfg(target_os = "freebsd")] {
+ /// The max signal we can send to a process on FreeBSD.
+ /// See [https://www.freebsd.org/cgi/man.cgi?query=signal&apropos=0&sektion=3&manpath=FreeBSD+13.1-RELEASE+and+Ports&arch=default&format=html]
+ /// for more details.
+ pub const MAX_PROCESS_SIGNAL: usize = 33;
+ } else if #[cfg(target_os = "windows")] {
+ /// The max signal we can send to a process. For Windows, we only have support for one signal (kill).
+ pub const MAX_PROCESS_SIGNAL: usize = 1;
+ } else {
+ /// The max signal we can send to a process. As a fallback, we only support one signal (kill).
+ pub const MAX_PROCESS_SIGNAL: usize = 1;
+ }
+}
+
pub struct App {
- #[builder(default = false, setter(skip))]
awaiting_second_char: bool,
-
- #[builder(default, setter(skip))]
second_char: Option<char>,
-
- // FIXME: The way we do deletes is really gross.
- #[builder(default, setter(skip))]
- pub dd_err: Option<String>,
-
- #[builder(default, setter(skip))]
+ pub dd_err: Option<String>, // FIXME: The way we do deletes is really gross.
to_delete_process_list: Option<(String, Vec<Pid>)>,
-
- #[builder(default, setter(skip))]
pub frozen_state: FrozenState,
-
- #[builder(default = Instant::now(), setter(skip))]
last_key_press: Instant,
-
- #[builder(default, setter(skip))]
pub converted_data: ConvertedData,
-
- #[builder(default, setter(skip))]
pub data_collection: DataCollection,
-
- #[builder(default, setter(skip))]
pub delete_dialog_state: AppDeleteDialogState,
-
- #[builder(default, setter(skip))]
pub help_dialog_state: AppHelpDialogState,
-
- #[builder(default = false)]
pub is_expanded: bool,
-
- #[builder(default = false, setter(skip))]
pub is_force_redraw: bool,
-
- #[builder(default = false, setter(skip))]
pub is_determining_widget_boundary: bool,
-
- #[builder(default = false, setter(skip))]
pub basic_mode_use_percent: bool,
-
#[cfg(target_family = "unix")]
- #[builder(default, setter(skip))]
pub user_table: data_harvester::processes::UserTable,
-
- pub cpu_state: CpuState,
- pub mem_state: MemState,
- pub net_state: NetState,
- pub proc_state: ProcState,
- pub temp_state: TempState,
- pub disk_state: DiskState,
- pub battery_state: BatteryState,
- pub basic_table_widget_state: Option<BasicTableWidgetState>,
+ pub states: AppWidgetStates,
pub app_config_fields: AppConfigFields,
pub widget_map: HashMap<u64, BottomWidget>,
pub current_widget: BottomWidget,
@@ -143,28 +124,38 @@ pub struct App {
pub filters: DataFilters,
}
-cfg_if::cfg_if! {
- if #[cfg(target_os = "linux")] {
- /// The max signal we can send to a process on Linux.
- pub const MAX_PROCESS_SIGNAL: usize = 64;
- } else if #[cfg(target_os = "macos")] {
- /// The max signal we can send to a process on macOS.
- pub const MAX_PROCESS_SIGNAL: usize = 31;
- } else if #[cfg(target_os = "freebsd")] {
- /// The max signal we can send to a process on FreeBSD.
- /// See [https://www.freebsd.org/cgi/man.cgi?query=signal&apropos=0&sektion=3&manpath=FreeBSD+13.1-RELEASE+and+Ports&arch=default&format=html]
- /// for more details.
- pub const MAX_PROCESS_SIGNAL: usize = 33;
- } else if #[cfg(target_os = "windows")] {
- /// The max signal we can send to a process. For Windows, we only have support for one signal (kill).
- pub const MAX_PROCESS_SIGNAL: usize = 1;
- } else {
- /// The max signal we can send to a process. As a fallback, we only support one signal (kill).
- pub const MAX_PROCESS_SIGNAL: usize = 1;
+impl App {
+ pub fn new(
+ app_config_fields: AppConfigFields, states: AppWidgetStates,
+ widget_map: HashMap<u64, BottomWidget>, current_widget: BottomWidget,
+ used_widgets: UsedWidgets, filters: DataFilters, is_expanded: bool,
+ ) -> Self {
+ Self {
+ awaiting_second_char: false,
+ second_char: None,
+ dd_err: None,
+ to_delete_process_list: None,
+ frozen_state: FrozenState::default(),
+ last_key_press: Instant::now(),
+ converted_data: ConvertedData::default(),
+ data_collection: DataCollection::default(),
+ delete_dialog_state: AppDeleteDialogState::default(),
+ help_dialog_state: AppHelpDialogState::default(),
+ is_expanded,
+ is_force_redraw: false,
+ is_determining_widget_boundary: false,
+ basic_mode_use_percent: false,
+ #[cfg(target_family = "unix")]
+ user_table: data_harvester::processes::UserTable::default(),
+ states,
+ app_config_fields,
+ widget_map,
+ current_widget,
+ used_widgets,
+ filters,
+ }
}
-}
-impl App {
pub fn reset(&mut self) {
// Reset multi
self.reset_multi_tap_keys();
@@ -174,7 +165,8 @@ impl App {
self.delete_dialog_state.is_showing_dd = false;
// Close all searches and reset it
- self.proc_state
+ self.states
+ .proc_state
.widget_states
.values_mut()
.for_each(|state| {
@@ -224,6 +216,7 @@ impl App {
match self.current_widget.widget_type {
BottomWidgetType::Proc => {
if let Some(pws) = self
+ .states
.proc_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -237,6 +230,7 @@ impl App {
}
BottomWidgetType::ProcSearch => {
if let Some(pws) = self
+ .states
.proc_state
.get_mut_widget_state(self.current_widget.widget_id - 1)
{
@@ -250,6 +244,7 @@ impl App {
}
BottomWidgetType::ProcSort => {
if let Some(pws) = self
+ .states
.proc_state
.get_mut_widget_state(self.current_widget.widget_id - 2)
{
@@ -297,6 +292,7 @@ impl App {
if !self.ignore_normal_keybinds() {
if let BottomWidgetType::Proc = self.current_widget.widget_type {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -311,7 +307,7 @@ impl App {
match &self.current_widget.widget_type {
BottomWidgetType::Proc | BottomWidgetType::ProcSort => {
// Toggle on
- if let Some(proc_widget_state) = self.proc_state.get_mut_widget_state(
+ if let Some(proc_widget_state) = self.states.proc_state.get_mut_widget_state(
self.current_widget.widget_id
- match &self.current_widget.widget_type {
BottomWidgetType::ProcSort => 2,
@@ -336,7 +332,7 @@ impl App {
_ => 0,
};
- if let Some(pws) = self.proc_state.get_mut_widget_state(widget_id) {
+ if let Some(pws) = self.states.proc_state.get_mut_widget_state(widget_id) {
pws.is_sort_open = !pws.is_sort_open;
pws.force_rerender = true;
@@ -361,7 +357,7 @@ impl App {
_ => 0,
};
- if let Some(pws) = self.proc_state.get_mut_widget_state(widget_id) {
+ if let Some(pws) = self.states.proc_state.get_mut_widget_state(widget_id) {
pws.table.toggle_order();
pws.force_data_update();
}
@@ -377,6 +373,7 @@ impl App {
}
BottomWidgetType::Proc => {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.widget_states
.get_mut(&self.current_widget.widget_id)
@@ -392,6 +389,7 @@ impl App {
pub fn toggle_ignore_case(&mut self) {
let is_in_search_widget = self.is_in_search_widget();
if let Some(proc_widget_state) = self
+ .states
.proc_state
.widget_states
.get_mut(&(self.current_widget.widget_id - 1))
@@ -406,6 +404,7 @@ impl App {
pub fn toggle_search_whole_word(&mut self) {
let is_in_search_widget = self.is_in_search_widget();
if let Some(proc_widget_state) = self
+ .states
.proc_state
.widget_states
.get_mut(&(self.current_widget.widget_id - 1))
@@ -420,6 +419,7 @@ impl App {
pub fn toggle_search_regex(&mut self) {
let is_in_search_widget = self.is_in_search_widget();
if let Some(proc_widget_state) = self
+ .states
.proc_state
.widget_states
.get_mut(&(self.current_widget.widget_id - 1))
@@ -433,6 +433,7 @@ impl App {
pub fn toggle_tree_mode(&mut self) {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.widget_states
.get_mut(&(self.current_widget.widget_id))
@@ -482,6 +483,7 @@ impl App {
} else if !self.is_in_dialog() {
if let BottomWidgetType::ProcSort = self.current_widget.widget_type {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.widget_states
.get_mut(&(self.current_widget.widget_id - 2))
@@ -498,6 +500,7 @@ impl App {
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
let is_in_search_widget = self.is_in_search_widget();
if let Some(proc_widget_state) = self
+ .states
.proc_state
.widget_states
.get_mut(&(self.current_widget.widget_id - 1))
@@ -544,6 +547,7 @@ impl App {
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
let is_in_search_widget = self.is_in_search_widget();
if let Some(proc_widget_state) = self
+ .states
.proc_state
.widget_states
.get_mut(&(self.current_widget.widget_id - 1))
@@ -583,7 +587,7 @@ impl App {
}
pub fn get_process_filter(&self, widget_id: u64) -> &Option<query::Query> {
- if let Some(process_widget_state) = self.proc_state.widget_states.get(&widget_id) {
+ if let Some(process_widget_state) = self.states.proc_state.widget_states.get(&widget_id) {
&process_widget_state.proc_search.search_state.query
} else {
&None
@@ -672,6 +676,7 @@ impl App {
BottomWidgetType::ProcSearch => {
let is_in_search_widget = self.is_in_search_widget();
if let Some(proc_widget_state) = self
+ .states
.proc_state
.get_mut_widget_state(self.current_widget.widget_id - 1)
{
@@ -688,6 +693,7 @@ impl App {
BottomWidgetType::Battery => {
if !self.converted_data.battery_data.is_empty() {
if let Some(battery_widget_state) = self
+ .states
.battery_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -731,6 +737,7 @@ impl App {
BottomWidgetType::ProcSearch => {
let is_in_search_widget = self.is_in_search_widget();
if let Some(proc_widget_state) = self
+ .states
.proc_state
.get_mut_widget_state(self.current_widget.widget_id - 1)
{
@@ -748,6 +755,7 @@ impl App {
if !self.converted_data.battery_data.is_empty() {
let battery_count = self.converted_data.battery_data.len();
if let Some(battery_widget_state) = self
+ .states
.battery_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -888,6 +896,7 @@ impl App {
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
let is_in_search_widget = self.is_in_search_widget();
if let Some(proc_widget_state) = self
+ .states
.proc_state
.widget_states
.get_mut(&(self.current_widget.widget_id - 1))
@@ -917,6 +926,7 @@ impl App {
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
let is_in_search_widget = self.is_in_search_widget();
if let Some(proc_widget_state) = self
+ .states
.proc_state
.widget_states
.get_mut(&(self.current_widget.widget_id - 1))
@@ -941,6 +951,7 @@ impl App {
pub fn clear_search(&mut self) {
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.widget_states
.get_mut(&(self.current_widget.widget_id - 1))
@@ -953,6 +964,7 @@ impl App {
pub fn clear_previous_word(&mut self) {
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.widget_states
.get_mut(&(self.current_widget.widget_id - 1))
@@ -1011,6 +1023,7 @@ impl App {
self.reset_multi_tap_keys();
if let Some(pws) = self
+ .states
.proc_state
.widget_states
.get(&self.current_widget.widget_id)
@@ -1055,6 +1068,7 @@ impl App {
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
let is_in_search_widget = self.is_in_search_widget();
if let Some(proc_widget_state) = self
+ .states
.proc_state
.widget_states
.get_mut(&(self.current_widget.widget_id - 1))
@@ -1159,6 +1173,7 @@ impl App {
self.second_char = Some('d');
}
} else if let Some(disk) = self
+ .states
.disk_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -1190,6 +1205,7 @@ impl App {
'c' => {
if let BottomWidgetType::Proc = self.current_widget.widget_type {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -1200,12 +1216,14 @@ impl App {
'm' => {
if let BottomWidgetType::Proc = self.current_widget.widget_type {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.get_mut_widget_state(self.current_widget.widget_id)
{
proc_widget_state.select_column(ProcWidgetColumn::Mem);
}
} else if let Some(disk) = self
+ .states
.disk_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -1215,12 +1233,14 @@ impl App {
'p' => {
if let BottomWidgetType::Proc = self.current_widget.widget_type {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.get_mut_widget_state(self.current_widget.widget_id)
{
proc_widget_state.select_column(ProcWidgetColumn::PidOrCount);
}
} else if let Some(disk) = self
+ .states
.disk_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -1230,6 +1250,7 @@ impl App {
'P' => {
if let BottomWidgetType::Proc = self.current_widget.widget_type {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -1240,12 +1261,14 @@ impl App {
'n' => {
if let BottomWidgetType::Proc = self.current_widget.widget_type {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.get_mut_widget_state(self.current_widget.widget_id)
{
proc_widget_state.select_column(ProcWidgetColumn::ProcNameOrCommand);
}
} else if let Some(disk) = self
+ .states
.disk_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -1264,12 +1287,14 @@ impl App {
if let BottomWidgetType::Proc = self.current_widget.widget_type {
self.toggle_tree_mode()
} else if let Some(temp) = self
+ .states
.temp_state
.get_mut_widget_state(self.current_widget.widget_id)
{
temp.table.set_sort_index(1);
temp.force_data_update();
} else if let Some(disk) = self
+ .states
.disk_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -1284,6 +1309,7 @@ impl App {
if let BottomWidgetType::Proc = self.current_widget.widget_type {
self.toggle_sort_menu()
} else if let Some(temp) = self
+ .states
.temp_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -1294,6 +1320,7 @@ impl App {
}
'u' => {
if let Some(disk) = self
+ .states
.disk_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -1302,6 +1329,7 @@ impl App {
}
'r' => {
if let Some(disk) = self
+ .states
.disk_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -1310,6 +1338,7 @@ impl App {
}
'w' => {
if let Some(disk) = self
+ .states
.disk_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -1418,14 +1447,17 @@ impl App {
| BottomWidgetType::ProcSort
| BottomWidgetType::Disk
| BottomWidgetType::Battery
- if self.basic_table_widget_state.is_some()
+ if self.states.basic_table_widget_state.is_some()
&& (*direction == WidgetDirection::Left
|| *direction == WidgetDirection::Right) =>
{
// Gotta do this for the sort widget
if let BottomWidgetType::ProcSort = new_widget.widget_type {
- if let Some(proc_widget_state) =
- self.proc_state.widget_states.get(&(new_widget_id - 2))
+ if let Some(proc_widget_state) = self
+ .states
+ .proc_state
+ .widget_states
+ .get(&(new_widget_id - 2))
{
if proc_widget_state.is_sort_open {
self.current_widget = new_widget.clone();
@@ -1445,7 +1477,7 @@ impl App {
}
if let Some(basic_table_widget_state) =
- &mut self.basic_table_widget_state
+ &mut self.states.basic_table_widget_state
{
basic_table_widget_state.currently_displayed_widget_id =
self.current_widget.widget_id;
@@ -1474,7 +1506,7 @@ impl App {
// Assuming we're in basic mode (BasicTables), then
// we want to move DOWN to the currently shown widget.
if let Some(basic_table_widget_state) =
- &mut self.basic_table_widget_state
+ &mut self.states.basic_table_widget_state
{
// We also want to move towards Proc if we had set it to ProcSort.
if let BottomWidgetType::ProcSort =
@@ -1512,6 +1544,7 @@ impl App {
match &new_widget.widget_type {
BottomWidgetType::CpuLegend => {
if let Some(cpu_widget_state) = self
+ .states
.cpu_state
.widget_states
.get(&(new_widget_id - *offset))
@@ -1535,6 +1568,7 @@ impl App {
BottomWidgetType::ProcSearch
| BottomWidgetType::ProcSort => {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.widget_states
.get(&(new_widget_id - *offset))
@@ -1593,6 +1627,7 @@ impl App {
match &new_widget.widget_type {
BottomWidgetType::CpuLegend => {
if let Some(cpu_widget_state) = self
+ .states
.cpu_state
.widget_states
.get(&(new_widget_id - *offset))
@@ -1613,6 +1648,7 @@ impl App {
BottomWidgetType::ProcSearch
| BottomWidgetType::ProcSort => {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.widget_states
.get(&(new_widget_id - *offset))
@@ -1671,6 +1707,7 @@ impl App {
match &self.current_widget.widget_type {
BottomWidgetType::CpuLegend => {
if let Some(cpu_widget_state) = self
+ .states
.cpu_state
.widget_states
.get(&(self.current_widget.widget_id - *offset))
@@ -1682,6 +1719,7 @@ impl App {
}
BottomWidgetType::ProcSearch | BottomWidgetType::ProcSort => {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.widget_states
.get(&(self.current_widget.widget_id - *offset))
@@ -1738,7 +1776,7 @@ impl App {
if let Some(new_widget_id) = current_widget.down_neighbour {
if let Some(new_widget) = self.widget_map.get(&new_widget_id) {
if let Some(proc_widget_state) =
- self.proc_state.get_widget_state(widget_id)
+ self.states.proc_state.get_widget_state(widget_id)
{
if proc_widget_state.is_search_enabled() {
self.current_widget = new_widget.clone();
@@ -1758,6 +1796,7 @@ impl App {
if let BottomWidgetType::Proc = self.current_widget.widget_type {
if let Some(new_widget_id) = self.current_widget.left_neighbour {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.widget_states
.get(&self.current_widget.widget_id)
@@ -1773,6 +1812,7 @@ impl App {
if let BottomWidgetType::Cpu = self.current_widget.widget_type {
if let Some(current_widget) = self.widget_map.get(&self.current_widget.widget_id) {
if let Some(cpu_widget_state) = self
+ .states
.cpu_state
.widget_states
.get(&self.current_widget.widget_id)
@@ -1818,6 +1858,7 @@ impl App {
} else if let BottomWidgetType::Cpu = self.current_widget.widget_type {
if let Some(current_widget) = self.widget_map.get(&self.current_widget.widget_id) {
if let Some(cpu_widget_state) = self
+ .states
.cpu_state
.widget_states
.get(&self.current_widget.widget_id)
@@ -1839,6 +1880,7 @@ impl App {
match self.current_widget.widget_type {
BottomWidgetType::Proc => {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -1847,6 +1889,7 @@ impl App {
}
BottomWidgetType::ProcSort => {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.get_mut_widget_state(self.current_widget.widget_id - 2)
{
@@ -1855,6 +1898,7 @@ impl App {
}
BottomWidgetType::Temp => {
if let Some(temp_widget_state) = self
+ .states
.temp_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -1863,6 +1907,7 @@ impl App {
}
BottomWidgetType::Disk => {
if let Some(disk_widget_state) = self
+ .states
.disk_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -1871,6 +1916,7 @@ impl App {
}
BottomWidgetType::CpuLegend => {
if let Some(cpu_widget_state) = self
+ .states
.cpu_state
.get_mut_widget_state(self.current_widget.widget_id - 1)
{
@@ -1893,6 +1939,7 @@ impl App {
match self.current_widget.widget_type {
BottomWidgetType::Proc => {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -1901,6 +1948,7 @@ impl App {
}
BottomWidgetType::ProcSort => {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.get_mut_widget_state(self.current_widget.widget_id - 2)
{
@@ -1909,6 +1957,7 @@ impl App {
}
BottomWidgetType::Temp => {
if let Some(temp_widget_state) = self
+ .states
.temp_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -1917,6 +1966,7 @@ impl App {
}
BottomWidgetType::Disk => {
if let Some(disk_widget_state) = self
+ .states
.disk_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -1927,6 +1977,7 @@ impl App {
}
BottomWidgetType::CpuLegend => {
if let Some(cpu_widget_state) = self
+ .states
.cpu_state
.get_mut_widget_state(self.current_widget.widget_id - 1)
{
@@ -1969,6 +2020,7 @@ impl App {
fn change_process_sort_position(&mut self, num_to_change_by: i64) {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.get_mut_widget_state(self.current_widget.widget_id - 2)
{
@@ -1980,6 +2032,7 @@ impl App {
fn change_cpu_legend_position(&mut self, num_to_change_by: i64) {
if let Some(cpu_widget_state) = self
+ .states
.cpu_state
.widget_states
.get_mut(&(self.current_widget.widget_id - 1))
@@ -1991,6 +2044,7 @@ impl App {
/// Returns the new position.
fn change_process_position(&mut self, num_to_change_by: i64) -> Option<usize> {
if let Some(proc_widget_state) = self
+ .states
.proc_state
.get_mut_widget_state(self.current_widget.widget_id)
{
@@ -2002,6 +2056,7 @@ impl App {
fn change_temp_position(&mut self, num_to_change_by: i64) {
if let Some(temp_widget_state) = self
+ .states
.temp_state
.widget_states
.get_mut(&self.current_widget.widget_id)
@@ -2012,6 +2067,7 @@ impl App {
fn change_disk_position(&mut self, num_to_change_by: i64) {
if let Some(disk_widget_state) = self
+ .states
.disk_state
.widget_states
.get_mut(&self.current_widget.widget_id)
@@ -2097,6 +2153,7 @@ impl App {
fn toggle_collapsing_process_branch(&mut self) {
if let Some(pws) = self
+ .states
.proc_state
.widget_states
.get_mut(&self.current_widget.widget_id)
@@ -2109,6 +2166,7 @@ impl App {
match self.current_widget.widget_type {
BottomWidgetType::Cpu => {
if let Some(cpu_widget_state) = self
+ .states
.cpu_state
.widget_states
.get_mut(&self.current_widget.widget_id)
@@ -2117,7 +2175,7 @@ impl App {
+ self.app_config_fields.time_interval;
if new_time <= self.app_config_fields.retention_ms {
cpu_widget_state.current_display_time = new_time;
- self.cpu_state.force_update = Some(self.current_widget.widget_id);
+ self.states.cpu_state.force_update = Some(self.current_widget.widget_id);
if self.app_config_fields.autohide_time {
cpu_widget_state.autohide_timer = Some(Instant::now());
}
@@ -2125,7 +2183,7 @@ impl App {
!= self.app_config_fields.retention_ms
{
cpu_widget_state.current_display_time = self.app_config_fields.retention_ms;
- self.cpu_state.force_update = Some(self.current_widget.widget_id);
+ self.states.cpu_state.force_update = Some(self.current_widget.widget_id);
if self.app_config_fields.autohide_time {
cpu_widget_state.autohide_timer = Some(Instant::now());