From 9dfbe6f4e31ce9e3ef47b484da26f51de6c0e900 Mon Sep 17 00:00:00 2001 From: pbspbsingh Date: Sun, 23 Oct 2022 13:31:17 -0700 Subject: cargo fmt --- src/ui.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/ui.rs') diff --git a/src/ui.rs b/src/ui.rs index 4b27b82..f9ddbb9 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -21,7 +21,6 @@ use tui::{ use crate::generation::*; - pub struct StatefulList { state: ListState, items: Vec, @@ -100,10 +99,7 @@ impl App { } } -pub fn run_app( - terminal: &mut Terminal, - mut app: App, -) -> io::Result<()> { +pub fn run_app(terminal: &mut Terminal, mut app: App) -> io::Result<()> { let mut last_tick = Instant::now(); let mut item_cnt = 1; loop { @@ -121,19 +117,16 @@ pub fn run_app( item_cnt += 1; } app.items.next(); - app.cur_gen = - gen_from_file(&app.items.items[item_cnt].1); + app.cur_gen = gen_from_file(&app.items.items[item_cnt].1); } KeyCode::Up | KeyCode::Char('k') => { if item_cnt == 0 { item_cnt = app.items.items.len() - 1; - } - else { + } else { item_cnt -= 1; } app.items.previous(); - app.cur_gen = - gen_from_file(&app.items.items[item_cnt].1); + app.cur_gen = gen_from_file(&app.items.items[item_cnt].1); } KeyCode::Char('n') => { terminal.draw(|f| ui_game(f, &mut app))?; @@ -203,7 +196,11 @@ fn ui_game(f: &mut Frame, app: &mut App) { // Create a List from all list items and highlight the currently selected one let items = List::new(items) - .block(Block::default().borders(Borders::ALL).title("Cool Patterns")) + .block( + Block::default() + .borders(Borders::ALL) + .title("Cool Patterns"), + ) .highlight_style( Style::default() .bg(Color::Blue) @@ -213,7 +210,6 @@ fn ui_game(f: &mut Frame, app: &mut App) { f.render_stateful_widget(items, chunks[0], &mut app.items.state); - let nxt = next_gen(app); let spans = gen_to_spans(&nxt); render_gen(f, chunks[1], &spans) -- cgit v1.2.3