[Git][NTPsec/ntpsec][master] In ntpq peers, don't resize on a > 80 column display in -n mode...

Eric S. Raymond gitlab at mg.gitlab.com
Mon Nov 14 11:17:34 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
abd271ae by Eric S. Raymond at 2016-11-14T06:14:33-05:00
In ntpq peers, don't resize on a > 80 column display in -n mode...

...the extra space can't be used effectively, and this prevents excessive
whitespace on very wide displays that makes the display hard to read.

- - - - -


2 changed files:

- ntpq/ntpq
- pylib/util.py


Changes:

=====================================
ntpq/ntpq
=====================================
--- a/ntpq/ntpq
+++ b/ntpq/ntpq
@@ -287,10 +287,15 @@ usage: help [ command ]
     def __dopeers(self, showall, mode):
         if not self.__dogetassoc():
             return
+        if self.showhostnames:
+            termwidth = termsize()[1]
+        else:
+            termwidth = None	# Default width 
         report = PeerSummary(mode,
                              self.pktversion,
                              self.showhostnames,
                              self.wideremote,
+                             termwidth=termwidth,
                              debug=interpreter.debug)
         maxhostlen = 0
         if len(self.chosts) > 1:


=====================================
pylib/util.py
=====================================
--- a/pylib/util.py
+++ b/pylib/util.py
@@ -68,7 +68,7 @@ def termsize():
 
 class PeerSummary:
     "Reusable report generator for peer statistics"
-    def __init__(self, displaymode, pktversion, showhostnames, wideremote, debug=0):
+    def __init__(self, displaymode, pktversion, showhostnames, wideremote, termwidth=None, debug=0):
         self.displaymode = displaymode		# peers/apeers.opeers
         self.pktversion = pktversion		# interpretation of flash bits
         self.showhostnames = showhostnames	# If false, display numeric IPs
@@ -76,8 +76,8 @@ class PeerSummary:
         self.debug = debug
         # By default, the peer spreadsheet layout is designed so lines just
         # fit in 80 characters. This tells us how much extra horizontal space
-        # we have available on a wider terminal emulator
-        self.horizontal_slack = termsize()[1] - 80
+        # we have available on a wider terminal emulator.
+        self.horizontal_slack = (termwidth or 80) - 80
         # Peer spreadsheet column widths
         self.namewidth = 15 + self.horizontal_slack
         self.refidwidth = 15



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/abd271aecd9bee1c64aec4b3c94b6575a119dcc1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161114/2a0312b4/attachment.html>


More information about the vc mailing list