summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
Diffstat (limited to 'src/library')
-rw-r--r--src/library/extend.rs2
-rw-r--r--src/library/insert.rs4
-rw-r--r--src/library/layout.rs28
-rw-r--r--src/library/style.rs16
4 files changed, 25 insertions, 25 deletions
diff --git a/src/library/extend.rs b/src/library/extend.rs
index e388c9c8..6396274e 100644
--- a/src/library/extend.rs
+++ b/src/library/extend.rs
@@ -7,7 +7,7 @@ use crate::prelude::*;
///
/// # Return value
/// The name of the value's type as a string.
-pub fn type_(ctx: &mut EvalContext, args: &mut Args) -> Value {
+pub fn type_(ctx: &mut EvalContext, args: &mut ValueArgs) -> Value {
if let Some(value) = args.require::<Value>(ctx, "value") {
value.type_name().into()
} else {
diff --git a/src/library/insert.rs b/src/library/insert.rs
index eff54e91..4f0f6489 100644
--- a/src/library/insert.rs
+++ b/src/library/insert.rs
@@ -10,12 +10,12 @@ use crate::prelude::*;
///
/// # Positional arguments
/// - Path to image file: of type `string`.
-pub fn image(ctx: &mut EvalContext, args: &mut Args) -> Value {
+pub fn image(ctx: &mut EvalContext, args: &mut ValueArgs) -> Value {
let path = args.require::<Spanned<String>>(ctx, "path to image file");
let width = args.get(ctx, "width");
let height = args.get(ctx, "height");
- Value::template(move |ctx| {
+ Value::template("image", move |ctx| {
if let Some(path) = &path {
let loaded = ctx.env.resources.load(&path.v, ImageResource::parse);
if let Some((res, img)) = loaded {
diff --git a/src/library/layout.rs b/src/library/layout.rs
index 44c98536..3577ee36 100644
--- a/src/library/layout.rs
+++ b/src/library/layout.rs
@@ -26,14 +26,14 @@ use crate::prelude::*;
/// - `top`
/// - `bottom`
/// - `center`
-pub fn align(ctx: &mut EvalContext, args: &mut Args) -> Value {
+pub fn align(ctx: &mut EvalContext, args: &mut ValueArgs) -> Value {
let first = args.find(ctx);
let second = args.find(ctx);
let hor = args.get(ctx, "horizontal");
let ver = args.get(ctx, "vertical");
let body = args.find::<ValueTemplate>(ctx);
- Value::template(move |ctx| {
+ Value::template("align", move |ctx| {
let snapshot = ctx.state.clone();
let mut had = Gen::uniform(false);
@@ -157,7 +157,7 @@ impl Switch for Alignment {
}
}
-impl_type! {
+typify! {
Alignment: "alignment",
}
@@ -188,7 +188,7 @@ impl Display for Alignment {
/// - `rtl` (right to left)
/// - `ttb` (top to bottom)
/// - `btt` (bottom to top)
-pub fn box_(ctx: &mut EvalContext, args: &mut Args) -> Value {
+pub fn box_(ctx: &mut EvalContext, args: &mut ValueArgs) -> Value {
let width = args.get(ctx, "width");
let height = args.get(ctx, "height");
let main = args.get(ctx, "main-dir");
@@ -196,7 +196,7 @@ pub fn box_(ctx: &mut EvalContext, args: &mut Args) -> Value {
let color = args.get(ctx, "color");
let body = args.find::<ValueTemplate>(ctx);
- Value::template(move |ctx| {
+ Value::template("box", move |ctx| {
let snapshot = ctx.state.clone();
ctx.set_dirs(Gen::new(main, cross));
@@ -230,7 +230,7 @@ pub fn box_(ctx: &mut EvalContext, args: &mut Args) -> Value {
})
}
-impl_type! {
+typify! {
Dir: "direction"
}
@@ -238,7 +238,7 @@ impl_type! {
///
/// # Positional arguments
/// - Amount of spacing: of type `linear` relative to current font size.
-pub fn h(ctx: &mut EvalContext, args: &mut Args) -> Value {
+pub fn h(ctx: &mut EvalContext, args: &mut ValueArgs) -> Value {
spacing(ctx, args, SpecAxis::Horizontal)
}
@@ -246,15 +246,15 @@ pub fn h(ctx: &mut EvalContext, args: &mut Args) -> Value {
///
/// # Positional arguments
/// - Amount of spacing: of type `linear` relative to current font size.
-pub fn v(ctx: &mut EvalContext, args: &mut Args) -> Value {
+pub fn v(ctx: &mut EvalContext, args: &mut ValueArgs) -> Value {
spacing(ctx, args, SpecAxis::Vertical)
}
/// Apply spacing along a specific axis.
-fn spacing(ctx: &mut EvalContext, args: &mut Args, axis: SpecAxis) -> Value {
+fn spacing(ctx: &mut EvalContext, args: &mut ValueArgs, axis: SpecAxis) -> Value {
let spacing: Option<Linear> = args.require(ctx, "spacing");
- Value::template(move |ctx| {
+ Value::template("spacing", move |ctx| {
if let Some(linear) = spacing {
let amount = linear.resolve(ctx.state.font.font_size());
let spacing = NodeSpacing { amount, softness: Softness::Hard };
@@ -286,7 +286,7 @@ fn spacing(ctx: &mut EvalContext, args: &mut Args, axis: SpecAxis) -> Value {
/// - Flip width and height: `flip`, of type `bool`.
/// - Main layouting direction: `main-dir`, of type `direction`.
/// - Cross layouting direction: `cross-dir`, of type `direction`.
-pub fn page(ctx: &mut EvalContext, args: &mut Args) -> Value {
+pub fn page(ctx: &mut EvalContext, args: &mut ValueArgs) -> Value {
let paper = args.find::<Spanned<String>>(ctx).and_then(|name| {
Paper::from_name(&name.v).or_else(|| {
ctx.diag(error!(name.span, "invalid paper name"));
@@ -305,7 +305,7 @@ pub fn page(ctx: &mut EvalContext, args: &mut Args) -> Value {
let cross = args.get(ctx, "cross-dir");
let body = args.find::<ValueTemplate>(ctx);
- Value::template(move |ctx| {
+ Value::template("page", move |ctx| {
let snapshot = ctx.state.clone();
if let Some(paper) = paper {
@@ -370,8 +370,8 @@ pub fn page(ctx: &mut EvalContext, args: &mut Args) -> Value {
}
/// `pagebreak`: Start a new page.
-pub fn pagebreak(_: &mut EvalContext, _: &mut Args) -> Value {
- Value::template(move |ctx| {
+pub fn pagebreak(_: &mut EvalContext, _: &mut ValueArgs) -> Value {
+ Value::template("pagebreak", move |ctx| {
ctx.end_page_group(|_| true);
ctx.start_page_group(Softness::Hard);
})
diff --git a/src/library/style.rs b/src/library/style.rs
index 23bd5298..35727515 100644
--- a/src/library/style.rs
+++ b/src/library/style.rs
@@ -54,7 +54,7 @@ use crate::prelude::*;
/// - `expanded`
/// - `extra-expanded`
/// - `ultra-expanded`
-pub fn font(ctx: &mut EvalContext, args: &mut Args) -> Value {
+pub fn font(ctx: &mut EvalContext, args: &mut ValueArgs) -> Value {
let size = args.find::<Linear>(ctx);
let list: Vec<_> = args.filter::<FontFamily>(ctx).map(|f| f.to_string()).collect();
let style = args.get(ctx, "style");
@@ -65,7 +65,7 @@ pub fn font(ctx: &mut EvalContext, args: &mut Args) -> Value {
let monospace = args.get(ctx, "monospace");
let body = args.find::<ValueTemplate>(ctx);
- Value::template(move |ctx| {
+ Value::template("font", move |ctx| {
let snapshot = ctx.state.clone();
if let Some(linear) = size {
@@ -145,7 +145,7 @@ impl Display for FontFamily {
}
}
-impl_type! {
+typify! {
FontFamilies: "font family or array of font families",
Value::Str(string) => Self(vec![FontFamily::Named(string.to_lowercase())]),
Value::Array(values) => Self(values
@@ -156,16 +156,16 @@ impl_type! {
#(family: FontFamily) => Self(vec![family]),
}
-impl_type! {
+typify! {
FontFamily: "font family",
Value::Str(string) => Self::Named(string.to_lowercase())
}
-impl_type! {
+typify! {
FontStyle: "font style"
}
-impl_type! {
+typify! {
FontWeight: "font weight",
Value::Int(number) => {
let [min, max] = [Self::THIN, Self::BLACK];
@@ -180,7 +180,7 @@ impl_type! {
},
}
-impl_type! {
+typify! {
FontStretch: "font stretch"
}
@@ -191,7 +191,7 @@ impl_type! {
/// - Green component: of type `float`, between 0.0 and 1.0.
/// - Blue component: of type `float`, between 0.0 and 1.0.
/// - Alpha component: optional, of type `float`, between 0.0 and 1.0.
-pub fn rgb(ctx: &mut EvalContext, args: &mut Args) -> Value {
+pub fn rgb(ctx: &mut EvalContext, args: &mut ValueArgs) -> Value {
let r = args.require(ctx, "red component");
let g = args.require(ctx, "green component");
let b = args.require(ctx, "blue component");