1pub(crate) mod render;
8mod shape;
9mod spin;
10
11use rpi_tui::Component;
12
13pub use spin::{animating, replay, set_enabled};
14
15pub const MARK: &str = "@";
17
18pub fn window_title(status: &str) -> String {
20 if status.is_empty() {
21 format!("{MARK} rpi")
22 } else {
23 format!("{MARK} rpi {status}")
24 }
25}
26
27pub struct BrandLockup;
29
30impl BrandLockup {
31 pub fn new() -> Self {
32 Self
33 }
34}
35
36impl Default for BrandLockup {
37 fn default() -> Self {
38 Self::new()
39 }
40}
41
42impl Component for BrandLockup {
43 fn render(&self, _width: usize) -> Vec<String> {
44 render::lockup(spin::angle())
45 }
46
47 fn invalidate(&self) {
48 }
50
51 fn as_any(&self) -> &dyn std::any::Any {
52 self
53 }
54}
55
56#[cfg(test)]
57mod tests {
58 use super::*;
59
60 #[test]
61 fn lockup_fits_the_welcome_header() {
62 let rows = BrandLockup::new().render(80);
63 assert_eq!(rows.len(), render::ROWS);
64 }
65
66 #[test]
67 fn title_keeps_the_logo_identity_and_status_last() {
68 assert_eq!(window_title(""), "@ rpi");
69 assert_eq!(window_title("⟳"), "@ rpi ⟳");
70 assert_eq!(window_title("↻"), "@ rpi ↻");
71 assert!(!window_title("⟳").contains('\n'));
72 }
73}