mirror of https://github.com/python/cpython.git
gh-65824: Improve the "less" prompt in pydoc (GH-116050)
Output the line number, the percentage and the help about how to get help or quit the pager. Inspired by the GNU man.
This commit is contained in:
parent
7895a61168
commit
0704166f9a
11
Lib/pydoc.py
11
Lib/pydoc.py
|
@ -1685,8 +1685,17 @@ def plain(text):
|
||||||
def pipepager(text, cmd):
|
def pipepager(text, cmd):
|
||||||
"""Page through text by feeding it to another program."""
|
"""Page through text by feeding it to another program."""
|
||||||
import subprocess
|
import subprocess
|
||||||
|
env = os.environ.copy()
|
||||||
|
prompt_string = (
|
||||||
|
' '
|
||||||
|
'?ltline %lt?L/%L.'
|
||||||
|
':byte %bB?s/%s.'
|
||||||
|
'.'
|
||||||
|
'?e (END):?pB %pB\\%..'
|
||||||
|
' (press h for help or q to quit)')
|
||||||
|
env['LESS'] = '-RmPm{0}$PM{0}$'.format(prompt_string)
|
||||||
proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
|
proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
|
||||||
errors='backslashreplace')
|
errors='backslashreplace', env=env)
|
||||||
try:
|
try:
|
||||||
with proc.stdin as pipe:
|
with proc.stdin as pipe:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Improve the ``less`` prompt in :mod:`pydoc`.
|
Loading…
Reference in New Issue