Skip to content

Commit 9140798

Browse files
authored
bug: Fix widget highlighting styling for dialogs (#266)
Fixes styling for dialog titles. Cherry picked from commit 06573be.
1 parent 5675d81 commit 9140798

File tree

3 files changed

+37
-26
lines changed

3 files changed

+37
-26
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3838

3939
- [#253](https://github.com/ClementTsang/bottom/pull/253): Fix highlighted entries being stuck in another colour when the widget is not selected.
4040

41-
- [#253](https://github.com/ClementTsang/bottom/pull/253): Expanding a widget no longer overrides the widget title colour.
41+
- [#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.
4242

4343
- [#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.
4444

src/canvas/dialogs/dd_dialog.rs

+24-17
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,33 @@ impl KillDialog for Painter {
6363
) -> bool {
6464
if let Some(dd_text) = dd_text {
6565
let dd_title = if app_state.dd_err.is_some() {
66-
Span::styled(
67-
format!(
68-
" Error ─{}─ Esc to close ",
69-
"─".repeat(
70-
usize::from(draw_loc.width)
71-
.saturating_sub(DD_ERROR_BASE.chars().count() + 2)
72-
)
66+
Spans::from(vec![
67+
Span::styled(" Error ", self.colours.widget_title_style),
68+
Span::styled(
69+
format!(
70+
"─{}─ Esc to close ",
71+
"─".repeat(
72+
usize::from(draw_loc.width)
73+
.saturating_sub(DD_ERROR_BASE.chars().count() + 2)
74+
)
75+
),
76+
self.colours.border_style,
7377
),
74-
self.colours.border_style,
75-
)
78+
])
7679
} else {
77-
Span::styled(
78-
format!(
79-
" Confirm Kill Process ─{}─ Esc to close ",
80-
"─".repeat(
81-
usize::from(draw_loc.width).saturating_sub(DD_BASE.chars().count() + 2)
82-
)
80+
Spans::from(vec![
81+
Span::styled(" Confirm Kill Process ", self.colours.widget_title_style),
82+
Span::styled(
83+
format!(
84+
"─{}─ Esc to close ",
85+
"─".repeat(
86+
usize::from(draw_loc.width)
87+
.saturating_sub(DD_BASE.chars().count() + 2)
88+
)
89+
),
90+
self.colours.border_style,
8391
),
84-
self.colours.border_style,
85-
)
92+
])
8693
};
8794

8895
f.render_widget(

src/canvas/dialogs/help_dialog.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use tui::{
66
layout::{Alignment, Rect},
77
terminal::Frame,
88
text::Span,
9+
text::Spans,
910
widgets::{Block, Borders, Paragraph, Wrap},
1011
};
1112

@@ -22,15 +23,18 @@ impl HelpDialog for Painter {
2223
fn draw_help_dialog<B: Backend>(
2324
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect,
2425
) {
25-
let help_title = Span::styled(
26-
format!(
27-
" Help ─{}─ Esc to close ",
28-
"─".repeat(
29-
usize::from(draw_loc.width).saturating_sub(HELP_BASE.chars().count() + 2)
30-
)
26+
let help_title = Spans::from(vec![
27+
Span::styled(" Help ", self.colours.widget_title_style),
28+
Span::styled(
29+
format!(
30+
"─{}─ Esc to close ",
31+
"─".repeat(
32+
usize::from(draw_loc.width).saturating_sub(HELP_BASE.chars().count() + 2)
33+
)
34+
),
35+
self.colours.border_style,
3136
),
32-
self.colours.border_style,
33-
);
37+
]);
3438

3539
if app_state.should_get_widget_bounds() {
3640
// We must also recalculate how many lines are wrapping to properly get scrolling to work on

0 commit comments

Comments
 (0)