gbranden pushed a commit to branch master
in repository groff.

commit 2c8e354f221a3a155497ddb2215226ab0de63897
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Aug 4 18:28:52 2023 -0500

    [tbl]: Fix staggering of text block cells.
    
    * src/preproc/tbl/table.cpp: Add C preprocessor macro storing a "text
      block staggering macro".
    
      (block_entry::position_vertically): Call it in generated output with a
      negative half-vee motion.
    
      (block_entry::position_vertically, left_block_entry::print)
      (right_block_entry::print, center_block_entry::print)
      (alphabetic_block_entry::print): Call it in generated output with a
      positive half-vee motion (if staggering cell).
    
      (table::init_output): Write out its definition in generated output.
      It wraps the `sp` request.  If we're in a diversion, use the `\!`
      technique to recursively call ourselves and bubble up the spacing
      request a diversion level (spacing requests of anything other than 1v
      are ignored in diversions).  Otherwise, invoke the request.
    
    Fixes <https://savannah.gnu.org/bugs/?64454> a.k.a. Debian #1038391.
    Thanks to наб for the report and a good test case.
    
    ANNOUNCE: Credit наб.
---
 ANNOUNCE                  |  1 +
 ChangeLog                 | 22 ++++++++++++++++++++++
 src/preproc/tbl/table.cpp | 15 ++++++++++++++-
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/ANNOUNCE b/ANNOUNCE
index f07e7446d..0c71843b8 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -189,3 +189,4 @@ Mike Fulton
 Nikita Ivanov
 Peter Schaffter
 Ralph Corderoy
+наб
diff --git a/ChangeLog b/ChangeLog
index 7e2f4f943..de72ac7ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2023-08-04  G. Branden Robinson <[email protected]>
+
+       [tbl]: Fix staggering of text block cells.
+
+       * src/preproc/tbl/table.cpp: Add C preprocessor macro storing a
+       "text block staggering macro".
+       (block_entry::position_vertically): Call it in generated output
+       with a negative half-vee motion.
+       (block_entry::position_vertically, left_block_entry::print)
+       (right_block_entry::print, center_block_entry::print)
+       (alphabetic_block_entry::print): Call it in generated output
+       with a positive half-vee motion.
+       (table::init_output): Write out its definition in generated
+       output.  It wraps the `sp` request.  If we're in a diversion,
+       use the `\!` technique to recursively call ourselves and bubble
+       up the spacing request a diversion level (spacing requests of
+       anything other than 1v are ignored in diversions).  Otherwise,
+       invoke the request.
+
+       Fixes <https://savannah.gnu.org/bugs/?64454> a.k.a. Debian
+       #1038391.  Thanks to наб for the report and a good test case.
+
 2023-08-04  G. Branden Robinson <[email protected]>
 
        [tbl]: Regression-test Debian #1038391.
diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp
index bf4167303..c288a65af 100644
--- a/src/preproc/tbl/table.cpp
+++ b/src/preproc/tbl/table.cpp
@@ -59,6 +59,7 @@ const int DEFAULT_COLUMN_SEPARATION = 3;
 #define NEEDED_REG PREFIX "needed"
 #define REPEATED_MARK_MACRO PREFIX "rmk"
 #define REPEATED_VPT_MACRO PREFIX "rvpt"
+#define TEXT_BLOCK_STAGGERING_MACRO PREFIX "sp"
 #define SUPPRESS_BOTTOM_REG PREFIX "supbot"
 #define SAVED_DN_REG PREFIX "dn"
 #define SAVED_HYPHENATION_MODE_REG PREFIX "hyphmode"
@@ -677,7 +678,7 @@ void block_entry::position_vertically()
                  " CENTER, or BOTTOM");
     }
   if (mod->stagger)
-    prints(".sp -.5v\n");
+    prints("." TEXT_BLOCK_STAGGERING_MACRO " -.5v\n");
 }
 
 int block_entry::divert(int ncols, const string *mw, int *sep, int do_expand)
@@ -777,6 +778,8 @@ void left_block_entry::print()
 {
   printfs(".in +\\n[%1]u\n", column_start_reg(start_col));
   printfs(".%1\n", block_diversion_name(start_row, start_col));
+  if (mod->stagger)
+    prints("." TEXT_BLOCK_STAGGERING_MACRO " .5v\n");
   prints(".in\n");
 }
 
@@ -793,6 +796,8 @@ void right_block_entry::print()
          span_width_reg(start_col, end_col),
          block_width_reg(start_row, start_col));
   printfs(".%1\n", block_diversion_name(start_row, start_col));
+  if (mod->stagger)
+    prints("." TEXT_BLOCK_STAGGERING_MACRO " .5v\n");
   prints(".in\n");
 }
 
@@ -809,6 +814,8 @@ void center_block_entry::print()
          span_width_reg(start_col, end_col),
          block_width_reg(start_row, start_col));
   printfs(".%1\n", block_diversion_name(start_row, start_col));
+  if (mod->stagger)
+    prints("." TEXT_BLOCK_STAGGERING_MACRO " .5v\n");
   prints(".in\n");
 }
 
@@ -833,6 +840,8 @@ void alphabetic_block_entry::print()
          span_width_reg(start_col, end_col),
          span_alphabetic_width_reg(start_col, end_col));
   printfs(".%1\n", block_diversion_name(start_row, start_col));
+  if (mod->stagger)
+    prints("." TEXT_BLOCK_STAGGERING_MACRO " .5v\n");
   prints(".in\n");
 }
 
@@ -1847,6 +1856,10 @@ void table::init_output()
         ".nr " NEED_BOTTOM_RULE_REG " 1\n"
         ".nr " SUPPRESS_BOTTOM_REG " 0\n"
         ".eo\n"
+        ".de " TEXT_BLOCK_STAGGERING_MACRO "\n"
+        ".  ie !'\\n(.z'' \\!.3sp \"\\$1\"\n"
+        ".  el .sp \\$1\n"
+        "..\n"
         ".de " REPEATED_MARK_MACRO "\n"
         ".  mk \\$1\n"
         ".  if !'\\n(.z'' \\!." REPEATED_MARK_MACRO " \"\\$1\"\n"

_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to