bug-groff
[Top][All Lists]
Advanced

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

[bug #43532] man: put titles on separate lines when parts too wide, inst


From: G. Branden Robinson
Subject: [bug #43532] man: put titles on separate lines when parts too wide, instead of overlapping them
Date: Mon, 31 May 2021 04:32:20 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0

Update of bug #43532 (project groff):

                 Summary: [PATCH] man: put titles on separate lines when parts
too wide, instead of overlapping them => man: put titles on separate lines
when parts too wide, instead of overlapping them

    _______________________________________________________

Follow-up Comment #6:

Proposed patch.  Tested, seems to work.


diff --git a/tmac/an-old.tmac b/tmac/an-old.tmac
index 0eb568cb..45a97a10 100644
--- a/tmac/an-old.tmac
+++ b/tmac/an-old.tmac
@@ -306,8 +306,7 @@
 .\" Redefine these to customize the header & footer
 .
 .de1 PT
-.  tl '\\*[an-title](\\*[an-section])'\\*[an-extra3]'\
-\\*[an-title](\\*[an-section])'
+.  tl '\\*[an-pageref]'\\*[an-extra3]'\\*[an-pageref]'
 ..
 .
 .de1 BT
@@ -321,11 +320,57 @@
 .    tl '\\*[an-extra2]'\\*[an-extra1]'\\*[an-outer-footer-text]'
 ..
 .
+.\" Abbreviate the page title if it's too long for the header.  Leaves
+.\" string an-pageref defined for use in .PT and .an-footer.  Also
+.\" leaves an-title-abbv for possible use by .PT and .BT re-definers.
+.de1 an-abbreviate-title
+.  ds an-title-abbv \\*[an-title]\"
+.  ds an-title-string \\*[an-title]\"
+.  ds an-ellipsis \|.\|.\|.\|\"
+.  ds an-pageref \\*[an-title-abbv](\\*[an-section])\"
+.  nr an-header-width \\w'\\*[an-pageref]\\*[an-extra3]\\*[an-pageref]'
+.  while (\\n[an-header-width] >= \\n[.lt]) \{\
+.    \" The page title is too long; trim some bits out of the middle.
+.    length an-title-length \\*[an-title-string]
+.    \" roff division rounds integers toward zero.  Remove an additional
+.    \" character on each side of the midpoint to account for the
+.    \" ellipsis we add later.
+.    nr an-mark1 (\\n[an-title-length] / 2 - 2)
+.    nr an-mark2 (\\n[an-title-length] / 2 + 2)
+.    ds an-prefix \\*[an-title-string]\"
+.    ds an-suffix \\*[an-title-string]\"
+.    \" Use extremum operators to ensure that the first and last
+.    \" characters of the title remain intact (in cases of pathological
+.    \" shortening).
+.    substring an-prefix 0 (\\n[an-mark1] >? 1)
+.    substring an-suffix (\\n[an-mark2] <? (\\n[an-title-length] - 1) -1
+.    ds an-title-string \\*[an-prefix]\\*[an-suffix]\"
+.    ds an-title-abbv \\*[an-prefix]\\*[an-ellipsis]\\*[an-suffix]\"
+.    \" Measure the string again and give up if we made no progress.
+.    length an-title-new-length \\*[an-title-string]
+.    ie (\\n[an-title-new-length] >= \\n[an-title-length]) \
+.      break
+.    ds an-pageref \\*[an-title-abbv](\\*[an-section])\"
+.    nr an-header-width \
+       \\w'\\*[an-pageref]\\*[an-extra3]\\*[an-pageref]'
+.  \}
+.  rr an-title-length-prev
+.  rr an-mark1
+.  rr an-mark2
+.  rm an-prefix
+.  rm an-suffix
+.  rm an-title-string
+.  rr an-title-length
+.  rr an-header-width
+.  rm an-ellipsis
+..
+.
 .de1 an-header
 .  ev an-env
 .  ps \\n[PS]u
 .  vs \\n[VS]u
 .  lt \\n[LT]u
+.  an-abbreviate-title
 .  if !\\n[an-is-output-html] \{\
 .    if !\\n[cR] \
 .      sp .5i
@@ -356,7 +401,7 @@
 .  lt \\n[LT]u
 .  if !\\n[an-is-output-html] \{\
 .    ie \\n[cR] \
-.      ds an-outer-footer-text "\\*[an-title](\\*[an-section])\"
+.      ds an-outer-footer-text "\\*[an-pageref]\"
 .    el \{\
 .      ds an-outer-footer-text \\n[%]\"
 .      if r X \{\


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?43532>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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