mirror of
https://github.com/ClementTsang/bottom
synced 2024-11-10 14:44:18 +00:00
refactor: run cargo +nightly fmt with group_imports (#885)
* refactor: add some disabled unstable fmt options * run cargo +nightly fmt with group_imports * separate out the cfg-specific imports for clarity
This commit is contained in:
parent
f5ec9191f2
commit
99fc5fc2c8
54 changed files with 176 additions and 177 deletions
3
build.rs
3
build.rs
|
@ -1,10 +1,11 @@
|
||||||
use clap_complete::{generate_to, shells::Shell};
|
|
||||||
use std::{
|
use std::{
|
||||||
env, fs,
|
env, fs,
|
||||||
io::Result,
|
io::Result,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use clap_complete::{generate_to, shells::Shell};
|
||||||
|
|
||||||
include!("src/clap.rs");
|
include!("src/clap.rs");
|
||||||
|
|
||||||
fn create_dir(dir: &Path) -> Result<()> {
|
fn create_dir(dir: &Path) -> Result<()> {
|
||||||
|
|
|
@ -5,3 +5,8 @@ fn_args_layout = "Compressed"
|
||||||
use_field_init_shorthand = true
|
use_field_init_shorthand = true
|
||||||
tab_spaces = 4
|
tab_spaces = 4
|
||||||
max_width = 100
|
max_width = 100
|
||||||
|
|
||||||
|
# Unstable options, disabled by default.
|
||||||
|
# group_imports = "StdExternalCrate"
|
||||||
|
# wrap_comments = true
|
||||||
|
# format_code_in_doc_comments = true
|
||||||
|
|
11
src/app.rs
11
src/app.rs
|
@ -5,16 +5,15 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use concat_string::concat_string;
|
use concat_string::concat_string;
|
||||||
use unicode_segmentation::{GraphemeCursor, UnicodeSegmentation};
|
|
||||||
use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};
|
|
||||||
|
|
||||||
use typed_builder::*;
|
|
||||||
|
|
||||||
use data_farmer::*;
|
use data_farmer::*;
|
||||||
use data_harvester::temperature;
|
use data_harvester::temperature;
|
||||||
use layout_manager::*;
|
use layout_manager::*;
|
||||||
pub use states::*;
|
pub use states::*;
|
||||||
|
use typed_builder::*;
|
||||||
|
use unicode_segmentation::{GraphemeCursor, UnicodeSegmentation};
|
||||||
|
use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};
|
||||||
|
|
||||||
|
use self::widgets::{ProcWidget, ProcWidgetMode};
|
||||||
use crate::{
|
use crate::{
|
||||||
constants,
|
constants,
|
||||||
data_conversion::ConvertedData,
|
data_conversion::ConvertedData,
|
||||||
|
@ -23,8 +22,6 @@ use crate::{
|
||||||
Pid,
|
Pid,
|
||||||
};
|
};
|
||||||
|
|
||||||
use self::widgets::{ProcWidget, ProcWidgetMode};
|
|
||||||
|
|
||||||
pub mod data_farmer;
|
pub mod data_farmer;
|
||||||
pub mod data_harvester;
|
pub mod data_harvester;
|
||||||
pub mod frozen_state;
|
pub mod frozen_state;
|
||||||
|
|
|
@ -13,22 +13,20 @@
|
||||||
//! memory usage and higher CPU usage - you will be trying to process more and
|
//! memory usage and higher CPU usage - you will be trying to process more and
|
||||||
//! more points as this is used!
|
//! more points as this is used!
|
||||||
|
|
||||||
use once_cell::sync::Lazy;
|
use std::{time::Instant, vec::Vec};
|
||||||
|
|
||||||
use fxhash::FxHashMap;
|
use fxhash::FxHashMap;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
use std::{time::Instant, vec::Vec};
|
use regex::Regex;
|
||||||
|
|
||||||
#[cfg(feature = "battery")]
|
#[cfg(feature = "battery")]
|
||||||
use crate::data_harvester::batteries;
|
use crate::data_harvester::batteries;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
data_harvester::{cpu, disks, memory, network, processes::ProcessHarvest, temperature, Data},
|
data_harvester::{cpu, disks, memory, network, processes::ProcessHarvest, temperature, Data},
|
||||||
utils::gen_util::{get_decimal_bytes, GIGA_LIMIT},
|
utils::gen_util::{get_decimal_bytes, GIGA_LIMIT},
|
||||||
Pid,
|
Pid,
|
||||||
};
|
};
|
||||||
use regex::Regex;
|
|
||||||
|
|
||||||
pub type TimeOffset = f64;
|
pub type TimeOffset = f64;
|
||||||
pub type Value = f64;
|
pub type Value = f64;
|
||||||
|
|
|
@ -2,20 +2,19 @@
|
||||||
|
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
|
use futures::join;
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
use fxhash::FxHashMap;
|
use fxhash::FxHashMap;
|
||||||
|
|
||||||
#[cfg(not(target_os = "linux"))]
|
|
||||||
use sysinfo::{System, SystemExt};
|
|
||||||
|
|
||||||
#[cfg(feature = "battery")]
|
#[cfg(feature = "battery")]
|
||||||
use starship_battery::{Battery, Manager};
|
use starship_battery::{Battery, Manager};
|
||||||
|
|
||||||
use crate::app::layout_manager::UsedWidgets;
|
#[cfg(not(target_os = "linux"))]
|
||||||
|
use sysinfo::{System, SystemExt};
|
||||||
use futures::join;
|
|
||||||
|
|
||||||
use super::DataFilters;
|
use super::DataFilters;
|
||||||
|
use crate::app::layout_manager::UsedWidgets;
|
||||||
|
|
||||||
#[cfg(feature = "nvidia")]
|
#[cfg(feature = "nvidia")]
|
||||||
pub mod nvidia;
|
pub mod nvidia;
|
||||||
|
|
|
@ -18,14 +18,15 @@ cfg_if::cfg_if! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
|
use futures::StreamExt;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
components::tui_widget::time_chart::Point,
|
components::tui_widget::time_chart::Point,
|
||||||
data_harvester::cpu::{CpuData, CpuDataType, CpuHarvest, PastCpuTotal, PastCpuWork},
|
data_harvester::cpu::{CpuData, CpuDataType, CpuHarvest, PastCpuTotal, PastCpuWork},
|
||||||
};
|
};
|
||||||
|
|
||||||
use futures::StreamExt;
|
|
||||||
use std::collections::VecDeque;
|
|
||||||
|
|
||||||
pub async fn get_cpu_data_list(
|
pub async fn get_cpu_data_list(
|
||||||
show_average_cpu: bool, previous_cpu_times: &mut Vec<(PastCpuWork, PastCpuTotal)>,
|
show_average_cpu: bool, previous_cpu_times: &mut Vec<(PastCpuWork, PastCpuTotal)>,
|
||||||
previous_average_cpu_time: &mut Option<(PastCpuWork, PastCpuTotal)>,
|
previous_average_cpu_time: &mut Option<(PastCpuWork, PastCpuTotal)>,
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
//! Linux-specific functions regarding CPU usage.
|
//! Linux-specific functions regarding CPU usage.
|
||||||
|
|
||||||
use crate::components::tui_widget::time_chart::Point;
|
|
||||||
use heim::cpu::os::linux::CpuTimeExt;
|
use heim::cpu::os::linux::CpuTimeExt;
|
||||||
|
|
||||||
|
use crate::components::tui_widget::time_chart::Point;
|
||||||
|
|
||||||
pub fn convert_cpu_times(cpu_time: &heim::cpu::CpuTime) -> Point {
|
pub fn convert_cpu_times(cpu_time: &heim::cpu::CpuTime) -> Point {
|
||||||
let working_time: f64 = (cpu_time.user()
|
let working_time: f64 = (cpu_time.user()
|
||||||
+ cpu_time.nice()
|
+ cpu_time.nice()
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
//! Disk stats for FreeBSD.
|
//! Disk stats for FreeBSD.
|
||||||
|
|
||||||
use serde::Deserialize;
|
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
use super::{DiskHarvest, IoHarvest};
|
use super::{DiskHarvest, IoHarvest};
|
||||||
use crate::app::Filter;
|
use crate::app::Filter;
|
||||||
use crate::data_harvester::deserialize_xo;
|
use crate::data_harvester::deserialize_xo;
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
//! Data collection for memory via sysinfo.
|
//! Data collection for memory via sysinfo.
|
||||||
|
|
||||||
use crate::data_harvester::memory::{MemCollect, MemHarvest};
|
|
||||||
use sysinfo::{System, SystemExt};
|
use sysinfo::{System, SystemExt};
|
||||||
|
|
||||||
|
use crate::data_harvester::memory::{MemCollect, MemHarvest};
|
||||||
|
|
||||||
pub async fn get_mem_data(sys: &System, actually_get: bool, _get_gpu: bool) -> MemCollect {
|
pub async fn get_mem_data(sys: &System, actually_get: bool, _get_gpu: bool) -> MemCollect {
|
||||||
if !actually_get {
|
if !actually_get {
|
||||||
MemCollect {
|
MemCollect {
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
//! Gets network data via heim.
|
//! Gets network data via heim.
|
||||||
|
|
||||||
use super::NetworkHarvest;
|
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
|
use super::NetworkHarvest;
|
||||||
|
|
||||||
// TODO: Eventually make it so that this thing also takes individual usage into account, so we can show per-interface!
|
// TODO: Eventually make it so that this thing also takes individual usage into account, so we can show per-interface!
|
||||||
pub async fn get_network_data(
|
pub async fn get_network_data(
|
||||||
prev_net_access_time: Instant, prev_net_rx: &mut u64, prev_net_tx: &mut u64,
|
prev_net_access_time: Instant, prev_net_rx: &mut u64, prev_net_tx: &mut u64,
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
//! Gets network data via sysinfo.
|
//! Gets network data via sysinfo.
|
||||||
|
|
||||||
use super::NetworkHarvest;
|
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
|
use super::NetworkHarvest;
|
||||||
|
|
||||||
pub async fn get_network_data(
|
pub async fn get_network_data(
|
||||||
sys: &sysinfo::System, prev_net_access_time: Instant, prev_net_rx: &mut u64,
|
sys: &sysinfo::System, prev_net_access_time: Instant, prev_net_rx: &mut u64,
|
||||||
prev_net_tx: &mut u64, curr_time: Instant, actually_get: bool,
|
prev_net_tx: &mut u64, curr_time: Instant, actually_get: bool,
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
//! Process data collection for FreeBSD. Uses sysinfo.
|
//! Process data collection for FreeBSD. Uses sysinfo.
|
||||||
|
|
||||||
use serde::{Deserialize, Deserializer};
|
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use super::ProcessHarvest;
|
use serde::{Deserialize, Deserializer};
|
||||||
use sysinfo::System;
|
use sysinfo::System;
|
||||||
|
|
||||||
|
use super::ProcessHarvest;
|
||||||
use crate::data_harvester::deserialize_xo;
|
use crate::data_harvester::deserialize_xo;
|
||||||
use crate::data_harvester::processes::UserTable;
|
use crate::data_harvester::processes::UserTable;
|
||||||
|
|
||||||
|
|
|
@ -2,18 +2,15 @@
|
||||||
|
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
|
|
||||||
|
use fxhash::{FxHashMap, FxHashSet};
|
||||||
|
use procfs::process::{Process, Stat};
|
||||||
|
use sysinfo::ProcessStatus;
|
||||||
|
|
||||||
|
use super::{ProcessHarvest, UserTable};
|
||||||
use crate::components::tui_widget::time_chart::Point;
|
use crate::components::tui_widget::time_chart::Point;
|
||||||
use crate::utils::error::{self, BottomError};
|
use crate::utils::error::{self, BottomError};
|
||||||
use crate::Pid;
|
use crate::Pid;
|
||||||
|
|
||||||
use super::{ProcessHarvest, UserTable};
|
|
||||||
|
|
||||||
use sysinfo::ProcessStatus;
|
|
||||||
|
|
||||||
use procfs::process::{Process, Stat};
|
|
||||||
|
|
||||||
use fxhash::{FxHashMap, FxHashSet};
|
|
||||||
|
|
||||||
/// Maximum character length of a /proc/<PID>/stat process name.
|
/// Maximum character length of a /proc/<PID>/stat process name.
|
||||||
/// If it's equal or greater, then we instead refer to the command for the name.
|
/// If it's equal or greater, then we instead refer to the command for the name.
|
||||||
const MAX_STAT_NAME_LEN: usize = 15;
|
const MAX_STAT_NAME_LEN: usize = 15;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
//! Process data collection for macOS. Uses sysinfo and custom bindings.
|
//! Process data collection for macOS. Uses sysinfo and custom bindings.
|
||||||
|
|
||||||
use super::ProcessHarvest;
|
|
||||||
use sysinfo::System;
|
use sysinfo::System;
|
||||||
|
|
||||||
|
use super::ProcessHarvest;
|
||||||
use crate::{data_harvester::processes::UserTable, Pid};
|
use crate::{data_harvester::processes::UserTable, Pid};
|
||||||
mod sysctl_bindings;
|
mod sysctl_bindings;
|
||||||
|
|
||||||
|
|
|
@ -295,9 +295,10 @@ pub(crate) fn kinfo_process(pid: Pid) -> Result<kinfo_proc> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
/// A quick test to ensure that things are sized correctly.
|
/// A quick test to ensure that things are sized correctly.
|
||||||
#[test]
|
#[test]
|
||||||
fn test_struct_sizes() {
|
fn test_struct_sizes() {
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use super::ProcessHarvest;
|
|
||||||
use sysinfo::{CpuExt, PidExt, ProcessExt, ProcessStatus, System, SystemExt};
|
use sysinfo::{CpuExt, PidExt, ProcessExt, ProcessStatus, System, SystemExt};
|
||||||
|
|
||||||
|
use super::ProcessHarvest;
|
||||||
use crate::{data_harvester::processes::UserTable, utils::error::Result, Pid};
|
use crate::{data_harvester::processes::UserTable, utils::error::Result, Pid};
|
||||||
|
|
||||||
pub fn get_process_data<F>(
|
pub fn get_process_data<F>(
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
//! Process data collection for Windows. Uses sysinfo.
|
//! Process data collection for Windows. Uses sysinfo.
|
||||||
|
|
||||||
use super::ProcessHarvest;
|
|
||||||
use sysinfo::{CpuExt, PidExt, ProcessExt, System, SystemExt};
|
use sysinfo::{CpuExt, PidExt, ProcessExt, System, SystemExt};
|
||||||
|
|
||||||
|
use super::ProcessHarvest;
|
||||||
|
|
||||||
pub fn get_process_data(
|
pub fn get_process_data(
|
||||||
sys: &System, use_current_cpu_total: bool, mem_total_kb: u64,
|
sys: &System, use_current_cpu_total: bool, mem_total_kb: u64,
|
||||||
) -> crate::utils::error::Result<Vec<ProcessHarvest>> {
|
) -> crate::utils::error::Result<Vec<ProcessHarvest>> {
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
//! Gets temperature sensor data for Linux platforms.
|
//! Gets temperature sensor data for Linux platforms.
|
||||||
|
|
||||||
|
use std::{fs, path::Path};
|
||||||
|
|
||||||
|
use anyhow::{anyhow, Result};
|
||||||
|
|
||||||
use super::{is_temp_filtered, temp_vec_sort, TempHarvest, TemperatureType};
|
use super::{is_temp_filtered, temp_vec_sort, TempHarvest, TemperatureType};
|
||||||
use crate::app::{
|
use crate::app::{
|
||||||
data_harvester::temperature::{convert_celsius_to_fahrenheit, convert_celsius_to_kelvin},
|
data_harvester::temperature::{convert_celsius_to_fahrenheit, convert_celsius_to_kelvin},
|
||||||
Filter,
|
Filter,
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, Result};
|
|
||||||
use std::{fs, path::Path};
|
|
||||||
|
|
||||||
/// Get temperature sensors from the linux sysfs interface `/sys/class/hwmon`.
|
/// Get temperature sensors from the linux sysfs interface `/sys/class/hwmon`.
|
||||||
/// See [here](https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-hwmon) for
|
/// See [here](https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-hwmon) for
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
use crate::app::Filter;
|
use nvml_wrapper::enum_wrappers::device::TemperatureSensor;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
convert_celsius_to_fahrenheit, convert_celsius_to_kelvin, is_temp_filtered, TempHarvest,
|
convert_celsius_to_fahrenheit, convert_celsius_to_kelvin, is_temp_filtered, TempHarvest,
|
||||||
TemperatureType,
|
TemperatureType,
|
||||||
};
|
};
|
||||||
|
use crate::app::Filter;
|
||||||
use nvml_wrapper::enum_wrappers::device::TemperatureSensor;
|
|
||||||
|
|
||||||
use crate::data_harvester::nvidia::NVML_DATA;
|
use crate::data_harvester::nvidia::NVML_DATA;
|
||||||
|
|
||||||
pub fn add_nvidia_data(
|
pub fn add_nvidia_data(
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
//! Gets temperature data via sysinfo.
|
//! Gets temperature data via sysinfo.
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
convert_celsius_to_fahrenheit, convert_celsius_to_kelvin, is_temp_filtered, temp_vec_sort,
|
convert_celsius_to_fahrenheit, convert_celsius_to_kelvin, is_temp_filtered, temp_vec_sort,
|
||||||
TempHarvest, TemperatureType,
|
TempHarvest, TemperatureType,
|
||||||
};
|
};
|
||||||
use crate::app::Filter;
|
use crate::app::Filter;
|
||||||
use anyhow::Result;
|
|
||||||
|
|
||||||
pub fn get_temperature_data(
|
pub fn get_temperature_data(
|
||||||
sys: &sysinfo::System, temp_type: &TemperatureType, filter: &Option<Filter>,
|
sys: &sysinfo::System, temp_type: &TemperatureType, filter: &Option<Filter>,
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
use crate::error::{BottomError, Result};
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use typed_builder::*;
|
use typed_builder::*;
|
||||||
|
|
||||||
use crate::constants::DEFAULT_WIDGET_ID;
|
use crate::constants::DEFAULT_WIDGET_ID;
|
||||||
|
use crate::error::{BottomError, Result};
|
||||||
|
|
||||||
/// Represents a more usable representation of the layout, derived from the
|
/// Represents a more usable representation of the layout, derived from the
|
||||||
/// config.
|
/// config.
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use crate::utils::error::{
|
|
||||||
BottomError::{self, QueryError},
|
|
||||||
Result,
|
|
||||||
};
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::{borrow::Cow, collections::VecDeque};
|
use std::{borrow::Cow, collections::VecDeque};
|
||||||
|
|
||||||
use super::data_harvester::processes::ProcessHarvest;
|
use super::data_harvester::processes::ProcessHarvest;
|
||||||
|
use crate::utils::error::{
|
||||||
|
BottomError::{self, QueryError},
|
||||||
|
Result,
|
||||||
|
};
|
||||||
|
|
||||||
const DELIMITER_LIST: [char; 6] = ['=', '>', '<', '(', ')', '\"'];
|
const DELIMITER_LIST: [char; 6] = ['=', '>', '<', '(', ')', '\"'];
|
||||||
const COMPARISON_LIST: [&str; 3] = [">", "=", "<"];
|
const COMPARISON_LIST: [&str; 3] = [">", "=", "<"];
|
||||||
|
|
|
@ -2,15 +2,14 @@ use std::{collections::HashMap, time::Instant};
|
||||||
|
|
||||||
use unicode_segmentation::GraphemeCursor;
|
use unicode_segmentation::GraphemeCursor;
|
||||||
|
|
||||||
use crate::{
|
|
||||||
app::{layout_manager::BottomWidgetType, query::*},
|
|
||||||
constants,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::widgets::{
|
use super::widgets::{
|
||||||
BatteryWidgetState, CpuWidgetState, DiskTableWidget, MemWidgetState, NetWidgetState,
|
BatteryWidgetState, CpuWidgetState, DiskTableWidget, MemWidgetState, NetWidgetState,
|
||||||
ProcWidget, TempWidgetState,
|
ProcWidget, TempWidgetState,
|
||||||
};
|
};
|
||||||
|
use crate::{
|
||||||
|
app::{layout_manager::BottomWidgetType, query::*},
|
||||||
|
constants,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum CursorDirection {
|
pub enum CursorDirection {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::{borrow::Cow, time::Instant};
|
use std::{borrow::Cow, time::Instant};
|
||||||
|
|
||||||
use concat_string::concat_string;
|
use concat_string::concat_string;
|
||||||
|
|
||||||
use tui::{style::Style, text::Text, widgets::Row};
|
use tui::{style::Style, text::Text, widgets::Row};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
use fxhash::{FxHashMap, FxHashSet};
|
||||||
|
use itertools::Itertools;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::{
|
app::{
|
||||||
data_farmer::{DataCollection, ProcessData},
|
data_farmer::{DataCollection, ProcessData},
|
||||||
|
@ -15,9 +18,6 @@ use crate::{
|
||||||
Pid,
|
Pid,
|
||||||
};
|
};
|
||||||
|
|
||||||
use fxhash::{FxHashMap, FxHashSet};
|
|
||||||
use itertools::Itertools;
|
|
||||||
|
|
||||||
pub mod proc_widget_column;
|
pub mod proc_widget_column;
|
||||||
pub use proc_widget_column::*;
|
pub use proc_widget_column::*;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
|
use std::{borrow::Cow, cmp::Reverse};
|
||||||
|
|
||||||
|
use super::ProcWidgetData;
|
||||||
use crate::{
|
use crate::{
|
||||||
components::data_table::{ColumnHeader, SortsRow},
|
components::data_table::{ColumnHeader, SortsRow},
|
||||||
utils::gen_util::sort_partial_fn,
|
utils::gen_util::sort_partial_fn,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::{borrow::Cow, cmp::Reverse};
|
|
||||||
|
|
||||||
use super::ProcWidgetData;
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
||||||
pub enum ProcColumn {
|
pub enum ProcColumn {
|
||||||
CpuPercent,
|
CpuPercent,
|
||||||
|
|
|
@ -6,6 +6,7 @@ use std::{
|
||||||
use concat_string::concat_string;
|
use concat_string::concat_string;
|
||||||
use tui::{text::Text, widgets::Row};
|
use tui::{text::Text, widgets::Row};
|
||||||
|
|
||||||
|
use super::proc_widget_column::ProcColumn;
|
||||||
use crate::{
|
use crate::{
|
||||||
app::data_harvester::processes::ProcessHarvest,
|
app::data_harvester::processes::ProcessHarvest,
|
||||||
canvas::Painter,
|
canvas::Painter,
|
||||||
|
@ -15,8 +16,6 @@ use crate::{
|
||||||
Pid,
|
Pid,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::proc_widget_column::ProcColumn;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
enum IdType {
|
enum IdType {
|
||||||
Name(String),
|
Name(String),
|
||||||
|
|
|
@ -4,14 +4,6 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
|
||||||
use bottom::{
|
|
||||||
canvas::{self, canvas_colours::CanvasColours},
|
|
||||||
constants::*,
|
|
||||||
data_conversion::*,
|
|
||||||
options::*,
|
|
||||||
*,
|
|
||||||
};
|
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
io::stdout,
|
io::stdout,
|
||||||
|
@ -25,6 +17,13 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
|
use bottom::{
|
||||||
|
canvas::{self, canvas_colours::CanvasColours},
|
||||||
|
constants::*,
|
||||||
|
data_conversion::*,
|
||||||
|
options::*,
|
||||||
|
*,
|
||||||
|
};
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{EnableBracketedPaste, EnableMouseCapture},
|
event::{EnableBracketedPaste, EnableMouseCapture},
|
||||||
execute,
|
execute,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use itertools::izip;
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
use canvas_colours::*;
|
||||||
|
use itertools::izip;
|
||||||
use tui::{
|
use tui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Constraint, Direction, Layout, Rect},
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
|
@ -9,8 +10,6 @@ use tui::{
|
||||||
Frame, Terminal,
|
Frame, Terminal,
|
||||||
};
|
};
|
||||||
|
|
||||||
use canvas_colours::*;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::{
|
app::{
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
use crate::{
|
|
||||||
constants::*,
|
|
||||||
options::{Config, ConfigColours},
|
|
||||||
utils::error,
|
|
||||||
};
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use colour_utils::*;
|
use colour_utils::*;
|
||||||
use tui::style::{Color, Style};
|
use tui::style::{Color, Style};
|
||||||
|
|
||||||
use super::ColourScheme;
|
use super::ColourScheme;
|
||||||
|
use crate::{
|
||||||
|
constants::*,
|
||||||
|
options::{Config, ConfigColours},
|
||||||
|
utils::error,
|
||||||
|
};
|
||||||
mod colour_utils;
|
mod colour_utils;
|
||||||
|
|
||||||
pub struct CanvasColours {
|
pub struct CanvasColours {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
use tui::style::{Color, Style};
|
use tui::style::{Color, Style};
|
||||||
|
|
||||||
use crate::utils::error;
|
use crate::utils::error;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
|
|
||||||
use tui::{
|
use tui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
use std::cmp::{max, min};
|
use std::cmp::{max, min};
|
||||||
|
|
||||||
use unicode_width::UnicodeWidthStr;
|
|
||||||
|
|
||||||
use crate::{app::App, canvas::Painter, constants};
|
|
||||||
use tui::{
|
use tui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Alignment, Rect},
|
layout::{Alignment, Rect},
|
||||||
|
@ -11,6 +8,9 @@ use tui::{
|
||||||
text::Spans,
|
text::Spans,
|
||||||
widgets::{Block, Borders, Paragraph, Wrap},
|
widgets::{Block, Borders, Paragraph, Wrap},
|
||||||
};
|
};
|
||||||
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
|
use crate::{app::App, canvas::Painter, constants};
|
||||||
|
|
||||||
const HELP_BASE: &str = " Help ── Esc to close ";
|
const HELP_BASE: &str = " Help ── Esc to close ";
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
use std::{cmp::min, time::Instant};
|
||||||
|
|
||||||
use tui::layout::Rect;
|
use tui::layout::Rect;
|
||||||
|
|
||||||
use crate::app::CursorDirection;
|
use crate::app::CursorDirection;
|
||||||
use std::{cmp::min, time::Instant};
|
|
||||||
|
|
||||||
pub fn get_search_start_position(
|
pub fn get_search_start_position(
|
||||||
num_columns: usize, cursor_direction: &CursorDirection, cursor_bar: &mut usize,
|
num_columns: usize, cursor_direction: &CursorDirection, cursor_bar: &mut usize,
|
||||||
|
@ -89,10 +90,12 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_should_hide_x_label() {
|
fn test_should_hide_x_label() {
|
||||||
use crate::constants::*;
|
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
use tui::layout::Rect;
|
use tui::layout::Rect;
|
||||||
|
|
||||||
|
use crate::constants::*;
|
||||||
|
|
||||||
let rect = Rect::new(0, 0, 10, 10);
|
let rect = Rect::new(0, 0, 10, 10);
|
||||||
let small_rect = Rect::new(0, 0, 10, 6);
|
let small_rect = Rect::new(0, 0, 10, 6);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
use crate::{
|
|
||||||
app::{layout_manager::BottomWidgetType, App},
|
|
||||||
canvas::Painter,
|
|
||||||
};
|
|
||||||
|
|
||||||
use tui::{
|
use tui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||||
|
@ -12,6 +7,11 @@ use tui::{
|
||||||
widgets::{Block, Paragraph},
|
widgets::{Block, Paragraph},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
app::{layout_manager::BottomWidgetType, App},
|
||||||
|
canvas::Painter,
|
||||||
|
};
|
||||||
|
|
||||||
impl Painter {
|
impl Painter {
|
||||||
pub fn draw_basic_table_arrows<B: Backend>(
|
pub fn draw_basic_table_arrows<B: Backend>(
|
||||||
&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,
|
||||||
|
|
|
@ -1,9 +1,3 @@
|
||||||
use crate::{
|
|
||||||
app::App,
|
|
||||||
canvas::{drawing_utils::calculate_basic_use_bars, Painter},
|
|
||||||
constants::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
use tui::{
|
use tui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Constraint, Direction, Layout, Rect},
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
|
@ -13,6 +7,12 @@ use tui::{
|
||||||
};
|
};
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
app::App,
|
||||||
|
canvas::{drawing_utils::calculate_basic_use_bars, Painter},
|
||||||
|
constants::*,
|
||||||
|
};
|
||||||
|
|
||||||
impl Painter {
|
impl Painter {
|
||||||
pub fn draw_battery_display<B: Backend>(
|
pub fn draw_battery_display<B: Backend>(
|
||||||
&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,
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
|
|
||||||
|
use tui::{
|
||||||
|
backend::Backend,
|
||||||
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
|
terminal::Frame,
|
||||||
|
widgets::Block,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::{data_harvester::cpu::CpuDataType, App},
|
app::{data_harvester::cpu::CpuDataType, App},
|
||||||
canvas::Painter,
|
canvas::Painter,
|
||||||
|
@ -8,13 +15,6 @@ use crate::{
|
||||||
data_conversion::CpuWidgetData,
|
data_conversion::CpuWidgetData,
|
||||||
};
|
};
|
||||||
|
|
||||||
use tui::{
|
|
||||||
backend::Backend,
|
|
||||||
layout::{Constraint, Direction, Layout, Rect},
|
|
||||||
terminal::Frame,
|
|
||||||
widgets::Block,
|
|
||||||
};
|
|
||||||
|
|
||||||
impl Painter {
|
impl Painter {
|
||||||
/// Inspired by htop.
|
/// Inspired by htop.
|
||||||
pub fn draw_basic_cpu<B: Backend>(
|
pub fn draw_basic_cpu<B: Backend>(
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
use concat_string::concat_string;
|
||||||
|
use tui::{
|
||||||
|
backend::Backend,
|
||||||
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
|
terminal::Frame,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::{layout_manager::WidgetDirection, widgets::CpuWidgetState, App},
|
app::{layout_manager::WidgetDirection, widgets::CpuWidgetState, App},
|
||||||
canvas::{drawing_utils::should_hide_x_label, Painter},
|
canvas::{drawing_utils::should_hide_x_label, Painter},
|
||||||
|
@ -10,14 +17,6 @@ use crate::{
|
||||||
data_conversion::CpuWidgetData,
|
data_conversion::CpuWidgetData,
|
||||||
};
|
};
|
||||||
|
|
||||||
use concat_string::concat_string;
|
|
||||||
|
|
||||||
use tui::{
|
|
||||||
backend::Backend,
|
|
||||||
layout::{Constraint, Direction, Layout, Rect},
|
|
||||||
terminal::Frame,
|
|
||||||
};
|
|
||||||
|
|
||||||
const AVG_POSITION: usize = 1;
|
const AVG_POSITION: usize = 1;
|
||||||
const ALL_POSITION: usize = 0;
|
const ALL_POSITION: usize = 0;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
use crate::{
|
|
||||||
app::App, canvas::Painter, components::tui_widget::pipe_gauge::PipeGauge, constants::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
use tui::{
|
use tui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Constraint, Direction, Layout, Rect},
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
|
@ -9,6 +5,10 @@ use tui::{
|
||||||
widgets::Block,
|
widgets::Block,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
app::App, canvas::Painter, components::tui_widget::pipe_gauge::PipeGauge, constants::*,
|
||||||
|
};
|
||||||
|
|
||||||
impl Painter {
|
impl Painter {
|
||||||
pub fn draw_basic_memory<B: Backend>(
|
pub fn draw_basic_memory<B: Backend>(
|
||||||
&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,
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use crate::{
|
|
||||||
app::App,
|
|
||||||
canvas::{drawing_utils::should_hide_x_label, Painter},
|
|
||||||
components::time_graph::{GraphData, TimeGraph},
|
|
||||||
};
|
|
||||||
|
|
||||||
use tui::{
|
use tui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Constraint, Rect},
|
layout::{Constraint, Rect},
|
||||||
terminal::Frame,
|
terminal::Frame,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
app::App,
|
||||||
|
canvas::{drawing_utils::should_hide_x_label, Painter},
|
||||||
|
components::time_graph::{GraphData, TimeGraph},
|
||||||
|
};
|
||||||
|
|
||||||
impl Painter {
|
impl Painter {
|
||||||
pub fn draw_memory_graph<B: Backend>(
|
pub fn draw_memory_graph<B: Backend>(
|
||||||
&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,
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use crate::{app::App, canvas::Painter, constants::*};
|
|
||||||
|
|
||||||
use tui::{
|
use tui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Constraint, Direction, Layout, Rect},
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
|
@ -8,6 +6,8 @@ use tui::{
|
||||||
widgets::{Block, Paragraph},
|
widgets::{Block, Paragraph},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::{app::App, canvas::Painter, constants::*};
|
||||||
|
|
||||||
impl Painter {
|
impl Painter {
|
||||||
pub fn draw_basic_network<B: Backend>(
|
pub fn draw_basic_network<B: Backend>(
|
||||||
&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,
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
use tui::{
|
||||||
|
backend::Backend,
|
||||||
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
|
terminal::Frame,
|
||||||
|
text::Text,
|
||||||
|
widgets::{Block, Borders, Row, Table},
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::{App, AxisScaling},
|
app::{App, AxisScaling},
|
||||||
canvas::{drawing_utils::should_hide_x_label, Painter},
|
canvas::{drawing_utils::should_hide_x_label, Painter},
|
||||||
|
@ -9,14 +17,6 @@ use crate::{
|
||||||
utils::gen_util::*,
|
utils::gen_util::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use tui::{
|
|
||||||
backend::Backend,
|
|
||||||
layout::{Constraint, Direction, Layout, Rect},
|
|
||||||
terminal::Frame,
|
|
||||||
text::Text,
|
|
||||||
widgets::{Block, Borders, Row, Table},
|
|
||||||
};
|
|
||||||
|
|
||||||
impl Painter {
|
impl Painter {
|
||||||
pub fn draw_network<B: Backend>(
|
pub fn draw_network<B: Backend>(
|
||||||
&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,
|
||||||
|
|
|
@ -1,10 +1,3 @@
|
||||||
use crate::{
|
|
||||||
app::App,
|
|
||||||
canvas::{drawing_utils::get_search_start_position, Painter},
|
|
||||||
components::data_table::{DrawInfo, SelectionState},
|
|
||||||
constants::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
use tui::{
|
use tui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||||
|
@ -12,10 +5,16 @@ use tui::{
|
||||||
text::{Span, Spans},
|
text::{Span, Spans},
|
||||||
widgets::{Block, Borders, Paragraph},
|
widgets::{Block, Borders, Paragraph},
|
||||||
};
|
};
|
||||||
|
|
||||||
use unicode_segmentation::{GraphemeIndices, UnicodeSegmentation};
|
use unicode_segmentation::{GraphemeIndices, UnicodeSegmentation};
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
app::App,
|
||||||
|
canvas::{drawing_utils::get_search_start_position, Painter},
|
||||||
|
components::data_table::{DrawInfo, SelectionState},
|
||||||
|
constants::*,
|
||||||
|
};
|
||||||
|
|
||||||
const SORT_MENU_WIDTH: u16 = 7;
|
const SORT_MENU_WIDTH: u16 = 7;
|
||||||
|
|
||||||
impl Painter {
|
impl Painter {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use tui::{text::Text, widgets::Row};
|
use tui::{text::Text, widgets::Row};
|
||||||
|
|
||||||
use crate::canvas::Painter;
|
|
||||||
|
|
||||||
use super::{ColumnHeader, DataTableColumn};
|
use super::{ColumnHeader, DataTableColumn};
|
||||||
|
use crate::canvas::Painter;
|
||||||
|
|
||||||
pub trait DataToCell<H>
|
pub trait DataToCell<H>
|
||||||
where
|
where
|
||||||
|
|
|
@ -13,17 +13,16 @@ use tui::{
|
||||||
};
|
};
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
|
|
||||||
|
use super::{
|
||||||
|
CalculateColumnWidths, ColumnHeader, ColumnWidthBounds, DataTable, DataTableColumn, DataToCell,
|
||||||
|
SortType,
|
||||||
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
app::layout_manager::BottomWidget,
|
app::layout_manager::BottomWidget,
|
||||||
canvas::Painter,
|
canvas::Painter,
|
||||||
constants::{SIDE_BORDERS, TABLE_GAP_HEIGHT_LIMIT},
|
constants::{SIDE_BORDERS, TABLE_GAP_HEIGHT_LIMIT},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
|
||||||
CalculateColumnWidths, ColumnHeader, ColumnWidthBounds, DataTable, DataTableColumn, DataToCell,
|
|
||||||
SortType,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub enum SelectionState {
|
pub enum SelectionState {
|
||||||
NotSelected,
|
NotSelected,
|
||||||
Selected,
|
Selected,
|
||||||
|
|
|
@ -4,12 +4,11 @@ use concat_string::concat_string;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use tui::widgets::Row;
|
use tui::widgets::Row;
|
||||||
|
|
||||||
use crate::utils::gen_util::truncate_text;
|
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
ColumnHeader, ColumnWidthBounds, DataTable, DataTableColumn, DataTableProps, DataTableState,
|
ColumnHeader, ColumnWidthBounds, DataTable, DataTableColumn, DataTableProps, DataTableState,
|
||||||
DataTableStyling, DataToCell,
|
DataTableStyling, DataToCell,
|
||||||
};
|
};
|
||||||
|
use crate::utils::gen_util::truncate_text;
|
||||||
|
|
||||||
/// Denotes the sort order.
|
/// Denotes the sort order.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
use concat_string::concat_string;
|
||||||
use tui::{
|
use tui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Constraint, Rect},
|
layout::{Constraint, Rect},
|
||||||
|
@ -9,8 +10,6 @@ use tui::{
|
||||||
widgets::{Block, Borders, GraphType},
|
widgets::{Block, Borders, GraphType},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
||||||
use concat_string::concat_string;
|
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
|
|
||||||
use super::tui_widget::time_chart::{Axis, Dataset, Point, TimeChart, DEFAULT_LEGEND_CONSTRAINTS};
|
use super::tui_widget::time_chart::{Axis, Dataset, Point, TimeChart, DEFAULT_LEGEND_CONSTRAINTS};
|
||||||
|
@ -194,9 +193,8 @@ mod test {
|
||||||
text::{Span, Spans},
|
text::{Span, Spans},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::components::tui_widget::time_chart::Axis;
|
|
||||||
|
|
||||||
use super::TimeGraph;
|
use super::TimeGraph;
|
||||||
|
use crate::components::tui_widget::time_chart::Axis;
|
||||||
|
|
||||||
const Y_LABELS: [Cow<'static, str>; 3] = [
|
const Y_LABELS: [Cow<'static, str>; 3] = [
|
||||||
Cow::Borrowed("0%"),
|
Cow::Borrowed("0%"),
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use std::{borrow::Cow, cmp::max};
|
use std::{borrow::Cow, cmp::max};
|
||||||
|
|
||||||
use tui::{
|
use tui::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::{Constraint, Rect},
|
layout::{Constraint, Rect},
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::options::ConfigColours;
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
|
use crate::options::ConfigColours;
|
||||||
|
|
||||||
// Default widget ID
|
// Default widget ID
|
||||||
pub const DEFAULT_WIDGET_ID: u64 = 56709;
|
pub const DEFAULT_WIDGET_ID: u64 = 56709;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
//! This mainly concerns converting collected data into things that the canvas
|
//! This mainly concerns converting collected data into things that the canvas
|
||||||
//! can actually handle.
|
//! can actually handle.
|
||||||
|
|
||||||
|
use kstring::KString;
|
||||||
|
|
||||||
use crate::app::data_farmer::DataCollection;
|
use crate::app::data_farmer::DataCollection;
|
||||||
use crate::app::data_harvester::cpu::CpuDataType;
|
use crate::app::data_harvester::cpu::CpuDataType;
|
||||||
use crate::app::{
|
use crate::app::{
|
||||||
|
@ -11,8 +13,6 @@ use crate::components::tui_widget::time_chart::Point;
|
||||||
use crate::utils::gen_util::*;
|
use crate::utils::gen_util::*;
|
||||||
use crate::{app::AxisScaling, units::data_units::DataUnit};
|
use crate::{app::AxisScaling, units::data_units::DataUnit};
|
||||||
|
|
||||||
use kstring::KString;
|
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
pub struct ConvertedBatteryData {
|
pub struct ConvertedBatteryData {
|
||||||
pub battery_name: String,
|
pub battery_name: String,
|
||||||
|
|
18
src/lib.rs
18
src/lib.rs
|
@ -25,6 +25,13 @@ use std::{
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use app::{
|
||||||
|
data_harvester,
|
||||||
|
frozen_state::FrozenState,
|
||||||
|
layout_manager::{UsedWidgets, WidgetDirection},
|
||||||
|
App,
|
||||||
|
};
|
||||||
|
use constants::*;
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{
|
event::{
|
||||||
poll, read, DisableBracketedPaste, DisableMouseCapture, Event, KeyCode, KeyEvent,
|
poll, read, DisableBracketedPaste, DisableMouseCapture, Event, KeyCode, KeyEvent,
|
||||||
|
@ -34,17 +41,8 @@ use crossterm::{
|
||||||
style::Print,
|
style::Print,
|
||||||
terminal::{disable_raw_mode, LeaveAlternateScreen},
|
terminal::{disable_raw_mode, LeaveAlternateScreen},
|
||||||
};
|
};
|
||||||
|
|
||||||
use flume::{Receiver, Sender};
|
|
||||||
|
|
||||||
use app::{
|
|
||||||
data_harvester,
|
|
||||||
frozen_state::FrozenState,
|
|
||||||
layout_manager::{UsedWidgets, WidgetDirection},
|
|
||||||
App,
|
|
||||||
};
|
|
||||||
use constants::*;
|
|
||||||
use data_conversion::*;
|
use data_conversion::*;
|
||||||
|
use flume::{Receiver, Sender};
|
||||||
use options::*;
|
use options::*;
|
||||||
use utils::error;
|
use utils::error;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use regex::Regex;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
|
@ -8,6 +6,11 @@ use std::{
|
||||||
time::Instant,
|
time::Instant,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use layout_options::*;
|
||||||
|
use regex::Regex;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use typed_builder::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::{
|
app::{
|
||||||
layout_manager::*,
|
layout_manager::*,
|
||||||
|
@ -23,10 +26,6 @@ use crate::{
|
||||||
utils::error::{self, BottomError},
|
utils::error::{self, BottomError},
|
||||||
};
|
};
|
||||||
|
|
||||||
use typed_builder::*;
|
|
||||||
|
|
||||||
use layout_options::*;
|
|
||||||
|
|
||||||
pub mod layout_options;
|
pub mod layout_options;
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::app::layout_manager::*;
|
use crate::app::layout_manager::*;
|
||||||
use crate::error::Result;
|
use crate::error::Result;
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
/// Represents a row. This has a length of some sort (optional) and a vector
|
/// Represents a row. This has a length of some sort (optional) and a vector
|
||||||
/// of children.
|
/// of children.
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use std::{borrow::Cow, result};
|
use std::{borrow::Cow, result};
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
|
Loading…
Reference in a new issue