summaryrefslogtreecommitdiff
path: root/src/model/value.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-26 13:39:18 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-26 13:41:27 +0100
commit7af46fc025ee08eb78ae7f6898300083c886bf6f (patch)
tree5837d972961844650bc9668d8516d7b5239a8d18 /src/model/value.rs
parent3cdd8bfa40fe5fdf0c676af905c3c2c1f614ef24 (diff)
Dynamic labels
Diffstat (limited to 'src/model/value.rs')
-rw-r--r--src/model/value.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/model/value.rs b/src/model/value.rs
index aec68ca1..043fde34 100644
--- a/src/model/value.rs
+++ b/src/model/value.rs
@@ -6,7 +6,7 @@ use std::sync::Arc;
use siphasher::sip128::{Hasher128, SipHasher};
-use super::{format_str, ops, Args, Array, Cast, Content, Dict, Func, Str};
+use super::{format_str, ops, Args, Array, Cast, Content, Dict, Func, Label, Str};
use crate::diag::StrResult;
use crate::geom::{Abs, Angle, Color, Em, Fr, Length, Ratio, Rel, RgbaColor};
use crate::util::{format_eco, EcoString};
@@ -38,6 +38,8 @@ pub enum Value {
Color(Color),
/// A string: `"string"`.
Str(Str),
+ /// A label: `<intro>`.
+ Label(Label),
/// A content value: `[*Hi* there]`.
Content(Content),
/// An array of values: `(1, "hi", 12cm)`.
@@ -76,6 +78,7 @@ impl Value {
Self::Fraction(_) => Fr::TYPE_NAME,
Self::Color(_) => Color::TYPE_NAME,
Self::Str(_) => Str::TYPE_NAME,
+ Self::Label(_) => Label::TYPE_NAME,
Self::Content(_) => Content::TYPE_NAME,
Self::Array(_) => Array::TYPE_NAME,
Self::Dict(_) => Dict::TYPE_NAME,
@@ -130,6 +133,7 @@ impl Debug for Value {
Self::Fraction(v) => Debug::fmt(v, f),
Self::Color(v) => Debug::fmt(v, f),
Self::Str(v) => Debug::fmt(v, f),
+ Self::Label(v) => Debug::fmt(v, f),
Self::Content(_) => f.pad("[...]"),
Self::Array(v) => Debug::fmt(v, f),
Self::Dict(v) => Debug::fmt(v, f),
@@ -168,6 +172,7 @@ impl Hash for Value {
Self::Fraction(v) => v.hash(state),
Self::Color(v) => v.hash(state),
Self::Str(v) => v.hash(state),
+ Self::Label(v) => v.hash(state),
Self::Content(v) => v.hash(state),
Self::Array(v) => v.hash(state),
Self::Dict(v) => v.hash(state),
@@ -373,6 +378,7 @@ primitive! { Rel<Length>: "relative length",
primitive! { Fr: "fraction", Fraction }
primitive! { Color: "color", Color }
primitive! { Str: "string", Str }
+primitive! { Label: "label", Label }
primitive! { Content: "content",
Content,
None => Content::empty(),