diff --git a/Cargo.toml b/Cargo.toml index 0731af31..ca511bab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,7 +66,7 @@ phf = "0.13.1" phf_codegen = "0.13.0" prettytable-rs = "0.10.0" rand = { version = "0.9.0", features = ["small_rng"] } -ratatui = "0.29.0" +ratatui = "0.30.0" regex = "1.10.4" rustix = { version = "1.1.2", features = ["fs"] } sysinfo = "0.37.0" diff --git a/src/uu/tload/src/tui.rs b/src/uu/tload/src/tui.rs index 14d6761b..fc0cf052 100644 --- a/src/uu/tload/src/tui.rs +++ b/src/uu/tload/src/tui.rs @@ -6,7 +6,7 @@ use ratatui::{ buffer::Buffer, layout::{Constraint, Direction, Layout, Rect}, - style::{Style, Stylize}, + style::Style, symbols::Marker, text::{Line, Text}, widgets::{Axis, Block, Borders, Chart, Dataset, GraphType, Paragraph, Widget}, diff --git a/src/uu/top/src/tui/color.rs b/src/uu/top/src/tui/color.rs index c79d8d6b..86d3320a 100644 --- a/src/uu/top/src/tui/color.rs +++ b/src/uu/top/src/tui/color.rs @@ -3,63 +3,57 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -use ratatui::prelude::Stylize; -use ratatui::style::{Color, Styled}; +use ratatui::style::{Color, Style}; -pub(crate) trait TuiColor<'a, T>: Sized { - fn primary(self, colorful: bool) -> T; - fn bg_primary(self, colorful: bool) -> T; - fn secondary(self, colorful: bool) -> T; - fn bg_secondary(self, colorful: bool) -> T; - fn error(self, colorful: bool) -> T; +/// This is the trait used to adjust the TUI color options +pub(crate) trait TuiColorHelper: Sized { + fn primary(self, colorful: bool) -> Style; + fn bg_primary(self, colorful: bool) -> Style; + fn secondary(self, colorful: bool) -> Style; + fn bg_secondary(self, colorful: bool) -> Style; + fn error(self, colorful: bool) -> Style; } -impl<'a, T, U> TuiColor<'a, T> for U -where - U: Styled, -{ - fn primary(self, colorful: bool) -> T { - let style = self.style(); +impl TuiColorHelper for Style { + fn primary(self, colorful: bool) -> Style { if colorful { self.red() } else { - self.set_style(style) + self } } - fn bg_primary(self, colorful: bool) -> T { - let style = self.style().fg(Color::Black); + fn bg_primary(self, colorful: bool) -> Style { + let style = self.fg(Color::Black); if colorful { - self.set_style(style.bg(Color::Red)) + style.bg(Color::Red) } else { - self.set_style(style.bg(Color::White)) + style.bg(Color::White) } } - fn secondary(self, colorful: bool) -> T { - let style = self.style(); + fn secondary(self, colorful: bool) -> Style { if colorful { self.yellow() } else { - self.set_style(style) + self } } - fn bg_secondary(self, colorful: bool) -> T { - let style = self.style().fg(Color::Black); + fn bg_secondary(self, colorful: bool) -> Style { + let style = self.fg(Color::Black); if colorful { - self.set_style(style.bg(Color::Yellow)) + style.bg(Color::Yellow) } else { - self.set_style(style.bg(Color::White)) + style.bg(Color::White) } } - fn error(self, colorful: bool) -> T { - let style = self.style(); + fn error(self, colorful: bool) -> Style { if colorful { - self.set_style(style.fg(Color::Black).bg(Color::Red)) + self.fg(Color::Black).bg(Color::Red) } else { - self.set_style(style) + self } } } diff --git a/src/uu/top/src/tui/mod.rs b/src/uu/top/src/tui/mod.rs index 96c0f0ec..44a6d516 100644 --- a/src/uu/top/src/tui/mod.rs +++ b/src/uu/top/src/tui/mod.rs @@ -11,7 +11,7 @@ pub use input::*; use std::borrow::Cow; use crate::header::{format_memory, Header}; -use crate::tui::color::TuiColor; +use crate::tui::color::TuiColorHelper; use crate::tui::stat::{CpuGraphMode, MemoryGraphMode, TuiStat}; use crate::{InfoBar, ProcList}; use ratatui::prelude::*;