|
20 | 20 | import warnings
|
21 | 21 | from pathlib import Path
|
22 | 22 |
|
23 |
| -from IPython.core import page, payloadpage |
| 23 | +from IPython.core import page |
24 | 24 | from IPython.core.autocall import ZMQExitAutocall
|
25 | 25 | from IPython.core.displaypub import DisplayPublisher
|
26 | 26 | from IPython.core.error import UsageError
|
@@ -541,10 +541,38 @@ def init_environment(self):
|
541 | 541 | env["PAGER"] = "cat"
|
542 | 542 | env["GIT_PAGER"] = "cat"
|
543 | 543 |
|
| 544 | + def payloadpage_page(self, strg, start=0, screen_lines=0, pager_cmd=None): |
| 545 | + """Print a string, piping through a pager. |
| 546 | +
|
| 547 | + This version ignores the screen_lines and pager_cmd arguments and uses |
| 548 | + IPython's payload system instead. |
| 549 | +
|
| 550 | + Parameters |
| 551 | + ---------- |
| 552 | + strg : str or mime-dict |
| 553 | + Text to page, or a mime-type keyed dict of already formatted data. |
| 554 | + start : int |
| 555 | + Starting line at which to place the display. |
| 556 | + """ |
| 557 | + |
| 558 | + # Some routines may auto-compute start offsets incorrectly and pass a |
| 559 | + # negative value. Offset to 0 for robustness. |
| 560 | + start = max(0, start) |
| 561 | + |
| 562 | + data = strg if isinstance(strg, dict) else {"text/plain": strg} |
| 563 | + |
| 564 | + payload = dict( |
| 565 | + source="page", |
| 566 | + data=data, |
| 567 | + start=start, |
| 568 | + ) |
| 569 | + assert self.payload_manager is not None |
| 570 | + self.payload_manager.write_payload(payload) |
| 571 | + |
544 | 572 | def init_hooks(self):
|
545 | 573 | """Initialize hooks."""
|
546 | 574 | super().init_hooks()
|
547 |
| - self.set_hook("show_in_pager", page.as_hook(payloadpage.page), 99) |
| 575 | + self.set_hook("show_in_pager", page.as_hook(self.payloadpage_page), 99) |
548 | 576 |
|
549 | 577 | def init_data_pub(self):
|
550 | 578 | """Delay datapub init until request, for deprecation warnings"""
|
|
0 commit comments