mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-23 21:55:11 +02:00
bug: Fix hide table gap option not working in battery widget (#386)
Fixes the `hide_table_gap` option not working with the battery widget.
This commit is contained in:
parent
429978d1aa
commit
cfddb7e223
@ -35,6 +35,11 @@ impl BatteryDisplayWidget for Painter {
|
|||||||
} else {
|
} else {
|
||||||
self.colours.border_style
|
self.colours.border_style
|
||||||
};
|
};
|
||||||
|
let table_gap = if draw_loc.height < TABLE_GAP_HEIGHT_LIMIT {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
app_state.app_config_fields.table_gap
|
||||||
|
};
|
||||||
|
|
||||||
let title = if app_state.is_expanded {
|
let title = if app_state.is_expanded {
|
||||||
const TITLE_BASE: &str = " Battery ── Esc to go back ";
|
const TITLE_BASE: &str = " Battery ── Esc to go back ";
|
||||||
@ -156,16 +161,20 @@ impl BatteryDisplayWidget for Painter {
|
|||||||
Table::new([""].iter(), battery_rows)
|
Table::new([""].iter(), battery_rows)
|
||||||
.block(battery_block)
|
.block(battery_block)
|
||||||
.header_style(self.colours.table_header_style)
|
.header_style(self.colours.table_header_style)
|
||||||
.widths(&[Constraint::Percentage(50), Constraint::Percentage(50)]),
|
.widths(&[Constraint::Percentage(50), Constraint::Percentage(50)])
|
||||||
|
.header_gap(table_gap),
|
||||||
margined_draw_loc,
|
margined_draw_loc,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
let mut contents = vec![Spans::default(); table_gap as usize];
|
||||||
|
|
||||||
|
contents.push(Spans::from(Span::styled(
|
||||||
|
"No data found for this battery",
|
||||||
|
self.colours.text_style,
|
||||||
|
)));
|
||||||
|
|
||||||
f.render_widget(
|
f.render_widget(
|
||||||
Paragraph::new(Span::styled(
|
Paragraph::new(contents).block(battery_block),
|
||||||
"No data found for this battery",
|
|
||||||
self.colours.text_style,
|
|
||||||
))
|
|
||||||
.block(battery_block),
|
|
||||||
margined_draw_loc,
|
margined_draw_loc,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user