Added total rx + tx colouring options.

This commit is contained in:
ClementTsang 2020-02-27 17:54:39 -05:00
parent b32d2dca26
commit b00740a7dd
4 changed files with 41 additions and 13 deletions

View File

@ -901,14 +901,18 @@ impl Painter {
}) })
.style(self.colours.tx_style) .style(self.colours.tx_style)
.data(&network_data_tx), .data(&network_data_tx),
Dataset::default().name(&format!( Dataset::default()
"Total RX: {:7}", .name(&format!(
app_state.canvas_data.total_rx_display "Total RX: {:7}",
)), app_state.canvas_data.total_rx_display
Dataset::default().name(&format!( ))
"Total TX: {:7}", .style(self.colours.rx_total_style),
app_state.canvas_data.total_tx_display Dataset::default()
)), .name(&format!(
"Total TX: {:7}",
app_state.canvas_data.total_tx_display
))
.style(self.colours.tx_total_style),
]) ])
.render(f, draw_loc); .render(f, draw_loc);
} }

View File

@ -13,6 +13,8 @@ pub struct CanvasColours {
pub swap_style: Style, pub swap_style: Style,
pub rx_style: Style, pub rx_style: Style,
pub tx_style: Style, pub tx_style: Style,
pub rx_total_style: Style,
pub tx_total_style: Style,
pub avg_colour_style: Style, pub avg_colour_style: Style,
pub cpu_colour_styles: Vec<Style>, pub cpu_colour_styles: Vec<Style>,
pub border_style: Style, pub border_style: Style,
@ -30,13 +32,13 @@ impl Default for CanvasColours {
currently_selected_text_colour: Color::Black, currently_selected_text_colour: Color::Black,
currently_selected_bg_colour: Color::Cyan, currently_selected_bg_colour: Color::Cyan,
currently_selected_text_style: Style::default().fg(Color::Black).bg(Color::Cyan), currently_selected_text_style: Style::default().fg(Color::Black).bg(Color::Cyan),
table_header_style: Style::default() table_header_style: Style::default().fg(Color::LightBlue),
.fg(Color::LightBlue)
.modifier(Modifier::BOLD),
ram_style: Style::default().fg(STANDARD_FIRST_COLOUR), ram_style: Style::default().fg(STANDARD_FIRST_COLOUR),
swap_style: Style::default().fg(STANDARD_SECOND_COLOUR), swap_style: Style::default().fg(STANDARD_SECOND_COLOUR),
rx_style: Style::default().fg(STANDARD_FIRST_COLOUR), rx_style: Style::default().fg(STANDARD_FIRST_COLOUR),
tx_style: Style::default().fg(STANDARD_SECOND_COLOUR), tx_style: Style::default().fg(STANDARD_SECOND_COLOUR),
rx_total_style: Style::default().fg(STANDARD_THIRD_COLOUR),
tx_total_style: Style::default().fg(STANDARD_FOURTH_COLOUR),
avg_colour_style: Style::default().fg(AVG_COLOUR), avg_colour_style: Style::default().fg(AVG_COLOUR),
cpu_colour_styles: Vec::new(), cpu_colour_styles: Vec::new(),
border_style: Style::default().fg(text_colour), border_style: Style::default().fg(text_colour),
@ -89,6 +91,16 @@ impl CanvasColours {
Ok(()) Ok(())
} }
pub fn set_rx_total_colour(&mut self, colour: &str) -> error::Result<()> {
self.rx_total_style = get_style_from_config(colour)?;
Ok(())
}
pub fn set_tx_total_colour(&mut self, colour: &str) -> error::Result<()> {
self.tx_total_style = get_style_from_config(colour)?;
Ok(())
}
pub fn set_avg_cpu_colour(&mut self, colour: &str) -> error::Result<()> { pub fn set_avg_cpu_colour(&mut self, colour: &str) -> error::Result<()> {
self.avg_colour_style = get_style_from_config(colour)?; self.avg_colour_style = get_style_from_config(colour)?;
Ok(()) Ok(())

View File

@ -5,6 +5,8 @@ use tui::style::{Color, Style};
const GOLDEN_RATIO: f32 = 0.618_034; // Approx, good enough for use (also Clippy gets mad if it's too long) const GOLDEN_RATIO: f32 = 0.618_034; // Approx, good enough for use (also Clippy gets mad if it's too long)
pub const STANDARD_FIRST_COLOUR: Color = Color::LightMagenta; pub const STANDARD_FIRST_COLOUR: Color = Color::LightMagenta;
pub const STANDARD_SECOND_COLOUR: Color = Color::LightYellow; pub const STANDARD_SECOND_COLOUR: Color = Color::LightYellow;
pub const STANDARD_THIRD_COLOUR: Color = Color::LightCyan;
pub const STANDARD_FOURTH_COLOUR: Color = Color::LightGreen;
pub const AVG_COLOUR: Color = Color::Red; pub const AVG_COLOUR: Color = Color::Red;
lazy_static! { lazy_static! {
@ -66,8 +68,8 @@ pub fn gen_n_styles(num_to_gen: i32) -> Vec<Style> {
let mut colour_vec: Vec<Style> = vec![ let mut colour_vec: Vec<Style> = vec![
Style::default().fg(STANDARD_FIRST_COLOUR), Style::default().fg(STANDARD_FIRST_COLOUR),
Style::default().fg(STANDARD_SECOND_COLOUR), Style::default().fg(STANDARD_SECOND_COLOUR),
Style::default().fg(Color::LightCyan), Style::default().fg(STANDARD_THIRD_COLOUR),
Style::default().fg(Color::LightGreen), Style::default().fg(STANDARD_FOURTH_COLOUR),
Style::default().fg(Color::LightBlue), Style::default().fg(Color::LightBlue),
Style::default().fg(Color::LightRed), Style::default().fg(Color::LightRed),
Style::default().fg(Color::Cyan), Style::default().fg(Color::Cyan),

View File

@ -93,6 +93,8 @@ struct ConfigColours {
swap_color: Option<String>, swap_color: Option<String>,
rx_color: Option<String>, rx_color: Option<String>,
tx_color: Option<String>, tx_color: Option<String>,
rx_total_color: Option<String>,
tx_total_color: Option<String>,
border_color: Option<String>, border_color: Option<String>,
highlighted_border_color: Option<String>, highlighted_border_color: Option<String>,
text_color: Option<String>, text_color: Option<String>,
@ -731,6 +733,14 @@ fn generate_config_colours(config: &Config, painter: &mut canvas::Painter) -> er
painter.colours.set_tx_colour(tx_color)?; painter.colours.set_tx_colour(tx_color)?;
} }
if let Some(rx_total_color) = &colours.rx_total_color {
painter.colours.set_rx_total_colour(rx_total_color)?;
}
if let Some(tx_total_color) = &colours.tx_total_color {
painter.colours.set_tx_total_colour(tx_total_color)?;
}
if let Some(table_header_color) = &colours.table_header_color { if let Some(table_header_color) = &colours.table_header_color {
painter painter
.colours .colours