mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-13 23:26:41 +01:00
implement TokensIterator::peek
This commit is contained in:
parent
a949117017
commit
92fcb0af8f
7 changed files with 196 additions and 198 deletions
|
|
@ -1,5 +1,4 @@
|
|||
use crate::*;
|
||||
use RefAtom::*;
|
||||
pub use self::Direction::*;
|
||||
/// A cardinal direction.
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
|
|
@ -37,28 +36,28 @@ try_from_atoms!(<'a, E>: Bsp<RenderBox<'a, E>, RenderBox<'a, E>>: |state, atoms|
|
|||
if head.kind() != TokenKind::Key { return None }
|
||||
match head.text() {
|
||||
"bsp/n" => return Some(Self::n(
|
||||
state.get_content(atoms.next()?).expect("no south"),
|
||||
state.get_content(atoms.next()?).expect("no north")
|
||||
state.get_content(&atoms.next()?).expect("no south"),
|
||||
state.get_content(&atoms.next()?).expect("no north")
|
||||
)),
|
||||
"bsp/s" => return Some(Self::s(
|
||||
state.get_content(atoms.next()?).expect("no north"),
|
||||
state.get_content(atoms.next()?).expect("no south")
|
||||
state.get_content(&atoms.next()?).expect("no north"),
|
||||
state.get_content(&atoms.next()?).expect("no south")
|
||||
)),
|
||||
"bsp/e" => return Some(Self::e(
|
||||
state.get_content(atoms.next()?).expect("no west"),
|
||||
state.get_content(atoms.next()?).expect("no east")
|
||||
state.get_content(&atoms.next()?).expect("no west"),
|
||||
state.get_content(&atoms.next()?).expect("no east")
|
||||
)),
|
||||
"bsp/w" => return Some(Self::w(
|
||||
state.get_content(atoms.next()?).expect("no east"),
|
||||
state.get_content(atoms.next()?).expect("no west")
|
||||
state.get_content(&atoms.next()?).expect("no east"),
|
||||
state.get_content(&atoms.next()?).expect("no west")
|
||||
)),
|
||||
"bsp/a" => return Some(Self::a(
|
||||
state.get_content(atoms.next()?).expect("no above"),
|
||||
state.get_content(atoms.next()?).expect("no below")
|
||||
state.get_content(&atoms.next()?).expect("no above"),
|
||||
state.get_content(&atoms.next()?).expect("no below")
|
||||
)),
|
||||
"bsp/b" => return Some(Self::b(
|
||||
state.get_content(atoms.next()?).expect("no above"),
|
||||
state.get_content(atoms.next()?).expect("no below")
|
||||
state.get_content(&atoms.next()?).expect("no above"),
|
||||
state.get_content(&atoms.next()?).expect("no below")
|
||||
)),
|
||||
_ => {}
|
||||
}
|
||||
|
|
@ -124,22 +123,18 @@ impl<E: Output, A: Content<E>, B: Content<E>> BspAreas<E, A, B> for Bsp<A, B> {
|
|||
fn direction (&self) -> Direction { self.0 }
|
||||
fn contents (&self) -> (&A, &B) { (&self.1, &self.2) }
|
||||
}
|
||||
|
||||
/// Renders multiple things on top of each other,
|
||||
#[macro_export] macro_rules! lay {
|
||||
($($expr:expr),* $(,)?) => {{ let bsp = (); $(let bsp = Bsp::b(bsp, $expr);)*; bsp }}
|
||||
}
|
||||
|
||||
/// Stack southward.
|
||||
#[macro_export] macro_rules! col {
|
||||
($($expr:expr),* $(,)?) => {{ let bsp = (); $(let bsp = Bsp::s(bsp, $expr);)*; bsp }};
|
||||
}
|
||||
|
||||
/// Stack northward.
|
||||
#[macro_export] macro_rules! col_up {
|
||||
($($expr:expr),* $(,)?) => {{ let bsp = (); $(let bsp = Bsp::n(bsp, $expr);)*; bsp }}
|
||||
}
|
||||
|
||||
/// Stack eastward.
|
||||
#[macro_export] macro_rules! row {
|
||||
($($expr:expr),* $(,)?) => {{ let bsp = (); $(let bsp = Bsp::e(bsp, $expr);)*; bsp }};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue