pub(crate) mod render;
use rpi_tui::Component;
pub const MARK: &str = "@";
pub fn window_title(status: &str) -> String {
if status.is_empty() {
format!("{MARK} rpi")
} else {
format!("{MARK} rpi {status}")
}
}
pub struct BrandLockup;
impl BrandLockup {
pub fn new() -> Self {
Self
}
}
impl Default for BrandLockup {
fn default() -> Self {
Self::new()
}
}
impl Component for BrandLockup {
fn render(&self, _width: usize) -> Vec<String> {
render::lockup()
}
fn invalidate(&self) {
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
}
#[cfg(test)]
mod tests {
use super::*;
use rpi_tui::ansi::{strip_ansi, visible_width};
#[test]
fn lockup_fits_the_welcome_header() {
let rows = BrandLockup::new().render(80);
assert_eq!(rows.len(), render::ROWS);
assert_eq!(rows.len(), 12);
assert!(rows.iter().all(|row| visible_width(row) == render::COLS));
assert!(strip_ansi(&rows[5]).contains('█'));
}
#[test]
fn title_keeps_the_logo_identity_and_status_last() {
assert_eq!(window_title(""), "@ rpi");
assert_eq!(window_title("⟳"), "@ rpi ⟳");
assert_eq!(window_title("↻"), "@ rpi ↻");
assert!(!window_title("⟳").contains('\n'));
}
}