mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-24 06:05:10 +02:00
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.
This commit is contained in:
parent
9cea3e1a8d
commit
635e82a8a2
274
src/app.rs
274
src/app.rs
@ -10,7 +10,6 @@ use filter::*;
|
|||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use layout_manager::*;
|
use layout_manager::*;
|
||||||
pub use states::*;
|
pub use states::*;
|
||||||
use typed_builder::*;
|
|
||||||
use unicode_segmentation::{GraphemeCursor, UnicodeSegmentation};
|
use unicode_segmentation::{GraphemeCursor, UnicodeSegmentation};
|
||||||
|
|
||||||
use crate::widgets::{ProcWidgetColumn, ProcWidgetMode};
|
use crate::widgets::{ProcWidgetColumn, ProcWidgetMode};
|
||||||
@ -79,70 +78,6 @@ pub struct DataFilters {
|
|||||||
pub net_filter: Option<Filter>,
|
pub net_filter: Option<Filter>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(TypedBuilder)]
|
|
||||||
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))]
|
|
||||||
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 app_config_fields: AppConfigFields,
|
|
||||||
pub widget_map: HashMap<u64, BottomWidget>,
|
|
||||||
pub current_widget: BottomWidget,
|
|
||||||
pub used_widgets: UsedWidgets,
|
|
||||||
pub filters: DataFilters,
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(target_os = "linux")] {
|
if #[cfg(target_os = "linux")] {
|
||||||
/// The max signal we can send to a process on Linux.
|
/// The max signal we can send to a process on Linux.
|
||||||
@ -164,7 +99,63 @@ cfg_if::cfg_if! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct App {
|
||||||
|
awaiting_second_char: bool,
|
||||||
|
second_char: Option<char>,
|
||||||
|
pub dd_err: Option<String>, // FIXME: The way we do deletes is really gross.
|
||||||
|
to_delete_process_list: Option<(String, Vec<Pid>)>,
|
||||||
|
pub frozen_state: FrozenState,
|
||||||
|
last_key_press: Instant,
|
||||||
|
pub converted_data: ConvertedData,
|
||||||
|
pub data_collection: DataCollection,
|
||||||
|
pub delete_dialog_state: AppDeleteDialogState,
|
||||||
|
pub help_dialog_state: AppHelpDialogState,
|
||||||
|
pub is_expanded: bool,
|
||||||
|
pub is_force_redraw: bool,
|
||||||
|
pub is_determining_widget_boundary: bool,
|
||||||
|
pub basic_mode_use_percent: bool,
|
||||||
|
#[cfg(target_family = "unix")]
|
||||||
|
pub user_table: data_harvester::processes::UserTable,
|
||||||
|
pub states: AppWidgetStates,
|
||||||
|
pub app_config_fields: AppConfigFields,
|
||||||
|
pub widget_map: HashMap<u64, BottomWidget>,
|
||||||
|
pub current_widget: BottomWidget,
|
||||||
|
pub used_widgets: UsedWidgets,
|
||||||
|
pub filters: DataFilters,
|
||||||
|
}
|
||||||
|
|
||||||
impl App {
|
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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn reset(&mut self) {
|
pub fn reset(&mut self) {
|
||||||
// Reset multi
|
// Reset multi
|
||||||
self.reset_multi_tap_keys();
|
self.reset_multi_tap_keys();
|
||||||
@ -174,7 +165,8 @@ impl App {
|
|||||||
self.delete_dialog_state.is_showing_dd = false;
|
self.delete_dialog_state.is_showing_dd = false;
|
||||||
|
|
||||||
// Close all searches and reset it
|
// Close all searches and reset it
|
||||||
self.proc_state
|
self.states
|
||||||
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.values_mut()
|
.values_mut()
|
||||||
.for_each(|state| {
|
.for_each(|state| {
|
||||||
@ -224,6 +216,7 @@ impl App {
|
|||||||
match self.current_widget.widget_type {
|
match self.current_widget.widget_type {
|
||||||
BottomWidgetType::Proc => {
|
BottomWidgetType::Proc => {
|
||||||
if let Some(pws) = self
|
if let Some(pws) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -237,6 +230,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::ProcSearch => {
|
BottomWidgetType::ProcSearch => {
|
||||||
if let Some(pws) = self
|
if let Some(pws) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id - 1)
|
.get_mut_widget_state(self.current_widget.widget_id - 1)
|
||||||
{
|
{
|
||||||
@ -250,6 +244,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::ProcSort => {
|
BottomWidgetType::ProcSort => {
|
||||||
if let Some(pws) = self
|
if let Some(pws) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id - 2)
|
.get_mut_widget_state(self.current_widget.widget_id - 2)
|
||||||
{
|
{
|
||||||
@ -297,6 +292,7 @@ impl App {
|
|||||||
if !self.ignore_normal_keybinds() {
|
if !self.ignore_normal_keybinds() {
|
||||||
if let BottomWidgetType::Proc = self.current_widget.widget_type {
|
if let BottomWidgetType::Proc = self.current_widget.widget_type {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -311,7 +307,7 @@ impl App {
|
|||||||
match &self.current_widget.widget_type {
|
match &self.current_widget.widget_type {
|
||||||
BottomWidgetType::Proc | BottomWidgetType::ProcSort => {
|
BottomWidgetType::Proc | BottomWidgetType::ProcSort => {
|
||||||
// Toggle on
|
// 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
|
self.current_widget.widget_id
|
||||||
- match &self.current_widget.widget_type {
|
- match &self.current_widget.widget_type {
|
||||||
BottomWidgetType::ProcSort => 2,
|
BottomWidgetType::ProcSort => 2,
|
||||||
@ -336,7 +332,7 @@ impl App {
|
|||||||
_ => 0,
|
_ => 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.is_sort_open = !pws.is_sort_open;
|
||||||
pws.force_rerender = true;
|
pws.force_rerender = true;
|
||||||
|
|
||||||
@ -361,7 +357,7 @@ impl App {
|
|||||||
_ => 0,
|
_ => 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.table.toggle_order();
|
||||||
pws.force_data_update();
|
pws.force_data_update();
|
||||||
}
|
}
|
||||||
@ -377,6 +373,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::Proc => {
|
BottomWidgetType::Proc => {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&self.current_widget.widget_id)
|
.get_mut(&self.current_widget.widget_id)
|
||||||
@ -392,6 +389,7 @@ impl App {
|
|||||||
pub fn toggle_ignore_case(&mut self) {
|
pub fn toggle_ignore_case(&mut self) {
|
||||||
let is_in_search_widget = self.is_in_search_widget();
|
let is_in_search_widget = self.is_in_search_widget();
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&(self.current_widget.widget_id - 1))
|
.get_mut(&(self.current_widget.widget_id - 1))
|
||||||
@ -406,6 +404,7 @@ impl App {
|
|||||||
pub fn toggle_search_whole_word(&mut self) {
|
pub fn toggle_search_whole_word(&mut self) {
|
||||||
let is_in_search_widget = self.is_in_search_widget();
|
let is_in_search_widget = self.is_in_search_widget();
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&(self.current_widget.widget_id - 1))
|
.get_mut(&(self.current_widget.widget_id - 1))
|
||||||
@ -420,6 +419,7 @@ impl App {
|
|||||||
pub fn toggle_search_regex(&mut self) {
|
pub fn toggle_search_regex(&mut self) {
|
||||||
let is_in_search_widget = self.is_in_search_widget();
|
let is_in_search_widget = self.is_in_search_widget();
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&(self.current_widget.widget_id - 1))
|
.get_mut(&(self.current_widget.widget_id - 1))
|
||||||
@ -433,6 +433,7 @@ impl App {
|
|||||||
|
|
||||||
pub fn toggle_tree_mode(&mut self) {
|
pub fn toggle_tree_mode(&mut self) {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&(self.current_widget.widget_id))
|
.get_mut(&(self.current_widget.widget_id))
|
||||||
@ -482,6 +483,7 @@ impl App {
|
|||||||
} else if !self.is_in_dialog() {
|
} else if !self.is_in_dialog() {
|
||||||
if let BottomWidgetType::ProcSort = self.current_widget.widget_type {
|
if let BottomWidgetType::ProcSort = self.current_widget.widget_type {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&(self.current_widget.widget_id - 2))
|
.get_mut(&(self.current_widget.widget_id - 2))
|
||||||
@ -498,6 +500,7 @@ impl App {
|
|||||||
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
|
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
|
||||||
let is_in_search_widget = self.is_in_search_widget();
|
let is_in_search_widget = self.is_in_search_widget();
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&(self.current_widget.widget_id - 1))
|
.get_mut(&(self.current_widget.widget_id - 1))
|
||||||
@ -544,6 +547,7 @@ impl App {
|
|||||||
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
|
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
|
||||||
let is_in_search_widget = self.is_in_search_widget();
|
let is_in_search_widget = self.is_in_search_widget();
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&(self.current_widget.widget_id - 1))
|
.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> {
|
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
|
&process_widget_state.proc_search.search_state.query
|
||||||
} else {
|
} else {
|
||||||
&None
|
&None
|
||||||
@ -672,6 +676,7 @@ impl App {
|
|||||||
BottomWidgetType::ProcSearch => {
|
BottomWidgetType::ProcSearch => {
|
||||||
let is_in_search_widget = self.is_in_search_widget();
|
let is_in_search_widget = self.is_in_search_widget();
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id - 1)
|
.get_mut_widget_state(self.current_widget.widget_id - 1)
|
||||||
{
|
{
|
||||||
@ -688,6 +693,7 @@ impl App {
|
|||||||
BottomWidgetType::Battery => {
|
BottomWidgetType::Battery => {
|
||||||
if !self.converted_data.battery_data.is_empty() {
|
if !self.converted_data.battery_data.is_empty() {
|
||||||
if let Some(battery_widget_state) = self
|
if let Some(battery_widget_state) = self
|
||||||
|
.states
|
||||||
.battery_state
|
.battery_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -731,6 +737,7 @@ impl App {
|
|||||||
BottomWidgetType::ProcSearch => {
|
BottomWidgetType::ProcSearch => {
|
||||||
let is_in_search_widget = self.is_in_search_widget();
|
let is_in_search_widget = self.is_in_search_widget();
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id - 1)
|
.get_mut_widget_state(self.current_widget.widget_id - 1)
|
||||||
{
|
{
|
||||||
@ -748,6 +755,7 @@ impl App {
|
|||||||
if !self.converted_data.battery_data.is_empty() {
|
if !self.converted_data.battery_data.is_empty() {
|
||||||
let battery_count = self.converted_data.battery_data.len();
|
let battery_count = self.converted_data.battery_data.len();
|
||||||
if let Some(battery_widget_state) = self
|
if let Some(battery_widget_state) = self
|
||||||
|
.states
|
||||||
.battery_state
|
.battery_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -888,6 +896,7 @@ impl App {
|
|||||||
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
|
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
|
||||||
let is_in_search_widget = self.is_in_search_widget();
|
let is_in_search_widget = self.is_in_search_widget();
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&(self.current_widget.widget_id - 1))
|
.get_mut(&(self.current_widget.widget_id - 1))
|
||||||
@ -917,6 +926,7 @@ impl App {
|
|||||||
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
|
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
|
||||||
let is_in_search_widget = self.is_in_search_widget();
|
let is_in_search_widget = self.is_in_search_widget();
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&(self.current_widget.widget_id - 1))
|
.get_mut(&(self.current_widget.widget_id - 1))
|
||||||
@ -941,6 +951,7 @@ impl App {
|
|||||||
pub fn clear_search(&mut self) {
|
pub fn clear_search(&mut self) {
|
||||||
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
|
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&(self.current_widget.widget_id - 1))
|
.get_mut(&(self.current_widget.widget_id - 1))
|
||||||
@ -953,6 +964,7 @@ impl App {
|
|||||||
pub fn clear_previous_word(&mut self) {
|
pub fn clear_previous_word(&mut self) {
|
||||||
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
|
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&(self.current_widget.widget_id - 1))
|
.get_mut(&(self.current_widget.widget_id - 1))
|
||||||
@ -1011,6 +1023,7 @@ impl App {
|
|||||||
self.reset_multi_tap_keys();
|
self.reset_multi_tap_keys();
|
||||||
|
|
||||||
if let Some(pws) = self
|
if let Some(pws) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get(&self.current_widget.widget_id)
|
.get(&self.current_widget.widget_id)
|
||||||
@ -1055,6 +1068,7 @@ impl App {
|
|||||||
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
|
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
|
||||||
let is_in_search_widget = self.is_in_search_widget();
|
let is_in_search_widget = self.is_in_search_widget();
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&(self.current_widget.widget_id - 1))
|
.get_mut(&(self.current_widget.widget_id - 1))
|
||||||
@ -1159,6 +1173,7 @@ impl App {
|
|||||||
self.second_char = Some('d');
|
self.second_char = Some('d');
|
||||||
}
|
}
|
||||||
} else if let Some(disk) = self
|
} else if let Some(disk) = self
|
||||||
|
.states
|
||||||
.disk_state
|
.disk_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -1190,6 +1205,7 @@ impl App {
|
|||||||
'c' => {
|
'c' => {
|
||||||
if let BottomWidgetType::Proc = self.current_widget.widget_type {
|
if let BottomWidgetType::Proc = self.current_widget.widget_type {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -1200,12 +1216,14 @@ impl App {
|
|||||||
'm' => {
|
'm' => {
|
||||||
if let BottomWidgetType::Proc = self.current_widget.widget_type {
|
if let BottomWidgetType::Proc = self.current_widget.widget_type {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
proc_widget_state.select_column(ProcWidgetColumn::Mem);
|
proc_widget_state.select_column(ProcWidgetColumn::Mem);
|
||||||
}
|
}
|
||||||
} else if let Some(disk) = self
|
} else if let Some(disk) = self
|
||||||
|
.states
|
||||||
.disk_state
|
.disk_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -1215,12 +1233,14 @@ impl App {
|
|||||||
'p' => {
|
'p' => {
|
||||||
if let BottomWidgetType::Proc = self.current_widget.widget_type {
|
if let BottomWidgetType::Proc = self.current_widget.widget_type {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
proc_widget_state.select_column(ProcWidgetColumn::PidOrCount);
|
proc_widget_state.select_column(ProcWidgetColumn::PidOrCount);
|
||||||
}
|
}
|
||||||
} else if let Some(disk) = self
|
} else if let Some(disk) = self
|
||||||
|
.states
|
||||||
.disk_state
|
.disk_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -1230,6 +1250,7 @@ impl App {
|
|||||||
'P' => {
|
'P' => {
|
||||||
if let BottomWidgetType::Proc = self.current_widget.widget_type {
|
if let BottomWidgetType::Proc = self.current_widget.widget_type {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -1240,12 +1261,14 @@ impl App {
|
|||||||
'n' => {
|
'n' => {
|
||||||
if let BottomWidgetType::Proc = self.current_widget.widget_type {
|
if let BottomWidgetType::Proc = self.current_widget.widget_type {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
proc_widget_state.select_column(ProcWidgetColumn::ProcNameOrCommand);
|
proc_widget_state.select_column(ProcWidgetColumn::ProcNameOrCommand);
|
||||||
}
|
}
|
||||||
} else if let Some(disk) = self
|
} else if let Some(disk) = self
|
||||||
|
.states
|
||||||
.disk_state
|
.disk_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -1264,12 +1287,14 @@ impl App {
|
|||||||
if let BottomWidgetType::Proc = self.current_widget.widget_type {
|
if let BottomWidgetType::Proc = self.current_widget.widget_type {
|
||||||
self.toggle_tree_mode()
|
self.toggle_tree_mode()
|
||||||
} else if let Some(temp) = self
|
} else if let Some(temp) = self
|
||||||
|
.states
|
||||||
.temp_state
|
.temp_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
temp.table.set_sort_index(1);
|
temp.table.set_sort_index(1);
|
||||||
temp.force_data_update();
|
temp.force_data_update();
|
||||||
} else if let Some(disk) = self
|
} else if let Some(disk) = self
|
||||||
|
.states
|
||||||
.disk_state
|
.disk_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -1284,6 +1309,7 @@ impl App {
|
|||||||
if let BottomWidgetType::Proc = self.current_widget.widget_type {
|
if let BottomWidgetType::Proc = self.current_widget.widget_type {
|
||||||
self.toggle_sort_menu()
|
self.toggle_sort_menu()
|
||||||
} else if let Some(temp) = self
|
} else if let Some(temp) = self
|
||||||
|
.states
|
||||||
.temp_state
|
.temp_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -1294,6 +1320,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
'u' => {
|
'u' => {
|
||||||
if let Some(disk) = self
|
if let Some(disk) = self
|
||||||
|
.states
|
||||||
.disk_state
|
.disk_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -1302,6 +1329,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
'r' => {
|
'r' => {
|
||||||
if let Some(disk) = self
|
if let Some(disk) = self
|
||||||
|
.states
|
||||||
.disk_state
|
.disk_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -1310,6 +1338,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
'w' => {
|
'w' => {
|
||||||
if let Some(disk) = self
|
if let Some(disk) = self
|
||||||
|
.states
|
||||||
.disk_state
|
.disk_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -1418,14 +1447,17 @@ impl App {
|
|||||||
| BottomWidgetType::ProcSort
|
| BottomWidgetType::ProcSort
|
||||||
| BottomWidgetType::Disk
|
| BottomWidgetType::Disk
|
||||||
| BottomWidgetType::Battery
|
| BottomWidgetType::Battery
|
||||||
if self.basic_table_widget_state.is_some()
|
if self.states.basic_table_widget_state.is_some()
|
||||||
&& (*direction == WidgetDirection::Left
|
&& (*direction == WidgetDirection::Left
|
||||||
|| *direction == WidgetDirection::Right) =>
|
|| *direction == WidgetDirection::Right) =>
|
||||||
{
|
{
|
||||||
// Gotta do this for the sort widget
|
// Gotta do this for the sort widget
|
||||||
if let BottomWidgetType::ProcSort = new_widget.widget_type {
|
if let BottomWidgetType::ProcSort = new_widget.widget_type {
|
||||||
if let Some(proc_widget_state) =
|
if let Some(proc_widget_state) = self
|
||||||
self.proc_state.widget_states.get(&(new_widget_id - 2))
|
.states
|
||||||
|
.proc_state
|
||||||
|
.widget_states
|
||||||
|
.get(&(new_widget_id - 2))
|
||||||
{
|
{
|
||||||
if proc_widget_state.is_sort_open {
|
if proc_widget_state.is_sort_open {
|
||||||
self.current_widget = new_widget.clone();
|
self.current_widget = new_widget.clone();
|
||||||
@ -1445,7 +1477,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(basic_table_widget_state) =
|
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 =
|
basic_table_widget_state.currently_displayed_widget_id =
|
||||||
self.current_widget.widget_id;
|
self.current_widget.widget_id;
|
||||||
@ -1474,7 +1506,7 @@ impl App {
|
|||||||
// Assuming we're in basic mode (BasicTables), then
|
// Assuming we're in basic mode (BasicTables), then
|
||||||
// we want to move DOWN to the currently shown widget.
|
// we want to move DOWN to the currently shown widget.
|
||||||
if let Some(basic_table_widget_state) =
|
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.
|
// We also want to move towards Proc if we had set it to ProcSort.
|
||||||
if let BottomWidgetType::ProcSort =
|
if let BottomWidgetType::ProcSort =
|
||||||
@ -1512,6 +1544,7 @@ impl App {
|
|||||||
match &new_widget.widget_type {
|
match &new_widget.widget_type {
|
||||||
BottomWidgetType::CpuLegend => {
|
BottomWidgetType::CpuLegend => {
|
||||||
if let Some(cpu_widget_state) = self
|
if let Some(cpu_widget_state) = self
|
||||||
|
.states
|
||||||
.cpu_state
|
.cpu_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get(&(new_widget_id - *offset))
|
.get(&(new_widget_id - *offset))
|
||||||
@ -1535,6 +1568,7 @@ impl App {
|
|||||||
BottomWidgetType::ProcSearch
|
BottomWidgetType::ProcSearch
|
||||||
| BottomWidgetType::ProcSort => {
|
| BottomWidgetType::ProcSort => {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get(&(new_widget_id - *offset))
|
.get(&(new_widget_id - *offset))
|
||||||
@ -1593,6 +1627,7 @@ impl App {
|
|||||||
match &new_widget.widget_type {
|
match &new_widget.widget_type {
|
||||||
BottomWidgetType::CpuLegend => {
|
BottomWidgetType::CpuLegend => {
|
||||||
if let Some(cpu_widget_state) = self
|
if let Some(cpu_widget_state) = self
|
||||||
|
.states
|
||||||
.cpu_state
|
.cpu_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get(&(new_widget_id - *offset))
|
.get(&(new_widget_id - *offset))
|
||||||
@ -1613,6 +1648,7 @@ impl App {
|
|||||||
BottomWidgetType::ProcSearch
|
BottomWidgetType::ProcSearch
|
||||||
| BottomWidgetType::ProcSort => {
|
| BottomWidgetType::ProcSort => {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get(&(new_widget_id - *offset))
|
.get(&(new_widget_id - *offset))
|
||||||
@ -1671,6 +1707,7 @@ impl App {
|
|||||||
match &self.current_widget.widget_type {
|
match &self.current_widget.widget_type {
|
||||||
BottomWidgetType::CpuLegend => {
|
BottomWidgetType::CpuLegend => {
|
||||||
if let Some(cpu_widget_state) = self
|
if let Some(cpu_widget_state) = self
|
||||||
|
.states
|
||||||
.cpu_state
|
.cpu_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get(&(self.current_widget.widget_id - *offset))
|
.get(&(self.current_widget.widget_id - *offset))
|
||||||
@ -1682,6 +1719,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::ProcSearch | BottomWidgetType::ProcSort => {
|
BottomWidgetType::ProcSearch | BottomWidgetType::ProcSort => {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get(&(self.current_widget.widget_id - *offset))
|
.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_id) = current_widget.down_neighbour {
|
||||||
if let Some(new_widget) = self.widget_map.get(&new_widget_id) {
|
if let Some(new_widget) = self.widget_map.get(&new_widget_id) {
|
||||||
if let Some(proc_widget_state) =
|
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() {
|
if proc_widget_state.is_search_enabled() {
|
||||||
self.current_widget = new_widget.clone();
|
self.current_widget = new_widget.clone();
|
||||||
@ -1758,6 +1796,7 @@ impl App {
|
|||||||
if let BottomWidgetType::Proc = self.current_widget.widget_type {
|
if let BottomWidgetType::Proc = self.current_widget.widget_type {
|
||||||
if let Some(new_widget_id) = self.current_widget.left_neighbour {
|
if let Some(new_widget_id) = self.current_widget.left_neighbour {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get(&self.current_widget.widget_id)
|
.get(&self.current_widget.widget_id)
|
||||||
@ -1773,6 +1812,7 @@ impl App {
|
|||||||
if let BottomWidgetType::Cpu = self.current_widget.widget_type {
|
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(current_widget) = self.widget_map.get(&self.current_widget.widget_id) {
|
||||||
if let Some(cpu_widget_state) = self
|
if let Some(cpu_widget_state) = self
|
||||||
|
.states
|
||||||
.cpu_state
|
.cpu_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get(&self.current_widget.widget_id)
|
.get(&self.current_widget.widget_id)
|
||||||
@ -1818,6 +1858,7 @@ impl App {
|
|||||||
} else if let BottomWidgetType::Cpu = self.current_widget.widget_type {
|
} 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(current_widget) = self.widget_map.get(&self.current_widget.widget_id) {
|
||||||
if let Some(cpu_widget_state) = self
|
if let Some(cpu_widget_state) = self
|
||||||
|
.states
|
||||||
.cpu_state
|
.cpu_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get(&self.current_widget.widget_id)
|
.get(&self.current_widget.widget_id)
|
||||||
@ -1839,6 +1880,7 @@ impl App {
|
|||||||
match self.current_widget.widget_type {
|
match self.current_widget.widget_type {
|
||||||
BottomWidgetType::Proc => {
|
BottomWidgetType::Proc => {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -1847,6 +1889,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::ProcSort => {
|
BottomWidgetType::ProcSort => {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id - 2)
|
.get_mut_widget_state(self.current_widget.widget_id - 2)
|
||||||
{
|
{
|
||||||
@ -1855,6 +1898,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::Temp => {
|
BottomWidgetType::Temp => {
|
||||||
if let Some(temp_widget_state) = self
|
if let Some(temp_widget_state) = self
|
||||||
|
.states
|
||||||
.temp_state
|
.temp_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -1863,6 +1907,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::Disk => {
|
BottomWidgetType::Disk => {
|
||||||
if let Some(disk_widget_state) = self
|
if let Some(disk_widget_state) = self
|
||||||
|
.states
|
||||||
.disk_state
|
.disk_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -1871,6 +1916,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::CpuLegend => {
|
BottomWidgetType::CpuLegend => {
|
||||||
if let Some(cpu_widget_state) = self
|
if let Some(cpu_widget_state) = self
|
||||||
|
.states
|
||||||
.cpu_state
|
.cpu_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id - 1)
|
.get_mut_widget_state(self.current_widget.widget_id - 1)
|
||||||
{
|
{
|
||||||
@ -1893,6 +1939,7 @@ impl App {
|
|||||||
match self.current_widget.widget_type {
|
match self.current_widget.widget_type {
|
||||||
BottomWidgetType::Proc => {
|
BottomWidgetType::Proc => {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -1901,6 +1948,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::ProcSort => {
|
BottomWidgetType::ProcSort => {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id - 2)
|
.get_mut_widget_state(self.current_widget.widget_id - 2)
|
||||||
{
|
{
|
||||||
@ -1909,6 +1957,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::Temp => {
|
BottomWidgetType::Temp => {
|
||||||
if let Some(temp_widget_state) = self
|
if let Some(temp_widget_state) = self
|
||||||
|
.states
|
||||||
.temp_state
|
.temp_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -1917,6 +1966,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::Disk => {
|
BottomWidgetType::Disk => {
|
||||||
if let Some(disk_widget_state) = self
|
if let Some(disk_widget_state) = self
|
||||||
|
.states
|
||||||
.disk_state
|
.disk_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -1927,6 +1977,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::CpuLegend => {
|
BottomWidgetType::CpuLegend => {
|
||||||
if let Some(cpu_widget_state) = self
|
if let Some(cpu_widget_state) = self
|
||||||
|
.states
|
||||||
.cpu_state
|
.cpu_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id - 1)
|
.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) {
|
fn change_process_sort_position(&mut self, num_to_change_by: i64) {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id - 2)
|
.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) {
|
fn change_cpu_legend_position(&mut self, num_to_change_by: i64) {
|
||||||
if let Some(cpu_widget_state) = self
|
if let Some(cpu_widget_state) = self
|
||||||
|
.states
|
||||||
.cpu_state
|
.cpu_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&(self.current_widget.widget_id - 1))
|
.get_mut(&(self.current_widget.widget_id - 1))
|
||||||
@ -1991,6 +2044,7 @@ impl App {
|
|||||||
/// Returns the new position.
|
/// Returns the new position.
|
||||||
fn change_process_position(&mut self, num_to_change_by: i64) -> Option<usize> {
|
fn change_process_position(&mut self, num_to_change_by: i64) -> Option<usize> {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.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) {
|
fn change_temp_position(&mut self, num_to_change_by: i64) {
|
||||||
if let Some(temp_widget_state) = self
|
if let Some(temp_widget_state) = self
|
||||||
|
.states
|
||||||
.temp_state
|
.temp_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&self.current_widget.widget_id)
|
.get_mut(&self.current_widget.widget_id)
|
||||||
@ -2012,6 +2067,7 @@ impl App {
|
|||||||
|
|
||||||
fn change_disk_position(&mut self, num_to_change_by: i64) {
|
fn change_disk_position(&mut self, num_to_change_by: i64) {
|
||||||
if let Some(disk_widget_state) = self
|
if let Some(disk_widget_state) = self
|
||||||
|
.states
|
||||||
.disk_state
|
.disk_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&self.current_widget.widget_id)
|
.get_mut(&self.current_widget.widget_id)
|
||||||
@ -2097,6 +2153,7 @@ impl App {
|
|||||||
|
|
||||||
fn toggle_collapsing_process_branch(&mut self) {
|
fn toggle_collapsing_process_branch(&mut self) {
|
||||||
if let Some(pws) = self
|
if let Some(pws) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&self.current_widget.widget_id)
|
.get_mut(&self.current_widget.widget_id)
|
||||||
@ -2109,6 +2166,7 @@ impl App {
|
|||||||
match self.current_widget.widget_type {
|
match self.current_widget.widget_type {
|
||||||
BottomWidgetType::Cpu => {
|
BottomWidgetType::Cpu => {
|
||||||
if let Some(cpu_widget_state) = self
|
if let Some(cpu_widget_state) = self
|
||||||
|
.states
|
||||||
.cpu_state
|
.cpu_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&self.current_widget.widget_id)
|
.get_mut(&self.current_widget.widget_id)
|
||||||
@ -2117,7 +2175,7 @@ impl App {
|
|||||||
+ self.app_config_fields.time_interval;
|
+ self.app_config_fields.time_interval;
|
||||||
if new_time <= self.app_config_fields.retention_ms {
|
if new_time <= self.app_config_fields.retention_ms {
|
||||||
cpu_widget_state.current_display_time = new_time;
|
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 {
|
if self.app_config_fields.autohide_time {
|
||||||
cpu_widget_state.autohide_timer = Some(Instant::now());
|
cpu_widget_state.autohide_timer = Some(Instant::now());
|
||||||
}
|
}
|
||||||
@ -2125,7 +2183,7 @@ impl App {
|
|||||||
!= self.app_config_fields.retention_ms
|
!= self.app_config_fields.retention_ms
|
||||||
{
|
{
|
||||||
cpu_widget_state.current_display_time = 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 {
|
if self.app_config_fields.autohide_time {
|
||||||
cpu_widget_state.autohide_timer = Some(Instant::now());
|
cpu_widget_state.autohide_timer = Some(Instant::now());
|
||||||
}
|
}
|
||||||
@ -2134,6 +2192,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::Mem => {
|
BottomWidgetType::Mem => {
|
||||||
if let Some(mem_widget_state) = self
|
if let Some(mem_widget_state) = self
|
||||||
|
.states
|
||||||
.mem_state
|
.mem_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&self.current_widget.widget_id)
|
.get_mut(&self.current_widget.widget_id)
|
||||||
@ -2142,7 +2201,7 @@ impl App {
|
|||||||
+ self.app_config_fields.time_interval;
|
+ self.app_config_fields.time_interval;
|
||||||
if new_time <= self.app_config_fields.retention_ms {
|
if new_time <= self.app_config_fields.retention_ms {
|
||||||
mem_widget_state.current_display_time = new_time;
|
mem_widget_state.current_display_time = new_time;
|
||||||
self.mem_state.force_update = Some(self.current_widget.widget_id);
|
self.states.mem_state.force_update = Some(self.current_widget.widget_id);
|
||||||
if self.app_config_fields.autohide_time {
|
if self.app_config_fields.autohide_time {
|
||||||
mem_widget_state.autohide_timer = Some(Instant::now());
|
mem_widget_state.autohide_timer = Some(Instant::now());
|
||||||
}
|
}
|
||||||
@ -2150,7 +2209,7 @@ impl App {
|
|||||||
!= self.app_config_fields.retention_ms
|
!= self.app_config_fields.retention_ms
|
||||||
{
|
{
|
||||||
mem_widget_state.current_display_time = self.app_config_fields.retention_ms;
|
mem_widget_state.current_display_time = self.app_config_fields.retention_ms;
|
||||||
self.mem_state.force_update = Some(self.current_widget.widget_id);
|
self.states.mem_state.force_update = Some(self.current_widget.widget_id);
|
||||||
if self.app_config_fields.autohide_time {
|
if self.app_config_fields.autohide_time {
|
||||||
mem_widget_state.autohide_timer = Some(Instant::now());
|
mem_widget_state.autohide_timer = Some(Instant::now());
|
||||||
}
|
}
|
||||||
@ -2159,6 +2218,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::Net => {
|
BottomWidgetType::Net => {
|
||||||
if let Some(net_widget_state) = self
|
if let Some(net_widget_state) = self
|
||||||
|
.states
|
||||||
.net_state
|
.net_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&self.current_widget.widget_id)
|
.get_mut(&self.current_widget.widget_id)
|
||||||
@ -2167,7 +2227,7 @@ impl App {
|
|||||||
+ self.app_config_fields.time_interval;
|
+ self.app_config_fields.time_interval;
|
||||||
if new_time <= self.app_config_fields.retention_ms {
|
if new_time <= self.app_config_fields.retention_ms {
|
||||||
net_widget_state.current_display_time = new_time;
|
net_widget_state.current_display_time = new_time;
|
||||||
self.net_state.force_update = Some(self.current_widget.widget_id);
|
self.states.net_state.force_update = Some(self.current_widget.widget_id);
|
||||||
if self.app_config_fields.autohide_time {
|
if self.app_config_fields.autohide_time {
|
||||||
net_widget_state.autohide_timer = Some(Instant::now());
|
net_widget_state.autohide_timer = Some(Instant::now());
|
||||||
}
|
}
|
||||||
@ -2175,7 +2235,7 @@ impl App {
|
|||||||
!= self.app_config_fields.retention_ms
|
!= self.app_config_fields.retention_ms
|
||||||
{
|
{
|
||||||
net_widget_state.current_display_time = self.app_config_fields.retention_ms;
|
net_widget_state.current_display_time = self.app_config_fields.retention_ms;
|
||||||
self.net_state.force_update = Some(self.current_widget.widget_id);
|
self.states.net_state.force_update = Some(self.current_widget.widget_id);
|
||||||
if self.app_config_fields.autohide_time {
|
if self.app_config_fields.autohide_time {
|
||||||
net_widget_state.autohide_timer = Some(Instant::now());
|
net_widget_state.autohide_timer = Some(Instant::now());
|
||||||
}
|
}
|
||||||
@ -2190,6 +2250,7 @@ impl App {
|
|||||||
match self.current_widget.widget_type {
|
match self.current_widget.widget_type {
|
||||||
BottomWidgetType::Cpu => {
|
BottomWidgetType::Cpu => {
|
||||||
if let Some(cpu_widget_state) = self
|
if let Some(cpu_widget_state) = self
|
||||||
|
.states
|
||||||
.cpu_state
|
.cpu_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&self.current_widget.widget_id)
|
.get_mut(&self.current_widget.widget_id)
|
||||||
@ -2198,7 +2259,7 @@ impl App {
|
|||||||
- self.app_config_fields.time_interval;
|
- self.app_config_fields.time_interval;
|
||||||
if new_time >= constants::STALE_MIN_MILLISECONDS {
|
if new_time >= constants::STALE_MIN_MILLISECONDS {
|
||||||
cpu_widget_state.current_display_time = new_time;
|
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 {
|
if self.app_config_fields.autohide_time {
|
||||||
cpu_widget_state.autohide_timer = Some(Instant::now());
|
cpu_widget_state.autohide_timer = Some(Instant::now());
|
||||||
}
|
}
|
||||||
@ -2206,7 +2267,7 @@ impl App {
|
|||||||
!= constants::STALE_MIN_MILLISECONDS
|
!= constants::STALE_MIN_MILLISECONDS
|
||||||
{
|
{
|
||||||
cpu_widget_state.current_display_time = constants::STALE_MIN_MILLISECONDS;
|
cpu_widget_state.current_display_time = constants::STALE_MIN_MILLISECONDS;
|
||||||
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 {
|
if self.app_config_fields.autohide_time {
|
||||||
cpu_widget_state.autohide_timer = Some(Instant::now());
|
cpu_widget_state.autohide_timer = Some(Instant::now());
|
||||||
}
|
}
|
||||||
@ -2215,6 +2276,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::Mem => {
|
BottomWidgetType::Mem => {
|
||||||
if let Some(mem_widget_state) = self
|
if let Some(mem_widget_state) = self
|
||||||
|
.states
|
||||||
.mem_state
|
.mem_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&self.current_widget.widget_id)
|
.get_mut(&self.current_widget.widget_id)
|
||||||
@ -2223,7 +2285,7 @@ impl App {
|
|||||||
- self.app_config_fields.time_interval;
|
- self.app_config_fields.time_interval;
|
||||||
if new_time >= constants::STALE_MIN_MILLISECONDS {
|
if new_time >= constants::STALE_MIN_MILLISECONDS {
|
||||||
mem_widget_state.current_display_time = new_time;
|
mem_widget_state.current_display_time = new_time;
|
||||||
self.mem_state.force_update = Some(self.current_widget.widget_id);
|
self.states.mem_state.force_update = Some(self.current_widget.widget_id);
|
||||||
if self.app_config_fields.autohide_time {
|
if self.app_config_fields.autohide_time {
|
||||||
mem_widget_state.autohide_timer = Some(Instant::now());
|
mem_widget_state.autohide_timer = Some(Instant::now());
|
||||||
}
|
}
|
||||||
@ -2231,7 +2293,7 @@ impl App {
|
|||||||
!= constants::STALE_MIN_MILLISECONDS
|
!= constants::STALE_MIN_MILLISECONDS
|
||||||
{
|
{
|
||||||
mem_widget_state.current_display_time = constants::STALE_MIN_MILLISECONDS;
|
mem_widget_state.current_display_time = constants::STALE_MIN_MILLISECONDS;
|
||||||
self.mem_state.force_update = Some(self.current_widget.widget_id);
|
self.states.mem_state.force_update = Some(self.current_widget.widget_id);
|
||||||
if self.app_config_fields.autohide_time {
|
if self.app_config_fields.autohide_time {
|
||||||
mem_widget_state.autohide_timer = Some(Instant::now());
|
mem_widget_state.autohide_timer = Some(Instant::now());
|
||||||
}
|
}
|
||||||
@ -2240,6 +2302,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::Net => {
|
BottomWidgetType::Net => {
|
||||||
if let Some(net_widget_state) = self
|
if let Some(net_widget_state) = self
|
||||||
|
.states
|
||||||
.net_state
|
.net_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&self.current_widget.widget_id)
|
.get_mut(&self.current_widget.widget_id)
|
||||||
@ -2248,7 +2311,7 @@ impl App {
|
|||||||
- self.app_config_fields.time_interval;
|
- self.app_config_fields.time_interval;
|
||||||
if new_time >= constants::STALE_MIN_MILLISECONDS {
|
if new_time >= constants::STALE_MIN_MILLISECONDS {
|
||||||
net_widget_state.current_display_time = new_time;
|
net_widget_state.current_display_time = new_time;
|
||||||
self.net_state.force_update = Some(self.current_widget.widget_id);
|
self.states.net_state.force_update = Some(self.current_widget.widget_id);
|
||||||
if self.app_config_fields.autohide_time {
|
if self.app_config_fields.autohide_time {
|
||||||
net_widget_state.autohide_timer = Some(Instant::now());
|
net_widget_state.autohide_timer = Some(Instant::now());
|
||||||
}
|
}
|
||||||
@ -2256,7 +2319,7 @@ impl App {
|
|||||||
!= constants::STALE_MIN_MILLISECONDS
|
!= constants::STALE_MIN_MILLISECONDS
|
||||||
{
|
{
|
||||||
net_widget_state.current_display_time = constants::STALE_MIN_MILLISECONDS;
|
net_widget_state.current_display_time = constants::STALE_MIN_MILLISECONDS;
|
||||||
self.net_state.force_update = Some(self.current_widget.widget_id);
|
self.states.net_state.force_update = Some(self.current_widget.widget_id);
|
||||||
if self.app_config_fields.autohide_time {
|
if self.app_config_fields.autohide_time {
|
||||||
net_widget_state.autohide_timer = Some(Instant::now());
|
net_widget_state.autohide_timer = Some(Instant::now());
|
||||||
}
|
}
|
||||||
@ -2269,12 +2332,13 @@ impl App {
|
|||||||
|
|
||||||
fn reset_cpu_zoom(&mut self) {
|
fn reset_cpu_zoom(&mut self) {
|
||||||
if let Some(cpu_widget_state) = self
|
if let Some(cpu_widget_state) = self
|
||||||
|
.states
|
||||||
.cpu_state
|
.cpu_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&self.current_widget.widget_id)
|
.get_mut(&self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
cpu_widget_state.current_display_time = self.app_config_fields.default_time_value;
|
cpu_widget_state.current_display_time = self.app_config_fields.default_time_value;
|
||||||
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 {
|
if self.app_config_fields.autohide_time {
|
||||||
cpu_widget_state.autohide_timer = Some(Instant::now());
|
cpu_widget_state.autohide_timer = Some(Instant::now());
|
||||||
}
|
}
|
||||||
@ -2283,12 +2347,13 @@ impl App {
|
|||||||
|
|
||||||
fn reset_mem_zoom(&mut self) {
|
fn reset_mem_zoom(&mut self) {
|
||||||
if let Some(mem_widget_state) = self
|
if let Some(mem_widget_state) = self
|
||||||
|
.states
|
||||||
.mem_state
|
.mem_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&self.current_widget.widget_id)
|
.get_mut(&self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
mem_widget_state.current_display_time = self.app_config_fields.default_time_value;
|
mem_widget_state.current_display_time = self.app_config_fields.default_time_value;
|
||||||
self.mem_state.force_update = Some(self.current_widget.widget_id);
|
self.states.mem_state.force_update = Some(self.current_widget.widget_id);
|
||||||
if self.app_config_fields.autohide_time {
|
if self.app_config_fields.autohide_time {
|
||||||
mem_widget_state.autohide_timer = Some(Instant::now());
|
mem_widget_state.autohide_timer = Some(Instant::now());
|
||||||
}
|
}
|
||||||
@ -2297,12 +2362,13 @@ impl App {
|
|||||||
|
|
||||||
fn reset_net_zoom(&mut self) {
|
fn reset_net_zoom(&mut self) {
|
||||||
if let Some(net_widget_state) = self
|
if let Some(net_widget_state) = self
|
||||||
|
.states
|
||||||
.net_state
|
.net_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&self.current_widget.widget_id)
|
.get_mut(&self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
net_widget_state.current_display_time = self.app_config_fields.default_time_value;
|
net_widget_state.current_display_time = self.app_config_fields.default_time_value;
|
||||||
self.net_state.force_update = Some(self.current_widget.widget_id);
|
self.states.net_state.force_update = Some(self.current_widget.widget_id);
|
||||||
if self.app_config_fields.autohide_time {
|
if self.app_config_fields.autohide_time {
|
||||||
net_widget_state.autohide_timer = Some(Instant::now());
|
net_widget_state.autohide_timer = Some(Instant::now());
|
||||||
}
|
}
|
||||||
@ -2333,7 +2399,7 @@ impl App {
|
|||||||
// Short circuit if we're in basic table... we might have to handle the basic table arrow
|
// Short circuit if we're in basic table... we might have to handle the basic table arrow
|
||||||
// case here...
|
// case here...
|
||||||
|
|
||||||
if let Some(bt) = &mut self.basic_table_widget_state {
|
if let Some(bt) = &mut self.states.basic_table_widget_state {
|
||||||
if let (
|
if let (
|
||||||
Some((left_tlc_x, left_tlc_y)),
|
Some((left_tlc_x, left_tlc_y)),
|
||||||
Some((left_brc_x, left_brc_y)),
|
Some((left_brc_x, left_brc_y)),
|
||||||
@ -2350,8 +2416,10 @@ impl App {
|
|||||||
self.current_widget = new_widget.clone();
|
self.current_widget = new_widget.clone();
|
||||||
|
|
||||||
if let BottomWidgetType::Proc = &new_widget.widget_type {
|
if let BottomWidgetType::Proc = &new_widget.widget_type {
|
||||||
if let Some(proc_widget_state) =
|
if let Some(proc_widget_state) = self
|
||||||
self.proc_state.get_widget_state(new_widget.widget_id)
|
.states
|
||||||
|
.proc_state
|
||||||
|
.get_widget_state(new_widget.widget_id)
|
||||||
{
|
{
|
||||||
if proc_widget_state.is_sort_open {
|
if proc_widget_state.is_sort_open {
|
||||||
self.move_widget_selection(&WidgetDirection::Left);
|
self.move_widget_selection(&WidgetDirection::Left);
|
||||||
@ -2372,8 +2440,10 @@ impl App {
|
|||||||
self.current_widget = new_widget.clone();
|
self.current_widget = new_widget.clone();
|
||||||
|
|
||||||
if let BottomWidgetType::ProcSort = &new_widget.widget_type {
|
if let BottomWidgetType::ProcSort = &new_widget.widget_type {
|
||||||
if let Some(proc_widget_state) =
|
if let Some(proc_widget_state) = self
|
||||||
self.proc_state.get_widget_state(new_widget.widget_id - 2)
|
.states
|
||||||
|
.proc_state
|
||||||
|
.get_widget_state(new_widget.widget_id - 2)
|
||||||
{
|
{
|
||||||
if proc_widget_state.is_sort_open {
|
if proc_widget_state.is_sort_open {
|
||||||
self.move_widget_selection(&WidgetDirection::Right);
|
self.move_widget_selection(&WidgetDirection::Right);
|
||||||
@ -2429,7 +2499,7 @@ impl App {
|
|||||||
| BottomWidgetType::Disk
|
| BottomWidgetType::Disk
|
||||||
| BottomWidgetType::Battery => {
|
| BottomWidgetType::Battery => {
|
||||||
if let Some(basic_table_widget_state) =
|
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 =
|
basic_table_widget_state.currently_displayed_widget_id =
|
||||||
self.current_widget.widget_id;
|
self.current_widget.widget_id;
|
||||||
@ -2475,6 +2545,7 @@ impl App {
|
|||||||
match &self.current_widget.widget_type {
|
match &self.current_widget.widget_type {
|
||||||
BottomWidgetType::Proc => {
|
BottomWidgetType::Proc => {
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_widget_state(self.current_widget.widget_id)
|
.get_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -2502,6 +2573,7 @@ impl App {
|
|||||||
BottomWidgetType::ProcSort => {
|
BottomWidgetType::ProcSort => {
|
||||||
// TODO: [Feature] This could sort if you double click!
|
// TODO: [Feature] This could sort if you double click!
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_widget_state(self.current_widget.widget_id - 2)
|
.get_widget_state(self.current_widget.widget_id - 2)
|
||||||
{
|
{
|
||||||
@ -2516,6 +2588,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::CpuLegend => {
|
BottomWidgetType::CpuLegend => {
|
||||||
if let Some(cpu_widget_state) = self
|
if let Some(cpu_widget_state) = self
|
||||||
|
.states
|
||||||
.cpu_state
|
.cpu_state
|
||||||
.get_widget_state(self.current_widget.widget_id - 1)
|
.get_widget_state(self.current_widget.widget_id - 1)
|
||||||
{
|
{
|
||||||
@ -2530,6 +2603,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::Temp => {
|
BottomWidgetType::Temp => {
|
||||||
if let Some(temp_widget_state) = self
|
if let Some(temp_widget_state) = self
|
||||||
|
.states
|
||||||
.temp_state
|
.temp_state
|
||||||
.get_widget_state(self.current_widget.widget_id)
|
.get_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -2544,6 +2618,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::Disk => {
|
BottomWidgetType::Disk => {
|
||||||
if let Some(disk_widget_state) = self
|
if let Some(disk_widget_state) = self
|
||||||
|
.states
|
||||||
.disk_state
|
.disk_state
|
||||||
.get_widget_state(self.current_widget.widget_id)
|
.get_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -2565,6 +2640,7 @@ impl App {
|
|||||||
match &self.current_widget.widget_type {
|
match &self.current_widget.widget_type {
|
||||||
BottomWidgetType::Proc => {
|
BottomWidgetType::Proc => {
|
||||||
if let Some(state) = self
|
if let Some(state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -2575,6 +2651,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::Temp => {
|
BottomWidgetType::Temp => {
|
||||||
if let Some(temp) = self
|
if let Some(temp) = self
|
||||||
|
.states
|
||||||
.temp_state
|
.temp_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -2585,6 +2662,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::Disk => {
|
BottomWidgetType::Disk => {
|
||||||
if let Some(disk) = self
|
if let Some(disk) = self
|
||||||
|
.states
|
||||||
.disk_state
|
.disk_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -2600,6 +2678,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
BottomWidgetType::Battery => {
|
BottomWidgetType::Battery => {
|
||||||
if let Some(battery_widget_state) = self
|
if let Some(battery_widget_state) = self
|
||||||
|
.states
|
||||||
.battery_state
|
.battery_state
|
||||||
.get_mut_widget_state(self.current_widget.widget_id)
|
.get_mut_widget_state(self.current_widget.widget_id)
|
||||||
{
|
{
|
||||||
@ -2648,6 +2727,7 @@ impl App {
|
|||||||
// In particular, encapsulate this entire logic and add some tests to make it less potentially error-prone.
|
// In particular, encapsulate this entire logic and add some tests to make it less potentially error-prone.
|
||||||
let is_in_search_widget = self.is_in_search_widget();
|
let is_in_search_widget = self.is_in_search_widget();
|
||||||
if let Some(proc_widget_state) = self
|
if let Some(proc_widget_state) = self
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get_mut(&(self.current_widget.widget_id - 1))
|
.get_mut(&(self.current_widget.widget_id - 1))
|
||||||
|
@ -14,6 +14,17 @@ use crate::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub struct AppWidgetStates {
|
||||||
|
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>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum CursorDirection {
|
pub enum CursorDirection {
|
||||||
Left,
|
Left,
|
||||||
|
@ -233,7 +233,7 @@ fn main() -> Result<()> {
|
|||||||
if app.used_widgets.use_disk {
|
if app.used_widgets.use_disk {
|
||||||
app.converted_data.ingest_disk_data(&app.data_collection);
|
app.converted_data.ingest_disk_data(&app.data_collection);
|
||||||
|
|
||||||
for disk in app.disk_state.widget_states.values_mut() {
|
for disk in app.states.disk_state.widget_states.values_mut() {
|
||||||
disk.force_data_update();
|
disk.force_data_update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,7 +245,7 @@ fn main() -> Result<()> {
|
|||||||
app.app_config_fields.temperature_type,
|
app.app_config_fields.temperature_type,
|
||||||
);
|
);
|
||||||
|
|
||||||
for temp in app.temp_state.widget_states.values_mut() {
|
for temp in app.states.temp_state.widget_states.values_mut() {
|
||||||
temp.force_data_update();
|
temp.force_data_update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,7 +297,7 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
// Processes
|
// Processes
|
||||||
if app.used_widgets.use_proc {
|
if app.used_widgets.use_proc {
|
||||||
for proc in app.proc_state.widget_states.values_mut() {
|
for proc in app.states.proc_state.widget_states.values_mut() {
|
||||||
proc.force_data_update();
|
proc.force_data_update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ impl Painter {
|
|||||||
app_state.delete_dialog_state.button_positions = vec![];
|
app_state.delete_dialog_state.button_positions = vec![];
|
||||||
|
|
||||||
// Reset battery dialog...
|
// Reset battery dialog...
|
||||||
for battery_widget in app_state.battery_state.widget_states.values_mut() {
|
for battery_widget in app_state.states.battery_state.widget_states.values_mut() {
|
||||||
battery_widget.tab_click_locs = None;
|
battery_widget.tab_click_locs = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -480,7 +480,7 @@ impl Painter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut later_widget_id: Option<u64> = None;
|
let mut later_widget_id: Option<u64> = None;
|
||||||
if let Some(basic_table_widget_state) = &app_state.basic_table_widget_state {
|
if let Some(basic_table_widget_state) = &app_state.states.basic_table_widget_state {
|
||||||
let widget_id = basic_table_widget_state.currently_displayed_widget_id;
|
let widget_id = basic_table_widget_state.currently_displayed_widget_id;
|
||||||
later_widget_id = Some(widget_id);
|
later_widget_id = Some(widget_id);
|
||||||
if vertical_chunks[3].width >= 2 {
|
if vertical_chunks[3].width >= 2 {
|
||||||
|
@ -32,6 +32,7 @@ impl Painter {
|
|||||||
return Some(Text::from(vec![
|
return Some(Text::from(vec![
|
||||||
Spans::from(""),
|
Spans::from(""),
|
||||||
if app_state
|
if app_state
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.get(&app_state.current_widget.widget_id)
|
.get(&app_state.current_widget.widget_id)
|
||||||
|
@ -140,7 +140,7 @@ impl Painter {
|
|||||||
// actually too large - so, we assume all of them are one too big and check via < (see
|
// actually too large - so, we assume all of them are one too big and check via < (see
|
||||||
// https://github.com/ClementTsang/bottom/pull/459 for details).
|
// https://github.com/ClementTsang/bottom/pull/459 for details).
|
||||||
// - So in other words, to make it simple, we keep this to a standard and overshoot by one here.
|
// - So in other words, to make it simple, we keep this to a standard and overshoot by one here.
|
||||||
if let Some(basic_table) = &mut app_state.basic_table_widget_state {
|
if let Some(basic_table) = &mut app_state.states.basic_table_widget_state {
|
||||||
basic_table.left_tlc =
|
basic_table.left_tlc =
|
||||||
Some((margined_draw_loc[0].x, margined_draw_loc[0].y + 1));
|
Some((margined_draw_loc[0].x, margined_draw_loc[0].y + 1));
|
||||||
basic_table.left_brc = Some((
|
basic_table.left_brc = Some((
|
||||||
|
@ -20,8 +20,11 @@ impl Painter {
|
|||||||
widget_id: u64,
|
widget_id: u64,
|
||||||
) {
|
) {
|
||||||
let should_get_widget_bounds = app_state.should_get_widget_bounds();
|
let should_get_widget_bounds = app_state.should_get_widget_bounds();
|
||||||
if let Some(battery_widget_state) =
|
if let Some(battery_widget_state) = app_state
|
||||||
app_state.battery_state.widget_states.get_mut(&widget_id)
|
.states
|
||||||
|
.battery_state
|
||||||
|
.widget_states
|
||||||
|
.get_mut(&widget_id)
|
||||||
{
|
{
|
||||||
let is_on_widget = widget_id == app_state.current_widget.widget_id;
|
let is_on_widget = widget_id == app_state.current_widget.widget_id;
|
||||||
let border_style = if is_on_widget {
|
let border_style = if is_on_widget {
|
||||||
|
@ -38,7 +38,9 @@ impl Painter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.draw_cpu_graph(f, app_state, draw_loc, widget_id);
|
self.draw_cpu_graph(f, app_state, draw_loc, widget_id);
|
||||||
if let Some(cpu_widget_state) = app_state.cpu_state.widget_states.get_mut(&widget_id) {
|
if let Some(cpu_widget_state) =
|
||||||
|
app_state.states.cpu_state.widget_states.get_mut(&widget_id)
|
||||||
|
{
|
||||||
cpu_widget_state.is_legend_hidden = true;
|
cpu_widget_state.is_legend_hidden = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +182,8 @@ impl Painter {
|
|||||||
const Y_BOUNDS: [f64; 2] = [0.0, 100.5];
|
const Y_BOUNDS: [f64; 2] = [0.0, 100.5];
|
||||||
const Y_LABELS: [Cow<'static, str>; 2] = [Cow::Borrowed(" 0%"), Cow::Borrowed("100%")];
|
const Y_LABELS: [Cow<'static, str>; 2] = [Cow::Borrowed(" 0%"), Cow::Borrowed("100%")];
|
||||||
|
|
||||||
if let Some(cpu_widget_state) = app_state.cpu_state.widget_states.get_mut(&widget_id) {
|
if let Some(cpu_widget_state) = app_state.states.cpu_state.widget_states.get_mut(&widget_id)
|
||||||
|
{
|
||||||
let cpu_data = &app_state.converted_data.cpu_data;
|
let cpu_data = &app_state.converted_data.cpu_data;
|
||||||
let border_style = self.get_border_style(widget_id, app_state.current_widget.widget_id);
|
let border_style = self.get_border_style(widget_id, app_state.current_widget.widget_id);
|
||||||
let x_bounds = [0, cpu_widget_state.current_display_time];
|
let x_bounds = [0, cpu_widget_state.current_display_time];
|
||||||
@ -237,7 +240,11 @@ impl Painter {
|
|||||||
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, widget_id: u64,
|
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, widget_id: u64,
|
||||||
) {
|
) {
|
||||||
let recalculate_column_widths = app_state.should_get_widget_bounds();
|
let recalculate_column_widths = app_state.should_get_widget_bounds();
|
||||||
if let Some(cpu_widget_state) = app_state.cpu_state.widget_states.get_mut(&(widget_id - 1))
|
if let Some(cpu_widget_state) = app_state
|
||||||
|
.states
|
||||||
|
.cpu_state
|
||||||
|
.widget_states
|
||||||
|
.get_mut(&(widget_id - 1))
|
||||||
{
|
{
|
||||||
// TODO: This line (and the one above, see caller) is pretty dumb but I guess needed for now. Refactor if possible!
|
// TODO: This line (and the one above, see caller) is pretty dumb but I guess needed for now. Refactor if possible!
|
||||||
cpu_widget_state.is_legend_hidden = false;
|
cpu_widget_state.is_legend_hidden = false;
|
||||||
|
@ -11,7 +11,12 @@ impl Painter {
|
|||||||
&self, f: &mut Frame<'_, B>, app_state: &mut app::App, draw_loc: Rect, widget_id: u64,
|
&self, f: &mut Frame<'_, B>, app_state: &mut app::App, draw_loc: Rect, widget_id: u64,
|
||||||
) {
|
) {
|
||||||
let recalculate_column_widths = app_state.should_get_widget_bounds();
|
let recalculate_column_widths = app_state.should_get_widget_bounds();
|
||||||
if let Some(disk_widget_state) = app_state.disk_state.widget_states.get_mut(&widget_id) {
|
if let Some(disk_widget_state) = app_state
|
||||||
|
.states
|
||||||
|
.disk_state
|
||||||
|
.widget_states
|
||||||
|
.get_mut(&widget_id)
|
||||||
|
{
|
||||||
let is_on_widget = app_state.current_widget.widget_id == widget_id;
|
let is_on_widget = app_state.current_widget.widget_id == widget_id;
|
||||||
|
|
||||||
let draw_info = DrawInfo {
|
let draw_info = DrawInfo {
|
||||||
|
@ -20,7 +20,8 @@ impl Painter {
|
|||||||
const Y_BOUNDS: [f64; 2] = [0.0, 100.5];
|
const Y_BOUNDS: [f64; 2] = [0.0, 100.5];
|
||||||
const Y_LABELS: [Cow<'static, str>; 2] = [Cow::Borrowed(" 0%"), Cow::Borrowed("100%")];
|
const Y_LABELS: [Cow<'static, str>; 2] = [Cow::Borrowed(" 0%"), Cow::Borrowed("100%")];
|
||||||
|
|
||||||
if let Some(mem_widget_state) = app_state.mem_state.widget_states.get_mut(&widget_id) {
|
if let Some(mem_widget_state) = app_state.states.mem_state.widget_states.get_mut(&widget_id)
|
||||||
|
{
|
||||||
let border_style = self.get_border_style(widget_id, app_state.current_widget.widget_id);
|
let border_style = self.get_border_style(widget_id, app_state.current_widget.widget_id);
|
||||||
let x_bounds = [0, mem_widget_state.current_display_time];
|
let x_bounds = [0, mem_widget_state.current_display_time];
|
||||||
let hide_x_labels = should_hide_x_label(
|
let hide_x_labels = should_hide_x_label(
|
||||||
|
@ -55,7 +55,9 @@ impl Painter {
|
|||||||
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, widget_id: u64,
|
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, widget_id: u64,
|
||||||
hide_legend: bool,
|
hide_legend: bool,
|
||||||
) {
|
) {
|
||||||
if let Some(network_widget_state) = app_state.net_state.widget_states.get_mut(&widget_id) {
|
if let Some(network_widget_state) =
|
||||||
|
app_state.states.net_state.widget_states.get_mut(&widget_id)
|
||||||
|
{
|
||||||
let network_data_rx = &app_state.converted_data.network_data_rx;
|
let network_data_rx = &app_state.converted_data.network_data_rx;
|
||||||
let network_data_tx = &app_state.converted_data.network_data_tx;
|
let network_data_tx = &app_state.converted_data.network_data_tx;
|
||||||
let time_start = -(network_widget_state.current_display_time as f64);
|
let time_start = -(network_widget_state.current_display_time as f64);
|
||||||
|
@ -24,7 +24,7 @@ impl Painter {
|
|||||||
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, draw_border: bool,
|
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, draw_border: bool,
|
||||||
widget_id: u64,
|
widget_id: u64,
|
||||||
) {
|
) {
|
||||||
if let Some(proc_widget_state) = app_state.proc_state.widget_states.get(&widget_id) {
|
if let Some(proc_widget_state) = app_state.states.proc_state.widget_states.get(&widget_id) {
|
||||||
let search_height = if draw_border { 5 } else { 3 };
|
let search_height = if draw_border { 5 } else { 3 };
|
||||||
let is_sort_open = proc_widget_state.is_sort_open;
|
let is_sort_open = proc_widget_state.is_sort_open;
|
||||||
|
|
||||||
@ -58,7 +58,12 @@ impl Painter {
|
|||||||
self.draw_processes_table(f, app_state, proc_draw_loc, widget_id);
|
self.draw_processes_table(f, app_state, proc_draw_loc, widget_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(proc_widget_state) = app_state.proc_state.widget_states.get_mut(&widget_id) {
|
if let Some(proc_widget_state) = app_state
|
||||||
|
.states
|
||||||
|
.proc_state
|
||||||
|
.widget_states
|
||||||
|
.get_mut(&widget_id)
|
||||||
|
{
|
||||||
// Reset redraw marker.
|
// Reset redraw marker.
|
||||||
if proc_widget_state.force_rerender {
|
if proc_widget_state.force_rerender {
|
||||||
proc_widget_state.force_rerender = false;
|
proc_widget_state.force_rerender = false;
|
||||||
@ -72,7 +77,12 @@ impl Painter {
|
|||||||
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, widget_id: u64,
|
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, widget_id: u64,
|
||||||
) {
|
) {
|
||||||
let should_get_widget_bounds = app_state.should_get_widget_bounds();
|
let should_get_widget_bounds = app_state.should_get_widget_bounds();
|
||||||
if let Some(proc_widget_state) = app_state.proc_state.widget_states.get_mut(&widget_id) {
|
if let Some(proc_widget_state) = app_state
|
||||||
|
.states
|
||||||
|
.proc_state
|
||||||
|
.widget_states
|
||||||
|
.get_mut(&widget_id)
|
||||||
|
{
|
||||||
let recalculate_column_widths =
|
let recalculate_column_widths =
|
||||||
should_get_widget_bounds || proc_widget_state.force_rerender;
|
should_get_widget_bounds || proc_widget_state.force_rerender;
|
||||||
|
|
||||||
@ -145,8 +155,11 @@ impl Painter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(proc_widget_state) =
|
if let Some(proc_widget_state) = app_state
|
||||||
app_state.proc_state.widget_states.get_mut(&(widget_id - 1))
|
.states
|
||||||
|
.proc_state
|
||||||
|
.widget_states
|
||||||
|
.get_mut(&(widget_id - 1))
|
||||||
{
|
{
|
||||||
let is_on_widget = widget_id == app_state.current_widget.widget_id;
|
let is_on_widget = widget_id == app_state.current_widget.widget_id;
|
||||||
let num_columns = usize::from(draw_loc.width);
|
let num_columns = usize::from(draw_loc.width);
|
||||||
@ -298,7 +311,12 @@ impl Painter {
|
|||||||
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, widget_id: u64,
|
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, widget_id: u64,
|
||||||
) {
|
) {
|
||||||
let should_get_widget_bounds = app_state.should_get_widget_bounds();
|
let should_get_widget_bounds = app_state.should_get_widget_bounds();
|
||||||
if let Some(pws) = app_state.proc_state.widget_states.get_mut(&(widget_id - 2)) {
|
if let Some(pws) = app_state
|
||||||
|
.states
|
||||||
|
.proc_state
|
||||||
|
.widget_states
|
||||||
|
.get_mut(&(widget_id - 2))
|
||||||
|
{
|
||||||
let recalculate_column_widths = should_get_widget_bounds || pws.force_rerender;
|
let recalculate_column_widths = should_get_widget_bounds || pws.force_rerender;
|
||||||
|
|
||||||
let is_on_widget = widget_id == app_state.current_widget.widget_id;
|
let is_on_widget = widget_id == app_state.current_widget.widget_id;
|
||||||
|
@ -11,7 +11,12 @@ impl Painter {
|
|||||||
&self, f: &mut Frame<'_, B>, app_state: &mut app::App, draw_loc: Rect, widget_id: u64,
|
&self, f: &mut Frame<'_, B>, app_state: &mut app::App, draw_loc: Rect, widget_id: u64,
|
||||||
) {
|
) {
|
||||||
let recalculate_column_widths = app_state.should_get_widget_bounds();
|
let recalculate_column_widths = app_state.should_get_widget_bounds();
|
||||||
if let Some(temp_widget_state) = app_state.temp_state.widget_states.get_mut(&widget_id) {
|
if let Some(temp_widget_state) = app_state
|
||||||
|
.states
|
||||||
|
.temp_state
|
||||||
|
.widget_states
|
||||||
|
.get_mut(&widget_id)
|
||||||
|
{
|
||||||
let is_on_widget = app_state.current_widget.widget_id == widget_id;
|
let is_on_widget = app_state.current_widget.widget_id == widget_id;
|
||||||
|
|
||||||
let draw_info = DrawInfo {
|
let draw_info = DrawInfo {
|
||||||
|
20
src/lib.rs
20
src/lib.rs
@ -342,7 +342,7 @@ pub fn update_data(app: &mut App) {
|
|||||||
FrozenState::Frozen(data) => data,
|
FrozenState::Frozen(data) => data,
|
||||||
};
|
};
|
||||||
|
|
||||||
for proc in app.proc_state.widget_states.values_mut() {
|
for proc in app.states.proc_state.widget_states.values_mut() {
|
||||||
if proc.force_update_data {
|
if proc.force_update_data {
|
||||||
proc.ingest_data(data_source);
|
proc.ingest_data(data_source);
|
||||||
proc.force_update_data = false;
|
proc.force_update_data = false;
|
||||||
@ -350,23 +350,23 @@ pub fn update_data(app: &mut App) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Make this CPU force update less terrible.
|
// FIXME: Make this CPU force update less terrible.
|
||||||
if app.cpu_state.force_update.is_some() {
|
if app.states.cpu_state.force_update.is_some() {
|
||||||
app.converted_data.ingest_cpu_data(data_source);
|
app.converted_data.ingest_cpu_data(data_source);
|
||||||
app.converted_data.load_avg_data = data_source.load_avg_harvest;
|
app.converted_data.load_avg_data = data_source.load_avg_harvest;
|
||||||
|
|
||||||
app.cpu_state.force_update = None;
|
app.states.cpu_state.force_update = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: This is a bit of a temp hack to move data over.
|
// FIXME: This is a bit of a temp hack to move data over.
|
||||||
{
|
{
|
||||||
let data = &app.converted_data.cpu_data;
|
let data = &app.converted_data.cpu_data;
|
||||||
for cpu in app.cpu_state.widget_states.values_mut() {
|
for cpu in app.states.cpu_state.widget_states.values_mut() {
|
||||||
cpu.update_table(data);
|
cpu.update_table(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let data = &app.converted_data.temp_data;
|
let data = &app.converted_data.temp_data;
|
||||||
for temp in app.temp_state.widget_states.values_mut() {
|
for temp in app.states.temp_state.widget_states.values_mut() {
|
||||||
if temp.force_update_data {
|
if temp.force_update_data {
|
||||||
temp.ingest_data(data);
|
temp.ingest_data(data);
|
||||||
temp.force_update_data = false;
|
temp.force_update_data = false;
|
||||||
@ -375,7 +375,7 @@ pub fn update_data(app: &mut App) {
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
let data = &app.converted_data.disk_data;
|
let data = &app.converted_data.disk_data;
|
||||||
for disk in app.disk_state.widget_states.values_mut() {
|
for disk in app.states.disk_state.widget_states.values_mut() {
|
||||||
if disk.force_update_data {
|
if disk.force_update_data {
|
||||||
disk.ingest_data(data);
|
disk.ingest_data(data);
|
||||||
disk.force_update_data = false;
|
disk.force_update_data = false;
|
||||||
@ -384,7 +384,7 @@ pub fn update_data(app: &mut App) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: [OPT] Prefer reassignment over new vectors?
|
// TODO: [OPT] Prefer reassignment over new vectors?
|
||||||
if app.mem_state.force_update.is_some() {
|
if app.states.mem_state.force_update.is_some() {
|
||||||
app.converted_data.mem_data = convert_mem_data_points(data_source);
|
app.converted_data.mem_data = convert_mem_data_points(data_source);
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
{
|
{
|
||||||
@ -400,10 +400,10 @@ pub fn update_data(app: &mut App) {
|
|||||||
{
|
{
|
||||||
app.converted_data.gpu_data = convert_gpu_data(data_source);
|
app.converted_data.gpu_data = convert_gpu_data(data_source);
|
||||||
}
|
}
|
||||||
app.mem_state.force_update = None;
|
app.states.mem_state.force_update = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
if app.net_state.force_update.is_some() {
|
if app.states.net_state.force_update.is_some() {
|
||||||
let (rx, tx) = get_rx_tx_data_points(
|
let (rx, tx) = get_rx_tx_data_points(
|
||||||
data_source,
|
data_source,
|
||||||
&app.app_config_fields.network_scale_type,
|
&app.app_config_fields.network_scale_type,
|
||||||
@ -412,7 +412,7 @@ pub fn update_data(app: &mut App) {
|
|||||||
);
|
);
|
||||||
app.converted_data.network_data_rx = rx;
|
app.converted_data.network_data_rx = rx;
|
||||||
app.converted_data.network_data_tx = tx;
|
app.converted_data.network_data_tx = tx;
|
||||||
app.net_state.force_update = None;
|
app.states.net_state.force_update = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,27 +428,35 @@ pub fn build_app(
|
|||||||
let net_filter =
|
let net_filter =
|
||||||
get_ignore_list(&config.net_filter).context("Update 'net_filter' in your config file")?;
|
get_ignore_list(&config.net_filter).context("Update 'net_filter' in your config file")?;
|
||||||
|
|
||||||
Ok(App::builder()
|
let states = AppWidgetStates {
|
||||||
.app_config_fields(app_config_fields)
|
cpu_state: CpuState::init(cpu_state_map),
|
||||||
.cpu_state(CpuState::init(cpu_state_map))
|
mem_state: MemState::init(mem_state_map),
|
||||||
.mem_state(MemState::init(mem_state_map))
|
net_state: NetState::init(net_state_map),
|
||||||
.net_state(NetState::init(net_state_map))
|
proc_state: ProcState::init(proc_state_map),
|
||||||
.proc_state(ProcState::init(proc_state_map))
|
temp_state: TempState::init(temp_state_map),
|
||||||
.disk_state(DiskState::init(disk_state_map))
|
disk_state: DiskState::init(disk_state_map),
|
||||||
.temp_state(TempState::init(temp_state_map))
|
battery_state: BatteryState::init(battery_state_map),
|
||||||
.battery_state(BatteryState::init(battery_state_map))
|
basic_table_widget_state,
|
||||||
.basic_table_widget_state(basic_table_widget_state)
|
};
|
||||||
.current_widget(widget_map.get(&initial_widget_id).unwrap().clone()) // TODO: [UNWRAP] - many of the unwraps are fine (like this one) but do a once-over and/or switch to expect?
|
|
||||||
.widget_map(widget_map)
|
let current_widget = widget_map.get(&initial_widget_id).unwrap().clone();
|
||||||
.used_widgets(used_widgets)
|
let filters = DataFilters {
|
||||||
.is_expanded(expanded_upon_startup && !use_basic_mode)
|
disk_filter,
|
||||||
.filters(DataFilters {
|
mount_filter,
|
||||||
disk_filter,
|
temp_filter,
|
||||||
mount_filter,
|
net_filter,
|
||||||
temp_filter,
|
};
|
||||||
net_filter,
|
let is_expanded = expanded_upon_startup && !use_basic_mode;
|
||||||
})
|
|
||||||
.build())
|
Ok(App::new(
|
||||||
|
app_config_fields,
|
||||||
|
states,
|
||||||
|
widget_map,
|
||||||
|
current_widget,
|
||||||
|
used_widgets,
|
||||||
|
filters,
|
||||||
|
is_expanded,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_widget_layout(
|
pub fn get_widget_layout(
|
||||||
@ -1048,10 +1056,11 @@ mod test {
|
|||||||
if (default_app.app_config_fields == testing_app.app_config_fields)
|
if (default_app.app_config_fields == testing_app.app_config_fields)
|
||||||
&& default_app.is_expanded == testing_app.is_expanded
|
&& default_app.is_expanded == testing_app.is_expanded
|
||||||
&& default_app
|
&& default_app
|
||||||
|
.states
|
||||||
.proc_state
|
.proc_state
|
||||||
.widget_states
|
.widget_states
|
||||||
.iter()
|
.iter()
|
||||||
.zip(testing_app.proc_state.widget_states.iter())
|
.zip(testing_app.states.proc_state.widget_states.iter())
|
||||||
.all(|(a, b)| (a.1.test_equality(b.1)))
|
.all(|(a, b)| (a.1.test_equality(b.1)))
|
||||||
{
|
{
|
||||||
panic!("failed on {arg_name}");
|
panic!("failed on {arg_name}");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user