groff-commit
[Top][All Lists]
Advanced

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

[groff] 16/35: [man]: Refactor `EX` and `EE` macros.


From: G. Branden Robinson
Subject: [groff] 16/35: [man]: Refactor `EX` and `EE` macros.
Date: Mon, 21 Feb 2022 06:15:55 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 15f8188656ef0ebed797eb5981b012b590fc77ad
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Feb 16 19:49:58 2022 +1100

    [man]: Refactor `EX` and `EE` macros.
    
    * tmac/an-ext.tmac: Add new `mC` string to store the font name to be
      used for example regions.  In AT&T device-independent troff, "CW" was
      a common name, so use that.  It is however a terrible fit for groff's
      font family and style-combination functionality, and is inflexible in
      the face of font selection requests and escape sequences within the
      example region.  (One either needs to know the names of the fonts
      available on the output device, or suffer the indignity of mixed
      constant-width and proportional typefaces.)  Relatedly, drop
      groff-specific font remapping requests.
    
      (EX, EE): Ignore definition if GNU troff is the formatter.  Drop font
      family manipulation.  Drop specialized logic for groff's DVI output
      device.
    
    * tmac/an.tmac (initialization): Resurrect font remapping requests here.
    
      (EX, EE): Add new definitions, saving and restoring more state and
      remapping DVI output device fonts to reflect the absence of CWB and
      CWBI faces.
---
 ChangeLog        | 24 ++++++++++++++++++++++++
 tmac/an-ext.tmac | 27 ++++++++-------------------
 tmac/an.tmac     | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 78 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index eee25d51..b4a55ac7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2022-02-16  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [man]: Refactor `EX` and `EE` macros.
+
+       * tmac/an-ext.tmac: Add new `mC` string to store the font name
+       to be used for example regions.  In AT&T device-independent
+       troff, "CW" was a common name, so use that.  It is however a
+       terrible fit for groff's font family and style-combination
+       functionality, and is inflexible in the face of font selection
+       requests and escape sequences within the example region.  (One
+       either needs to know the names of the fonts available on the
+       output device, or suffer the indignity of mixed constant-width
+       and proportional typefaces.)  Relatedly, drop groff-specific
+       font remapping requests.
+       (EX, EE): Ignore definition if GNU troff is the formatter.  Drop
+       font family manipulation.  Drop specialized logic for groff's
+       DVI output device.
+
+       * tmac/an.tmac (initialization): Resurrect font remapping
+       requests here.
+       (EX, EE): Add new definitions, saving and restoring more state
+       and remapping DVI output device fonts to reflect the absence of
+       CWB and CWBI faces.
+
 2022-02-16  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * tmac/an-ext.tmac: Slightly refactor.  Stop using groff's `HY`
diff --git a/tmac/an-ext.tmac b/tmac/an-ext.tmac
index 15011e53..0ddf29d3 100644
--- a/tmac/an-ext.tmac
+++ b/tmac/an-ext.tmac
@@ -27,6 +27,9 @@
 .if \n(mX>1 \
 .  nx
 .
+.\" Define this to your implementation's constant-width typeface.
+.ds mC CW
+.
 .\" In AT&T troff, there was no register exposing the hyphenation mode,
 .\" and no way to save and restore it.  Set this to a reasonable value
 .\" for your implementation and preference.
@@ -54,14 +57,6 @@
 .\}
 .
 .
-.\" Map mono-width fonts to standard fonts for groff's TTY device.
-.if n \{\
-.  do ftr CR R
-.  do ftr CI I
-.  do ftr CB B
-.  do ftr CBI BI
-.\}
-.
 .\" groff has glyph entities for angle brackets.
 .ie \n(.g \{\
 .  ds mL \(la\"
@@ -238,27 +233,21 @@
 .
 .
 .\" Start example.
+.if \n(.g .ig
 .de EX
-.  do ds mF \\n[.fam]
 .  nr mE \\n(.f
-.  nr mP \\n(PD \" Save paragraph distance.
+.  nr mP \\n(PD
 .  nr PD 1v
 .  nf
-.  \" Work around Savannah #59522.
-.  ie !'\\*[.T]'dvi' \{\
-.    do fam C
-.    ft R
-.  \}
-.  el \
-.    ft CW
+.  ft \\*(mC
 ..
 .
 .
 .\" End example.
+.if \n(.g .ig
 .de EE
-.  do fam \\*(mF
 .  ft \\n(mE
-.  nr PD \\n(mP \" Restore paragraph distance.
+.  nr PD \\n(mP
 .  fi
 ..
 .
diff --git a/tmac/an.tmac b/tmac/an.tmac
index a568d69c..a9e18286 100644
--- a/tmac/an.tmac
+++ b/tmac/an.tmac
@@ -926,6 +926,44 @@
 .    RB [ \\$1 ]
 ..
 .
+.\" Begin an example (typically of source code or shell input).
+.de1 EX
+.  ds an*saved-family \\n[.fam]
+.  nr an*saved-font \\n[.f]
+.  nr an*saved-paragraph-distance \\n[PD]
+.  nr PD 1v
+.  nf
+.  \" If using the DVI output device, we have no constant-width fonts of
+.  \" bold weight and, relatedly, no constant-width family (because that
+.  \" requires all four styles).  Remap the bold styles to normal ones.
+.  ie '\*[.T]'dvi' \{\
+.    ftr R CW
+.    ftr B CW
+.    ftr I CWI
+.    ftr BI CWI
+.  \}
+.  el .fam C
+.  ft R
+..
+.
+.\" End example.
+.de EE
+.  \" Undo the remappings from `EX`.
+.  ie '\*[.T]'dvi' \{\
+.    ftr R
+.    ftr B
+.    ftr I
+.    ftr BI
+.  \}
+.  fam \\*[an*saved-family]
+.  ft \\n[an*saved-font]
+.  nr PD \\n[an*saved-paragraph-distance]
+.  fi
+.  rr an*saved-paragraph-distance
+.  rr an*saved-font
+.  rm an*saved-family
+..
+.
 .\" Set a man page cross reference.
 .\" .MR page-title page-section [trailing-text]
 .de1 MR
@@ -1049,6 +1087,14 @@
 .nr an-is-output-html 0
 .if '\*[.T]'html' .nr an-is-output-html 1
 .
+.\" Map monospaced fonts to standard styles for groff's nroff devices.
+.if n \{\
+.  ftr CR R
+.  ftr CI I
+.  ftr CB B
+.  ftr CBI BI
+.\}
+.
 .\" Load man macro extensions.
 .mso an-ext.tmac
 .



reply via email to

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