diff options
| author | pbspbsingh <prashant.bhushansingh@gmail.com> | 2022-10-23 13:31:17 -0700 |
|---|---|---|
| committer | pbspbsingh <prashant.bhushansingh@gmail.com> | 2022-10-23 13:31:17 -0700 |
| commit | 9dfbe6f4e31ce9e3ef47b484da26f51de6c0e900 (patch) | |
| tree | 085a737dcd22fe4e13645df5f235d6a6e3e897c0 /src/ui.rs | |
| parent | 0cae5089cb84478060794cadbbfc924d4b9ae9cd (diff) | |
| download | gof-rs-9dfbe6f4e31ce9e3ef47b484da26f51de6c0e900.tar.xz gof-rs-9dfbe6f4e31ce9e3ef47b484da26f51de6c0e900.zip | |
cargo fmt
Diffstat (limited to 'src/ui.rs')
| -rw-r--r-- | src/ui.rs | 22 |
1 files changed, 9 insertions, 13 deletions
@@ -21,7 +21,6 @@ use tui::{ use crate::generation::*; - pub struct StatefulList<T> { state: ListState, items: Vec<T>, @@ -100,10 +99,7 @@ impl App { } } -pub fn run_app<B: Backend>( - terminal: &mut Terminal<B>, - mut app: App, -) -> io::Result<()> { +pub fn run_app<B: Backend>(terminal: &mut Terminal<B>, 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<B: Backend>( 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<B: Backend>(f: &mut Frame<B>, 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<B: Backend>(f: &mut Frame<B>, 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) |
