use ratatui::style::{Color, Style};
use crate::domain::process::{ProcessKind, ProcessState};
pub const FOCUS_BORDER_COLOR: Color = Color::Cyan;
pub const IDLE_BORDER_COLOR: Color = Color::DarkGray;
pub fn border_style(focused: bool) -> Style {
let color = if focused {
FOCUS_BORDER_COLOR
} else {
IDLE_BORDER_COLOR
};
Style::default().fg(color)
}
pub const HEADER_COLOR: Color = Color::Gray;
pub const COUNT_COLOR: Color = Color::DarkGray;
pub const DESCRIPTION_COLOR: Color = Color::DarkGray;
pub const SELECTED_COLOR: Color = Color::White;
pub const SELECTION_MARKER: &str = "▎";
const STOPPING_GLYPH: &str = "◌";
const STOPPING_COLOR: Color = Color::Yellow;
pub fn status_indicator(state: ProcessState) -> (&'static str, Color) {
match state {
ProcessState::Running => ("●", Color::Green),
ProcessState::Paused => ("‖", Color::Cyan),
ProcessState::Stopping => (STOPPING_GLYPH, STOPPING_COLOR),
ProcessState::Restarting => ("◐", Color::Yellow),
ProcessState::Crashed => ("●", Color::Red),
ProcessState::Pending | ProcessState::Exited => ("○", Color::DarkGray),
}
}
pub fn section_title(kind: ProcessKind) -> &'static str {
match kind {
ProcessKind::Agent => "AGENTS",
ProcessKind::Terminal => "TERMINALS",
ProcessKind::Command => "COMMANDS",
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn stopping_has_a_transition_indicator() {
let stopping = status_indicator(ProcessState::Stopping);
assert_eq!(stopping, (STOPPING_GLYPH, STOPPING_COLOR));
assert_ne!(stopping, status_indicator(ProcessState::Running));
assert_ne!(stopping, status_indicator(ProcessState::Exited));
}
}