mirror of
https://github.com/python/cpython.git
synced 2025-07-10 04:45:36 +00:00
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
2 changed files with 11 additions and 1 deletions
11
Lib/pydoc.py
11
Lib/pydoc.py
|
@ -1685,8 +1685,17 @@ def plain(text):
|
|||
def pipepager(text, cmd):
|
||||
"""Page through text by feeding it to another program."""
|
||||
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,
|
||||
errors='backslashreplace')
|
||||
errors='backslashreplace', env=env)
|
||||
try:
|
||||
with proc.stdin as pipe:
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue