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