use crate::app::{AppState, Action};
use crate::input::InputEvent;
use crate::errors::ComponentError;
use crossterm::event::KeyCode::*;
pub fn handle_branch_create_mode(event: InputEvent, _state: &AppState) -> Result<Option<Action>, ComponentError> {
if let InputEvent::Key(key) = &event {
if key.kind == crossterm::event::KeyEventKind::Press {
return Ok(match key.code {
Esc => Some(Action::CancelBranchCreate),
Enter => Some(Action::BranchSubmit),
Backspace => Some(Action::BranchInputBackspace),
Char(c) => Some(Action::BranchInputChar(c)),
_ => None,
});
}
}
Ok(None)
}
pub fn handle_stash_create_mode(event: InputEvent, _state: &AppState) -> Result<Option<Action>, ComponentError> {
if let InputEvent::Key(key) = &event {
if key.kind == crossterm::event::KeyEventKind::Press {
return Ok(match key.code {
Esc => Some(Action::CancelStashCreate),
Enter => Some(Action::StashSubmit),
Backspace => Some(Action::StashInputBackspace),
Char(c) => Some(Action::StashInputChar(c)),
_ => None,
});
}
}
Ok(None)
}