use crate::{
ui::{Key, KeyModifiers},
InnerAction, InputAction,
};
use super::config::PasswordConfig;
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum PasswordPromptAction {
ValueInput(InputAction),
ToggleDisplayMode,
}
impl InnerAction for PasswordPromptAction {
type Config = PasswordConfig;
fn from_key(key: Key, config: &PasswordConfig) -> Option<Self> {
let action = match key {
Key::Char('r' | 'R', m)
if m.contains(KeyModifiers::CONTROL) && config.enable_display_toggle =>
{
Self::ToggleDisplayMode
}
key => match InputAction::from_key(key, &()) {
Some(action) => Self::ValueInput(action),
None => return None,
},
};
Some(action)
}
}