From 1d99b2bbbeedcb680c367f691e1484d9f37d541a Mon Sep 17 00:00:00 2001 From: Dmitry Sobolev Date: Wed, 2 Apr 2025 23:47:27 -0400 Subject: [PATCH 1/2] added restart --- src/ui.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index 07237608..ef001d76 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -387,14 +387,15 @@ impl Ui { "movement: hjkl / ← ↓ ↑ →", "expose tile: spacebar", "flag tile: f", + "restart: r", "quit: q", ], ':', ) - .into_iter() - .map(|line| format!("{:^width$}", line, width = usize::from(grid_width))) - .map(ListItem::new) - .collect::>(), + .into_iter() + .map(|line| format!("{:^width$}", line, width = usize::from(grid_width))) + .map(ListItem::new) + .collect::>(), ) .block(Block::default().borders(Borders::NONE)); frame.render_widget(help_text_block, middle_mines_rects[2]); @@ -402,7 +403,7 @@ impl Ui { let info_text_split_rects = Layout::default() .direction(Direction::Vertical) .constraints(vec![ - Constraint::Min(vertical_pad_block_height - 3), + Constraint::Min(vertical_pad_block_height.saturating_sub(3)), Constraint::Length(3), ]) .split(middle_mines_rects[0]); @@ -520,6 +521,10 @@ impl Ui { app.expose_all()?; } } + Key::Char('r') => { + app = App::new(Board::new(rows, columns, mines)?); + lost = false; + } Key::Char('q') => break, _ => {} } From 5b1a37489fc46b017e10bb4ba3e0c8e8d25261ad Mon Sep 17 00:00:00 2001 From: Dmitry Sobolev Date: Wed, 2 Apr 2025 23:52:40 -0400 Subject: [PATCH 2/2] revert indent --- src/ui.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index ef001d76..15b437eb 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -392,10 +392,10 @@ impl Ui { ], ':', ) - .into_iter() - .map(|line| format!("{:^width$}", line, width = usize::from(grid_width))) - .map(ListItem::new) - .collect::>(), + .into_iter() + .map(|line| format!("{:^width$}", line, width = usize::from(grid_width))) + .map(ListItem::new) + .collect::>(), ) .block(Block::default().borders(Borders::NONE)); frame.render_widget(help_text_block, middle_mines_rects[2]);