fzf_wrapped/
options.rs

1//! This module contains the enum's that represent certain `fzf` cli options
2
3// TODO: Impelemnt TryFrom trait for options
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
6/// Enum to represent the scoring schemes fzf can use
7pub enum Scheme {
8    Default,
9    Path,
10    History,
11}
12
13impl Default for Scheme {
14    fn default() -> Self {
15        Self::Default
16    }
17}
18
19impl ToString for Scheme {
20    fn to_string(&self) -> String {
21        match self {
22            Self::Default => "default",
23            Self::Path => "path",
24            Self::History => "history",
25        }
26        .to_string()
27    }
28}
29
30impl From<String> for Scheme {
31    fn from(value: String) -> Self {
32        match value.to_lowercase().as_str() {
33            "default" => Self::Default,
34            "path" => Self::Path,
35            "history" => Self::History,
36            _ => Self::default(),
37        }
38    }
39}
40
41#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
42/// Enum to represent the different themes fzf can have
43pub enum Color {
44    Dark,
45    Light,
46    Sixteen,
47    Bw,
48}
49
50impl Default for Color {
51    fn default() -> Self {
52        Self::Dark
53    }
54}
55
56impl ToString for Color {
57    fn to_string(&self) -> String {
58        match self {
59            Self::Dark => "dark",
60            Self::Light => "light",
61            Self::Sixteen => "16",
62            Self::Bw => "bw",
63        }
64        .to_string()
65    }
66}
67
68impl From<String> for Color {
69    fn from(value: String) -> Self {
70        match value.to_lowercase().as_str() {
71            "dark" => Self::Dark,
72            "light" => Self::Light,
73            "16" | "sixteen" => Self::Sixteen,
74            "bw" => Self::Bw,
75            _ => Self::default(),
76        }
77    }
78}
79
80#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
81/// An Enum to represent the possible layouts to display `fzf` with
82pub enum Layout {
83    Default,
84    Reverse,
85    ReverseList,
86}
87
88impl Default for Layout {
89    fn default() -> Self {
90        Self::Default
91    }
92}
93
94impl ToString for Layout {
95    fn to_string(&self) -> String {
96        match self {
97            Layout::Default => "default",
98            Layout::Reverse => "reverse",
99            Layout::ReverseList => "reverse-list",
100        }
101        .to_string()
102    }
103}
104
105impl From<String> for Layout {
106    fn from(value: String) -> Self {
107        match value.to_lowercase().as_str() {
108            "default" => Layout::Default,
109            "reverse" => Layout::Reverse,
110            "reverse-list" => Layout::ReverseList,
111            _ => Layout::default(),
112        }
113    }
114}
115
116#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
117/// An Enum to represent the possible borders to display around the finder
118pub enum Border {
119    None,
120    Rounded,
121    Sharp,
122    Horizontal,
123    Vertical,
124    Top,
125    Bottom,
126    Left,
127    Right,
128}
129
130impl Default for Border {
131    fn default() -> Self {
132        Self::None
133    }
134}
135
136impl ToString for Border {
137    fn to_string(&self) -> String {
138        match self {
139            Border::None => "none",
140            Border::Rounded => "rounded",
141            Border::Sharp => "sharp",
142            Border::Horizontal => "horizontal",
143            Border::Vertical => "vertical",
144            Border::Top => "top",
145            Border::Bottom => "bottom",
146            Border::Left => "left",
147            Border::Right => "right",
148        }
149        .to_string()
150    }
151}
152
153impl From<String> for Border {
154    fn from(value: String) -> Self {
155        match value.to_lowercase().as_str() {
156            "none" => Border::None,
157            "rounded" => Border::Rounded,
158            "sharp" => Border::Sharp,
159            "horizontal" => Border::Horizontal,
160            "vertical" => Border::Vertical,
161            "top" => Border::Top,
162            "bottom" => Border::Bottom,
163            "left" => Border::Left,
164            "right" => Border::Right,
165            _ => Border::default(),
166        }
167    }
168}