From 4e8cc2bc5c79090c8bb1f7cb7b2226152024b765 Mon Sep 17 00:00:00 2001 From: Liam <33645555+lj3954@users.noreply.github.com> Date: Wed, 21 Aug 2024 09:48:14 -0700 Subject: [PATCH] refactor: Improve filter naming --- src/filter.rs | 6 +++--- src/state.rs | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) 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() {