#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum InputMode {
#[default]
Normal,
Insert,
Search,
}
impl InputMode {
pub fn indicator(&self) -> &'static str {
match self {
InputMode::Normal => "N",
InputMode::Insert => "I",
InputMode::Search => "/",
}
}
pub fn captures_input(&self) -> bool {
matches!(self, InputMode::Insert | InputMode::Search)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_default_is_normal() {
assert_eq!(InputMode::default(), InputMode::Normal);
}
#[test]
fn test_indicator() {
assert_eq!(InputMode::Normal.indicator(), "N");
assert_eq!(InputMode::Insert.indicator(), "I");
assert_eq!(InputMode::Search.indicator(), "/");
}
#[test]
fn test_captures_input() {
assert!(!InputMode::Normal.captures_input());
assert!(InputMode::Insert.captures_input());
assert!(InputMode::Search.captures_input());
}
}