MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / ppaged

Method ppaged

cmd2/cmd2.py:1751–1870  ·  view source on GitHub ↗

Print output using a pager. A pager is used when the terminal is interactive and may exit immediately if the output fits on the screen. A pager is not used inside a script (Python or text) or when output is redirected or piped, and in these cases, output is sent to `poutput`

(
        self,
        *objects: Any,
        sep: str = " ",
        end: str = "\n",
        style: StyleType | None = None,
        chop: bool = False,
        soft_wrap: bool = True,
        justify: JustifyMethod | None = None,
        emoji: bool = False,
        markup: bool = False,
        highlight: bool = False,
        rich_print_kwargs: Mapping[str, Any] | None = None,
        **kwargs: Any,  # noqa: ARG002
    )

Source from the content-addressed store, hash-verified

1749 )
1750
1751 def ppaged(
1752 self,
1753 *objects: Any,
1754 sep: str = " ",
1755 end: str = "\n",
1756 style: StyleType | None = None,
1757 chop: bool = False,
1758 soft_wrap: bool = True,
1759 justify: JustifyMethod | None = None,
1760 emoji: bool = False,
1761 markup: bool = False,
1762 highlight: bool = False,
1763 rich_print_kwargs: Mapping[str, Any] | None = None,
1764 **kwargs: Any, # noqa: ARG002
1765 ) -> None:
1766 """Print output using a pager.
1767
1768 A pager is used when the terminal is interactive and may exit immediately if the output
1769 fits on the screen. A pager is not used inside a script (Python or text) or when output is
1770 redirected or piped, and in these cases, output is sent to `poutput`.
1771
1772 :param chop: True -> causes lines longer than the screen width to be chopped (truncated) rather than wrapped
1773 - truncated text is still accessible by scrolling with the right & left arrow keys
1774 - chopping is ideal for displaying wide tabular data as is done in utilities like pgcli
1775 False -> causes lines longer than the screen width to wrap to the next line
1776 - wrapping is ideal when you want to keep users from having to use horizontal scrolling
1777 WARNING: On Windows, the text always wraps regardless of what the chop argument is set to
1778 :param soft_wrap: Enable soft wrap mode. If True, lines of text will not be word-wrapped or cropped to
1779 fit the terminal width. Defaults to True.
1780
1781 Note: If chop is True and a pager is used, soft_wrap is automatically set to True to
1782 prevent wrapping and allow for horizontal scrolling.
1783
1784 For details on the other parameters, refer to the `print_to` method documentation.
1785 """
1786 # Detect if we are running within an interactive terminal.
1787 # Don't try to use the pager when being run by a continuous integration system like Jenkins + pexpect.
1788 functional_terminal = (
1789 self.stdin.isatty()
1790 and self.stdout.isatty()
1791 and (sys.platform.startswith("win") or os.environ.get("TERM") is not None)
1792 )
1793
1794 # A pager application blocks, so only run one if not redirecting or running a script (either text or Python).
1795 can_block = not (self._redirecting or self.in_pyscript() or self.in_script())
1796
1797 # Check if we are outputting to a pager.
1798 if functional_terminal and can_block:
1799 # Chopping overrides soft_wrap
1800 if chop:
1801 soft_wrap = True
1802
1803 # Generate the bytes to send to the pager
1804 console = self._get_core_print_console(
1805 file=self.stdout,
1806 emoji=emoji,
1807 markup=markup,
1808 highlight=highlight,

Calls 7

in_pyscriptMethod · 0.95
in_scriptMethod · 0.95
poutputMethod · 0.95
isattyMethod · 0.80
printMethod · 0.80
getMethod · 0.45