kanban-tui 0.4.1

Terminal user interface for the kanban project management tool
Documentation
use kanban_core::InputState;

/// UI state for search mode.
///
/// This struct manages the search input and active state.
/// The actual search logic is in the domain layer.
pub struct SearchState {
    pub input: InputState,
    pub is_active: bool,
}

impl SearchState {
    pub fn new() -> Self {
        Self {
            input: InputState::new(),
            is_active: false,
        }
    }

    pub fn activate(&mut self) {
        self.is_active = true;
        self.input.clear();
    }

    pub fn deactivate(&mut self) {
        self.is_active = false;
        self.input.clear();
    }

    pub fn query(&self) -> &str {
        self.input.as_str()
    }

    pub fn is_empty(&self) -> bool {
        self.input.as_str().is_empty()
    }

    pub fn active_query(&self) -> Option<&str> {
        if self.is_active {
            Some(self.query())
        } else {
            None
        }
    }
}

impl Default for SearchState {
    fn default() -> Self {
        Self::new()
    }
}