feat: animate loading spinners in pane titles

This commit is contained in:
2026-10-10 01:11:41 +02:00
parent c89e3591fd
commit a4db9808dc
2 changed files with 67 additions and 16 deletions
+53 -13
View File
File diff suppressed because one or more lines are too long
+11
View File
@@ -87,6 +87,15 @@ impl Thumbnail {
}
}
pub fn is_loading(&self) -> bool {
self.selected.is_some()
&& self.error.is_none()
&& !self
.image
.as_ref()
.is_some_and(|image| image.complete && image.protocol.protocol_type().is_some())
}
pub fn draw(&mut self, frame: &mut Frame, area: Rect) {
self.poll();
if area.width == 0 || area.height == 0 || self.selected.is_none() {
@@ -301,6 +310,7 @@ mod tests {
let mut terminal = Terminal::new(TestBackend::new(100, 40)).unwrap();
for area in [Rect::new(3, 2, 80, 18), Rect::new(7, 4, 30, 8)] {
terminal.draw(|frame| thumbnail.draw(frame, area)).unwrap();
assert!(thumbnail.is_loading());
let response = requests_rx
.recv_timeout(Duration::from_secs(2))
.unwrap()
@@ -308,6 +318,7 @@ mod tests {
.unwrap();
replies_tx.send(Ok(response)).unwrap();
terminal.draw(|frame| thumbnail.draw(frame, area)).unwrap();
assert!(!thumbnail.is_loading());
let buffer = terminal.backend().buffer();
let pixels: Vec<_> = (0..40)
.flat_map(|y| (0..100).map(move |x| (x, y)))