use std::path::PathBuf;
#[derive(Clone, Debug, PartialEq, Eq, Default)]
pub enum Mode {
#[default]
Normal,
Insert,
Visual,
VisualLine,
Command(String),
Search { query: String, reverse: bool },
Prompt(Prompt),
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Prompt {
pub kind: PromptKind,
pub target: PathBuf,
pub input: String,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum PromptKind {
Create,
Rename,
Move,
Delete { entries: usize },
Export { format: crate::export::Format, justify: bool },
}
impl PromptKind {
pub fn title(&self) -> &'static str {
match self {
PromptKind::Create => " new ",
PromptKind::Rename => " rename ",
PromptKind::Move => " move ",
PromptKind::Delete { .. } => " delete ",
PromptKind::Export { .. } => " export ",
}
}
pub fn is_confirm(&self) -> bool {
matches!(self, PromptKind::Delete { .. })
}
}
impl Mode {
pub fn allows_past_end(&self) -> bool {
matches!(self, Mode::Insert)
}
}