refactor: Improve filter naming

This commit is contained in:
Liam 2024-08-21 09:48:14 -07:00
parent 388c073116
commit 4e8cc2bc5c
No known key found for this signature in database
2 changed files with 7 additions and 7 deletions

View File

@ -16,14 +16,14 @@ pub enum SearchAction {
Update,
}
pub struct FilterInstance {
pub struct Filter {
search_input: Vec<char>,
in_search_mode: bool,
input_position: usize,
items: Vec<ListEntry>,
}
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")

View File

@ -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<Line> = Vec::new();
if !self.at_root() {