work
authorBen Pfaff <blp@cs.stanford.edu>
Mon, 1 Dec 2025 16:57:16 +0000 (08:57 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 1 Dec 2025 16:57:16 +0000 (08:57 -0800)
rust/pspp/src/output/render.rs

index 9b4d71cc5799e65751f12e955298a083baa717dc..25e40a56db6eaea3189046b99b1d1729f2238429 100644 (file)
@@ -686,6 +686,7 @@ impl Page {
         pixel0: usize,
         pixel1: usize,
     ) -> Arc<Self> {
+        dbg!((a, &extent, pixel0, pixel1));
         let b = !a;
         let z0 = extent.start;
         let z1 = extent.end;
@@ -756,8 +757,10 @@ impl Page {
             p0: pixel0,
             p1: pixel1,
         };
+
         // Add overflows along the left side...
         if self.h[a] == 0 || z0 > self.h[a] || pixel0 > 0 {
+            dbg!();
             let mut z = 0;
             while z < self.n[b] {
                 let d = Coord2::for_axis((a, z0), z);
@@ -1174,6 +1177,7 @@ impl Break {
         let mut size = self
             .page
             .axis_width(self.axis, 0..rule_ofs(self.page.h[self.axis]));
+        dbg!(size);
 
         // If we have a pixel offset and there is no header, then we omit
         // the leftmost rule of the body.  Otherwise the rendering is deceptive
@@ -1185,24 +1189,28 @@ impl Break {
         // assume that the width of a merged rule is the larger of the widths of
         // either rule individually.
         if self.pixel == 0 || self.page.h[self.axis] > 0 {
-            size += max(
+            size += dbg!(max(
                 self.page.rule_width(self.axis, self.page.h[self.axis]),
                 self.page.rule_width(self.axis, self.z),
-            );
+            ));
         }
 
         // Width of body, minus any pixel offset in the leftmost cell.
-        size += self
-            .page
-            .joined_width(self.axis, self.z..cell)
-            .checked_sub(self.pixel)
-            .unwrap();
+        dbg!(self.z..cell);
+        dbg!(&self.page.cp[self.axis]);
+        size += dbg!(
+            self.page
+                .joined_width(self.axis, self.z..cell)
+                .strict_sub(self.pixel)
+        );
 
         // Width of rightmost rule in body merged with leftmost rule in headers.
-        size += max(
+        size += dbg!(max(
             self.page.rule_width_r(self.axis, 0),
             self.page.rule_width(self.axis, cell),
-        );
+        ));
+
+        dbg!((cell, size));
 
         size
     }
@@ -1217,7 +1225,10 @@ impl Break {
             return None;
         }
 
-        self.find_breakpoint(device, size).map(|(z, pixel)| {
+        dbg!(&self.page);
+        dbg!(&self.page.cp[self.axis]);
+        dbg!((self.axis, self.z, size));
+        dbg!(self.find_breakpoint(device, size)).map(|(z, pixel)| {
             let page = match pixel {
                 0 => self.page.select(self.axis, self.z..z, self.pixel, 0),
                 pixel => self.page.select(
@@ -1235,6 +1246,7 @@ impl Break {
 
     fn break_cell(&self, device: &dyn Device, z: usize, overflow: usize) -> usize {
         if self.cell_is_breakable(device, z) {
+            dbg!(z);
             // If there is no right header and we render a partial cell
             // on the right side of the body, then we omit the rightmost
             // rule of the body.  Otherwise the rendering is deceptive
@@ -1333,6 +1345,10 @@ impl Break {
     /// This is just a heuristic.  Breaking cells across page boundaries can
     /// save space, but it looks ugly.
     fn cell_is_breakable(&self, device: &dyn Device, cell: usize) -> bool {
+        dbg!((
+            self.page.cell_width(self.axis, cell),
+            device.params().min_break[self.axis]
+        ));
         self.page.cell_width(self.axis, cell) >= device.params().min_break[self.axis]
     }
 }