once again, why did i begin to refactor this

This commit is contained in:
🪞👃🪞 2025-01-18 00:13:36 +01:00
parent 297f9b30df
commit 798de37172
15 changed files with 582 additions and 602 deletions

View file

@ -1,4 +1,5 @@
use crate::*;
use RefAtom::*;
#[derive(Debug, Copy, Clone, Default)] pub enum Alignment { #[default] Center, X, Y, NW, N, NE, E, SE, S, SW, W }
pub struct Align<E, A>(PhantomData<E>, Alignment, A);
impl<E, A> Align<E, A> {
@ -44,13 +45,12 @@ impl<E: Output, A: Content<E>> Content<E> for Align<E, A> {
to.place(Content::layout(self, to.area()), &self.content())
}
}
impl<'a, E: Output + 'a, T: EdnViewData<'a, E>> TryFromEdn<'a, T> for Align<E, RenderBox<'a, E>> {
impl<'a, E: Output + 'a, T: ViewContext<'a, E>> TryFromEdn<'a, T> for Align<E, RenderBox<'a, E>> {
fn try_from_edn (
state: &'a T,
head: &Atom<impl AsRef<str>>,
tail: &'a [Atom<impl AsRef<str>>]
head: &impl Atom,
tail: &'a [impl Atom]
) -> Option<Self> {
use Atom::*;
Some(match (head.to_ref(), tail) {
(Key("align/c"), [a]) => Self::c(state.get_content(a).expect("no content")),
(Key("align/x"), [a]) => Self::x(state.get_content(a).expect("no content")),