bug: fix side borders in basic mode (#1110)

Seems like I broke this when migrating from tui-rs to ratatui. This just
uses explicit enum variants to set my side borders and a test to try and
make sure this doesn't happen again.
This commit is contained in:
Clement Tsang 2023-04-21 00:07:45 -04:00 committed by GitHub
parent 3618449d42
commit 8b81dfba47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,5 @@
use once_cell::sync::Lazy;
use tui::widgets::Borders;
use crate::options::ConfigColours;
@ -21,7 +22,7 @@ pub const TABLE_GAP_HEIGHT_LIMIT: u16 = 7;
pub const TIME_LABEL_HEIGHT_LIMIT: u16 = 7;
// Side borders
pub const SIDE_BORDERS: tui::widgets::Borders = tui::widgets::Borders::from_bits_truncate(20);
pub const SIDE_BORDERS: Borders = Borders::LEFT.union(Borders::RIGHT);
pub static DEFAULT_TEXT_STYLE: Lazy<tui::style::Style> =
Lazy::new(|| tui::style::Style::default().fg(tui::style::Color::Gray));
pub static DEFAULT_HEADER_STYLE: Lazy<tui::style::Style> =
@ -738,4 +739,14 @@ mod test {
"the two should be equal, or this test should be updated"
)
}
/// This test exists because previously, [`SIDE_BORDERS`] was set incorrectly after I moved from
/// tui-rs to ratatui.
#[test]
fn assert_side_border_bits_match() {
assert_eq!(
SIDE_BORDERS,
Borders::ALL.difference(Borders::TOP.union(Borders::BOTTOM))
)
}
}