gbranden pushed a commit to branch master
in repository groff.

commit 0f7c7dbac90e73a6a8fad7944af1c9eaff5a4f6c
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
AuthorDate: Sun Jul 27 20:33:33 2025 -0500

    [troff]: Make `pev` request report color data.
    
    Make `pev` request report previous and current stroke and fill colors.
    They are properties of the environment, this request already reports
    plenty of data that are otherwise available via built-in registers, and
    the _previous_ values thereofre are not thus exposed.
    
    * src/roff/troff/env.h (class environment): Declare new public member
      functions `get_prev_stroke_color()` and
      `get_prev_fill_color_string()`.
    
    * src/roff/troff/env.cpp (environment::get_prev_stroke_color_string):
      (environment::get_prev_fill_color_string): Define them.
    
      (environment::dump): Report the data.
    
    N.B., `get...string` are poor names for these functions.  They return
    C-style null-terminated strings, not groff "strings", which are general
    memory buffers that are not necessarily null-terminated.  What they
    return are more properly termed "symbols" internally, or better yet
    "identifiers" in the parlance of our documentation.
    
    Also, strictly, we should probably JSON-encode these names when dumping
    them since they can contain slashes, backslashes, and worse.
---
 ChangeLog              | 16 ++++++++++++++++
 src/roff/troff/env.cpp | 16 ++++++++++++++++
 src/roff/troff/env.h   |  2 ++
 3 files changed, 34 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 3d9e76bc2..5c7df0e91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2025-07-27  G. Branden Robinson <g.branden.robin...@gmail.com>
+
+       [troff]: Make `pev` request report previous and current stroke
+       and fill colors.  They are properties of the environment, this
+       request already reports plenty of data that are otherwise
+       available via built-in registers, and the _previous_ values
+       thereofre are not thus exposed.
+
+       * src/roff/troff/env.h (class environment): Declare new public
+       member functions `get_prev_stroke_color()` and
+       `get_prev_fill_color_string()`.
+       * src/roff/troff/env.cpp
+       (environment::get_prev_stroke_color_string):
+       (environment::get_prev_fill_color_string): Define them.
+       (environment::dump): Report the data.
+
 2025-07-27  G. Branden Robinson <g.branden.robin...@gmail.com>
 
        * src/roff/troff/env.cpp: Trivially refactor, continuing naming
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index af33cac75..caab0fd52 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -3411,6 +3411,16 @@ const char *environment::get_fill_color_string()
   return fill_color->nm.contents();
 }
 
+const char *environment::get_prev_stroke_color_string()
+{
+  return prev_stroke_color->nm.contents();
+}
+
+const char *environment::get_prev_fill_color_string()
+{
+  return prev_fill_color->nm.contents();
+}
+
 const char *environment::get_font_name_string()
 {
   symbol f = get_font_name(fontno, this);
@@ -3638,6 +3648,12 @@ void environment::dump()
 #ifdef WIDOW_CONTROL
   errprint("  widow control: %1\n", want_widow_control ? "yes" : "no");
 #endif /* WIDOW_CONTROL */
+  errprint("  previous stroke color: %1\n",
+          get_prev_stroke_color_string());
+  errprint("  stroke color: %1\n", get_stroke_color_string());
+  errprint("  previous fill color: %1\n",
+          get_prev_fill_color_string());
+  errprint("  fill color: %1\n", get_fill_color_string());
   fflush(stderr);
 }
 
diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h
index a084da693..d683a0a1a 100644
--- a/src/roff/troff/env.h
+++ b/src/roff/troff/env.h
@@ -365,6 +365,8 @@ public:
   void space_newline();
   const char *get_stroke_color_string();
   const char *get_fill_color_string();
+  const char *get_prev_stroke_color_string();
+  const char *get_prev_fill_color_string();
   const char *get_font_family_string();
   const char *get_font_name_string();
   const char *get_style_name_string();

_______________________________________________
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to