style: shorten default bar fade decorations

This commit is contained in:
2026-10-12 22:09:32 +02:00
parent 1cd56cf3f6
commit bb5c247ab2
6 changed files with 36 additions and 25 deletions
+24 -11
View File
@@ -7145,7 +7145,7 @@ mod tests {
.draw(|frame| views.draw(frame, &mut editor))
.unwrap();
let title = pane_screen(&terminal, Rect::new(0, 0, 80, 1));
assert!(title.ends_with("░▒▓ bat 27% "), "{title}");
assert!(title.trim_end().ends_with("bat 27%"), "{title}");
assert_eq!(views.document.geometry.unwrap().1.y, 1);
editor
@@ -7159,11 +7159,7 @@ mod tests {
assert!(title.contains("電") && title.contains("池"), "{title}");
assert!(title.contains("e\u{301}�90%"), "{title}");
assert!(!title.contains("bat 27%"), "{title}");
let start = 80 - (editor.label("battery").width() + 5) as u16;
let buffer = terminal.backend().buffer();
for (offset, glyph) in [(0, "░"), (1, "▒"), (2, "▓"), (3, " ")] {
assert_eq!(buffer[(start + offset, 0)].symbol(), glyph);
}
assert_eq!(buffer[(78, 0)].symbol(), "%");
assert_eq!(buffer[(79, 0)].symbol(), " ");
assert_eq!(views.document.geometry.unwrap().1.y, 1);
@@ -7175,14 +7171,18 @@ mod tests {
terminal
.draw(|frame| views.draw(frame, &mut editor))
.unwrap();
assert!(pane_screen(&terminal, Rect::new(0, 0, 80, 1)).ends_with("░▒▓ live "));
assert!(
pane_screen(&terminal, Rect::new(0, 0, 80, 1))
.trim_end()
.ends_with("live")
);
assert!(!screen_text(&terminal).contains("90%"));
editor.set_label("battery".into(), String::new()).unwrap();
terminal
.draw(|frame| views.draw(frame, &mut editor))
.unwrap();
let title = pane_screen(&terminal, Rect::new(0, 0, 80, 1));
assert!(title.ends_with("░▒▓ bat 28% "), "{title}");
assert!(title.trim_end().ends_with("bat 28%"), "{title}");
assert!(!title.contains("live"), "{title}");
assert_eq!(views.document.geometry.unwrap().1.y, 1);
assert!(editor.set_battery_charge(None));
@@ -7208,6 +7208,13 @@ mod tests {
let line = if at_top { top } else { bottom };
[&mut line.left, &mut line.center, &mut line.right][anchor]
.push("battery".into());
line.segments.insert(
"battery".into(),
SegmentConfig {
padding: 0,
..SegmentConfig::default()
},
);
});
let mut terminal =
Terminal::new(ratatui::backend::TestBackend::new(48, 6)).unwrap();
@@ -7218,9 +7225,9 @@ mod tests {
.unwrap();
let y = if at_top { 0 } else { 5 };
let row = pane_screen(&terminal, Rect::new(0, y, 48, 1));
assert_eq!(row.trim(), "░▒▓ bat 27%");
let x = [0, 18, 36][anchor];
assert_eq!(terminal.backend().buffer()[(x, y)].symbol(), "░");
assert_eq!(row.trim(), "bat 27%");
let x = [0, 20, 41][anchor];
assert_eq!(terminal.backend().buffer()[(x, y)].symbol(), "b");
}
}
configure_chrome(&mut editor, |top, bottom| {
@@ -7251,6 +7258,12 @@ mod tests {
"edit {}",
directory.file("active.txt", "ACTIVE").display()
));
configure_chrome(&mut editor, |top, _| {
let tabs = top.segments.get_mut("tabs").unwrap();
tabs.leading_edge = "<<<".into();
tabs.trailing_edge = ">>>".into();
top.segments.get_mut("battery").unwrap().leading_edge = "<<<".into();
});
editor.set_label("battery".into(), "90%".into()).unwrap();
for width in [28, 29, 80] {
let mut terminal = Terminal::new(ratatui::backend::TestBackend::new(width, 2)).unwrap();
@@ -7269,7 +7282,7 @@ mod tests {
if width == 28 {
assert!(!title.contains("90%"), "{title}");
} else {
assert!(title.ends_with(" ░▒▓ 90% "), "{title}");
assert!(title.ends_with(" <<< 90% "), "{title}");
}
}
editor