diff options
| -rw-r--r-- | src/generation.rs | 4 | ||||
| -rw-r--r-- | src/ui.rs | 2585 |
2 files changed, 18 insertions, 2571 deletions
diff --git a/src/generation.rs b/src/generation.rs index 4031c46..63aa3e3 100644 --- a/src/generation.rs +++ b/src/generation.rs @@ -17,7 +17,7 @@ use std::{ error::Error, fs::File, io::{self, BufRead, BufReader, Write}, - path::Path, + path::PathBuf, thread::sleep, time::Duration, }; @@ -159,7 +159,7 @@ pub fn next_gen(app: &mut App) -> Gen { nxt_gen } -pub fn gen_from_file(path: &Path) -> Gen { +pub fn gen_from_file(path: &PathBuf) -> Gen { let mut gen = Gen::new(); let file = File::open(path).expect("File not found"); let reader = BufReader::new(file); @@ -6,7 +6,7 @@ use crossterm::{ use std::{ error::Error, io, - path::Path, + path::{Path, PathBuf}, thread::sleep, time::{Duration, Instant}, }; @@ -74,2576 +74,23 @@ impl<T> StatefulList<T> { /// /// Check the event handling at the bottom to see how to change the state on incoming events. /// Check the drawing logic for items on how to specify the highlighting style for selected items. -pub struct App<'a> { - pub items: StatefulList<(&'a str, &'a Path)>, +pub struct App { + pub items: StatefulList<(String, PathBuf)>, pub flag_cur: bool, pub layout: Layout, pub cur_gen: Gen, } -impl<'a> App<'a> { - pub fn new() -> App<'a> { +impl App { + pub fn new() -> App { + let mut v = vec![]; + for i in 1..=513 { + let name = format!("pattern{}", i); + let p = format!("./presets/patterns/pattern{}.txt", i); + v.push((name.to_owned(), Path::new(p.as_str()).to_owned())); + } App { - items: StatefulList::with_items(vec