Skip to content

Commit

Permalink
Format.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsuereth committed Jul 4, 2024
1 parent f931720 commit 781a009
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/registry/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use ratatui::{
widgets::{Block, BorderType, Borders, Paragraph},
Frame,
};
use tui_textarea::TextArea;
use std::io::stdout;
use tui_textarea::TextArea;

/// Parameters for the `registry search` sub-command
#[derive(Debug, Args)]
Expand Down Expand Up @@ -77,7 +77,7 @@ impl<'a> SearchApp<'a> {
.title("Search (press `Esc` or `Ctrl-Q` to stop running) ")
.title_style(Style::default().fg(Color::Green)),
);
SearchApp {
SearchApp {
schema,
search_area,
}
Expand Down Expand Up @@ -108,18 +108,25 @@ impl<'a> SearchApp<'a> {
}

// Renders the current results of the search string or state of the UI.
fn results(&self) -> Paragraph<'a> {
let results: Vec<Line<'a>> =
self.schema.catalog.attributes.iter()
.filter(|a| a.name.contains(self.search_string().as_str()))
.map(|a| Line::default().style(Style::default().fg(Color::LightBlue)).spans(vec!(Span::raw(" - "), Span::raw(&a.name))))
.collect();
fn results(&self) -> Paragraph<'a> {
let results: Vec<Line<'a>> = self
.schema
.catalog
.attributes
.iter()
.filter(|a| a.name.contains(self.search_string().as_str()))
.map(|a| {
Line::default()
.style(Style::default().fg(Color::LightBlue))
.spans(vec![Span::raw(" - "), Span::raw(&a.name)])
})
.collect();
let block = Block::new()
.border_type(BorderType::Rounded)
.borders(Borders::ALL)
.border_style(Style::default().fg(Color::White))
.style(Style::default().bg(Color::Black))
.title("Results");
.title("Results [Attributes]");

Paragraph::new(results).block(block)
}
Expand All @@ -131,7 +138,6 @@ impl<'a> SearchApp<'a> {
&self.search_area
}


// Renders the text-UI to the current frame.
fn render(&self, frame: &mut Frame<'_>) {
// Set up the UI such that we have a title block,
Expand Down

0 comments on commit 781a009

Please sign in to comment.