mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-25 06:35:07 +02:00
refactor: move data passing for table to another step (#863)
* refactor: remove redundant scroll direction enum This was made redundant from the table refactor. * add some todos/docs * refactor: temp hack to pass in data on process
This commit is contained in:
parent
3296feae50
commit
064d740c6d
@ -726,7 +726,7 @@ impl App {
|
|||||||
KillSignal::Kill(prev_signal) => {
|
KillSignal::Kill(prev_signal) => {
|
||||||
self.delete_dialog_state.selected_signal = match prev_signal - 1 {
|
self.delete_dialog_state.selected_signal = match prev_signal - 1 {
|
||||||
0 => KillSignal::Cancel,
|
0 => KillSignal::Cancel,
|
||||||
// 32+33 are skipped
|
// 32 + 33 are skipped
|
||||||
33 => KillSignal::Kill(31),
|
33 => KillSignal::Kill(31),
|
||||||
signal => KillSignal::Kill(signal),
|
signal => KillSignal::Kill(signal),
|
||||||
};
|
};
|
||||||
|
@ -61,7 +61,6 @@ pub struct ProcessData {
|
|||||||
|
|
||||||
impl ProcessData {
|
impl ProcessData {
|
||||||
fn ingest(&mut self, list_of_processes: Vec<ProcessHarvest>) {
|
fn ingest(&mut self, list_of_processes: Vec<ProcessHarvest>) {
|
||||||
// TODO: [Optimization] Probably more efficient to all of this in the data collection step, but it's fine for now.
|
|
||||||
self.process_parent_mapping.clear();
|
self.process_parent_mapping.clear();
|
||||||
|
|
||||||
// Reverse as otherwise the pid mappings are in the wrong order.
|
// Reverse as otherwise the pid mappings are in the wrong order.
|
||||||
@ -212,8 +211,6 @@ impl DataCollection {
|
|||||||
|
|
||||||
pub fn eat_data(&mut self, harvested_data: Box<Data>) {
|
pub fn eat_data(&mut self, harvested_data: Box<Data>) {
|
||||||
let harvested_time = harvested_data.last_collection_time;
|
let harvested_time = harvested_data.last_collection_time;
|
||||||
// trace!("Harvested time: {:?}", harvested_time);
|
|
||||||
// trace!("New current instant: {:?}", self.current_instant);
|
|
||||||
let mut new_entry = TimedData::default();
|
let mut new_entry = TimedData::default();
|
||||||
|
|
||||||
// Network
|
// Network
|
||||||
@ -245,7 +242,7 @@ impl DataCollection {
|
|||||||
self.eat_cpu(cpu, &mut new_entry);
|
self.eat_cpu(cpu, &mut new_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load Average
|
// Load average
|
||||||
if let Some(load_avg) = harvested_data.load_avg {
|
if let Some(load_avg) = harvested_data.load_avg {
|
||||||
self.eat_load_avg(load_avg, &mut new_entry);
|
self.eat_load_avg(load_avg, &mut new_entry);
|
||||||
}
|
}
|
||||||
|
@ -12,20 +12,6 @@ use super::widgets::{
|
|||||||
ProcWidget, TempWidgetState,
|
ProcWidget, TempWidgetState,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum ScrollDirection {
|
|
||||||
// UP means scrolling up --- this usually DECREMENTS
|
|
||||||
Up,
|
|
||||||
// DOWN means scrolling down --- this usually INCREMENTS
|
|
||||||
Down,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for ScrollDirection {
|
|
||||||
fn default() -> Self {
|
|
||||||
ScrollDirection::Down
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum CursorDirection {
|
pub enum CursorDirection {
|
||||||
Left,
|
Left,
|
||||||
@ -112,7 +98,7 @@ impl Default for AppSearchState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AppSearchState {
|
impl AppSearchState {
|
||||||
/// Returns a reset but still enabled app search state
|
/// Resets the [`AppSearchState`] to its default state, albeit still enabled.
|
||||||
pub fn reset(&mut self) {
|
pub fn reset(&mut self) {
|
||||||
*self = AppSearchState {
|
*self = AppSearchState {
|
||||||
is_enabled: self.is_enabled,
|
is_enabled: self.is_enabled,
|
||||||
@ -120,6 +106,7 @@ impl AppSearchState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns whether the [`AppSearchState`] has an invalid or blank search.
|
||||||
pub fn is_invalid_or_blank_search(&self) -> bool {
|
pub fn is_invalid_or_blank_search(&self) -> bool {
|
||||||
self.is_blank_search || self.is_invalid_search
|
self.is_blank_search || self.is_invalid_search
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,31 @@ impl ColumnHeader for CpuWidgetColumn {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DataToCell<CpuWidgetColumn> for CpuWidgetData {
|
pub enum CpuWidgetTableData {
|
||||||
|
All,
|
||||||
|
Entry {
|
||||||
|
data_type: CpuDataType,
|
||||||
|
last_entry: f64,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CpuWidgetTableData {
|
||||||
|
pub fn from_cpu_widget_data(data: &CpuWidgetData) -> CpuWidgetTableData {
|
||||||
|
match data {
|
||||||
|
CpuWidgetData::All => CpuWidgetTableData::All,
|
||||||
|
CpuWidgetData::Entry {
|
||||||
|
data_type,
|
||||||
|
data: _,
|
||||||
|
last_entry,
|
||||||
|
} => CpuWidgetTableData::Entry {
|
||||||
|
data_type: *data_type,
|
||||||
|
last_entry: *last_entry,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DataToCell<CpuWidgetColumn> for CpuWidgetTableData {
|
||||||
fn to_cell<'a>(&'a self, column: &CpuWidgetColumn, calculated_width: u16) -> Option<Text<'a>> {
|
fn to_cell<'a>(&'a self, column: &CpuWidgetColumn, calculated_width: u16) -> Option<Text<'a>> {
|
||||||
const CPU_HIDE_BREAKPOINT: u16 = 5;
|
const CPU_HIDE_BREAKPOINT: u16 = 5;
|
||||||
|
|
||||||
@ -64,13 +88,12 @@ impl DataToCell<CpuWidgetColumn> for CpuWidgetData {
|
|||||||
// This is the same for the use percentages - we just *always* show them, and *always* hide the CPU column if
|
// This is the same for the use percentages - we just *always* show them, and *always* hide the CPU column if
|
||||||
// it is too small.
|
// it is too small.
|
||||||
match &self {
|
match &self {
|
||||||
CpuWidgetData::All => match column {
|
CpuWidgetTableData::All => match column {
|
||||||
CpuWidgetColumn::CPU => Some(truncate_text("All", calculated_width)),
|
CpuWidgetColumn::CPU => Some(truncate_text("All", calculated_width)),
|
||||||
CpuWidgetColumn::Use => None,
|
CpuWidgetColumn::Use => None,
|
||||||
},
|
},
|
||||||
CpuWidgetData::Entry {
|
CpuWidgetTableData::Entry {
|
||||||
data_type,
|
data_type,
|
||||||
data: _,
|
|
||||||
last_entry,
|
last_entry,
|
||||||
} => match column {
|
} => match column {
|
||||||
CpuWidgetColumn::CPU => {
|
CpuWidgetColumn::CPU => {
|
||||||
@ -106,10 +129,9 @@ impl DataToCell<CpuWidgetColumn> for CpuWidgetData {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn style_row<'a>(&self, row: Row<'a>, painter: &Painter) -> Row<'a> {
|
fn style_row<'a>(&self, row: Row<'a>, painter: &Painter) -> Row<'a> {
|
||||||
let style = match self {
|
let style = match self {
|
||||||
CpuWidgetData::All => painter.colours.all_colour_style,
|
CpuWidgetTableData::All => painter.colours.all_colour_style,
|
||||||
CpuWidgetData::Entry {
|
CpuWidgetTableData::Entry {
|
||||||
data_type,
|
data_type,
|
||||||
data: _,
|
|
||||||
last_entry: _,
|
last_entry: _,
|
||||||
} => match data_type {
|
} => match data_type {
|
||||||
CpuDataType::Avg => painter.colours.avg_colour_style,
|
CpuDataType::Avg => painter.colours.avg_colour_style,
|
||||||
@ -138,7 +160,7 @@ pub struct CpuWidgetState {
|
|||||||
pub is_legend_hidden: bool,
|
pub is_legend_hidden: bool,
|
||||||
pub show_avg: bool,
|
pub show_avg: bool,
|
||||||
pub autohide_timer: Option<Instant>,
|
pub autohide_timer: Option<Instant>,
|
||||||
pub table: DataTable<CpuWidgetData, CpuWidgetColumn>,
|
pub table: DataTable<CpuWidgetTableData, CpuWidgetColumn>,
|
||||||
pub styling: CpuWidgetStyling,
|
pub styling: CpuWidgetStyling,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,4 +194,12 @@ impl CpuWidgetState {
|
|||||||
styling: CpuWidgetStyling::from_colours(colours),
|
styling: CpuWidgetStyling::from_colours(colours),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn ingest_data(&mut self, data: &[CpuWidgetData]) {
|
||||||
|
self.table.set_data(
|
||||||
|
data.iter()
|
||||||
|
.map(CpuWidgetTableData::from_cpu_widget_data)
|
||||||
|
.collect(),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,4 +144,8 @@ impl DiskTableWidget {
|
|||||||
table: DataTable::new(COLUMNS, props, styling),
|
table: DataTable::new(COLUMNS, props, styling),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn ingest_data(&mut self, data: &[DiskWidgetData]) {
|
||||||
|
self.table.set_data(data.to_vec());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,9 +80,6 @@ pub struct ProcWidget {
|
|||||||
/// The state of the main table.
|
/// The state of the main table.
|
||||||
pub table: ProcessTable,
|
pub table: ProcessTable,
|
||||||
|
|
||||||
/// The stored process data for this specific table.
|
|
||||||
pub table_data: Vec<ProcWidgetData>,
|
|
||||||
|
|
||||||
/// The state of the togglable table that controls sorting.
|
/// The state of the togglable table that controls sorting.
|
||||||
pub sort_table: SortTable,
|
pub sort_table: SortTable,
|
||||||
|
|
||||||
@ -224,17 +221,19 @@ impl ProcWidget {
|
|||||||
|
|
||||||
let id_pid_map = FxHashMap::default();
|
let id_pid_map = FxHashMap::default();
|
||||||
|
|
||||||
ProcWidget {
|
let mut table = ProcWidget {
|
||||||
proc_search: process_search_state,
|
proc_search: process_search_state,
|
||||||
table,
|
table,
|
||||||
table_data: vec![],
|
|
||||||
sort_table,
|
sort_table,
|
||||||
id_pid_map,
|
id_pid_map,
|
||||||
is_sort_open: false,
|
is_sort_open: false,
|
||||||
mode,
|
mode,
|
||||||
force_rerender: true,
|
force_rerender: true,
|
||||||
force_update_data: false,
|
force_update_data: false,
|
||||||
}
|
};
|
||||||
|
table.sort_table.set_data(table.column_text());
|
||||||
|
|
||||||
|
table
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_using_command(&self) -> bool {
|
pub fn is_using_command(&self) -> bool {
|
||||||
@ -264,7 +263,7 @@ impl ProcWidget {
|
|||||||
/// This function *only* updates the displayed process data. If there is a need to update the actual *stored* data,
|
/// This function *only* updates the displayed process data. If there is a need to update the actual *stored* data,
|
||||||
/// call it before this function.
|
/// call it before this function.
|
||||||
pub fn update_displayed_process_data(&mut self, data_collection: &DataCollection) {
|
pub fn update_displayed_process_data(&mut self, data_collection: &DataCollection) {
|
||||||
self.table_data = match &self.mode {
|
let data = match &self.mode {
|
||||||
ProcWidgetMode::Grouped | ProcWidgetMode::Normal => {
|
ProcWidgetMode::Grouped | ProcWidgetMode::Normal => {
|
||||||
self.get_normal_data(&data_collection.process_data.process_harvest)
|
self.get_normal_data(&data_collection.process_data.process_harvest)
|
||||||
}
|
}
|
||||||
@ -272,6 +271,7 @@ impl ProcWidget {
|
|||||||
self.get_tree_data(collapsed_pids, data_collection)
|
self.get_tree_data(collapsed_pids, data_collection)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
self.table.set_data(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_tree_data(
|
fn get_tree_data(
|
||||||
@ -587,6 +587,7 @@ impl ProcWidget {
|
|||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.sort_table.set_data(self.column_text());
|
||||||
self.force_data_update();
|
self.force_data_update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -664,6 +665,7 @@ impl ProcWidget {
|
|||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
self.sort_table.set_data(self.column_text());
|
||||||
self.force_rerender_and_update();
|
self.force_rerender_and_update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -702,6 +704,7 @@ impl ProcWidget {
|
|||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.sort_table.set_data(self.column_text());
|
||||||
self.force_rerender_and_update();
|
self.force_rerender_and_update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,4 +98,8 @@ impl TempWidgetState {
|
|||||||
table: DataTable::new(COLUMNS, props, styling),
|
table: DataTable::new(COLUMNS, props, styling),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn ingest_data(&mut self, data: &[TempWidgetData]) {
|
||||||
|
self.table.set_data(data.to_vec());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,4 +8,4 @@ pub mod mem_graph;
|
|||||||
pub mod network_basic;
|
pub mod network_basic;
|
||||||
pub mod network_graph;
|
pub mod network_graph;
|
||||||
pub mod process_table;
|
pub mod process_table;
|
||||||
pub mod temp_table;
|
pub mod temperature_table;
|
||||||
|
@ -247,7 +247,6 @@ impl Painter {
|
|||||||
cpu_widget_state.table.draw(
|
cpu_widget_state.table.draw(
|
||||||
f,
|
f,
|
||||||
&draw_info,
|
&draw_info,
|
||||||
app_state.converted_data.cpu_data.clone(),
|
|
||||||
app_state.widget_map.get_mut(&widget_id),
|
app_state.widget_map.get_mut(&widget_id),
|
||||||
self,
|
self,
|
||||||
);
|
);
|
||||||
|
@ -24,7 +24,6 @@ impl Painter {
|
|||||||
disk_widget_state.table.draw(
|
disk_widget_state.table.draw(
|
||||||
f,
|
f,
|
||||||
&draw_info,
|
&draw_info,
|
||||||
app_state.converted_data.disk_data.clone(),
|
|
||||||
app_state.widget_map.get_mut(&widget_id),
|
app_state.widget_map.get_mut(&widget_id),
|
||||||
self,
|
self,
|
||||||
);
|
);
|
||||||
|
@ -91,7 +91,6 @@ impl Painter {
|
|||||||
proc_widget_state.table.draw(
|
proc_widget_state.table.draw(
|
||||||
f,
|
f,
|
||||||
&draw_info,
|
&draw_info,
|
||||||
proc_widget_state.table_data.clone(),
|
|
||||||
app_state.widget_map.get_mut(&widget_id),
|
app_state.widget_map.get_mut(&widget_id),
|
||||||
self,
|
self,
|
||||||
);
|
);
|
||||||
@ -324,12 +323,9 @@ impl Painter {
|
|||||||
selection_state: SelectionState::new(app_state.is_expanded, is_on_widget),
|
selection_state: SelectionState::new(app_state.is_expanded, is_on_widget),
|
||||||
};
|
};
|
||||||
|
|
||||||
let data = pws.column_text();
|
|
||||||
|
|
||||||
pws.sort_table.draw(
|
pws.sort_table.draw(
|
||||||
f,
|
f,
|
||||||
&draw_info,
|
&draw_info,
|
||||||
data,
|
|
||||||
app_state.widget_map.get_mut(&widget_id),
|
app_state.widget_map.get_mut(&widget_id),
|
||||||
self,
|
self,
|
||||||
);
|
);
|
||||||
|
@ -24,7 +24,6 @@ impl Painter {
|
|||||||
temp_widget_state.table.draw(
|
temp_widget_state.table.draw(
|
||||||
f,
|
f,
|
||||||
&draw_info,
|
&draw_info,
|
||||||
app_state.converted_data.temp_data.clone(),
|
|
||||||
app_state.widget_map.get_mut(&widget_id),
|
app_state.widget_map.get_mut(&widget_id),
|
||||||
self,
|
self,
|
||||||
);
|
);
|
@ -74,7 +74,7 @@ impl<DataType: DataToCell<H>, H: ColumnHeader, S: SortType, C: DataTableColumn<H
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the scroll position to be valid for the number of entries.
|
/// Updates the scroll position to be valid for the number of entries.
|
||||||
fn set_data(&mut self, data: Vec<DataType>) {
|
pub fn set_data(&mut self, data: Vec<DataType>) {
|
||||||
self.data = data;
|
self.data = data;
|
||||||
let max_pos = self.data.len().saturating_sub(1);
|
let max_pos = self.data.len().saturating_sub(1);
|
||||||
if self.state.current_index > max_pos {
|
if self.state.current_index > max_pos {
|
||||||
|
@ -141,11 +141,9 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw<B: Backend>(
|
pub fn draw<B: Backend>(
|
||||||
&mut self, f: &mut Frame<'_, B>, draw_info: &DrawInfo, data: Vec<DataType>,
|
&mut self, f: &mut Frame<'_, B>, draw_info: &DrawInfo, widget: Option<&mut BottomWidget>,
|
||||||
widget: Option<&mut BottomWidget>, painter: &Painter,
|
painter: &Painter,
|
||||||
) {
|
) {
|
||||||
self.set_data(data);
|
|
||||||
|
|
||||||
let draw_horizontal = !self.props.is_basic || draw_info.is_on_widget();
|
let draw_horizontal = !self.props.is_basic || draw_info.is_on_widget();
|
||||||
let draw_loc = draw_info.loc;
|
let draw_loc = draw_info.loc;
|
||||||
let margined_draw_loc = Layout::default()
|
let margined_draw_loc = Layout::default()
|
||||||
|
@ -59,22 +59,26 @@ pub struct ConvertedData {
|
|||||||
pub total_tx_display: String,
|
pub total_tx_display: String,
|
||||||
pub network_data_rx: Vec<Point>,
|
pub network_data_rx: Vec<Point>,
|
||||||
pub network_data_tx: Vec<Point>,
|
pub network_data_tx: Vec<Point>,
|
||||||
pub disk_data: Vec<DiskWidgetData>,
|
|
||||||
pub temp_data: Vec<TempWidgetData>,
|
|
||||||
|
|
||||||
pub mem_labels: Option<(String, String)>,
|
pub mem_labels: Option<(String, String)>,
|
||||||
pub swap_labels: Option<(String, String)>,
|
pub swap_labels: Option<(String, String)>,
|
||||||
#[cfg(feature = "zfs")]
|
|
||||||
pub arc_labels: Option<(String, String)>,
|
|
||||||
pub mem_data: Vec<Point>, // TODO: Switch this and all data points over to a better data structure...
|
pub mem_data: Vec<Point>, // TODO: Switch this and all data points over to a better data structure...
|
||||||
pub swap_data: Vec<Point>,
|
pub swap_data: Vec<Point>,
|
||||||
|
|
||||||
|
#[cfg(feature = "zfs")]
|
||||||
|
pub arc_labels: Option<(String, String)>,
|
||||||
#[cfg(feature = "zfs")]
|
#[cfg(feature = "zfs")]
|
||||||
pub arc_data: Vec<Point>,
|
pub arc_data: Vec<Point>,
|
||||||
|
|
||||||
|
#[cfg(feature = "gpu")]
|
||||||
|
pub gpu_data: Option<Vec<ConvertedGpuData>>,
|
||||||
|
|
||||||
pub load_avg_data: [f32; 3],
|
pub load_avg_data: [f32; 3],
|
||||||
pub cpu_data: Vec<CpuWidgetData>,
|
pub cpu_data: Vec<CpuWidgetData>,
|
||||||
pub battery_data: Vec<ConvertedBatteryData>,
|
pub battery_data: Vec<ConvertedBatteryData>,
|
||||||
#[cfg(feature = "gpu")]
|
pub disk_data: Vec<DiskWidgetData>,
|
||||||
pub gpu_data: Option<Vec<ConvertedGpuData>>,
|
pub temp_data: Vec<TempWidgetData>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConvertedData {
|
impl ConvertedData {
|
||||||
|
32
src/lib.rs
32
src/lib.rs
@ -22,7 +22,7 @@ use std::{
|
|||||||
sync::Arc,
|
sync::Arc,
|
||||||
sync::Condvar,
|
sync::Condvar,
|
||||||
sync::Mutex,
|
sync::Mutex,
|
||||||
thread,
|
thread::{self, JoinHandle},
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -35,6 +35,7 @@ use crossterm::{
|
|||||||
|
|
||||||
use app::{
|
use app::{
|
||||||
data_harvester,
|
data_harvester,
|
||||||
|
frozen_state::FrozenState,
|
||||||
layout_manager::{UsedWidgets, WidgetDirection},
|
layout_manager::{UsedWidgets, WidgetDirection},
|
||||||
App,
|
App,
|
||||||
};
|
};
|
||||||
@ -323,8 +324,8 @@ pub fn panic_hook(panic_info: &PanicInfo<'_>) {
|
|||||||
|
|
||||||
pub fn update_data(app: &mut App) {
|
pub fn update_data(app: &mut App) {
|
||||||
let data_source = match &app.frozen_state {
|
let data_source = match &app.frozen_state {
|
||||||
app::frozen_state::FrozenState::NotFrozen => &app.data_collection,
|
FrozenState::NotFrozen => &app.data_collection,
|
||||||
app::frozen_state::FrozenState::Frozen(data) => data,
|
FrozenState::Frozen(data) => data,
|
||||||
};
|
};
|
||||||
|
|
||||||
for proc in app.proc_state.widget_states.values_mut() {
|
for proc in app.proc_state.widget_states.values_mut() {
|
||||||
@ -338,9 +339,30 @@ pub fn update_data(app: &mut App) {
|
|||||||
if app.cpu_state.force_update.is_some() {
|
if app.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.cpu_state.force_update = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: This is a bit of a temp hack to move data over.
|
||||||
|
{
|
||||||
|
let data = &app.converted_data.cpu_data;
|
||||||
|
for cpu in app.cpu_state.widget_states.values_mut() {
|
||||||
|
cpu.ingest_data(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
let data = &app.converted_data.temp_data;
|
||||||
|
for temp in app.temp_state.widget_states.values_mut() {
|
||||||
|
temp.ingest_data(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
let data = &app.converted_data.disk_data;
|
||||||
|
for disk in app.disk_state.widget_states.values_mut() {
|
||||||
|
disk.ingest_data(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: [OPT] Prefer reassignment over new vectors?
|
// TODO: [OPT] Prefer reassignment over new vectors?
|
||||||
if app.mem_state.force_update.is_some() {
|
if app.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);
|
||||||
@ -375,7 +397,7 @@ pub fn create_input_thread(
|
|||||||
BottomEvent<crossterm::event::KeyEvent, crossterm::event::MouseEvent>,
|
BottomEvent<crossterm::event::KeyEvent, crossterm::event::MouseEvent>,
|
||||||
>,
|
>,
|
||||||
termination_ctrl_lock: Arc<Mutex<bool>>,
|
termination_ctrl_lock: Arc<Mutex<bool>>,
|
||||||
) -> std::thread::JoinHandle<()> {
|
) -> JoinHandle<()> {
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let mut mouse_timer = Instant::now();
|
let mut mouse_timer = Instant::now();
|
||||||
let mut keyboard_timer = Instant::now();
|
let mut keyboard_timer = Instant::now();
|
||||||
@ -421,7 +443,7 @@ pub fn create_collection_thread(
|
|||||||
termination_ctrl_lock: Arc<Mutex<bool>>, termination_ctrl_cvar: Arc<Condvar>,
|
termination_ctrl_lock: Arc<Mutex<bool>>, termination_ctrl_cvar: Arc<Condvar>,
|
||||||
app_config_fields: &app::AppConfigFields, filters: app::DataFilters,
|
app_config_fields: &app::AppConfigFields, filters: app::DataFilters,
|
||||||
used_widget_set: UsedWidgets,
|
used_widget_set: UsedWidgets,
|
||||||
) -> std::thread::JoinHandle<()> {
|
) -> JoinHandle<()> {
|
||||||
let temp_type = app_config_fields.temperature_type;
|
let temp_type = app_config_fields.temperature_type;
|
||||||
let use_current_cpu_total = app_config_fields.use_current_cpu_total;
|
let use_current_cpu_total = app_config_fields.use_current_cpu_total;
|
||||||
let show_average_cpu = app_config_fields.show_average_cpu;
|
let show_average_cpu = app_config_fields.show_average_cpu;
|
||||||
|
@ -1 +1,4 @@
|
|||||||
pub mod data_units;
|
pub mod data_units;
|
||||||
|
|
||||||
|
// FIXME: Maybe move temperature units here? idk.
|
||||||
|
// FIXME: Maybe combine this with utils?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user