diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-01-24 12:44:04 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-01-24 12:44:04 +0100 |
| commit | 03fddaf3aea778057aedd74dbcb27bae971ec22f (patch) | |
| tree | 37e3136e29e0e5d69ec8f56e43d156739d2931ab /src/layout/mod.rs | |
| parent | 78da2bdd5d77d1b8572e5e9da119bfa68127a3fa (diff) | |
Non-fatal argument parsing 🌋
Diffstat (limited to 'src/layout/mod.rs')
| -rw-r--r-- | src/layout/mod.rs | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 1cc16a26..209874a1 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -1,10 +1,11 @@ //! The core layouting engine. use std::io::{self, Write}; +use std::fmt::{self, Display, Formatter}; use smallvec::SmallVec; use toddle::query::{SharedFontLoader, FontIndex}; -use crate::error::Error; +use crate::error::Errors; use crate::syntax::{SyntaxModel, SpanVec}; use crate::size::{Size, Size2D, SizeBox}; use crate::style::LayoutStyle; @@ -93,7 +94,7 @@ pub struct LayoutContext<'a, 'p> { pub struct Layouted<T> { pub output: T, - pub errors: SpanVec<Error>, + pub errors: Errors, } impl<T> Layouted<T> { @@ -231,6 +232,15 @@ impl GenericAxis { } } +impl Display for GenericAxis { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + match self { + Primary => write!(f, "primary"), + Secondary => write!(f, "secondary"), + } + } +} + /// The two specific layouting axes. #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub enum SpecificAxis { @@ -253,6 +263,15 @@ impl SpecificAxis { } } +impl Display for SpecificAxis { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + match self { + Horizontal => write!(f, "horizontal"), + Vertical => write!(f, "vertical"), + } + } +} + /// Directions along which content is laid out. #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub enum Direction { @@ -298,6 +317,17 @@ impl Direction { } } +impl Display for Direction { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + match self { + LeftToRight => write!(f, "left-to-right"), + RightToLeft => write!(f, "right-to-left"), + TopToBottom => write!(f, "top-to-bottom"), + BottomToTop => write!(f, "bottom-to-top"), + } + } +} + /// Where to align a layout in a container. #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub struct LayoutAlignment { |
