groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 07/07: [tbl]: Save and restore hyphenation parameters.


From: G. Branden Robinson
Subject: [groff] 07/07: [tbl]: Save and restore hyphenation parameters.
Date: Fri, 29 Jan 2021 16:21:49 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit cee547e8839a82f8b21b2859a9370fd74f9793f3
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Jan 30 08:13:43 2021 +1100

    [tbl]: Save and restore hyphenation parameters.
    
    * src/preproc/tbl/table.cpp (table::init_output): When starting a table,
      save the hyphenation parameters (\n[.hy], \n[.hla], \n[.hlm],
      \n[.hym], \n[.hys]).  Restore them in the table reset macro
      (confusingly called "3init"), which is called before performing each
      diversion and before exiting a table.
    
      This enables people to, e.g., turn off hyphenation in a table text
      block with .nh, just as they can turn off adjustment with .na, without
      having to manually reset it.  The next text block, and the material
      after the table, will not be affected.
    
    Fixes <https://savannah.gnu.org/bugs/?59971>.
---
 ChangeLog                 | 17 +++++++++++++++++
 src/preproc/tbl/table.cpp | 17 ++++++++++++++++-
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 1ddb4b1..c74ba67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
 2021-01-30  G. Branden Robinson <g.branden.robinson@gmail.com>
 
+       [tbl]: Save and restore hyphenation parameters.
+
+       * src/preproc/tbl/table.cpp (table::init_output): When starting
+       a table, save the hyphenation parameters (\n[.hy], \n[.hla],
+       \n[.hlm], \n[.hym], \n[.hys]).  Restore them in the table reset
+       macro (confusingly called "3init"), which is called before
+       performing each diversion and before exiting a table.
+
+       This enables people to, e.g., turn off hyphenation in a table
+       text block with .nh, just as they can turn off adjustment with
+       .na, without having to manually reset it.  The next text block,
+       and the material after the table, will not be affected.
+
+       Fixes <https://savannah.gnu.org/bugs/?59971>.
+
+2021-01-30  G. Branden Robinson <g.branden.robinson@gmail.com>
+
        Add regression test for Savannah #59971.
 
        * src/preproc/tbl/tests/\
diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp
index 33a5c2d..8c83c7f 100644
--- a/src/preproc/tbl/table.cpp
+++ b/src/preproc/tbl/table.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2021 Free Software Foundation, Inc.
      Written by James Clark (jjc@jclark.com)
 
 This file is part of groff.
@@ -63,6 +63,11 @@ const int DEFAULT_COLUMN_SEPARATION = 3;
 #define ROW_MAX_LINE_REG PREFIX "lnmx"
 #define REPEATED_NM_SET_MACRO PREFIX "rlns"
 #define REPEATED_NM_SUS_MACRO PREFIX "rlnx"
+#define SAVED_HYPHENATION_MODE_REG PREFIX "hyphmode"
+#define SAVED_HYPHENATION_LANG_NAME PREFIX "hyphlang"
+#define SAVED_HYPHENATION_MAX_LINES_REG PREFIX "hyphmaxlines"
+#define SAVED_HYPHENATION_MARGIN_REG PREFIX "hyphmargin"
+#define SAVED_HYPHENATION_SPACE_REG PREFIX "hyphspace"
 
 // this must be one character
 #define COMPATIBLE_REG PREFIX "c"
@@ -1771,6 +1776,11 @@ void table::init_output()
         ".in \\n[.i]u\n"
         ".ll \\n[.l]u\n"
         ".ls \\n[.L]\n"
+        ".hy \\\\n[" SAVED_HYPHENATION_MODE_REG "]\n"
+        ".hla \\\\*[" SAVED_HYPHENATION_LANG_NAME "]\n"
+        ".hlm \\\\n[" SAVED_HYPHENATION_MAX_LINES_REG "]\n"
+        ".hym \\\\n[" SAVED_HYPHENATION_MARGIN_REG "]\n"
+        ".hys \\\\n[" SAVED_HYPHENATION_SPACE_REG "]\n"
         ".ad \\n[.j]\n"
         ".ie \\n[.u] .fi\n"
         ".el .nf\n"
@@ -1782,6 +1792,11 @@ void table::init_output()
         ".nr " SAVED_SIZE_REG " \\n[.s]\n"
         ".nr " SAVED_FILL_REG " \\n[.u]\n"
         ".ds " SAVED_TABS_NAME " \\n[.tabs]\n"
+        ".nr " SAVED_HYPHENATION_MODE_REG " \\n[.hy]\n"
+        ".ds " SAVED_HYPHENATION_LANG_NAME " \\n[.hla]\n"
+        ".nr " SAVED_HYPHENATION_MAX_LINES_REG " \\n[.hlm]\n"
+        ".nr " SAVED_HYPHENATION_MARGIN_REG " \\n[.hym]\n"
+        ".nr " SAVED_HYPHENATION_SPACE_REG " \\n[.hys]\n"
         ".nr T. 0\n"
         ".nr " CURRENT_ROW_REG " 0-1\n"
         ".nr " LAST_PASSED_ROW_REG " 0-1\n"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]