finally trying to start bringing in crisp properly

This commit is contained in:
Chris Cochrun 2024-11-19 17:45:04 -06:00
parent d6536f8a88
commit 6f33930cc9
4 changed files with 105 additions and 109 deletions

1
Cargo.lock generated
View file

@ -1257,7 +1257,6 @@ dependencies = [
[[package]]
name = "crisp"
version = "0.1.0"
source = "git+https://git.tfcconnection.org/chris/crisp#b01eda5e0e3df469b45ff91424f7ad6f806cbca3"
dependencies = [
"lazy_static",
"miette",

View file

@ -23,4 +23,4 @@ ron = "0.8.1"
sqlx = { version = "0.8.2", features = ["sqlite"] }
dirs = "5.0.1"
tokio = "1.41.1"
crisp = { git = "https://git.tfcconnection.org/chris/crisp" }
crisp = { path = "../crisp" }

View file

@ -222,8 +222,7 @@ fn lisp_to_background(lisp: &Value) -> Background {
v == Value::Keyword(Keyword::from("source"))
}) {
let path = list[source + 1];
let path = String::from(path);
Background::from(path)
Background::try_from(&path)
} else {
Background::default()
}
@ -365,46 +364,46 @@ impl Image {
}
}
fn build_image_bg(
atom: &Value,
image_map: &mut HashMap<String, String>,
map_index: usize,
) {
// This needs to be the cons that contains (image . ...)
// the image is a symbol and the rest are keywords and other maps
if atom.is_symbol() {
// We shouldn't get a symbol
return;
}
// fn build_image_bg(
// atom: &Value,
// image_map: &mut HashMap<String, String>,
// map_index: usize,
// ) {
// // This needs to be the cons that contains (image . ...)
// // the image is a symbol and the rest are keywords and other maps
// if atom.is_symbol() {
// // We shouldn't get a symbol
// return;
// }
for atom in
atom.list_iter().unwrap().map(|a| a.as_cons().unwrap())
{
if atom.car() == &Value::Symbol("image".into()) {
build_image_bg(atom.cdr(), image_map, map_index);
} else {
let atom = atom.car();
match atom {
Value::Keyword(keyword) => {
image_map.insert(keyword.to_string(), "".into());
build_image_bg(atom, image_map, map_index);
}
Value::Symbol(symbol) => {
// let mut key;
// let image_map = image_map
// .iter_mut()
// .enumerate()
// .filter(|(i, e)| i == &map_index)
// .map(|(i, (k, v))| v.push_str(symbol))
// .collect();
build_image_bg(atom, image_map, map_index);
}
Value::String(string) => {}
_ => {}
}
}
}
}
// for atom in
// atom.list_iter().unwrap().map(|a| a.as_cons().unwrap())
// {
// if atom.car() == &Value::Symbol("image".into()) {
// build_image_bg(atom.cdr(), image_map, map_index);
// } else {
// let atom = atom.car();
// match atom {
// Value::Keyword(keyword) => {
// image_map.insert(keyword.to_string(), "".into());
// build_image_bg(atom, image_map, map_index);
// }
// Value::Symbol(symbol) => {
// // let mut key;
// // let image_map = image_map
// // .iter_mut()
// // .enumerate()
// // .filter(|(i, e)| i == &map_index)
// // .map(|(i, (k, v))| v.push_str(symbol))
// // .collect();
// build_image_bg(atom, image_map, map_index);
// }
// Value::String(string) => {}
// _ => {}
// }
// }
// }
// }
// fn build_slide(exp: Value) -> Result<Slide> {
// let mut slide_builder = SlideBuilder::new();
@ -426,57 +425,57 @@ fn build_image_bg(
// todo!()
// }
fn build_slides(
cons: &lexpr::Cons,
mut current_symbol: Symbol,
mut slide_builder: SlideBuilder,
) -> SlideBuilder {
for value in cons.list_iter() {
dbg!(&current_symbol);
match value {
Value::Cons(v) => {
slide_builder = build_slides(
&v,
current_symbol.clone(),
slide_builder,
);
}
Value::Nil => {
dbg!(Value::Nil);
}
Value::Bool(boolean) => {
dbg!(boolean);
}
Value::Number(number) => {
dbg!(number);
}
Value::String(string) => {
dbg!(string);
}
Value::Symbol(symbol) => {
dbg!(symbol);
current_symbol =
Symbol::from_str(symbol).unwrap_or_default();
}
Value::Keyword(keyword) => {
dbg!(keyword);
}
Value::Null => {
dbg!("null");
}
Value::Char(c) => {
dbg!(c);
}
Value::Bytes(b) => {
dbg!(b);
}
Value::Vector(v) => {
dbg!(v);
}
}
}
slide_builder
}
// fn build_slides(
// cons: &lexpr::Cons,
// mut current_symbol: Symbol,
// mut slide_builder: SlideBuilder,
// ) -> SlideBuilder {
// for value in cons.list_iter() {
// dbg!(&current_symbol);
// match value {
// Value::Cons(v) => {
// slide_builder = build_slides(
// &v,
// current_symbol.clone(),
// slide_builder,
// );
// }
// Value::Nil => {
// dbg!(Value::Nil);
// }
// Value::Bool(boolean) => {
// dbg!(boolean);
// }
// Value::Number(number) => {
// dbg!(number);
// }
// Value::String(string) => {
// dbg!(string);
// }
// Value::Symbol(symbol) => {
// dbg!(symbol);
// current_symbol =
// Symbol::from_str(symbol).unwrap_or_default();
// }
// Value::Keyword(keyword) => {
// dbg!(keyword);
// }
// Value::Null => {
// dbg!("null");
// }
// Value::Char(c) => {
// dbg!(c);
// }
// Value::Bytes(b) => {
// dbg!(b);
// }
// Value::Vector(v) => {
// dbg!(v);
// }
// }
// }
// slide_builder
// }
#[cfg(test)]
mod test {

View file

@ -84,10 +84,12 @@ struct App {
impl Default for App {
fn default() -> Self {
let initial_slide = SlideBuilder::new()
.background(PathBuf::from(
.background(
Background::try_from(
"/home/chris/vids/test/chosensmol.mp4",
))
.expect("oops video")
)
.unwrap(),
)
.text("Hello")
.build()
.expect("oops slide");
@ -144,13 +146,11 @@ impl cosmic::Application for App {
let initial_slide = SlideBuilder::new()
.background(
PathBuf::from(
Background::try_from(
"/home/chris/vids/test/camprules2024.mp4",
)
.canonicalize()
.unwrap(),
)
.expect("oops video")
.text("")
.font("Quicksand")
.font_size(50)
@ -163,11 +163,9 @@ impl cosmic::Application for App {
let second_slide = SlideBuilder::new()
.background(
PathBuf::from("/home/chris/pics/frodo.jpg")
.canonicalize()
Background::try_from("/home/chris/pics/frodo.jpg")
.unwrap(),
)
.expect("oops video")
.text("Hello")
.font("Quicksand")
.font_size(50)
@ -180,11 +178,9 @@ impl cosmic::Application for App {
let tetrary_slide = SlideBuilder::new()
.background(
PathBuf::from("/home/chris/pics/wojaks/reddit_the_xenomorph_s bigass wojak folder/Chads/ChristianChad_x16_drawing.png")
.canonicalize()
Background::try_from("/home/chris/pics/wojaks/reddit_the_xenomorph_s bigass wojak folder/Chads/ChristianChad_x16_drawing.png")
.unwrap(),
)
.expect("oops video")
.text("Hello")
.font("Quicksand")
.font_size(50)
@ -583,8 +579,10 @@ where
fn test_slide<'a>() -> Element<'a, Message> {
if let Ok(slide) = SlideBuilder::new()
.background(PathBuf::from("/home/chris/pics/frodo.jpg"))
.unwrap()
.background(
Background::try_from("/home/chris/pics/frodo.jpg")
.unwrap(),
)
.text("This is a frodo")
.text_alignment(TextAlignment::TopCenter)
.font_size(50)