irongit

feat: off mode for filter

huncholanehuncholaneauthored
parent fe34cf3commit 2c7da3fa846688dd75e58921f2962a05a90e9794Browse files

1 file changed, +8 -2

+8-2src/widgets/miller.rs
@@ -112,6 +112,7 @@ pub struct MillerFilterResponse {
112112 /// Shows a text input with placeholder. Focus with shortcut key, Escape unfocuses.
113113 #[derive(Debug, Clone, Copy, PartialEq)]
114114 pub enum FilterMode {
115+ Off, // no filtering
115116 Fuzzy, // chars in order anywhere
116117 Contains, // case-insensitive substring
117118 Exact, // case-insensitive full match
@@ -120,14 +121,16 @@ pub enum FilterMode {
120121 impl FilterMode {
121122 fn next(self) -> Self {
122123 match self {
124+ FilterMode::Off => FilterMode::Fuzzy,
123125 FilterMode::Fuzzy => FilterMode::Contains,
124126 FilterMode::Contains => FilterMode::Exact,
125- FilterMode::Exact => FilterMode::Fuzzy,
127+ FilterMode::Exact => FilterMode::Off,
126128 }
127129 }
128130
129131 fn icon(self) -> &'static str {
130132 match self {
133+ FilterMode::Off => egui_phosphor::regular::PROHIBIT,
131134 FilterMode::Fuzzy => egui_phosphor::regular::WAVES,
132135 FilterMode::Contains => egui_phosphor::regular::TEXTBOX,
133136 FilterMode::Exact => egui_phosphor::regular::EQUALS,
@@ -136,6 +139,7 @@ impl FilterMode {
136139
137140 fn color(self) -> egui::Color32 {
138141 match self {
142+ FilterMode::Off => crate::theme::CatppuccinMocha::OVERLAY0,
139143 FilterMode::Fuzzy => crate::theme::CatppuccinMocha::PEACH,
140144 FilterMode::Contains => crate::theme::CatppuccinMocha::BLUE,
141145 FilterMode::Exact => crate::theme::CatppuccinMocha::GREEN,
@@ -144,6 +148,7 @@ impl FilterMode {
144148
145149 fn tooltip(self) -> &'static str {
146150 match self {
151+ FilterMode::Off => "Off (ctrl-f to cycle)",
147152 FilterMode::Fuzzy => "Fuzzy (ctrl-f to cycle)",
148153 FilterMode::Contains => "Contains (ctrl-f to cycle)",
149154 FilterMode::Exact => "Exact (ctrl-f to cycle)",
@@ -263,7 +268,7 @@ impl MillerFilter {
263268 /// Match a label against the query using the current filter mode.
264269 /// Supports `|` to OR multiple terms (e.g. "start|report" matches either).
265270 pub fn matches(&self, label: &str) -> bool {
266- if self.query.is_empty() {
271+ if self.mode == FilterMode::Off || self.query.is_empty() {
267272 return true;
268273 }
269274 self.query.split('|')
@@ -271,6 +276,7 @@ impl MillerFilter {
271276 let term = term.trim();
272277 if term.is_empty() { return false; }
273278 match self.mode {
279+ FilterMode::Off => true,
274280 FilterMode::Fuzzy => fuzzy_matches(term, label),
275281 FilterMode::Contains => label.to_lowercase().contains(&term.to_lowercase()),
276282 FilterMode::Exact => label.to_lowercase() == term.to_lowercase(),