summaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-03-28 12:44:05 +0200
committerLaurenz <laurmaedje@gmail.com>2021-03-29 15:02:15 +0200
commit8c27dc101043a4a24132bd73ad39a592f9c2b2ad (patch)
tree91b0dde4d1266cab84eabd95142000a300900788 /src/layout
parent318eb9021edc493f5181247dbb7963de34126688 (diff)
Write spaces and linebreaks into text runs ✒
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/par.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/layout/par.rs b/src/layout/par.rs
index e0b42821..4077e74b 100644
--- a/src/layout/par.rs
+++ b/src/layout/par.rs
@@ -15,7 +15,7 @@ pub struct ParNode {
}
/// A child of a paragraph node.
-#[derive(Debug, Clone, PartialEq)]
+#[derive(Clone, PartialEq)]
pub enum ParChild {
/// Spacing between other nodes.
Spacing(Length),
@@ -23,8 +23,18 @@ pub enum ParChild {
Text(TextNode, Align),
/// Any child node and how to align it in its line.
Any(AnyNode, Align),
- /// A forced linebreak.
- Linebreak,
+}
+
+impl Debug for ParChild {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ match self {
+ Self::Spacing(amount) => write!(f, "Spacing({:?})", amount),
+ Self::Text(node, align) => write!(f, "Text({:?}, {:?})", node.text, align),
+ Self::Any(any, align) => {
+ f.debug_tuple("Any").field(any).field(align).finish()
+ }
+ }
+ }
}
/// A consecutive, styled run of text.
@@ -38,7 +48,7 @@ pub struct TextNode {
impl Debug for TextNode {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- write!(f, "Text({})", self.text)
+ write!(f, "Text({:?})", self.text)
}
}
@@ -57,7 +67,6 @@ impl Layout for ParNode {
layouter.push_frame(frame, align);
}
}
- ParChild::Linebreak => layouter.finish_line(),
}
}
layouter.finish()