From 3dd40926b1fc1044c3ee4652ae51db16ca1090e1 Mon Sep 17 00:00:00 2001 From: Jeromos Kovacs Date: Sat, 28 Sep 2024 15:46:42 +0200 Subject: [PATCH] docs(README): updated; fix: cosmetics --- README.md | 10 +++++----- src/lib.rs | 9 +++++++-- src/ui.rs | 9 ++++----- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0c77e36..151c086 100644 --- a/README.md +++ b/README.md @@ -15,14 +15,14 @@ clone the repo and run `cargo r` - [x] error handling - [x] publishing to crates.io - [x] changing to `Canvas` for rendering viewer block - -## Warning! - -If your terminal is messed up by accident fix: on Mac, Linux: `reset`, on Windows: exit the app. +- [ ] *maybe* the ability to parse `.cells` files ## Acknowledgements -The core of this app is adapted from the great [Rust-Wasm tutorial](https://rustwasm.github.io/docs/book/). +- The core of this app is adapted from the [Rust-Wasm tutorial](https://rustwasm.github.io/docs/book/). +- main dependencies: + - ratatui: ui + - crossterm: ratatui backend ## License diff --git a/src/lib.rs b/src/lib.rs index af93457..e08879a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -208,8 +208,13 @@ impl Universe { }; Universe { area, cells } } + fn from_str(s: &str) -> Self { - let v = s.trim().lines().map(|l| l.into()).collect::>(); + let v = s + .trim() + .lines() + .map(std::convert::Into::into) + .collect::>(); Self::from_vec_str(&v) } @@ -231,7 +236,7 @@ impl Universe { } let cells = vec![Cell::default(); area.len()]; - let mut univ = Universe { cells, area }; + let mut univ = Universe { area, cells }; let (start_row, start_col) = ( (area.height - figur.height()) / 2, diff --git a/src/ui.rs b/src/ui.rs index 7742c8f..1dd8777 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -30,11 +30,10 @@ pub fn ui(f: &mut Frame, app: &mut App) { .border_type(BorderType::Rounded) .title("Conway's Game of Life"); // 2 blocks less: border - let new_area: crate::Area = ( - chunks[0].width * BRAILLE.width - 2 * BRAILLE.width, - chunks[0].height * BRAILLE.height - 2 * BRAILLE.height, - ) - .into(); + let new_area = Area::new( + (chunks[0].width - 2) * BRAILLE.width, + (chunks[0].height - 2) * BRAILLE.height, + ); // apply the area change if app.area != new_area { app.area = new_area;