bug: Fix widget highlighting styling for dialogs (#266)

Fixes styling for dialog titles.  Cherry picked from commit 06573becfa3c089ac4b2a17c9443f84b6a5af3e8.
This commit is contained in:
Clement Tsang 2020-10-13 02:45:01 -04:00 committed by GitHub
parent 5675d8192c
commit 914079868f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 26 deletions

View File

@ -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.

View File

@ -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(

View File

@ -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