1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
use std::str::FromStr;
use crate::error::{JoshutoError, JoshutoErrorKind, JoshutoResult};
/// Search and selection options globally valid for Joshuto (for all tabs)
#[derive(Clone, Debug)]
pub struct SearchOption {
pub string_case_sensitivity: CaseSensitivity,
pub glob_case_sensitivity: CaseSensitivity,
pub regex_case_sensitivity: CaseSensitivity,
pub fzf_case_sensitivity: CaseSensitivity,
}
#[derive(Clone, Copy, Debug)]
pub enum CaseSensitivity {
Insensitive,
Sensitive,
Smart,
}
impl std::default::Default for SearchOption {
fn default() -> Self {
Self {
string_case_sensitivity: CaseSensitivity::Insensitive,
glob_case_sensitivity: CaseSensitivity::Sensitive,
regex_case_sensitivity: CaseSensitivity::Sensitive,
fzf_case_sensitivity: CaseSensitivity::Insensitive,
}
}
}
impl FromStr for CaseSensitivity {
type Err = JoshutoError;
fn from_str(s: &str) -> JoshutoResult<Self> {
match s {
"insensitive" => Ok(Self::Insensitive),
"sensitive" => Ok(Self::Sensitive),
"smart" => Ok(Self::Smart),
otherwise => Err(JoshutoError::new(
JoshutoErrorKind::InvalidParameters,
format!("Case sensitivity '{otherwise}' unknown"),
)),
}
}
}
|