Expose page depth to the output routine
This commit is contained in:
1 parent
c8805af755
commit
62d3c4154e
4 files changed
+52
-7
No files matched your search
@@ -3,7 +3,7 @@
|
||||
//! Only the subset that decides *which* page box leaves the page builder is
|
||||
//! supported today: `\shipout\box255`, `\relax`, `\message{...}` and
|
||||
//! `\ifdim` comparisons over the page registers `\pagegoal`, `\pagetotal`,
|
||||
//! `\vsize`, `\topskip` and `\maxdepth`. Anything else is a parse error, which
|
||||
//! `\pagedepth`, `\vsize`, `\topskip` and `\maxdepth`. Anything else is a parse error, which
|
||||
//! makes `Engine::layout_paged` fall back to the scrolling builder.
|
||||
|
||||
use std::fmt;
|
||||
@@ -15,6 +15,8 @@ pub struct OutputContext {
|
||||
pub page_goal: i64,
|
||||
/// TeX `\pagetotal`: the height accumulated on the current page.
|
||||
pub page_total: i64,
|
||||
/// TeX `\pagedepth`: the depth of the page box so far.
|
||||
pub page_depth: i64,
|
||||
/// TeX `\vsize`: the configured page height.
|
||||
pub vsize: i64,
|
||||
/// TeX `\topskip`.
|
||||
@@ -96,6 +98,7 @@ enum Dimension {
|
||||
enum Register {
|
||||
PageGoal,
|
||||
PageTotal,
|
||||
PageDepth,
|
||||
Vsize,
|
||||
TopSkip,
|
||||
MaxDepth,
|
||||
@@ -108,6 +111,7 @@ impl Dimension {
|
||||
Self::Register(register) => match register {
|
||||
Register::PageGoal => context.page_goal,
|
||||
Register::PageTotal => context.page_total,
|
||||
Register::PageDepth => context.page_depth,
|
||||
Register::Vsize => context.vsize,
|
||||
Register::TopSkip => context.top_skip,
|
||||
Register::MaxDepth => context.max_depth,
|
||||
@@ -473,6 +477,7 @@ fn parse_dimension(tokens: &[Token], index: &mut usize) -> Result<Dimension, Str
|
||||
let register = match name.as_str() {
|
||||
"pagegoal" => Register::PageGoal,
|
||||
"pagetotal" => Register::PageTotal,
|
||||
"pagedepth" => Register::PageDepth,
|
||||
"vsize" => Register::Vsize,
|
||||
"topskip" => Register::TopSkip,
|
||||
"maxdepth" => Register::MaxDepth,
|
||||
@@ -560,6 +565,7 @@ mod tests {
|
||||
OutputContext {
|
||||
page_goal: 612 * 65_536,
|
||||
page_total,
|
||||
page_depth: 0,
|
||||
vsize: 612 * 65_536,
|
||||
top_skip: 10 * 65_536,
|
||||
max_depth: 0,
|
||||
@@ -575,6 +581,15 @@ mod tests {
|
||||
assert_eq!(program.shipout_count(&context(0)).unwrap(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn page_depth_register_is_visible() {
|
||||
let program = OutputProgram::parse(r"\ifdim\pagedepth>4pt\shipout\box255\fi").unwrap();
|
||||
let mut deep = context(0);
|
||||
deep.page_depth = 5 * 65_536;
|
||||
assert_eq!(program.shipout_count(&deep).unwrap(), 1);
|
||||
assert_eq!(program.shipout_count(&context(0)).unwrap(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn conditional_ships_only_large_pages() {
|
||||
let program = OutputProgram::parse(r"\ifdim\pagetotal>50pt\shipout\box255\fi").unwrap();
|
||||
|
||||
Reference in new issue
Block a user