#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Mode {
#[default]
Normal,
Insert,
Visual,
VisualLine,
Command,
Search,
Tree,
}
impl Mode {
#[must_use]
pub const fn name(self) -> &'static str {
match self {
Self::Normal => "NORMAL",
Self::Insert => "INSERT",
Self::Visual => "VISUAL",
Self::VisualLine => "V-LINE",
Self::Command => "COMMAND",
Self::Search => "SEARCH",
Self::Tree => "TREE",
}
}
#[must_use]
pub const fn is_visual(self) -> bool {
matches!(self, Self::Visual | Self::VisualLine)
}
#[must_use]
pub const fn is_insert(self) -> bool {
matches!(self, Self::Insert)
}
#[must_use]
pub const fn is_command(self) -> bool {
matches!(self, Self::Command)
}
#[must_use]
pub const fn is_search(self) -> bool {
matches!(self, Self::Search)
}
#[must_use]
pub const fn uses_bar_cursor(self) -> bool {
matches!(self, Self::Insert | Self::Command | Self::Search)
}
}