diff --git a/crates/trippy-tui/src/config/file.rs b/crates/trippy-tui/src/config/file.rs index 461bae91..41dad288 100644 --- a/crates/trippy-tui/src/config/file.rs +++ b/crates/trippy-tui/src/config/file.rs @@ -291,6 +291,10 @@ pub struct ConfigThemeColors { pub hops_table_header_text_color: Option, pub hops_table_row_active_text_color: Option, pub hops_table_row_inactive_text_color: Option, + pub hops_table_row_active_selected_bg_color: Option, + pub hops_table_row_active_selected_text_color: Option, + pub hops_table_row_inactive_selected_bg_color: Option, + pub hops_table_row_inactive_selected_text_color: Option, pub hops_chart_selected_color: Option, pub hops_chart_unselected_color: Option, pub hops_chart_axis_color: Option, @@ -331,6 +335,16 @@ impl Default for ConfigThemeColors { hops_table_header_text_color: Some(theme.hops_table_header_text), hops_table_row_active_text_color: Some(theme.hops_table_row_active_text), hops_table_row_inactive_text_color: Some(theme.hops_table_row_inactive_text), + hops_table_row_active_selected_bg_color: Some(theme.hops_table_row_active_selected_bg), + hops_table_row_active_selected_text_color: Some( + theme.hops_table_row_active_selected_text, + ), + hops_table_row_inactive_selected_bg_color: Some( + theme.hops_table_row_inactive_selected_bg, + ), + hops_table_row_inactive_selected_text_color: Some( + theme.hops_table_row_inactive_selected_text, + ), hops_chart_selected_color: Some(theme.hops_chart_selected), hops_chart_unselected_color: Some(theme.hops_chart_unselected), hops_chart_axis_color: Some(theme.hops_chart_axis), diff --git a/crates/trippy-tui/src/config/theme.rs b/crates/trippy-tui/src/config/theme.rs index eac972ac..db758041 100644 --- a/crates/trippy-tui/src/config/theme.rs +++ b/crates/trippy-tui/src/config/theme.rs @@ -29,6 +29,14 @@ pub struct TuiTheme { pub hops_table_row_active_text: TuiColor, /// The color of text of inactive rows in the hops table. pub hops_table_row_inactive_text: TuiColor, + /// The background color of selected active rows in the hops table. + pub hops_table_row_active_selected_bg: TuiColor, + /// The color of text of selected active rows in the hops table. + pub hops_table_row_active_selected_text: TuiColor, + /// The background color of selected inactive rows in the hops table. + pub hops_table_row_inactive_selected_bg: TuiColor, + /// The color of text of selected inactive rows in the hops table. + pub hops_table_row_inactive_selected_text: TuiColor, /// The color of the selected series in the hops chart. pub hops_chart_selected: TuiColor, /// The color of the unselected series in the hops chart. @@ -94,6 +102,10 @@ impl Default for TuiTheme { hops_table_header_text: TuiColor::Black, hops_table_row_active_text: TuiColor::Gray, hops_table_row_inactive_text: TuiColor::DarkGray, + hops_table_row_active_selected_bg: TuiColor::Gray, + hops_table_row_active_selected_text: TuiColor::Black, + hops_table_row_inactive_selected_bg: TuiColor::DarkGray, + hops_table_row_inactive_selected_text: TuiColor::Black, hops_chart_selected: TuiColor::Green, hops_chart_unselected: TuiColor::Gray, hops_chart_axis: TuiColor::DarkGray, @@ -161,6 +173,22 @@ impl From<(HashMap, ConfigThemeColors)> for TuiTheme { .get(&TuiThemeItem::HopsTableRowInactiveTextColor) .or(cfg.hops_table_row_inactive_text_color.as_ref()) .unwrap_or(&Self::default().hops_table_row_inactive_text), + hops_table_row_active_selected_bg: *color_map + .get(&TuiThemeItem::HopsTableRowActiveSelectedBgColor) + .or(cfg.hops_table_row_active_selected_bg_color.as_ref()) + .unwrap_or(&Self::default().hops_table_row_active_selected_bg), + hops_table_row_active_selected_text: *color_map + .get(&TuiThemeItem::HopsTableRowActiveSelectedTextColor) + .or(cfg.hops_table_row_active_selected_text_color.as_ref()) + .unwrap_or(&Self::default().hops_table_row_active_selected_text), + hops_table_row_inactive_selected_bg: *color_map + .get(&TuiThemeItem::HopsTableRowInactiveSelectedBgColor) + .or(cfg.hops_table_row_inactive_selected_bg_color.as_ref()) + .unwrap_or(&Self::default().hops_table_row_inactive_selected_bg), + hops_table_row_inactive_selected_text: *color_map + .get(&TuiThemeItem::HopsTableRowInactiveSelectedTextColor) + .or(cfg.hops_table_row_inactive_selected_text_color.as_ref()) + .unwrap_or(&Self::default().hops_table_row_inactive_selected_text), hops_chart_selected: *color_map .get(&TuiThemeItem::HopsChartSelectedColor) .or(cfg.hops_chart_selected_color.as_ref()) @@ -290,6 +318,14 @@ pub enum TuiThemeItem { HopsTableRowActiveTextColor, /// The color of text of inactive rows in the hops table. HopsTableRowInactiveTextColor, + /// The background color of selected active rows in the hops table. + HopsTableRowActiveSelectedBgColor, + /// The color of text of selected active rows in the hops table. + HopsTableRowActiveSelectedTextColor, + /// The background color of selected inactive rows in the hops table. + HopsTableRowInactiveSelectedBgColor, + /// The color of text of selected inactive rows in the hops table. + HopsTableRowInactiveSelectedTextColor, /// The color of the selected series in the hops chart. HopsChartSelectedColor, /// The color of the unselected series in the hops chart. diff --git a/crates/trippy-tui/src/frontend/render/settings.rs b/crates/trippy-tui/src/frontend/render/settings.rs index ba040ae6..50d2ffe6 100644 --- a/crates/trippy-tui/src/frontend/render/settings.rs +++ b/crates/trippy-tui/src/frontend/render/settings.rs @@ -431,6 +431,22 @@ fn format_theme_settings(app: &TuiApp) -> Vec { "hops-table-row-inactive-text-color", theme::fmt_color(theme.hops_table_row_inactive_text), ), + SettingsItem::new( + "hops-table-row-active-selected-bg-color", + theme::fmt_color(theme.hops_table_row_active_selected_bg), + ), + SettingsItem::new( + "hops-table-row-active-selected-text-color", + theme::fmt_color(theme.hops_table_row_active_selected_text), + ), + SettingsItem::new( + "hops-table-row-inactive-selected-bg-color", + theme::fmt_color(theme.hops_table_row_inactive_selected_bg), + ), + SettingsItem::new( + "hops-table-row-inactive-selected-text-color", + theme::fmt_color(theme.hops_table_row_inactive_selected_text), + ), SettingsItem::new( "hops-chart-selected-color", theme::fmt_color(theme.hops_chart_selected), @@ -539,7 +555,7 @@ pub fn settings_tabs() -> [(String, usize); 7] { (t!("settings_tab_dns_title").to_string(), 5), (t!("settings_tab_geoip_title").to_string(), 1), (t!("settings_tab_bindings_title").to_string(), 37), - (t!("settings_tab_theme_title").to_string(), 33), + (t!("settings_tab_theme_title").to_string(), 35), (t!("settings_tab_columns_title").to_string(), 0), ] } diff --git a/crates/trippy-tui/src/frontend/render/table.rs b/crates/trippy-tui/src/frontend/render/table.rs index 828cdbe3..b8cfa00d 100644 --- a/crates/trippy-tui/src/frontend/render/table.rs +++ b/crates/trippy-tui/src/frontend/render/table.rs @@ -9,7 +9,7 @@ use itertools::Itertools; use ratatui::Frame; use ratatui::layout::Rect; use ratatui::prelude::Line; -use ratatui::style::{Modifier, Style}; +use ratatui::style::Style; use ratatui::widgets::{Block, BorderType, Borders, Cell, Row, Table}; use std::fmt::Write; use std::net::IpAddr; @@ -46,7 +46,14 @@ pub fn render(f: &mut Frame<'_>, app: &mut TuiApp, rect: Rect) { let config = &app.tui_config; let widths = config.tui_columns.constraints(rect); let header = render_table_header(app.tui_config.theme, &config.tui_columns); - let selected_style = Style::default().add_modifier(Modifier::REVERSED); + let selected_style = match app.selected_hop() { + Some(hop) if !app.tracer_data().is_in_round(hop, app.selected_flow) => Style::default() + .fg(config.theme.hops_table_row_inactive_selected_text) + .bg(config.theme.hops_table_row_inactive_selected_bg), + _ => Style::default() + .fg(config.theme.hops_table_row_active_selected_text) + .bg(config.theme.hops_table_row_active_selected_bg), + }; let rows = app .tracer_data() .hops_for_flow(app.selected_flow) diff --git a/crates/trippy-tui/src/frontend/theme.rs b/crates/trippy-tui/src/frontend/theme.rs index 2c44dc5e..169db491 100644 --- a/crates/trippy-tui/src/frontend/theme.rs +++ b/crates/trippy-tui/src/frontend/theme.rs @@ -26,6 +26,14 @@ pub struct Theme { pub hops_table_row_active_text: Color, /// The color of text of inactive rows in the hops table. pub hops_table_row_inactive_text: Color, + /// The background color of selected active rows in the hops table. + pub hops_table_row_active_selected_bg: Color, + /// The color of text of selected active rows in the hops table. + pub hops_table_row_active_selected_text: Color, + /// The background color of selected inactive rows in the hops table. + pub hops_table_row_inactive_selected_bg: Color, + /// The color of text of selected inactive rows in the hops table. + pub hops_table_row_inactive_selected_text: Color, /// The color of the selected series in the hops chart. pub hops_chart_selected: Color, /// The color of the unselected series in the hops chart. @@ -91,6 +99,16 @@ impl From for Theme { hops_table_header_text: Color::from(value.hops_table_header_text), hops_table_row_active_text: Color::from(value.hops_table_row_active_text), hops_table_row_inactive_text: Color::from(value.hops_table_row_inactive_text), + hops_table_row_active_selected_bg: Color::from(value.hops_table_row_active_selected_bg), + hops_table_row_active_selected_text: Color::from( + value.hops_table_row_active_selected_text, + ), + hops_table_row_inactive_selected_bg: Color::from( + value.hops_table_row_inactive_selected_bg, + ), + hops_table_row_inactive_selected_text: Color::from( + value.hops_table_row_inactive_selected_text, + ), hops_chart_selected: Color::from(value.hops_chart_selected), hops_chart_unselected: Color::from(value.hops_chart_unselected), hops_chart_axis: Color::from(value.hops_chart_axis), diff --git a/crates/trippy-tui/tests/resources/snapshots/trippy_tui__print__tests__output@tui_theme_items_match.snap b/crates/trippy-tui/tests/resources/snapshots/trippy_tui__print__tests__output@tui_theme_items_match.snap index 7df61cdc..17d9b16f 100644 --- a/crates/trippy-tui/tests/resources/snapshots/trippy_tui__print__tests__output@tui_theme_items_match.snap +++ b/crates/trippy-tui/tests/resources/snapshots/trippy_tui__print__tests__output@tui_theme_items_match.snap @@ -1,4 +1,4 @@ --- source: crates/trippy-tui/src/print.rs --- -TUIthemecoloritems:bg-color,border-color,text-color,tab-text-color,hops-table-header-bg-color,hops-table-header-text-color,hops-table-row-active-text-color,hops-table-row-inactive-text-color,hops-chart-selected-color,hops-chart-unselected-color,hops-chart-axis-color,frequency-chart-bar-color,frequency-chart-text-color,flows-chart-bar-selected-color,flows-chart-bar-unselected-color,flows-chart-text-current-color,flows-chart-text-non-current-color,samples-chart-color,samples-chart-lost-color,help-dialog-bg-color,help-dialog-text-color,settings-tab-text-color,settings-dialog-bg-color,settings-table-header-text-color,settings-table-header-bg-color,settings-table-row-text-color,map-world-color,map-radius-color,map-selected-color,map-info-panel-border-color,map-info-panel-bg-color,map-info-panel-text-color,info-bar-bg-color,info-bar-text-color +TUIthemecoloritems:bg-color,border-color,text-color,tab-text-color,hops-table-header-bg-color,hops-table-header-text-color,hops-table-row-active-text-color,hops-table-row-inactive-text-color,hops-table-row-active-selected-bg-color,hops-table-row-active-selected-text-color,hops-table-row-inactive-selected-bg-color,hops-table-row-inactive-selected-text-color,hops-chart-selected-color,hops-chart-unselected-color,hops-chart-axis-color,frequency-chart-bar-color,frequency-chart-text-color,flows-chart-bar-selected-color,flows-chart-bar-unselected-color,flows-chart-text-current-color,flows-chart-text-non-current-color,samples-chart-color,samples-chart-lost-color,help-dialog-bg-color,help-dialog-text-color,settings-tab-text-color,settings-dialog-bg-color,settings-table-header-text-color,settings-table-header-bg-color,settings-table-row-text-color,map-world-color,map-radius-color,map-selected-color,map-info-panel-border-color,map-info-panel-bg-color,map-info-panel-text-color,info-bar-bg-color,info-bar-text-color diff --git a/docs/src/content/docs/reference/theme.md b/docs/src/content/docs/reference/theme.md index 3f69b46d..05d5db48 100644 --- a/docs/src/content/docs/reference/theme.md +++ b/docs/src/content/docs/reference/theme.md @@ -8,42 +8,46 @@ sidebar: The following table lists the default Tui color theme. These can be overridden with the `--tui-theme-colors` command line option or in the `theme-colors` section of the configuration file. -| Item | Description | Default | -| ------------------------------------ | --------------------------------------------------------- | ------------ | -| `bg-color` | The default background color | `Black` | -| `border-color` | The default color of borders | `Gray` | -| `text-color` | The default color of text | `Gray` | -| `tab-text-color` | The color of the text in traces tabs | `Green` | -| `hops-table-header-bg-color` | The background color of the hops table header | `White` | -| `hops-table-header-text-color` | The color of text in the hops table header | `Black` | -| `hops-table-row-active-text-color` | The color of text of active rows in the hops table | `Gray` | -| `hops-table-row-inactive-text-color` | The color of text of inactive rows in the hops table | `DarkGray` | -| `hops-chart-selected-color` | The color of the selected series in the hops chart | `Green` | -| `hops-chart-unselected-color` | The color of the unselected series in the hops chart | `Gray` | -| `hops-chart-axis-color` | The color of the axis in the hops chart | `DarkGray` | -| `frequency-chart-bar-color` | The color of bars in the frequency chart | `Green` | -| `frequency-chart-text-color` | The color of text in the bars of the frequency chart | `Gray` | -| `flows-chart-bar-selected-color` | The color of the selected flow bar in the flows chart | `Green` | -| `flows-chart-bar-unselected-color` | The color of the unselected flow bar in the flows chart | `DarkGray` | -| `flows-chart-text-current-color` | The color of the current flow text in the flows chart | `LightGreen` | -| `flows-chart-text-non-current-color` | The color of the non-current flow text in the flows chart | `White` | -| `samples-chart-color` | The color of the samples chart | `Yellow` | -| `samples-chart-lost-color` | The color of the samples chart for lost probes | `Red` | -| `help-dialog-bg-color` | The background color of the help dialog | `Blue` | -| `help-dialog-text-color` | The color of the text in the help dialog | `Gray` | -| `settings-dialog-bg-color` | The background color of the settings dialog | `blue` | -| `settings-tab-text-color` | The color of the text in settings dialog tabs | `green` | -| `settings-table-header-text-color` | The color of text in the settings table header | `black` | -| `settings-table-header-bg-color` | The background color of the settings table header | `white` | -| `settings-table-row-text-color` | The color of text of rows in the settings table | `gray` | -| `map-world-color` | The color of the map world diagram | `white` | -| `map-radius-color` | The color of the map accuracy radius circle | `yellow` | -| `map-selected-color` | The color of the map selected item box | `green` | -| `map-info-panel-border-color` | The color of border of the map info panel | `gray` | -| `map-info-panel-bg-color` | The background color of the map info panel | `black` | -| `map-info-panel-text-color` | The color of text in the map info panel | `gray` | -| `info-bar-bg-color` | The background color of the information bar | `white` | -| `info-bar-text-color` | The color of text in the information bar | `black` | +| Item | Description | Default | +| --------------------------------------------- | ---------------------------------------------------------------- | ------------ | +| `bg-color` | The default background color | `Black` | +| `border-color` | The default color of borders | `Gray` | +| `text-color` | The default color of text | `Gray` | +| `tab-text-color` | The color of the text in traces tabs | `Green` | +| `hops-table-header-bg-color` | The background color of the hops table header | `White` | +| `hops-table-header-text-color` | The color of text in the hops table header | `Black` | +| `hops-table-row-active-text-color` | The color of text of active rows in the hops table | `Gray` | +| `hops-table-row-inactive-text-color` | The color of text of inactive rows in the hops table | `DarkGray` | +| `hops-table-row-active-selected-bg-color` | The background color of selected active rows in the hops table | `Gray` | +| `hops-table-row-active-selected-text-color` | The color of text of selected active rows in the hops table | `Black` | +| `hops-table-row-inactive-selected-bg-color` | The background color of selected inactive rows in the hops table | `Gray` | +| `hops-table-row-inactive-selected-text-color` | The color of text of selected inactive rows in the hops table | `DarkGray` | +| `hops-chart-selected-color` | The color of the selected series in the hops chart | `Green` | +| `hops-chart-unselected-color` | The color of the unselected series in the hops chart | `Gray` | +| `hops-chart-axis-color` | The color of the axis in the hops chart | `DarkGray` | +| `frequency-chart-bar-color` | The color of bars in the frequency chart | `Green` | +| `frequency-chart-text-color` | The color of text in the bars of the frequency chart | `Gray` | +| `flows-chart-bar-selected-color` | The color of the selected flow bar in the flows chart | `Green` | +| `flows-chart-bar-unselected-color` | The color of the unselected flow bar in the flows chart | `DarkGray` | +| `flows-chart-text-current-color` | The color of the current flow text in the flows chart | `LightGreen` | +| `flows-chart-text-non-current-color` | The color of the non-current flow text in the flows chart | `White` | +| `samples-chart-color` | The color of the samples chart | `Yellow` | +| `samples-chart-lost-color` | The color of the samples chart for lost probes | `Red` | +| `help-dialog-bg-color` | The background color of the help dialog | `Blue` | +| `help-dialog-text-color` | The color of the text in the help dialog | `Gray` | +| `settings-dialog-bg-color` | The background color of the settings dialog | `blue` | +| `settings-tab-text-color` | The color of the text in settings dialog tabs | `green` | +| `settings-table-header-text-color` | The color of text in the settings table header | `black` | +| `settings-table-header-bg-color` | The background color of the settings table header | `white` | +| `settings-table-row-text-color` | The color of text of rows in the settings table | `gray` | +| `map-world-color` | The color of the map world diagram | `white` | +| `map-radius-color` | The color of the map accuracy radius circle | `yellow` | +| `map-selected-color` | The color of the map selected item box | `green` | +| `map-info-panel-border-color` | The color of border of the map info panel | `gray` | +| `map-info-panel-bg-color` | The background color of the map info panel | `black` | +| `map-info-panel-text-color` | The color of text in the map info panel | `gray` | +| `info-bar-bg-color` | The background color of the information bar | `white` | +| `info-bar-text-color` | The color of text in the information bar | `black` | The supported [ANSI colors](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors) are: diff --git a/trippy-config-sample.toml b/trippy-config-sample.toml index 1408ac7f..d65e33be 100644 --- a/trippy-config-sample.toml +++ b/trippy-config-sample.toml @@ -358,6 +358,10 @@ hops-table-header-bg-color = "white" hops-table-header-text-color = "black" hops-table-row-active-text-color = "gray" hops-table-row-inactive-text-color = "darkgray" +hops-table-row-active-selected-bg-color = "gray" +hops-table-row-active-selected-text-color = "black" +hops-table-row-inactive-selected-bg-color = "darkgray" +hops-table-row-inactive-selected-text-color = "black" hops-chart-selected-color = "green" hops-chart-unselected-color = "gray" hops-chart-axis-color = "darkgray"