diff --git a/src/filter.rs b/src/filter.rs index 0a17056d..3e90af8f 100644 --- a/src/filter.rs +++ b/src/filter.rs @@ -16,14 +16,14 @@ pub enum SearchAction { Update, } -pub struct FilterInstance { +pub struct Filter { search_input: Vec, in_search_mode: bool, input_position: usize, items: Vec, } -impl FilterInstance { +impl Filter { pub fn new() -> Self { Self { search_input: vec![], @@ -78,7 +78,7 @@ impl FilterInstance { self.items.sort_by(|a, b| a.node.name.cmp(&b.node.name)); } } - pub fn draw(&self, frame: &mut Frame, area: Rect, theme: &Theme) { + pub fn draw_searchbar(&self, frame: &mut Frame, area: Rect, theme: &Theme) { //Set the search bar text (If empty use the placeholder) let display_text = if !self.in_search_mode && self.search_input.is_empty() { Span::raw("Press / to search") diff --git a/src/state.rs b/src/state.rs index bbfbcbd0..1f23fd99 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1,5 +1,5 @@ use crate::{ - filter::{FilterInstance, SearchAction}, + filter::{Filter, SearchAction}, float::{Float, FloatContent}, floating_text::FloatingText, running_command::{Command, RunningCommand}, @@ -32,7 +32,7 @@ pub struct AppState { /// This is the state asociated with the list widget, used to display the selection in the /// widget selection: ListState, - filter: FilterInstance, + filter: Filter, } pub enum Focus { @@ -59,7 +59,7 @@ impl AppState { current_tab: ListState::default().with_selected(Some(0)), visit_stack: vec![root_id], selection: ListState::default().with_selected(Some(0)), - filter: FilterInstance::new(), + filter: Filter::new(), }; state.update_items(); state @@ -107,7 +107,7 @@ impl AppState { .constraints([Constraint::Length(3), Constraint::Min(1)].as_ref()) .split(horizontal[1]); - self.filter.draw(frame, chunks[0], &self.theme); + self.filter.draw_searchbar(frame, chunks[0], &self.theme); let mut items: Vec = Vec::new(); if !self.at_root() {