summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2020-11-22 13:44:40 -0800
committerGitHub <noreply@github.com>2020-11-22 16:44:40 -0500
commit6aa0dd64a663029a0c77159c4229e00a10967b86 (patch)
treef2c4d2508a8dd42a6a5b877b7887f358419adfff
parent5abb1ce1a3cd847bfd876d5b7f940db25e7e6aca (diff)
other: Switch to once_cell (#324)
Switch from lazy_static to once_cell.
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/app/data_farmer.rs7
-rw-r--r--src/app/data_harvester/processes.rs2
-rw-r--r--src/canvas/canvas_colours/colour_utils.rs12
-rw-r--r--src/canvas/widgets/cpu_graph.rs10
-rw-r--r--src/canvas/widgets/disk_table.rs10
-rw-r--r--src/canvas/widgets/network_graph.rs10
-rw-r--r--src/canvas/widgets/process_table.rs146
-rw-r--r--src/canvas/widgets/temp_table.rs11
-rw-r--r--src/constants.rs231
-rw-r--r--src/data_conversion.rs1
12 files changed, 233 insertions, 211 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 6005be33..bc2b3138 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -125,9 +125,9 @@ dependencies = [
"heim",
"indexmap",
"itertools",
- "lazy_static",
"libc",
"log",
+ "once_cell",
"predicates",
"regex",
"serde",
diff --git a/Cargo.toml b/Cargo.toml
index f88c0b19..2f7fdf6c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -35,8 +35,8 @@ dirs-next = "2.0.0"
futures = "0.3.8"
indexmap = "1.6.0"
itertools = "0.9.0"
-lazy_static = "1.4.0"
libc = "0.2"
+once_cell = "1.5.2"
regex = "1.4.2"
serde = {version = "1.0", features = ["derive"] }
sysinfo = "0.15.3"
diff --git a/src/app/data_farmer.rs b/src/app/data_farmer.rs
index 5238c9cc..6120afa5 100644
--- a/src/app/data_farmer.rs
+++ b/src/app/data_farmer.rs
@@ -1,4 +1,3 @@
-use lazy_static::lazy_static;
/// In charge of cleaning, processing, and managing data. I couldn't think of
/// a better name for the file. Since I called data collection "harvesting",
/// then this is the farmer I guess.
@@ -13,6 +12,8 @@ use lazy_static::lazy_static;
/// call the purging function. Failure to do so *will* result in a growing
/// 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 crate::{
@@ -245,9 +246,7 @@ impl DataCollection {
if let Some(trim) = device.name.split('/').last() {
let io_device = if cfg!(target_os = "macos") {
// Must trim one level further!
- lazy_static! {
- static ref DISK_REGEX: Regex = Regex::new(r"disk\d+").unwrap();
- }
+ static DISK_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"disk\d+").unwrap());
if let Some(disk_trim) = DISK_REGEX.find(trim) {
io.get(disk_trim.as_str())
} else {
diff --git a/src/app/data_harvester/processes.rs b/src/app/data_harvester/processes.rs
index ce104082..a182db23 100644
--- a/src/app/data_harvester/processes.rs
+++ b/src/app/data_harvester/processes.rs
@@ -11,7 +11,7 @@ use std::collections::{hash_map::RandomState, HashMap};
#[cfg(not(target_os = "linux"))]
use sysinfo::{ProcessExt, ProcessorExt, System, SystemExt};
-/// Maximum character length of a /proc/<PID>/stat process name.
+/// Maximum character length of a /proc/<PID>/stat process name that we'll accept.
#[cfg(target_os = "linux")]
const MAX_STAT_NAME_LEN: usize = 15;
diff --git a/src/canvas/canvas_colours/colour_utils.rs b/src/canvas/canvas_colours/colour_utils.rs
index 3cad2686..47ab49f5 100644
--- a/src/canvas/canvas_colours/colour_utils.rs
+++ b/src/canvas/canvas_colours/colour_utils.rs
@@ -1,4 +1,4 @@
-use lazy_static::lazy_static;
+use once_cell::sync::Lazy;
use std::collections::HashMap;
use tui::style::{Color, Style};
@@ -14,8 +14,8 @@ pub const STANDARD_HIGHLIGHT_COLOUR: Color = Color::LightBlue;
pub const AVG_COLOUR: Color = Color::Red;
pub const ALL_COLOUR: Color = Color::Green;
-lazy_static! {
- static ref COLOR_NAME_LOOKUP_TABLE: HashMap<&'static str, Color> = [
+static COLOR_NAME_LOOKUP_TABLE: Lazy<HashMap<&'static str, Color>> = Lazy::new(|| {
+ [
("reset", Color::Reset),
("black", Color::Black),
("red", Color::Red),
@@ -33,12 +33,12 @@ lazy_static! {
("lightblue", Color::LightBlue),
("lightmagenta", Color::LightMagenta),
("lightcyan", Color::LightCyan),
- ("white", Color::White)
+ ("white", Color::White),
]
.iter()
.copied()
- .collect();
-}
+ .collect()
+});
pub fn convert_hex_to_color(hex: &str) -> error::Result<Color> {
fn hex_err(hex: &str) -> error::Result<u8> {
diff --git a/src/canvas/widgets/cpu_graph.rs b/src/canvas/widgets/cpu_graph.rs
index 571af6ca..e757c826 100644
--- a/src/canvas/widgets/cpu_graph.rs
+++ b/src/canvas/widgets/cpu_graph.rs
@@ -1,4 +1,4 @@
-use lazy_static::lazy_static;
+use once_cell::sync::Lazy;
use std::borrow::Cow;
use unicode_segmentation::UnicodeSegmentation;
@@ -26,12 +26,12 @@ const CPU_LEGEND_HEADER: [&str; 2] = ["CPU", "Use%"];
const AVG_POSITION: usize = 1;
const ALL_POSITION: usize = 0;
-lazy_static! {
- static ref CPU_LEGEND_HEADER_LENS: Vec<u16> = CPU_LEGEND_HEADER
+static CPU_LEGEND_HEADER_LENS: Lazy<Vec<u16>> = Lazy::new(|| {
+ CPU_LEGEND_HEADER
.iter()
.map(|entry| entry.len() as u16)
- .collect::<Vec<_>>();
-}
+ .collect::<Vec<_>>()
+});
pub trait CpuGraphWidget {
fn draw_cpu<B: Backend>(
diff --git a/src/canvas/widgets/disk_table.rs b/src/canvas/widgets/disk_table.rs
index 9d249f4e..0fee787a 100644
--- a/src/canvas/widgets/disk_table.rs
+++ b/src/canvas/widgets/disk_table.rs
@@ -1,4 +1,4 @@
-use lazy_static::lazy_static;
+use once_cell::sync::Lazy;
use tui::{
backend::Backend,
layout::{Constraint, Direction, Layout, Rect},
@@ -21,12 +21,12 @@ use unicode_segmentation::UnicodeSegmentation;
const DISK_HEADERS: [&str; 7] = ["Disk", "Mount", "Used", "Free", "Total", "R/s", "W/s"];
-lazy_static! {
- static ref DISK_HEADERS_LENS: Vec<u16> = DISK_HEADERS
+static DISK_HEADERS_LENS: Lazy<Vec<u16>> = Lazy::new(|| {
+ DISK_HEADERS
.iter()
.map(|entry| entry.len() as u16)
- .collect::<Vec<_>>();
-}
+ .collect::<Vec<_>>()
+});
pub trait DiskTableWidget {
fn draw_disk_table<B: Backend>(
diff --git a/src/canvas/widgets/network_graph.rs b/src/canvas/widgets/network_graph.rs
index 9c825091..ce9d1ce7 100644
--- a/src/canvas/widgets/network_graph.rs
+++ b/src/canvas/widgets/network_graph.rs
@@ -1,4 +1,4 @@
-use lazy_static::lazy_static;
+use once_cell::sync::Lazy;
use std::cmp::max;
use unicode_segmentation::UnicodeSegmentation;
@@ -21,12 +21,12 @@ use tui::{
const NETWORK_HEADERS: [&str; 4] = ["RX", "TX", "Total RX", "Total TX"];
-lazy_static! {
- static ref NETWORK_HEADERS_LENS: Vec<u16> = NETWORK_HEADERS
+static NETWORK_HEADERS_LENS: Lazy<Vec<u16>> = Lazy::new(|| {
+ NETWORK_HEADERS
.iter()
.map(|entry| entry.len() as u16)
- .collect::<Vec<_>>();
-}
+ .collect::<Vec<_>>()
+});
pub trait NetworkGraphWidget {
fn draw_network<B: Backend>(
diff --git a/src/canvas/widgets/process_table.rs b/src/canvas/widgets/process_table.rs
index 22e54c16..e9e9ec40 100644
--- a/src/canvas/widgets/process_table.rs
+++ b/src/canvas/widgets/process_table.rs
@@ -19,6 +19,81 @@ use std::borrow::Cow;
use unicode_segmentation::{GraphemeIndices, UnicodeSegmentation};
use unicode_width::UnicodeWidthStr;
+use once_cell::sync::Lazy;
+
+static PROCESS_HEADERS_HARD_WIDTH_NO_GROUP: Lazy<Vec<Option<u16>>> = Lazy::new(|| {
+ vec![
+ Some(7),
+ None,
+ Some(8),
+ Some(8),
+ Some(8),
+ Some(8),
+ Some(7),
+ Some(8),
+ ]
+});
+static PROCESS_HEADERS_HARD_WIDTH_GROUPED: Lazy<Vec<Option<u16>>> = Lazy::new(|| {
+ vec![
+ Some(7),
+ None,
+ Some(8),
+ Some(8),
+ Some(8),
+ Some(8),
+ Some(7),
+ Some(8),
+ None,
+ ]
+});
+
+static PROCESS_HEADERS_SOFT_WIDTH_MAX_GROUPED_COMMAND: Lazy<Vec<Option<f64>>> =
+ Lazy::new(|| vec![None, Some(0.7), None, None, None, None, None, None]);
+static PROCESS_HEADERS_SOFT_WIDTH_MAX_GROUPED_TREE: Lazy<Vec<Option<f64>>> =
+ Lazy::new(|| vec![None, Some(0.5), None, None, None, None, None, None]);
+static PROCESS_HEADERS_SOFT_WIDTH_MAX_GROUPED_ELSE: Lazy<Vec<Option<f64>>> =
+ Lazy::new(|| vec![None, Some(0.4), None, None, None, None, None, None]);
+
+static PROCESS_HEADERS_SOFT_WIDTH_MAX_NO_GROUP_COMMAND: Lazy<Vec<Option<f64>>> = Lazy::new(|| {
+ vec![
+ None,
+ Some(0.7),
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ Some(0.2),
+ ]
+});
+static PROCESS_HEADERS_SOFT_WIDTH_MAX_NO_GROUP_TREE: Lazy<Vec<Option<f64>>> = Lazy::new(|| {
+ vec![
+ None,
+ Some(0.5),
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ Some(0.2),
+ ]
+});
+static PROCESS_HEADERS_SOFT_WIDTH_MAX_NO_GROUP_ELSE: Lazy<Vec<Option<f64>>> = Lazy::new(|| {
+ vec![
+ None,
+ Some(0.3),
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ Some(0.2),
+ ]
+});
+
pub trait ProcessTableWidget {
/// Draws and handles all process-related drawing. Use this.
/// - `widget_id` here represents the widget ID of the process widget itself!
@@ -222,28 +297,9 @@ impl ProcessTableWidget for Painter {
// Calculate widths
let hard_widths = if proc_widget_state.is_grouped {
- vec![
- Some(7),
- None,
- Some(8),
- Some(8),
- Some(8),
- Some(8),
- Some(7),
- Some(8),
- ]
+ &*PROCESS_HEADERS_HARD_WIDTH_GROUPED
} else {
- vec![
- Some(7),
- None,
- Some(8),
- Some(8),
- Some(8),
- Some(8),
- Some(7),
- Some(8),
- None,
- ]
+ &*PROCESS_HEADERS_HARD_WIDTH_NO_GROUP
};
if recalculate_column_widths {
@@ -274,7 +330,7 @@ impl ProcessTableWidget for Painter {
.table_width_state
.desired_column_widths
.iter()
- .zip(&hard_widths)
+ .zip(hard_widths)
.map(|(current, hard)| {
if let Some(hard) = hard {
if *hard > *current {
@@ -290,48 +346,18 @@ impl ProcessTableWidget for Painter {
let soft_widths_max = if proc_widget_state.is_grouped {
if proc_widget_state.is_using_command {
- vec![None, Some(0.7), None, None, None, None, None, None]
+ &*PROCESS_HEADERS_SOFT_WIDTH_MAX_GROUPED_COMMAND
} else if proc_widget_state.is_tree_mode {
- vec![None, Some(0.5), None, None, None, None, None, None]
+ &*PROCESS_HEADERS_SOFT_WIDTH_MAX_GROUPED_TREE
} else {
- vec![None, Some(0.4), None, None, None, None, None, None]
+ &*PROCESS_HEADERS_SOFT_WIDTH_MAX_GROUPED_ELSE
}
} else if proc_widget_state.is_using_command {
- vec![
- None,
- Some(0.7),
- None,
- None,
- None,
- None,
- None,
- None,
- Some(0.2),
- ]
+ &*PROCESS_HEADERS_SOFT_WIDTH_MAX_NO_GROUP_COMMAND
} else if proc_widget_state.is_tree_mode {
- vec![
- None,
- Some(0.5),
- None,
- None,
- None,
- None,
- None,
- None,
- Some(0.2),
- ]
+ &*PROCESS_HEADERS_SOFT_WIDTH_MAX_NO_GROUP_TREE
} else {
- vec![
- None,
- Some(0.3),
- None,
- None,
- None,
- None,
- None,
- None,
- Some(0.2),
- ]
+ &*PROCESS_HEADERS_SOFT_WIDTH_MAX_NO_GROUP_ELSE
};
proc_widget_state.table_width_state.calculated_column_widths =
@@ -339,7 +365,7 @@ impl ProcessTableWidget for Painter {
draw_loc.width,
&hard_widths,
&soft_widths_min,
- &soft_widths_max,
+ soft_widths_max,
&(proc_widget_state
.table_width_state
.desired_column_widths
@@ -363,7 +389,7 @@ impl ProcessTableWidget for Painter {
let ccw = &proc_widget_state.table_width_state.calculated_column_widths;
let process_rows = sliced_vec.iter().map(|(data, disabled)| {
- let truncated_data = data.iter().zip(&hard_widths).enumerate().map(
+ let truncated_data = data.iter().zip(hard_widths).enumerate().map(
|(itx, ((entry, alternative), width))| {
if let (Some(desired_col_width), Some(calculated_col_width)) =
(dcw.get(itx), ccw.get(itx))
diff --git a/src/canvas/widgets/temp_table.rs b/src/canvas/widgets/temp_table.rs
index 497cb703..07b5d730 100644
--- a/src/canvas/widgets/temp_table.rs
+++ b/src/canvas/widgets/temp_table.rs
@@ -1,4 +1,4 @@
-use lazy_static::lazy_static;
+use once_cell::sync::Lazy;
use tui::{
backend::Backend,
layout::{Constraint, Direction, Layout, Rect},
@@ -21,12 +21,13 @@ use unicode_segmentation::UnicodeSegmentation;
const TEMP_HEADERS: [&str; 2] = ["Sensor", "Temp"];
-lazy_static! {
- static ref TEMP_HEADERS_LENS: Vec<u16> = TEMP_HEADERS
+static TEMP_HEADERS_LENS: Lazy<Vec<u16>> = Lazy::new(|| {
+ TEMP_HEADERS
.iter()
.map(|entry| entry.len() as u16)
- .collect::<Vec<_>>();
-}
+ .collect::<Vec<_>>()
+});
+
pub trait TempTableWidget {
fn draw_temp_table<B: Backend>(
&self, f: &mut Frame<'_, B>, app_state: &mut app::App, draw_loc: Rect, draw_border: bool,
diff --git a/src/constants.rs b/src/constants.rs
index a5bce3cf..0a6de6b1 100644
--- a/src/constants.rs
+++ b/src/constants.rs
@@ -1,6 +1,5 @@
-use lazy_static::lazy_static;
-
use crate::options::ConfigColours;
+use once_cell::sync::Lazy;
// Default widget ID
pub const DEFAULT_WIDGET_ID: u64 = 56709;
@@ -24,120 +23,116 @@ pub const TABLE_GAP_HEIGHT_LIMIT: u16 = 7;
pub const TIME_LABEL_HEIGHT_LIMIT: u16 = 7;
// Side borders
-lazy_static! {
- pub static ref SIDE_BORDERS: tui::widgets::Borders =
- tui::widgets::Borders::from_bits_truncate(20);
- pub static ref TOP_LEFT_RIGHT: tui::widgets::Borders =
- tui::widgets::Borders::from_bits_truncate(22);
- pub static ref BOTTOM_LEFT_RIGHT: tui::widgets::Borders =
- tui::widgets::Borders::from_bits_truncate(28);
- pub static ref DEFAULT_TEXT_STYLE: tui::style::Style =
- tui::style::Style::default().fg(tui::style::Color::Gray);
- pub static ref DEFAULT_HEADER_STYLE: tui::style::Style =
- tui::style::Style::default().fg(tui::style::Color::LightBlue);
-}
+pub static SIDE_BORDERS: Lazy<tui::widgets::Borders> =
+ Lazy::new(|| tui::widgets::Borders::from_bits_truncate(20));
+pub static TOP_LEFT_RIGHT: Lazy<tui::widgets::Borders> =
+ Lazy::new(|| tui::widgets::Borders::from_bits_truncate(22));
+pub static BOTTOM_LEFT_RIGHT: Lazy<tui::widgets::Borders> =
+ Lazy::new(|| tui::widgets::Borders::from_bits_truncate(28));
+pub static DEFAULT_TEXT_STYLE: Lazy<tui::style::Style> =
+ Lazy::new(|| tui::style::Style::default().fg(tui::style::Color::Gray));
+pub static DEFAULT_HEADER_STYLE: Lazy<tui::style::Style> =
+ Lazy::new(|| tui::style::Style::default().fg(tui::style::Color::LightBlue));
// Colour profiles
-lazy_static! {
- pub static ref DEFAULT_LIGHT_MODE_COLOUR_PALETTE: ConfigColours = ConfigColours {
- text_color: Some("black".to_string()),
- border_color: Some("black".to_string()),
- table_header_color: Some("black".to_string()),
- widget_title_color: Some("black".to_string()),
- selected_text_color: Some("white".to_string()),
- graph_color: Some("black".to_string()),
- disabled_text_color: Some("gray".to_string()),
- ..ConfigColours::default()
- };
- pub static ref GRUVBOX_COLOUR_PALETTE: ConfigColours = ConfigColours {
- table_header_color: Some("#83a598".to_string()),
- all_cpu_color: Some("#8ec07c".to_string()),
- avg_cpu_color: Some("#fb4934".to_string()),
- cpu_core_colors: Some(vec![
- "#cc241d".to_string(),
- "#98971a".to_string(),
- "#d79921".to_string(),
- "#458588".to_string(),
- "#b16286".to_string(),
- "#689d6a".to_string(),
- "#fe8019".to_string(),
- "#b8bb26".to_string(),
- "#fabd2f".to_string(),
- "#83a598".to_string(),
- "#d3869b".to_string(),
- "#d65d0e".to_string(),
- "#9d0006".to_string(),
- "#79740e".to_string(),
- "#b57614".to_string(),
- "#076678".to_string(),
- "#8f3f71".to_string(),
- "#427b58".to_string(),
- "#d65d03".to_string(),
- "#af3a03".to_string(),
- ]),
- ram_color: Some("#8ec07c".to_string()),
- swap_color: Some("#fabd2f".to_string()),
- rx_color: Some("#8ec07c".to_string()),
- tx_color: Some("#fabd2f".to_string()),
- rx_total_color: Some("#689d6a".to_string()),
- tx_total_color: Some("#d79921".to_string()),
- border_color: Some("#ebdbb2".to_string()),
- highlighted_border_color: Some("#fe8019".to_string()),
- disabled_text_color: Some("#665c54".to_string()),
- text_color: Some("#ebdbb2".to_string()),
- selected_text_color: Some("#1d2021".to_string()),
- selected_bg_color: Some("#ebdbb2".to_string()),
- widget_title_color: Some("#ebdbb2".to_string()),
- graph_color: Some("#ebdbb2".to_string()),
- high_battery_color: Some("#98971a".to_string()),
- medium_battery_color: Some("#fabd2f".to_string()),
- low_battery_color: Some("#fb4934".to_string())
- };
- pub static ref GRUVBOX_LIGHT_COLOUR_PALETTE: ConfigColours = ConfigColours {
- table_header_color: Some("#076678".to_string()),
- all_cpu_color: Some("#8ec07c".to_string()),
- avg_cpu_color: Some("#fb4934".to_string()),
- cpu_core_colors: Some(vec![
- "#cc241d".to_string(),
- "#98971a".to_string(),
- "#d79921".to_string(),
- "#458588".to_string(),
- "#b16286".to_string(),
- "#689d6a".to_string(),
- "#fe8019".to_string(),
- "#b8bb26".to_string(),
- "#fabd2f".to_string(),
- "#83a598".to_string(),
- "#d3869b".to_string(),
- "#d65d0e".to_string(),
- "#9d0006".to_string(),
- "#79740e".to_string(),
- "#b57614".to_string(),
- "#076678".to_string(),
- "#8f3f71".to_string(),
- "#427b58".to_string(),
- "#d65d03".to_string(),
- "#af3a03".to_string(),
- ]),
- ram_color: Some("#427b58".to_string()),
- swap_color: Some("#cc241d".to_string()),
- rx_color: Some("#427b58".to_string()),
- tx_color: Some("#cc241d".to_string()),
- rx_total_color: Some("#689d6a".to_string()),
- tx_total_color: Some("#9d0006".to_string()),
- border_color: Some("#3c3836".to_string()),
- highlighted_border_color: Some("#af3a03".to_string()),
- disabled_text_color: Some("#d5c4a1".to_string()),
- text_color: Some("#3c3836".to_string()),
- selected_text_color: Some("#ebdbb2".to_string()),
- selected_bg_color: Some("#3c3836".to_string()),
- widget_title_color: Some("#3c3836".to_string()),
- graph_color: Some("#3c3836".to_string()),
- high_battery_color: Some("#98971a".to_string()),
- medium_battery_color: Some("#d79921".to_string()),
- low_battery_color: Some("#cc241d".to_string())
- };
-}
+pub static DEFAULT_LIGHT_MODE_COLOUR_PALETTE: Lazy<ConfigColours> = Lazy::new(|| ConfigColours {
+ text_color: Some("black".to_string()),
+ border_color: Some("black".to_string()),
+ table_header_color: Some("black".to_string()),
+ widget_title_color: Some("black".to_string()),
+ selected_text_color: Some("white".to_string()),
+ graph_color: Some("black".to_string()),
+ disabled_text_color: Some("gray".to_string()),
+ ..ConfigColours::default()
+});
+pub static GRUVBOX_COLOUR_PALETTE: Lazy<ConfigColours> = Lazy::new(|| ConfigColours {
+ table_header_color: Some("#83a598".to_string()),
+ all_cpu_color: Some("#8ec07c".to_string()),
+ avg_cpu_color: Some("#fb4934".to_string()),
+ cpu_core_colors: Some(vec![
+ "#cc241d".to_string(),
+ "#98971a".to_string(),
+ "#d79921".to_string(),
+ "#458588".to_string(),
+ "#b16286".to_string(),
+ "#689d6a".to_string(),
+ "#fe8019".to_string(),
+ "#b8bb26".to_string(),
+ "#fabd2f".to_string(),
+ "#83a598".to_string(),
+ "#d3869b".to_string(),
+ "#d65d0e".to_string(),
+ "#9d0006".to_string(),
+ "#79740e".to_string(),
+ "#b57614".to_string(),
+ "#076678".to_string(),
+ "#8f3f71".to_string(),
+ "#427b58".to_string(),
+ "#d65d03".to_string(),
+ "#af3a03".to_string(),
+ ]),
+ ram_color: Some("#8ec07c".to_string()),
+ swap_color: Some("#fabd2f".to_string()),
+ rx_color: Some("#8ec07c".to_string()),
+ tx_color: Some("#fabd2f".to_string()),
+ rx_total_color: Some("#689d6a".to_string()),
+ tx_total_color: Some("#d79921".to_string()),
+ border_color: Some("#ebdbb2".to_string()),
+ highlighted_border_color: Some("#fe8019".to_string()),
+ disabled_text_color: Some("#665c54".to_string()),
+ text_color: Some("#ebdbb2".to_string()),
+ selected_text_color: Some("#1d2021".to_string()),
+ selected_bg_color: Some("#ebdbb2".to_string()),
+ widget_title_color: Some("#ebdbb2".to_string()),
+ graph_color: Some("#ebdbb2".to_string()),
+ high_battery_color: Some("#98971a".to_string()),
+ medium_battery_color: Some("#fabd2f".to_string()),
+ low_battery_color: Some("#fb4934".to_string()),
+});
+pub static GRUVBOX_LIGHT_COLOUR_PALETTE: Lazy<ConfigColours> = Lazy::new(|| ConfigColours {
+ table_header_color: Some("#076678".to_string()),
+ all_cpu_color: Some("#8ec07c".to_string()),
+ avg_cpu_color: Some("#fb4934".to_string()),
+ cpu_core_colors: Some(vec![
+ "#cc241d".to_string(),
+ "#98971a".to_string(),
+ "#d79921".to_string(),
+ "#458588".to_string(),
+ "#b16286".to_string(),
+ "#689d6a".to_string(),
+ "#fe8019".to_string(),
+ "#b8bb26".to_string(),
+ "#fabd2f".to_string(),
+ "#83a598".to_string(),
+ "#d3869b".to_string(),
+ "#d65d0e".to_string(),
+ "#9d0006".to_string(),
+ "#79740e".to_string(),
+ "#b57614".to_string(),
+ "#076678".to_string(),
+ "#8f3f71".to_string(),
+ "#427b58".to_string(),
+ "#d65d03".to_string(),
+ "#af3a03".to_string(),
+ ]),
+ ram_color: Some("#427b58".to_string()),
+ swap_color: Some("#cc241d".to_string()),
+ rx_color: Some("#427b58".to_string()),
+ tx_color: Some("#cc241d".to_string()),
+ rx_total_color: Some("#689d6a".to_string()),
+ tx_total_color: Some("#9d0006".to_string()),
+ border_color: Some("#3c3836".to_string()),
+ highlighted_border_color: Some("#af3a03".to_string()),
+ disabled_text_color: Some("#d5c4a1".to_string()),
+ text_color: Some("#3c3836".to_string()),
+ selected_text_color: Some("#ebdbb2".to_string()),
+ selected_bg_color: Some("#3c3836".to_string()),
+ widget_title_color: Some("#3c3836".to_string()),
+ graph_color: Some("#3c3836".to_string()),
+ high_battery_color: Some("#98971a".to_string()),
+ medium_battery_color: Some("#d79921".to_string()),
+ low_battery_color: Some("#cc241d".to_string()),
+});
// Help text
pub const HELP_CONTENTS_TEXT: [&str; 8] = [
@@ -277,8 +272,8 @@ pub const BASIC_MEM_HELP_TEXT: [&str; 2] = [
"% Toggle between values and percentages for memory usage",
];
-lazy_static! {
- pub static ref HELP_TEXT: Vec<Vec<&'static str>> = vec![
+pub static HELP_TEXT: Lazy<Vec<Vec<&'static str>>> = Lazy::new(|| {
+ vec![
HELP_CONTENTS_TEXT.to_vec(),
GENERAL_HELP_TEXT.to_vec(),
CPU_HELP_TEXT.to_vec(),
@@ -287,8 +282,8 @@ lazy_static! {
SORT_HELP_TEXT.to_vec(),
BATTERY_HELP_TEXT.to_vec(),
BASIC_MEM_HELP_TEXT.to_vec(),
- ];
-}
+ ]
+});
// Default layouts
pub const DEFAULT_LAYOUT: &str = r##"
diff --git a/src/data_conversion.rs b/src/data_conversion.rs
index 5bf31edf..db1f5bb9 100644
--- a/src/data_conversion.rs
+++ b/src/data_conversion.rs
@@ -62,6 +62,7 @@ pub struct ConvertedProcessData {
pub tw_f64: f64,
pub process_state: String,
pub process_char: char,
+
/// Prefix printed before the process when displayed.
pub process_description_prefix: Option<String>,
/// Whether to mark this process entry as disabled (mostly for tree mode).