From b32d2dca26e1703d0753ca801ce85038749983ba Mon Sep 17 00:00:00 2001 From: ClementTsang Date: Thu, 27 Feb 2020 17:42:34 -0500 Subject: [PATCH 1/2] Tiny formatting fix. --- src/canvas/canvas_colours.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/canvas/canvas_colours.rs b/src/canvas/canvas_colours.rs index 667bc6e5..b69a98ab 100644 --- a/src/canvas/canvas_colours.rs +++ b/src/canvas/canvas_colours.rs @@ -53,38 +53,47 @@ impl CanvasColours { self.text_style = get_style_from_config(colour)?; Ok(()) } + pub fn set_border_colour(&mut self, colour: &str) -> error::Result<()> { self.border_style = get_style_from_config(colour)?; Ok(()) } + pub fn set_highlighted_border_colour(&mut self, colour: &str) -> error::Result<()> { self.highlighted_border_style = get_style_from_config(colour)?; Ok(()) } + pub fn set_table_header_colour(&mut self, colour: &str) -> error::Result<()> { self.table_header_style = get_style_from_config(colour)?.modifier(Modifier::BOLD); Ok(()) } + pub fn set_ram_colour(&mut self, colour: &str) -> error::Result<()> { self.ram_style = get_style_from_config(colour)?; Ok(()) } + pub fn set_swap_colour(&mut self, colour: &str) -> error::Result<()> { self.swap_style = get_style_from_config(colour)?; Ok(()) } + pub fn set_rx_colour(&mut self, colour: &str) -> error::Result<()> { self.rx_style = get_style_from_config(colour)?; Ok(()) } + pub fn set_tx_colour(&mut self, colour: &str) -> error::Result<()> { self.tx_style = get_style_from_config(colour)?; Ok(()) } + pub fn set_avg_cpu_colour(&mut self, colour: &str) -> error::Result<()> { self.avg_colour_style = get_style_from_config(colour)?; Ok(()) } + pub fn set_cpu_colours(&mut self, colours: &[String]) -> error::Result<()> { let max_amount = std::cmp::min(colours.len(), NUM_COLOURS as usize); for (itx, colour) in colours.iter().enumerate() { @@ -95,6 +104,7 @@ impl CanvasColours { } Ok(()) } + pub fn generate_remaining_cpu_colours(&mut self) { let remaining_num_colours = NUM_COLOURS - self.cpu_colour_styles.len() as i32; self.cpu_colour_styles @@ -108,6 +118,7 @@ impl CanvasColours { .bg(self.currently_selected_bg_colour); Ok(()) } + pub fn set_scroll_entry_bg_color(&mut self, colour: &str) -> error::Result<()> { self.currently_selected_bg_colour = get_colour_from_config(colour)?; self.currently_selected_text_style = Style::default() From b00740a7dd4f49b89370e77bd34553d648f7f647 Mon Sep 17 00:00:00 2001 From: ClementTsang Date: Thu, 27 Feb 2020 17:54:39 -0500 Subject: [PATCH 2/2] Added total rx + tx colouring options. --- src/canvas.rs | 20 ++++++++++++-------- src/canvas/canvas_colours.rs | 18 +++++++++++++++--- src/canvas/canvas_colours/colour_utils.rs | 6 ++++-- src/main.rs | 10 ++++++++++ 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/canvas.rs b/src/canvas.rs index 24644a27..00d7130f 100644 --- a/src/canvas.rs +++ b/src/canvas.rs @@ -901,14 +901,18 @@ impl Painter { }) .style(self.colours.tx_style) .data(&network_data_tx), - Dataset::default().name(&format!( - "Total RX: {:7}", - app_state.canvas_data.total_rx_display - )), - Dataset::default().name(&format!( - "Total TX: {:7}", - app_state.canvas_data.total_tx_display - )), + Dataset::default() + .name(&format!( + "Total RX: {:7}", + app_state.canvas_data.total_rx_display + )) + .style(self.colours.rx_total_style), + Dataset::default() + .name(&format!( + "Total TX: {:7}", + app_state.canvas_data.total_tx_display + )) + .style(self.colours.tx_total_style), ]) .render(f, draw_loc); } diff --git a/src/canvas/canvas_colours.rs b/src/canvas/canvas_colours.rs index b69a98ab..949a90c5 100644 --- a/src/canvas/canvas_colours.rs +++ b/src/canvas/canvas_colours.rs @@ -13,6 +13,8 @@ pub struct CanvasColours { pub swap_style: Style, pub rx_style: Style, pub tx_style: Style, + pub rx_total_style: Style, + pub tx_total_style: Style, pub avg_colour_style: Style, pub cpu_colour_styles: Vec