Print function for debugging

This commit is contained in:
Laurenz 2022-05-27 14:19:58 +02:00
parent 9950a69d23
commit ae68a15a46

View File

@ -70,7 +70,7 @@ fn main() {
);
styles.set(TextNode::SIZE, TextSize(Length::pt(10.0).into()));
// Hook up two more colors and an assert function into the global scope.
// Hook up helpers into the global scope.
let mut std = typst::library::new();
std.define("conifer", RgbaColor::new(0x9f, 0xEB, 0x52, 0xFF));
std.define("forest", RgbaColor::new(0x43, 0xA1, 0x27, 0xFF));
@ -82,6 +82,17 @@ fn main() {
}
Ok(Value::None)
});
std.def_fn("print", move |_, args| {
print!("> ");
for (i, value) in args.all::<Value>()?.into_iter().enumerate() {
if i > 0 {
print!(", ")
}
print!("{value:?}");
}
println!();
Ok(Value::None)
});
// Create loader and context.
let loader = FsLoader::new().with_path(FONT_DIR);