[patch enhancement 1] Give users free choice of help output width, adapt to any COLUMNS setting desired by user
Roland Eggner
edvx1 at systemanalysen.net
Mon Dec 30 13:09:12 CST 2013
# HG changeset patch
# Parent 2ebe7db1590cf77d43b355df753f0c8491eb2eba
# User Roland Eggner < odv at systomanalyson.not s/o/e/g >
# Date 1388262822 -3600
[enhancement 1] Give users free choice of help output width, adapt to any COLUMNS setting desired by user.
COLUMNS=80: “hg help“ output unmodified
COLUMNS=96: “hg help” output nicer, increased width of first field saves all continuation lines
COLUMNS=160: “hg help -v” output nicer, increased width of first field saves all continuation lines
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3411,7 +3411,7 @@ def help_(ui, name=None, **opts):
Returns 0 if successful.
"""
- textwidth = min(ui.termwidth(), 80) - 2
+ textwidth = ui.termwidth() - 2
keep = ui.verbose and ['verbose'] or []
text = help.help_(ui, name, **opts)
diff --git a/mercurial/minirst.py b/mercurial/minirst.py
--- a/mercurial/minirst.py
+++ b/mercurial/minirst.py
@@ -182,8 +182,6 @@ def splitparagraphs(blocks):
i += 1
return blocks
-_fieldwidth = 14
-
def updatefieldlists(blocks):
"""Find key for field lists."""
i = 0
@@ -503,6 +501,9 @@ def formatblock(block, width):
return '%s\n%s\n' % (term, util.wrap(text, width=width,
initindent=defindent,
hangindent=defindent))
+ # _fieldwidth + 1 = width of commands column in command table
+ # _fieldwidth + 1 = indention of continuation lines
+ _fieldwidth = min(width / 6 + 1, 26)
subindent = indent
if block['type'] == 'bullet':
if block['lines'][0].startswith('| '):
diff --git a/tests/test-minirst.py.out b/tests/test-minirst.py.out
--- a/tests/test-minirst.py.out
+++ b/tests/test-minirst.py.out
@@ -414,37 +414,34 @@ marker after the option. It is treated a
== fields ==
60 column format:
----------------------------------------------------------------------
-a First item.
-ab Second item. Indentation and wrapping is
- handled automatically.
+a First item.
+ab Second item. Indentation and wrapping is handled
+ automatically.
Next list:
-small The larger key below triggers full indentation
- here.
+small The larger key below triggers full indentation
+ here.
much too large
- This key is big enough to get its own line.
+ This key is big enough to get its own line.
----------------------------------------------------------------------
30 column format:
----------------------------------------------------------------------
-a First item.
-ab Second item.
- Indentation and
- wrapping is
- handled
- automatically.
+a First item.
+ab Second item. Indentation
+ and wrapping is handled
+ automatically.
Next list:
-small The larger key
- below triggers
- full indentation
- here.
+small
+ The larger key below
+ triggers full
+ indentation here.
much too large
- This key is big
- enough to get
- its own line.
+ This key is big enough
+ to get its own line.
----------------------------------------------------------------------
html format:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20131230/f54550d8/attachment.pgp>
More information about the Mercurial-devel
mailing list