diff --git a/Cargo.toml b/Cargo.toml index 135437b..541fed6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,10 +12,10 @@ keywords = ["matrix", "matrix-rain", "emoji", "cmatrix", "rain"] categories = ["command-line-utilities"] [dependencies] -clap = { version = "3.1.18", features = ["cargo"] } +clap = { version = "4.5.18", features = ["cargo", "derive"] } crossterm = "0.27.0" rand = "0.8.5" -itertools = "0.10.3" +itertools = "0.13.0" ezemoji = "0.2.0" [profile.release] diff --git a/README.md b/README.md index 727b84c..e98aaa4 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ OPTIONS: all - This shows most of the Character Groups all at once. alphalow - Lower Case Alphabet Characters alphaup - Upper Case Alphabet Characters + alphanum - All Alphabets and Numbers arrow - Arrow Emojis or Fancy Characters bin - All Ones and Zeros cards - Playing Cards diff --git a/src/characters.rs b/src/characters.rs index 82e5def..cc65536 100644 --- a/src/characters.rs +++ b/src/characters.rs @@ -1,221 +1,162 @@ -use ezemoji::*; +use clap::ValueEnum; +#[repr(u16)] #[derive(Debug, Clone, Copy)] pub enum CharWidth { - Single, - Double, + Single = 1, + Double = 2, } -impl CharWidth { - pub fn width(self) -> u16 { - match self { - Self::Single => 1, - Self::Double => 2, - } - } -} - -#[derive(Debug, Clone, Copy)] +#[derive(Debug, ValueEnum, Clone, Copy)] pub enum Characters { - All(AllEmojis), - Alphalow(LowerAlpha), - Alphaup(UpperAlpha), - Arrow(Arrow), - Bin(Bin), - Cards(Cards), - Clock(Clock), - Crab(Crab), - Dominosh(HorizontalDominos), - Dominosv(VerticalDominos), - Earth(Earth), - Emojis(Emojis), - Jap(Japanese), - LargeLetters(LargeLetter), - Moon(Moon), - Num(Numbers), - NumberedBalls(NumberedBalls), - NumberedCubes(NumberedCubes), - Plants(Plant), - Smile(Smile), - Shapes(Shape), + All, + Alphalow, + Alphaup, + AlphaNum, + Arrow, + Bin, + Cards, + Clock, + Crab, + Dominosh, + Dominosv, + Earth, + Emojis, + Jap, + LargeLetters, + Moon, + Num, + NumberedBalls, + NumberedCubes, + Plants, + Smile, + Shapes, +} + +impl std::fmt::Display for Characters { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let value = match self { + Characters::All => "all", + Characters::Alphalow => "alphalow", + Characters::Alphaup => "alphaup", + Characters::AlphaNum => "alphanum", + Characters::Arrow => "arrow", + Characters::Bin => "bin", + Characters::Cards => "cards", + Characters::Clock => "clock", + Characters::Crab => "crab", + Characters::Dominosh => "dominosh", + Characters::Dominosv => "dominosv", + Characters::Earth => "earth", + Characters::Emojis => "emojis", + Characters::Jap => "jap", + Characters::LargeLetters => "largeletters", + Characters::Moon => "moon", + Characters::Num => "num", + Characters::NumberedBalls => "numberedballs", + Characters::NumberedCubes => "numberedcubes", + Characters::Plants => "plants", + Characters::Smile => "smile", + Characters::Shapes => "shapes", + }; + write!(f, "{}", value) + } } impl Characters { - pub fn width(&self) -> u16 { - match self { - Self::All(_) => CharWidth::Double.width(), - Self::Alphalow(_) => CharWidth::Single.width(), - Self::Alphaup(_) => CharWidth::Single.width(), - Self::Arrow(_) => CharWidth::Double.width(), - Self::Bin(_) => CharWidth::Single.width(), - Self::Cards(_) => CharWidth::Double.width(), - Self::Clock(_) => CharWidth::Double.width(), - Self::Crab(_) => CharWidth::Double.width(), - Self::Dominosh(_) => CharWidth::Double.width(), - Self::Dominosv(_) => CharWidth::Single.width(), - Self::Earth(_) => CharWidth::Double.width(), - Self::Emojis(_) => CharWidth::Double.width(), - Self::Jap(_) => CharWidth::Single.width(), - Self::LargeLetters(_) => CharWidth::Double.width(), - Self::Moon(_) => CharWidth::Double.width(), - Self::Num(_) => CharWidth::Single.width(), - Self::NumberedBalls(_) => CharWidth::Double.width(), - Self::NumberedCubes(_) => CharWidth::Double.width(), - Self::Plants(_) => CharWidth::Double.width(), - Self::Smile(_) => CharWidth::Double.width(), - Self::Shapes(_) => CharWidth::Double.width(), - } - } - pub fn as_vec_u32(&self) -> Vec { match self { - Self::All(c) => c.as_vec_u32(), - Self::Alphalow(c) => c.as_vec_u32(), - Self::Alphaup(c) => c.as_vec_u32(), - Self::Arrow(c) => c.as_vec_u32(), - Self::Bin(c) => c.as_vec_u32(), - Self::Cards(c) => c.as_vec_u32(), - Self::Clock(c) => c.as_vec_u32(), - Self::Crab(c) => c.as_vec_u32(), - Self::Dominosh(c) => c.as_vec_u32(), - Self::Dominosv(c) => c.as_vec_u32(), - Self::Earth(c) => c.as_vec_u32(), - Self::Emojis(c) => c.as_vec_u32(), - Self::Jap(c) => c.as_vec_u32(), - Self::LargeLetters(c) => c.as_vec_u32(), - Self::Moon(c) => c.as_vec_u32(), - Self::Num(c) => c.as_vec_u32(), - Self::NumberedBalls(c) => c.as_vec_u32(), - Self::NumberedCubes(c) => c.as_vec_u32(), - Self::Plants(c) => c.as_vec_u32(), - Self::Smile(c) => c.as_vec_u32(), - Self::Shapes(c) => c.as_vec_u32(), + Self::All => Self::Alphalow + .as_vec_u32() + .into_iter() + .chain(Self::Alphaup.as_vec_u32()) + .chain(Self::AlphaNum.as_vec_u32()) + .chain(Self::Arrow.as_vec_u32()) + .chain(Self::Bin.as_vec_u32()) + .chain(Self::Cards.as_vec_u32()) + .chain(Self::Clock.as_vec_u32()) + .chain(Self::Crab.as_vec_u32()) + .chain(Self::Dominosh.as_vec_u32()) + .chain(Self::Dominosv.as_vec_u32()) + .chain(Self::Earth.as_vec_u32()) + .chain(Self::Emojis.as_vec_u32()) + .chain(Self::Jap.as_vec_u32()) + .chain(Self::LargeLetters.as_vec_u32()) + .chain(Self::Moon.as_vec_u32()) + .chain(Self::Num.as_vec_u32()) + .chain(Self::NumberedBalls.as_vec_u32()) + .chain(Self::NumberedCubes.as_vec_u32()) + .chain(Self::Plants.as_vec_u32()) + .chain(Self::Smile.as_vec_u32()) + .chain(Self::Shapes.as_vec_u32()) + .collect(), + Self::Alphalow => (97..=122).collect(), + Self::Alphaup => (65..=90).collect(), + Self::AlphaNum => Self::Alphalow + .as_vec_u32() + .into_iter() + .chain(Self::Alphaup.as_vec_u32()) + .chain(Self::Num.as_vec_u32()) + .collect(), + Self::Arrow => (129024..=129035) + .chain(129040..=129095) + .chain(129168..=129195) + .chain(129168..=129195) + .chain(129104..=129113) + .collect(), + Self::Bin => (48..=49).collect(), + Self::Cards => (127137..=127166) + .chain(127169..=127182) + .chain(127185..=127198) + .collect(), + Self::Clock => (128336..=128359).collect(), + Self::Crab => vec![129408], + Self::Dominosh => (127024..=127073).collect(), + Self::Dominosv => (127074..=127123).collect(), + Self::Earth => (127757..=127760).collect(), + Self::Emojis => (129292..=129400) // Hearts + .chain(129402..=129482) // Diamonds + .chain(129484..=129535) // Clubs + // Spades? + .collect(), + Self::Jap => (65382..=65437).collect(), + Self::LargeLetters => (127462..=127487).collect(), + Self::Moon => (127760..=127773).collect(), + Self::Num => (48..=57).collect(), + Self::NumberedBalls => (127312..=127337).collect(), + Self::NumberedCubes => (127344..=127369).collect(), + Self::Plants => (127793..=127827).collect(), + Self::Smile => (128512..=128518).collect(), + Self::Shapes => (128992..=129003).collect(), } } } -impl From for Characters { - fn from(e: ezemoji::AllEmojis) -> Self { - Self::All(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::LowerAlpha) -> Self { - Self::Alphalow(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::UpperAlpha) -> Self { - Self::Alphaup(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::Arrow) -> Self { - Self::Arrow(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::Bin) -> Self { - Self::Bin(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::Cards) -> Self { - Self::Cards(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::Clock) -> Self { - Self::Clock(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::Crab) -> Self { - Self::Crab(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::HorizontalDominos) -> Self { - Self::Dominosh(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::VerticalDominos) -> Self { - Self::Dominosv(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::Earth) -> Self { - Self::Earth(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::Emojis) -> Self { - Self::Emojis(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::Japanese) -> Self { - Self::Jap(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::LargeLetter) -> Self { - Self::LargeLetters(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::Moon) -> Self { - Self::Moon(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::Numbers) -> Self { - Self::Num(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::NumberedBalls) -> Self { - Self::NumberedBalls(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::NumberedCubes) -> Self { - Self::NumberedCubes(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::Plant) -> Self { - Self::Plants(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::Smile) -> Self { - Self::Smile(e) - } -} - -impl From for Characters { - fn from(e: ezemoji::Shape) -> Self { - Self::Shapes(e) +impl Characters { + pub fn width(&self) -> u16 { + match self { + Self::All => CharWidth::Double as u16, + Self::Alphalow => CharWidth::Single as u16, + Self::Alphaup => CharWidth::Single as u16, + Self::AlphaNum => CharWidth::Single as u16, + Self::Arrow => CharWidth::Double as u16, + Self::Bin => CharWidth::Single as u16, + Self::Cards => CharWidth::Double as u16, + Self::Clock => CharWidth::Double as u16, + Self::Crab => CharWidth::Double as u16, + Self::Dominosh => CharWidth::Double as u16, + Self::Dominosv => CharWidth::Single as u16, + Self::Earth => CharWidth::Double as u16, + Self::Emojis => CharWidth::Double as u16, + Self::Jap => CharWidth::Single as u16, + Self::LargeLetters => CharWidth::Double as u16, + Self::Moon => CharWidth::Double as u16, + Self::Num => CharWidth::Single as u16, + Self::NumberedBalls => CharWidth::Double as u16, + Self::NumberedCubes => CharWidth::Double as u16, + Self::Plants => CharWidth::Double as u16, + Self::Smile => CharWidth::Double as u16, + Self::Shapes => CharWidth::Double as u16, + } } } diff --git a/src/cli.rs b/src/cli.rs new file mode 100644 index 0000000..4fd74b6 --- /dev/null +++ b/src/cli.rs @@ -0,0 +1,144 @@ +use super::{AUTHOR, MAXSPEED, MINSPEED}; +use crate::characters::Characters; +use crate::direction::Direction; +use clap::{crate_description, crate_name, crate_version, Parser}; + +const HELP_DIRECTION: &str = "Set the direction of the Rain. +Default is set to down/south +OPTIONS: + up, north, + down, south, + left, west, + right, east +"; + +const HELP_COLORS: &str = "Set color of Rain with color string name or tuple +OPTIONS: + white, + red, + blue, + green, + r,g,b +"; + +const HELP_CHARS: &str = "Set what kind of characters are printed as rain. +OPTIONS: + all - This shows most of the Character Groups all at once. + alphalow - Lower Case Alphabet Characters + alphaup - Upper Case Alphabet Characters + arrow - Arrow Emojis or Fancy Characters + bin - All Ones and Zeros + cards - Playing Cards + clock - 🕑 + crab - 🦀 + dominosh - 🀽 + dominosv - 🁫 + earth - 🌎 + emojis - This is just a bunch of random Emojis + jap - Japanese Characters + large-letters - Cool Looking Large Letters + moon - 🌕 + num - Good ol fashion Numbers + numbered-balls - These are like pool balls + numbered-cubes - These are like the pool balls but just cubes + plants - Plants of sorts + smile - 😃 + shapes - Squares and Circles of a few colors +"; + +const HELP_HEAD: &str = "Set the color of the first char in Rain. +OPTIONS: + white, + red, + blue, + green, + r,g,b +"; + +#[derive(Debug, Parser)] +#[command( + author = AUTHOR, + about = "A cross platform matrix rain made with Rust.", + long_about = Some(crate_description!()), + color = clap::ColorChoice::Always, + name = crate_name!(), + version = crate_version!())] +pub struct Cli { + #[arg(short, long, default_value_t = false)] + pub shade: bool, + #[arg(short, long, help = HELP_CHARS, default_value_t = Characters::Bin)] + pub chars: Characters, + #[arg(short = 'C', long, help = HELP_COLORS, default_value_t = String::from("green"))] + pub color: String, + #[arg(short = 'H', long, help = HELP_HEAD, default_value_t = String::from("white"))] + pub head: String, + #[arg(short, long, help = HELP_DIRECTION, default_value_t = Direction::Down)] + pub direction: Direction, + #[arg(short = 'S', long, default_value_t = format!("{MAXSPEED},{MINSPEED}"))] + pub speed: String, +} + +impl Cli { + pub fn rain_color(&self) -> (u8, u8, u8) { + into_color(&self.color) + } + pub fn head_color(&self) -> (u8, u8, u8) { + into_color(&self.head) + } + + pub fn speed(&self) -> (u64, u64) { + match self.speed.into_tuple() { + Ok((max, min)) => (max, min), + _ => (MAXSPEED, MINSPEED), + } + } + pub fn speed_range(&self) -> std::ops::Range { + let (max, min) = self.speed(); + max..min + } +} + +pub fn into_color(value: &str) -> (u8, u8, u8) { + match value { + c if StrTuple::<(u8, u8, u8)>::into_tuple(c).is_ok() => match c.into_tuple() { + Ok((r, g, b)) => (r, g, b), + _ => (255, 255, 255), + }, + "red" => (255, 0, 0), + "blue" => (0, 0, 255), + "green" => (0, 255, 0), + _ => (255, 255, 255), + } +} + +impl StrTuple<(u64, u64)> for &str { + type Error = std::num::ParseIntError; + fn into_tuple(self) -> Result<(u64, u64), Self::Error> { + let mut nums = Vec::new(); + for num in self.split(',') { + nums.push(num.parse::()?); + } + let a = nums[0]; + let b = nums[1]; + Ok((a, b)) + } +} + +impl StrTuple<(u8, u8, u8)> for &str { + type Error = std::num::ParseIntError; + fn into_tuple(self) -> Result<(u8, u8, u8), Self::Error> { + let mut nums = Vec::new(); + for num in self.split(',') { + nums.push(num.parse::()?); + } + let a = nums[0]; + let b = nums[1]; + let c = nums[2]; + Ok((a, b, c)) + } +} + +trait StrTuple { + type Error; + fn into_tuple(self) -> Result; +} diff --git a/src/direction.rs b/src/direction.rs index 0ee9055..78ec666 100644 --- a/src/direction.rs +++ b/src/direction.rs @@ -1,7 +1,20 @@ -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +use clap::ValueEnum; + +#[derive(Debug, ValueEnum, Clone, Copy, PartialEq, Eq)] pub enum Direction { Up, Down, Left, Right, } + +impl std::fmt::Display for Direction { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Up => write!(f, "Up"), + Self::Down => write!(f, "down"), + Self::Left => write!(f, "Left"), + Self::Right => write!(f, "Right"), + } + } +} diff --git a/src/gen.rs b/src/gen.rs index 973100a..d17693e 100644 --- a/src/gen.rs +++ b/src/gen.rs @@ -52,13 +52,11 @@ pub fn color_function(shading: bool) -> fn(style::Color, style::Color, u8) -> Ve } } -// TODO: I feel like slowest and fastest are labeled wrong......... -/// Generates Timing for rain to fall. AKA the speed of the rain fall. -pub fn times(width: usize, (slowest, fastest): (u64, u64)) -> Vec<(Instant, Duration)> { +pub fn times(width: usize, (fastest, slowest): (u64, u64)) -> Vec<(Instant, Duration)> { let now = Instant::now(); let mut rng = thread_rng(); - (0..width) - .map(|_| (now, Duration::from_millis(rng.gen_range(slowest..fastest)))) + (0..width.max(1)) + .map(|_| (now, Duration::from_millis(rng.gen_range(fastest..slowest)))) .collect() } @@ -66,7 +64,7 @@ pub fn times(width: usize, (slowest, fastest): (u64, u64)) -> Vec<(Instant, Dura pub fn lengths(width: usize, height: usize) -> Vec { let mut rng = thread_rng(); (0..width.max(1)) - .map(|_| rng.gen_range(4..(height - 10).max(4))) + .map(|_| rng.gen_range(4..(height.saturating_sub(10)).max(5))) .collect() } diff --git a/src/main.rs b/src/main.rs index baa9307..cb5e769 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,14 +1,15 @@ -mod arguments; +// mod arguments; mod characters; +mod cli; mod direction; mod gen; mod rain; mod term; mod update; mod user_input; -mod user_settings; // None Standard Crates +use clap::Parser; use crossterm::{cursor, execute, queue, style, terminal}; use rand::{thread_rng, Rng}; @@ -16,14 +17,13 @@ use rand::{thread_rng, Rng}; use std::io::{stdout, Stdout, Write}; // Modules -use arguments::cargs; +//use arguments::cargs; use characters::Characters; use direction::Direction; use rain::Rain; use term::{clear, draw}; use update::{reset, update}; use user_input::user_input; -use user_settings::UserSettings; const MAXSPEED: u64 = 40; const MINSPEED: u64 = 200; @@ -37,18 +37,18 @@ Email: cowboy8625@protonmail.com struct App { stdout: Stdout, - user_settings: UserSettings, + settings: cli::Cli, } impl App { - fn new(user_settings: UserSettings) -> Self { + fn new(settings: cli::Cli) -> Self { Self { stdout: stdout(), - user_settings, + settings, } } fn run(&mut self) -> std::io::Result<()> { - let (width, height) = match self.user_settings.direction { + let (width, height) = match self.settings.direction { Direction::Left | Direction::Right => { let (w, h) = terminal::size()?; (h, w) @@ -56,30 +56,25 @@ impl App { Direction::Up | Direction::Down => terminal::size()?, }; - let create_color = gen::color_function(self.user_settings.shading); + let create_color = gen::color_function(self.settings.shade); - let mut rain = Rain::new(create_color, width, height, &self.user_settings); + let mut rain = Rain::new(create_color, width, height, &self.settings); let mut is_running = true; terminal::enable_raw_mode()?; execute!(self.stdout, terminal::EnterAlternateScreen, cursor::Hide)?; while is_running { - is_running = user_input( - &mut self.stdout, - &mut rain, - &self.user_settings, - create_color, - )?; + is_running = user_input(&mut self.stdout, &mut rain, &self.settings, create_color)?; draw( &mut self.stdout, &rain, - self.user_settings.group.width(), - &self.user_settings.direction, + self.settings.chars.width(), + &self.settings.direction, )?; self.stdout.flush()?; update(&mut rain); - reset(create_color, &mut rain, &self.user_settings); + reset(create_color, &mut rain, &self.settings); } Ok(()) } @@ -94,6 +89,6 @@ impl Drop for App { } fn main() -> std::io::Result<()> { - let user_settings = cargs(); - App::new(user_settings).run() + let settings = cli::Cli::parse(); + App::new(settings).run() } diff --git a/src/rain.rs b/src/rain.rs index 1c6c54b..fa2a83c 100644 --- a/src/rain.rs +++ b/src/rain.rs @@ -1,4 +1,5 @@ -use crate::{gen, style, UserSettings}; +use crate::cli::Cli; +use crate::{gen, style}; use std::time::{Duration, Instant}; #[derive(Debug)] @@ -9,28 +10,27 @@ pub struct Rain { pub colors: Vec>, pub time: Vec<(Instant, Duration)>, pub queue: Vec, - pub width: u16, pub height: u16, } impl Rain { - pub fn new(create_color: F, width: u16, height: u16, us: &UserSettings) -> Self + pub fn new(create_color: F, width: u16, height: u16, settings: &Cli) -> Self where F: Fn(style::Color, style::Color, u8) -> Vec, { - let w = (width / us.group.width()) as usize; + let w = (width / settings.chars.width()) as usize; let h = height as usize; - let charaters = gen::charater_vecs(w, height, &us.group); + let charaters = gen::charater_vecs(w, height, &settings.chars); let locations = vec![0; w]; let length = gen::lengths(w, h); let colors = gen::colors( create_color, - us.head_color, + settings.head_color(), w, &length, - us.rain_color.into(), + settings.rain_color().into(), ); - let time = gen::times(w, us.speed); + let time = gen::times(w, settings.speed()); let queue = Vec::with_capacity(w); Self { charaters, @@ -39,7 +39,6 @@ impl Rain { colors, time, queue, - width, height, } } diff --git a/src/update.rs b/src/update.rs index 45e68eb..f3c3576 100644 --- a/src/update.rs +++ b/src/update.rs @@ -1,4 +1,5 @@ -use crate::{gen, style, thread_rng, Rain, Rng, UserSettings}; +use crate::cli::Cli; +use crate::{gen, style, thread_rng, Rain, Rng}; use itertools::izip; use std::time::{Duration, Instant}; @@ -14,7 +15,7 @@ pub fn update(rain: &mut Rain) { } } -pub fn reset(create_color: F, rain: &mut Rain, us: &UserSettings) +pub fn reset(create_color: F, rain: &mut Rain, settings: &Cli) where F: Fn(style::Color, style::Color, u8) -> Vec, { @@ -24,17 +25,17 @@ where let now = Instant::now(); for i in rain.queue.iter() { if rain.locations[*i] > hsize + rain.length[*i] { - rain.charaters[*i] = gen::create_drop_chars(h16, &us.group); + rain.charaters[*i] = gen::create_drop_chars(h16, &settings.chars); rain.locations[*i] = 0; - rain.length[*i] = rng.gen_range(4..hsize - 10); + rain.length[*i] = rng.gen_range(4..hsize.saturating_sub(10).max(5)); rain.colors[*i] = create_color( - us.rain_color.into(), - us.head_color.into(), + settings.rain_color().into(), + settings.head_color().into(), rain.length[*i] as u8, ); rain.time[*i] = ( now, - Duration::from_millis(rng.gen_range(us.speed.0..us.speed.1)), + Duration::from_millis(rng.gen_range(settings.speed_range())), ); } } diff --git a/src/user_input.rs b/src/user_input.rs index 56aae77..1884a75 100644 --- a/src/user_input.rs +++ b/src/user_input.rs @@ -1,11 +1,13 @@ -use crate::{clear, Rain, UserSettings}; +use crate::cli::Cli; +use crate::{clear, Rain}; use crossterm::{event, style}; use std::io::Stdout; use std::time::Duration; + pub fn user_input( stdout: &mut Stdout, rain: &mut Rain, - user_settings: &UserSettings, + settings: &Cli, create_color: fn(style::Color, style::Color, u8) -> Vec, ) -> std::io::Result { if event::poll(Duration::from_millis(50))? { @@ -31,7 +33,7 @@ pub fn user_input( } event::Event::Resize(w, h) => { clear(stdout)?; - *rain = Rain::new(create_color, w, h, user_settings); + *rain = Rain::new(create_color, w, h, settings); } _ => {} }