groff-commit
[Top][All Lists]
Advanced

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

[groff] 102/115: [eqn]: Add `thick_space` and `thin_space` classes.


From: G. Branden Robinson
Subject: [groff] 102/115: [eqn]: Add `thick_space` and `thin_space` classes.
Date: Thu, 1 Jun 2023 10:46:17 -0400 (EDT)

gbranden pushed a commit to branch branden-2022-06-01
in repository groff.

commit cbea8bd166afb9710abb7c19ee6e543f44437f02
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri May 19 00:27:34 2023 -0500

    [eqn]: Add `thick_space` and `thin_space` classes.
    
    * src/preproc/eqn/box.cpp:
    * src/preproc/eqn/box.h: Do it.
    
    At present they are copy-and-paste jobs of `half_space` and
    `full_space`.  But watch this space...
---
 ChangeLog               |  7 +++++++
 src/preproc/eqn/box.cpp | 37 +++++++++++++++++++++++++++++++++++++
 src/preproc/eqn/box.h   | 14 ++++++++++++++
 3 files changed, 58 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index c2f1b9caa..195896e03 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-05-19  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [eqn]: Add `thick_space` and `thin_space` classes.
+
+       * src/preproc/eqn/box.cpp:
+       * src/preproc/eqn/box.h: Do it.
+
 2023-05-18  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [eqn]: Trivially refactor.  Rename "space_box" class to
diff --git a/src/preproc/eqn/box.cpp b/src/preproc/eqn/box.cpp
index 4626409dd..d63c2800a 100644
--- a/src/preproc/eqn/box.cpp
+++ b/src/preproc/eqn/box.cpp
@@ -616,6 +616,33 @@ void full_space_box::output()
     printf("<mtext>&ensp;</mtext>");
 }
 
+thick_space_box::thick_space_box()
+{
+  spacing_type = SUPPRESS_TYPE;
+}
+
+void thick_space_box::output()
+{
+  if (output_format == troff)
+    printf("\\h'%dM'", thick_space);
+  else if (output_format == mathml)
+    // &ThickSpace; doesn't display right under Firefox 1.5.
+    printf("<mtext>&ensp;</mtext>");
+}
+
+thin_space_box::thin_space_box()
+{
+  spacing_type = SUPPRESS_TYPE;
+}
+
+void thin_space_box::output()
+{
+  if (output_format == troff)
+    printf("\\h'%dM'", thin_space);
+  else if (output_format == mathml)
+    printf("<mtext>&ThinSpace;</mtext>");
+}
+
 void box_list::list_debug_print(const char *sep)
 {
   p[0]->debug_print();
@@ -640,6 +667,16 @@ void full_space_box::debug_print()
   fprintf(stderr, "~");
 }
 
+void thick_space_box::debug_print()
+{
+  fprintf(stderr, "~");
+}
+
+void thin_space_box::debug_print()
+{
+  fprintf(stderr, "^");
+}
+
 void tab_box::debug_print()
 {
   fprintf(stderr, "<tab>");
diff --git a/src/preproc/eqn/box.h b/src/preproc/eqn/box.h
index b21e2e329..93277f3c0 100644
--- a/src/preproc/eqn/box.h
+++ b/src/preproc/eqn/box.h
@@ -182,6 +182,20 @@ public:
   void debug_print();
 };
 
+class thick_space_box : public simple_box {
+public:
+  thick_space_box();
+  void output();
+  void debug_print();
+};
+
+class thin_space_box : public simple_box {
+public:
+  thin_space_box();
+  void output();
+  void debug_print();
+};
+
 class tab_box : public box {
   int disabled;
 public:



reply via email to

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