diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2020-08-16 01:25:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-16 04:25:59 -0400 |
commit | 08e49b63c162f16cb35262cd48da324c779c1a1c (patch) | |
tree | 446d654cb60cbd0475b193b6e28900bad46c88e8 | |
parent | 9068108d0fe977ec6fc01dc7d8d29674a88c2f6a (diff) |
refactor: Revert tui upgrade to 0.10
Reverts tui upgrade, there are some bugs and issues - namely, issues with rendering text.
We can revert this commit when those bugs are dealt with (should be fine after 0.10.1, tested building from the repo).
-rw-r--r-- | Cargo.lock | 6 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/canvas.rs | 79 | ||||
-rw-r--r-- | src/canvas/canvas_colours.rs | 2 | ||||
-rw-r--r-- | src/canvas/dialogs/dd_dialog.rs | 149 | ||||
-rw-r--r-- | src/canvas/dialogs/help_dialog.rs | 36 | ||||
-rw-r--r-- | src/canvas/widgets/basic_table_arrows.rs | 15 | ||||
-rw-r--r-- | src/canvas/widgets/battery_display.rs | 128 | ||||
-rw-r--r-- | src/canvas/widgets/cpu_basic.rs | 22 | ||||
-rw-r--r-- | src/canvas/widgets/cpu_graph.rs | 47 | ||||
-rw-r--r-- | src/canvas/widgets/disk_table.rs | 46 | ||||
-rw-r--r-- | src/canvas/widgets/mem_basic.rs | 13 | ||||
-rw-r--r-- | src/canvas/widgets/mem_graph.rs | 50 | ||||
-rw-r--r-- | src/canvas/widgets/network_basic.rs | 26 | ||||
-rw-r--r-- | src/canvas/widgets/network_graph.rs | 55 | ||||
-rw-r--r-- | src/canvas/widgets/process_table.rs | 80 | ||||
-rw-r--r-- | src/canvas/widgets/temp_table.rs | 30 | ||||
-rw-r--r-- | src/constants.rs | 188 |
18 files changed, 548 insertions, 426 deletions
@@ -1345,13 +1345,15 @@ checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" [[package]] name = "tui" -version = "0.10.0" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a977b0bb2e2033a6fef950f218f13622c3c34e59754b704ce3492dedab1dfe95" +checksum = "9533d39bef0ae8f510e8a99d78702e68d1bbf0b98a78ec9740509d287010ae1e" dependencies = [ "bitflags", "cassowary", "crossterm", + "either", + "itertools", "unicode-segmentation", "unicode-width", ] @@ -39,7 +39,7 @@ serde = {version = "1.0", features = ["derive"] } unicode-segmentation = "1.6.0" unicode-width = "0.1.7" # tui = {version = "0.10.0", features = ["crossterm"], default-features = false, git = "https://github.com/fdehau/tui-rs.git"} -tui = {version = "0.10.0", features = ["crossterm"], default-features = false } +tui = {version = "0.9.5", features = ["crossterm"], default-features = false } # For debugging only... fern = "0.6.0" diff --git a/src/canvas.rs b/src/canvas.rs index 8ff9c31b..563651b8 100644 --- a/src/canvas.rs +++ b/src/canvas.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use tui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, - text::{Span, Spans}, + widgets::Text, Frame, Terminal, }; @@ -55,7 +55,7 @@ pub struct Painter { pub colours: CanvasColours, height: u16, width: u16, - styled_help_text: Vec<Spans<'static>>, + styled_help_text: Vec<Text<'static>>, is_mac_os: bool, row_constraints: Vec<Constraint>, col_constraints: Vec<Vec<Constraint>>, @@ -163,27 +163,28 @@ impl Painter { styled_help_spans.extend( section .iter() - .map(|&text| Span::styled(text, self.colours.text_style)) + .map(|&text| Text::styled(text, self.colours.text_style)) .collect::<Vec<_>>(), ); } else { // Not required check but it runs only a few times... so whatever ig, prevents me from // being dumb and leaving a help text section only one line long. if section.len() > 1 { - styled_help_spans.push(Span::from("")); + styled_help_spans.push(Text::raw("\n\n")); styled_help_spans - .push(Span::styled(section[0], self.colours.table_header_style)); + .push(Text::styled(section[0], self.colours.table_header_style)); styled_help_spans.extend( section[1..] .iter() - .map(|&text| Span::styled(text, self.colours.text_style)) + .map(|&text| Text::styled(text, self.colours.text_style)) .collect::<Vec<_>>(), ); } } }); - self.styled_help_text = styled_help_spans.into_iter().map(Spans::from).collect(); + // self.styled_help_text = styled_help_spans.into_iter().map(Spans::from).collect(); + self.styled_help_text = styled_help_spans; } pub fn draw_data<B: Backend>( @@ -251,36 +252,44 @@ impl Painter { let dd_text = self.get_dd_spans(app_state); - let (text_width, text_height) = if let Some(dd_text) = &dd_text { - let width = if f.size().width < 100 { + let (text_width, text_height) = ( + if f.size().width < 100 { f.size().width * 90 / 100 } else { - let min_possible_width = (f.size().width * 50 / 100) as usize; - let mut width = dd_text.width(); - - // This should theoretically never allow width to be 0... we can be safe and do an extra check though. - while width > (f.size().width as usize) && width / 2 > min_possible_width { - width /= 2; - } - - std::cmp::max(width, min_possible_width) as u16 - }; - - ( - width, - (dd_text.height() + 2 + (dd_text.width() / width as usize)) as u16, - ) - } else { - // AFAIK this shouldn't happen, unless something went wrong... - ( - if f.size().width < 100 { - f.size().width * 90 / 100 - } else { - f.size().width * 50 / 100 - }, - 7, - ) - }; + f.size().width * 50 / 100 + }, + 7, + ); + // let (text_width, text_height) = if let Some(dd_text) = &dd_text { + // let width = if f.size().width < 100 { + // f.size().width * 90 / 100 + // } else { + // let min_possible_width = (f.size().width * 50 / 100) as usize; + // let mut width = dd_text.width(); + + // // This should theoretically never allow width to be 0... we can be safe and do an extra check though. + // while width > (f.size().width as usize) && width / 2 > min_possible_width { + // width /= 2; + // } + + // std::cmp::max(width, min_possible_width) as u16 + // }; + + // ( + // width, + // (dd_text.height() + 2 + (dd_text.width() / width as usize)) as u16, + // ) + // } else { + // // AFAIK this shouldn't happen, unless something went wrong... + // ( + // if f.size().width < 100 { + // f.size().width * 90 / 100 + // } else { + // f.size().width * 50 / 100 + // }, + // 7, + // ) + // }; let vertical_bordering = f.size().height.saturating_sub(text_height) / 2; let vertical_dialog_chunk = Layout::default() diff --git a/src/canvas/canvas_colours.rs b/src/canvas/canvas_colours.rs index 5d0e6584..d7724568 100644 --- a/src/canvas/canvas_colours.rs +++ b/src/canvas/canvas_colours.rs @@ -85,7 +85,7 @@ impl CanvasColours { } pub fn set_table_header_colour(&mut self, colour: &str) -> error::Result<()> { - self.table_header_style = get_style_from_config(colour)?.add_modifier(Modifier::BOLD); + self.table_header_style = get_style_from_config(colour)?.modifier(Modifier::BOLD); Ok(()) } diff --git a/src/canvas/dialogs/dd_dialog.rs b/src/canvas/dialogs/dd_dialog.rs index 18f89d68..8b3f342c 100644 --- a/src/canvas/dialogs/dd_dialog.rs +++ b/src/canvas/dialogs/dd_dialog.rs @@ -2,8 +2,7 @@ use tui::{ backend::Backend, layout::{Alignment, Rect}, terminal::Frame, - text::{Span, Spans, Text}, - widgets::{Block, Borders, Paragraph, Wrap}, + widgets::{Block, Borders, Paragraph, Text}, }; use crate::{app::App, canvas::Painter}; @@ -12,61 +11,58 @@ const DD_BASE: &str = " Confirm Kill Process ── Esc to close "; const DD_ERROR_BASE: &str = " Error ── Esc to close "; pub trait KillDialog { - fn get_dd_spans(&self, app_state: &App) -> Option<Text<'_>>; + fn get_dd_spans(&self, app_state: &App) -> Option<Vec<Text<'_>>>; fn draw_dd_dialog<B: Backend>( - &self, f: &mut Frame<'_, B>, dd_text: Option<Text<'_>>, app_state: &App, draw_loc: Rect, + &self, f: &mut Frame<'_, B>, dd_text: Option<Vec<Text<'_>>>, app_state: &App, + draw_loc: Rect, ) -> bool; } impl KillDialog for Painter { - fn get_dd_spans(&self, app_state: &App) -> Option<Text<'_>> { + fn get_dd_spans(&self, app_state: &App) -> Option<Vec<Text<'_>>> { if let Some(dd_err) = &app_state.dd_err { - return Some(Text::from(Spans::from(format!( - "Failure to properly kill the process - {}", - dd_err - )))); + return Some(vec![ + Text::raw("\n"), + Text::raw(format!("Failure to properly kill the process - {}", dd_err)), + ]); } else if let Some(to_kill_processes) = app_state.get_to_delete_processes() { if let Some(first_pid) = to_kill_processes.1.first() { - return Some(Text::from(vec![ - Spans::from(vec![]), - Spans::from(vec![ - if app_state.is_grouped(app_state.current_widget.widget_id) { - if to_kill_processes.1.len() != 1 { - Span::from(format!( - "Kill {} processes with the name \"{}\"?", - to_kill_processes.1.len(), - to_kill_processes.0 - )) - } else { - Span::from(format!( - "Kill 1 process with the name \"{}\"?", - to_kill_processes.0 - )) - } - } else { - Span::from(format!( - "Kill process \"{}\" with PID {}?", - to_kill_processes.0, first_pid + return Some(vec![ + Text::raw("\n"), + if app_state.is_grouped(app_state.current_widget.widget_id) { + if to_kill_processes.1.len() != 1 { + Text::raw(format!( + "Kill {} processes with the name \"{}\"?", + to_kill_processes.1.len(), + to_kill_processes.0 )) - }, - ]), - Spans::from(vec![]), - Spans::from(vec![ - if app_state.delete_dialog_state.is_on_yes { - Span::styled("Yes", self.colours.currently_selected_text_style) - } else { - Span::from("Yes") - }, - Span::from(" "), - if app_state.delete_dialog_state.is_on_yes { - Span::from("No") } else { - Span::styled("No", self.colours.currently_selected_text_style) - }, - ]), - Spans::from(vec![]), - ])); + Text::raw(format!( + "Kill 1 process with the name \"{}\"?", + to_kill_processes.0 + )) + } + } else { + Text::raw(format!( + "Kill process \"{}\" with PID {}?", + to_kill_processes.0, first_pid + )) + }, + Text::raw("\n\n"), + if app_state.delete_dialog_state.is_on_yes { + Text::styled("Yes", self.colours.currently_selected_text_style) + } else { + Text::raw("Yes") + }, + Text::raw(" "), + if app_state.delete_dialog_state.is_on_yes { + Text::raw("No") + } else { + Text::styled("No", self.colours.currently_selected_text_style) + }, + Text::raw("\n"), + ]); } } @@ -74,44 +70,63 @@ impl KillDialog for Painter { } fn draw_dd_dialog<B: Backend>( - &self, f: &mut Frame<'_, B>, dd_text: Option<Text<'_>>, app_state: &App, draw_loc: Rect, + &self, f: &mut Frame<'_, B>, dd_text: Option<Vec<Text<'_>>>, app_state: &App, + draw_loc: Rect, ) -> bool { if let Some(dd_text) = dd_text { + // let dd_title = if app_state.dd_err.is_some() { + // Text::styled( + // format!( + // " Error ─{}─ Esc to close ", + // "─".repeat( + // usize::from(draw_loc.width) + // .saturating_sub(DD_ERROR_BASE.chars().count() + 2) + // ) + // ), + // self.colours.border_style, + // ) + // } else { + // Text::styled( + // format!( + // " Confirm Kill Process ─{}─ Esc to close ", + // "─".repeat( + // usize::from(draw_loc.width).saturating_sub(DD_BASE.chars().count() + 2) + // ) + // ), + // self.colours.border_style, + // ) + // }; + let dd_title = if app_state.dd_err.is_some() { - Span::styled( - format!( - " Error ─{}─ Esc to close ", - "─".repeat( - usize::from(draw_loc.width) - .saturating_sub(DD_ERROR_BASE.chars().count() + 2) - ) - ), - self.colours.border_style, + format!( + " Error ─{}─ Esc to close ", + "─".repeat( + usize::from(draw_loc.width) + .saturating_sub(DD_ERROR_BASE.chars().count() + 2) + ) ) } else { - Span::styled( - format!( - " Confirm Kill Process ─{}─ Esc to close ", - "─".repeat( - usize::from(draw_loc.width).saturating_sub(DD_BASE.chars().count() + 2) - ) - ), - self.colours.border_style, + format!( + " Confirm Kill Process ─{}─ Esc to close ", + "─".repeat( + usize::from(draw_loc.width).saturating_sub(DD_BASE.chars().count() + 2) + ) ) }; f.render_widget( - Paragraph::new(dd_text) + Paragraph::new(dd_text.iter()) .block( Block::default() - .title(dd_title) + .title(&dd_title) + .title_style(self.colours.border_style) .style(self.colours.border_style) .borders(Borders::ALL) .border_style(self.colours.border_style), ) .style(self.colours.text_style) .alignment(Alignment::Center) - .wrap(Wrap { trim: true }), + .wrap(true), draw_loc, ); diff --git a/src/canvas/dialogs/help_dialog.rs b/src/canvas/dialogs/help_dialog.rs index 138622ce..8ef4d010 100644 --- a/src/canvas/dialogs/help_dialog.rs +++ b/src/canvas/dialogs/help_dialog.rs @@ -4,8 +4,7 @@ use tui::{ backend::Backend, layout::{Alignment, Rect}, terminal::Frame, - text::Span, - widgets::{Block, Borders, Paragraph, Wrap}, + widgets::{Block, Borders, Paragraph}, }; use crate::{app::App, canvas::Painter, constants}; @@ -22,14 +21,19 @@ impl HelpDialog for Painter { fn draw_help_dialog<B: Backend>( &self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, ) { - let help_title = Span::styled( - format!( - " Help ─{}─ Esc to close ", - "─".repeat( - usize::from(draw_loc.width).saturating_sub(HELP_BASE.chars().count() + 2) - ) - ), - self.colours.border_style, + // let help_title = Text::styled( + // format!( + // " Help ─{}─ Esc to close ", + // "─".repeat( + // usize::from(draw_loc.width).saturating_sub(HELP_BASE.chars().count() + 2) + // ) + // ), + // self.colours.border_style, + // ); + + let help_title = format!( + " Help ─{}─ Esc to close ", + "─".repeat(usize::from(draw_loc.width).saturating_sub(HELP_BASE.chars().count() + 2)) ); if app_state.is_force_redraw { @@ -95,24 +99,24 @@ impl HelpDialog for Painter { } f.render_widget( - Paragraph::new(self.styled_help_text.clone()) + Paragraph::new(self.styled_help_text.iter()) .block( Block::default() - .title(help_title) + .title(&help_title) + .title_style(self.colours.border_style) .style(self.colours.border_style) .borders(Borders::ALL) .border_style(self.colours.border_style), ) .style(self.colours.text_style) .alignment(Alignment::Left) - .wrap(Wrap { trim: true }) - .scroll(( + .wrap(true) + .scroll( app_state .help_dialog_state .scroll_state .current_scroll_index, - 0, - )), + ), draw_loc, ); } diff --git a/src/canvas/widgets/basic_table_arrows.rs b/src/canvas/widgets/basic_table_arrows.rs index 18beab83..591f71c6 100644 --- a/src/canvas/widgets/basic_table_arrows.rs +++ b/src/canvas/widgets/basic_table_arrows.rs @@ -10,8 +10,7 @@ use tui::{ backend::Backend, layout::{Constraint, Layout, Rect}, terminal::Frame, - text::{Span, Spans}, - widgets::{Block, Paragraph}, + widgets::{Block, Paragraph, Text}, }; pub trait BasicTableArrows { @@ -98,12 +97,10 @@ impl BasicTableArrows for Painter { usize::from(draw_loc.width).saturating_sub(6 + left_name.len() + right_name.len()); let arrow_text = vec![ - Spans::from(Span::from(String::default())), - Spans::from(vec![ - Span::styled(format!("◄ {}", left_name), self.colours.text_style), - Span::from(" ".repeat(num_spaces)), - Span::styled(format!("{} ►", right_name), self.colours.text_style), - ]), + Text::raw("\n"), + Text::styled(format!("◄ {}", left_name), self.colours.text_style), + Text::raw(" ".repeat(num_spaces)), + Text::styled(format!("{} ►", right_name), self.colours.text_style), ]; let margined_draw_loc = Layout::default() @@ -112,7 +109,7 @@ impl BasicTableArrows for Painter { .split(draw_loc); f.render_widget( - Paragraph::new(arrow_text).block(Block::default()), + Paragraph::new(arrow_text.iter()).block(Block::default()), margined_draw_loc[0], ); } diff --git a/src/canvas/widgets/battery_display.rs b/src/canvas/widgets/battery_display.rs index d716b53e..7c3b7896 100644 --- a/src/canvas/widgets/battery_display.rs +++ b/src/canvas/widgets/battery_display.rs @@ -8,8 +8,7 @@ use tui::{ backend::Backend, layout::{Constraint, Rect}, terminal::Frame, - text::{Span, Spans}, - widgets::{Block, Borders, Paragraph, Row, Table, Tabs}, + widgets::{Block, Borders, Paragraph, Row, Table, Tabs, Text}, }; pub trait BatteryDisplayWidget { @@ -34,25 +33,45 @@ impl BatteryDisplayWidget for Painter { self.colours.border_style }; + // let title = if app_state.is_expanded { + // const TITLE_BASE: &str = " Battery ── Esc to go back "; + // Span::styled( + // format!( + // " Battery ─{}─ Esc to go back ", + // "─".repeat( + // usize::from(draw_loc.width) + // .saturating_sub(TITLE_BASE.chars().count() + 2) + // ) + // ), + // border_and_title_style, + // ) + // } else { + // Span::styled(" Battery ".to_string(), self.colours.widget_title_style) + // }; + let title = if app_state.is_expanded { const TITLE_BASE: &str = " Battery ── Esc to go back "; - Span::styled( - format!( - " Battery ─{}─ Esc to go back ", - "─".repeat( - usize::from(draw_loc.width) - .saturating_sub(TITLE_BASE.chars().count() + 2) - ) - ), - border_and_title_style, + + format!( + " Battery ─{}─ Esc to go back ", + "─".repeat( + usize::from(draw_loc.width).saturating_sub(TITLE_BASE.chars().count() + 2) + ) ) } else { - Span::styled(" Battery ".to_string(), self.colours.widget_title_style) + " Battery ".to_string() + }; + + let title_style = if app_state.is_expanded { + border_and_title_style + } else { + self.colours.widget_title_style }; let battery_block = if draw_border { Block::default() - .title(title) + .title(&title) + .title_style(title_style) .borders(Borders::ALL) .border_style(border_and_title_style) } else if is_on_widget { @@ -63,22 +82,32 @@ impl BatteryDisplayWidget for Painter { Block::default().borders(Borders::NONE) }; - f.render_widget( - Tabs::new( - (app_state - .canvas_data - .battery_data - .iter() - .map(|battery| Spans::from(battery.battery_name.clone()))) - .collect::<Vec<_>>(), - ) - .block(battery_block.clone()) - .divider(tui::symbols::line::VERTICAL) - .style(self.colours.text_style) - .highlight_style(self.colours.currently_selected_text_style) - .select(battery_widget_state.currently_selected_battery_index), - draw_loc, - ); + // f.render_widget( + // // Tabs::new( + // // (app_state + // // .canvas_data + // // .battery_data + // // .iter() + // // .map(|battery| Spans::from(battery.battery_name.clone()))) + // // .collect::<Vec<_>>(), + // // ) + // Tabs::default() + // .titles( + // app_state + // .canvas_data + // .battery_data + // .iter() + // .map(|battery| &battery.battery_name) + // .collect::<Vec<_>>() + // .as_ref(), + // ) + // .block(battery_block) + // .divider(tui::symbols::line::VERTICAL) + // .style(self.colours.text_style) + // .highlight_style(self.colours.currently_selected_text_style) + // .select(battery_widget_state.currently_selected_battery_index), + // draw_loc, + // ); if let Some(battery_details) = app_state .canvas_data @@ -134,21 +163,52 @@ impl BatteryDisplayWidget for Painter { // Draw f.render_widget( Table::new([""].iter(), battery_rows) - .block(battery_block.clone()) + .block(battery_block) .header_style(self.colours.table_header_style) .widths([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref()), draw_loc, ); } else { f.render_widget( - Paragraph::new(Spans::from(Span::styled( - "No data found for this battery", - self.colours.text_style, - ))) + Paragraph::new( + [Text::styled( + "No data found for this battery", + self.colours.text_style, + )] + .iter(), + ) .block(battery_block), draw_loc, ); } + + // Has to be placed AFTER for tui 0.9, place BEFORE for 0.10. + f.render_widget( + // Tabs::new( + // (app_state + // .canvas_data + // .battery_data + // .iter() + // .map(|battery| Spans::from(battery.battery_name.clone()))) + // .collect::<Vec<_>>(), + // ) + Tabs::default() + .titles( + app_state + .canvas_data + .battery_data + .iter() + .map(|battery| &battery.battery_name) + .collect::<Vec<_>>() + .as_ref(), + ) + .block(battery_block) + .divider(tui::symbols::line::VERTICAL) + .style(self.colours.text_style) + .highlight_style(self.colours.currently_selected_text_style) + .select(battery_widget_state.currently_selected_battery_index), + draw_loc, + ); } } } diff --git a/src/canvas/widgets/cpu_basic.rs b/src/canvas/widgets/cpu_basic.rs index c8db2f33..4683a677 100644 --- a/src/canvas/widgets/cpu_basic.rs +++ b/src/canvas/widgets/cpu_basic.rs @@ -11,8 +11,7 @@ use tui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, terminal::Frame, - text::{Span, Spans}, - widgets::{Block, Paragraph}, + widgets::{Block, Paragraph, Text}, }; pub trait CpuBasicWidget { @@ -77,10 +76,10 @@ impl CpuBasicWidget for Painter { let num_bars = calculate_basic_use_bars(use_percentage, bar_length); format!( - "{:3}[{}{}{:3.0}%]", + "{:3}[{}{}{:3.0}%]\n", if app_state.app_config_fields.show_average_cpu { if cpu_index == 0 { - " AVG".to_string() + "AVG".to_string() } else { (cpu_index - 1).to_string() } @@ -109,11 +108,16 @@ impl CpuBasicWidget for Painter { let end_index = min(start_index + how_many_cpus, num_cpus); let cpu_column = (start_index..end_index) .map(|cpu_index| { - Spans::from(Span { - content: (&cpu_bars[cpu_index]).into(), - style: self.colours.cpu_colour_styles + // Spans::from(Span { + // content: (&cpu_bars[cpu_index]).into(), + // style: self.colours.cpu_colour_styles + // [cpu_index % self.colours.cpu_colour_styles.len()], + // }) + Text::styled( + &cpu_bars[cpu_index], + self.colours.cpu_colour_styles [cpu_index % self.colours.cpu_colour_styles.len()], - }) + ) }) .collect::<Vec<_>>(); @@ -126,7 +130,7 @@ impl CpuBasicWidget for Painter { .split(*chunk); f.render_widget( - Paragraph::new(cpu_column).block(Block::default()), + Paragraph::new(cpu_column.iter()).block(Block::default()), margined_loc[0], ); } diff --git a/src/canvas/widgets/cpu_graph.rs b/src/canvas/widgets/cpu_graph.rs index a01b7f5f..f31eb1f2 100644 --- a/src/canvas/widgets/cpu_graph.rs +++ b/src/canvas/widgets/cpu_graph.rs @@ -17,7 +17,6 @@ use tui::{ layout::{Constraint, Direction, Layout, Rect}, symbols::Marker, terminal::Frame, - text::Span, widgets::{Axis, Block, Borders, Chart, Dataset, Row, Table}, }; @@ -104,12 +103,17 @@ impl CpuGraphWidget for Painter { if let Some(cpu_widget_state) = app_state.cpu_state.widget_states.get_mut(&widget_id) { let cpu_data: &mut [ConvertedCpuData] = &mut app_state.canvas_data.cpu_data; - let display_time_labels = vec![ - Span::styled( - format!("{}s", cpu_widget_state.current_display_time / 1000), - self.colours.graph_style, - ), - Span::styled("0s".to_string(), self.colours.graph_style), + // let display_time_labels = vec![ + // Text::styled( + // format!("{}s", cpu_widget_state.current_display_time / 1000), + // self.colours.graph_style, + // ), + // Text::styled("0s".to_string(), self.colours.graph_style), + // ]; + + let display_time_labels = [ + fo |