diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2020-10-13 02:45:01 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-13 02:45:01 -0400 |
commit | 914079868f0bc5d1b709953bd8aaf0486ba32f65 (patch) | |
tree | 09cda26ee2aaf04a9ef7cabfa6314c1230c1b904 | |
parent | 5675d8192cbe94d7dbc3370315396a11a3aca02e (diff) |
bug: Fix widget highlighting styling for dialogs (#266)
Fixes styling for dialog titles. Cherry picked from commit 06573becfa3c089ac4b2a17c9443f84b6a5af3e8.
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | src/canvas/dialogs/dd_dialog.rs | 41 | ||||
-rw-r--r-- | src/canvas/dialogs/help_dialog.rs | 20 |
3 files changed, 37 insertions, 26 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index cbec6971..f1e6d803 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,7 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#253](https://github.com/ClementTsang/bottom/pull/253): Fix highlighted entries being stuck in another colour when the widget is not selected. -- [#253](https://github.com/ClementTsang/bottom/pull/253): Expanding a widget no longer overrides the widget title colour. +- [#253](https://github.com/ClementTsang/bottom/pull/253), [#266](https://github.com/ClementTsang/bottom/pull/266): Expanding a widget no longer overrides the widget/dialog title colour. - [#261](https://github.com/ClementTsang/bottom/pull/261): Fixed process names occasionally showing up as truncated, due to only using `/proc/<PID>/stat` as our data source. diff --git a/src/canvas/dialogs/dd_dialog.rs b/src/canvas/dialogs/dd_dialog.rs index 50dbc7ef..5069f309 100644 --- a/src/canvas/dialogs/dd_dialog.rs +++ b/src/canvas/dialogs/dd_dialog.rs @@ -63,26 +63,33 @@ impl KillDialog for Painter { ) -> bool { if let Some(dd_text) = dd_text { 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) - ) + Spans::from(vec![ + Span::styled(" Error ", self.colours.widget_title_style), + Span::styled( + format!( + "─{}─ Esc to close ", + "─".repeat( + usize::from(draw_loc.width) + .saturating_sub(DD_ERROR_BASE.chars().count() + 2) + ) + ), + self.colours.border_style, ), - self.colours.border_style, - ) + ]) } else { - Span::styled( - format!( - " Confirm Kill Process ─{}─ Esc to close ", - "─".repeat( - usize::from(draw_loc.width).saturating_sub(DD_BASE.chars().count() + 2) - ) + Spans::from(vec![ + Span::styled(" Confirm Kill Process ", self.colours.widget_title_style), + Span::styled( + format!( + "─{}─ Esc to close ", + "─".repeat( + usize::from(draw_loc.width) + .saturating_sub(DD_BASE.chars().count() + 2) + ) + ), + self.colours.border_style, ), - self.colours.border_style, - ) + ]) }; f.render_widget( diff --git a/src/canvas/dialogs/help_dialog.rs b/src/canvas/dialogs/help_dialog.rs index 752dc858..b3c9f579 100644 --- a/src/canvas/dialogs/help_dialog.rs +++ b/src/canvas/dialogs/help_dialog.rs @@ -6,6 +6,7 @@ use tui::{ layout::{Alignment, Rect}, terminal::Frame, text::Span, + text::Spans, widgets::{Block, Borders, Paragraph, Wrap}, }; @@ -22,15 +23,18 @@ 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) - ) + let help_title = Spans::from(vec![ + Span::styled(" Help ", self.colours.widget_title_style), + Span::styled( + format!( + "─{}─ Esc to close ", + "─".repeat( + usize::from(draw_loc.width).saturating_sub(HELP_BASE.chars().count() + 2) + ) + ), + self.colours.border_style, ), - self.colours.border_style, - ); + ]); if app_state.should_get_widget_bounds() { // We must also recalculate how many lines are wrapping to properly get scrolling to work on |