pub struct SearchState {
pub query: String,
pub origin: usize,
pub current: Option<usize>,
pub wrapped: bool,
}
impl SearchState {
pub fn new(origin: usize) -> Self {
SearchState {
query: String::new(),
origin,
current: None,
wrapped: false,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ReplacePhase {
EnterFind,
EnterWith,
EnterOptions,
Confirm(usize),
}
pub struct ReplaceState {
pub find: String,
pub with: String,
pub options: String,
pub phase: ReplacePhase,
pub count: usize,
}
impl ReplaceState {
pub fn new() -> Self {
ReplaceState {
find: String::new(),
with: String::new(),
options: String::new(),
phase: ReplacePhase::EnterFind,
count: 0,
}
}
pub fn whole_word(&self) -> bool {
self.options.contains(['w', 'W'])
}
pub fn from_top(&self) -> bool {
self.options.contains(['g', 'G'])
}
pub fn no_ask(&self) -> bool {
self.options.contains(['n', 'N'])
}
}