kanban-tui 0.4.0

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

pub fn handle_dialog_input(
    input: &mut InputState,
    key_code: KeyCode,
    allow_empty: bool,
) -> DialogAction {
    match key_code {
        KeyCode::Esc => DialogAction::Cancel,
        KeyCode::Enter => {
            if allow_empty || !input.is_empty() {
                DialogAction::Confirm
            } else {
                DialogAction::None
            }
        }
        KeyCode::Char(c) => {
            input.insert_char(c);
            DialogAction::None
        }
        KeyCode::Backspace => {
            input.backspace();
            DialogAction::None
        }
        KeyCode::Delete => {
            input.delete();
            DialogAction::None
        }
        KeyCode::Left => {
            input.move_left();
            DialogAction::None
        }
        KeyCode::Right => {
            input.move_right();
            DialogAction::None
        }
        KeyCode::Home => {
            input.move_home();
            DialogAction::None
        }
        KeyCode::End => {
            input.move_end();
            DialogAction::None
        }
        _ => DialogAction::None,
    }
}

pub enum DialogAction {
    None,
    Cancel,
    Confirm,
}