diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-06-16 12:44:36 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-06-16 12:44:36 -0400 |
commit | e3672dfec9c7f0919a726b3e105f06b9474b630f (patch) | |
tree | 5c8f6a5a37688a20f78d230745b273c66f888007 /cmd2/cmd2.py | |
parent | eb32a860d442f6990971bf9ab96db576c939587c (diff) | |
download | cmd2-git-e3672dfec9c7f0919a726b3e105f06b9474b630f.tar.gz |
Altered behavior further to lean towards giving the developer more power over the end user
Specifically:
- PAGER environment variable is not used by default to set cmd2.Cmd.pager
- This is done to ensure a consistent behavior of cmd2 applications across users by default
Developers are free to set pager and pager_chop in the __init__() for their class derived from cmd2.Cmd differently to ensure whatever behavior they desire.
Also:
- Updated the paged_output.py example to demonstrate using ppaged() with both wrapped and chopped/truncated text
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r-- | cmd2/cmd2.py | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 5244f73e..cff73f13 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -535,22 +535,16 @@ class Cmd(cmd.Cmd): self.matches_delimited = False # Set the pager(s) for use with the ppaged() method for displaying output using a pager - self.pager = os.environ.get('PAGER') - if not self.pager: - if sys.platform.startswith('win'): - self.pager = self.pager_chop = 'more' - else: - # Here is the meaning of the various flags we are using with the less command: - # -S causes lines longer than the screen width to be chopped (truncated) rather than wrapped - # -R causes ANSI "color" escape sequences to be output in raw form (i.e. colors are displayed) - # -X disables sending the termcap initialization and deinitialization strings to the terminal - # -F causes less to automatically exit if the entire file can be displayed on the first screen - self.pager = 'less -RXF' - self.pager_chop = 'less -SRXF' + if sys.platform.startswith('win'): + self.pager = self.pager_chop = 'more' else: - self.pager_chop = self.pager - if self.pager_chop.startswith('less'): - self.pager_chop += ' -S' + # Here is the meaning of the various flags we are using with the less command: + # -S causes lines longer than the screen width to be chopped (truncated) rather than wrapped + # -R causes ANSI "color" escape sequences to be output in raw form (i.e. colors are displayed) + # -X disables sending the termcap initialization and deinitialization strings to the terminal + # -F causes less to automatically exit if the entire file can be displayed on the first screen + self.pager = 'less -RXF' + self.pager_chop = 'less -SRXF' # ----- Methods related to presenting output to the user ----- |