Module: core.page — IPython 4.0.0 documentation

# Module: `core.page`

Paging capabilities for IPython.core

## Notes

For now this uses IPython hooks, so it can’t be in IPython.utils. If we can get rid of that dependency, we could move it there. —–

## 10 Functions

`IPython.core.page.` `display_page`(strng, start=0, screen_lines=25)

  Just display, no paging. screen_lines is ignored.

`IPython.core.page.` `as_hook`(page_func)

  Wrap a pager func to strip the `self` arg

  so it can be called as a hook.

`IPython.core.page.` `page_dumb`(strng, start=0, screen_lines=25)

  Very dumb ‘pager’ in Python, for when nothing else works.

  Only moves forward, same interface as page(), except for pager_cmd and mode.

`IPython.core.page.` `pager_page`(strng, start=0, screen_lines=0, pager_cmd=None)

  Display a string, piping through a pager after a certain length.

  strng can be a mime-bundle dict, supplying multiple representations, keyed by mime-type.

  The screen_lines parameter specifies the number of usable lines of your terminal screen (total lines minus lines you need to reserve to show other information).

  If you set screen_lines to a number <=0, page() will try to auto-determine your screen size and will only use up to (screen_size+screen_lines) for printing, paging after that. That is, if you want auto-detection but need to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for auto-detection without any lines reserved simply use screen_lines = 0.

  If a string won’t fit in the allowed lines, it is sent through the specified pager command. If none given, look for PAGER in the environment, and ultimately default to less.

  If no system pager works, the string is sent through a ‘dumb pager’ written in python, very simplistic.

`IPython.core.page.` `page`(data, start=0, screen_lines=0, pager_cmd=None)

  Display content in a pager, piping through a pager after a certain length.

  data can be a mime-bundle dict, supplying multiple representations, keyed by mime-type, or text.

  Pager is dispatched via the `show_in_pager` IPython hook. If no hook is registered, `pager_page` will be used.

`IPython.core.page.` `page_file`(fname, start=0, pager_cmd=None)

  Page a file, using an optional pager command and starting line.

`IPython.core.page.` `get_pager_cmd`(pager_cmd=None)

  Return a pager command.

  Makes some attempts at finding an OS-correct one.

`IPython.core.page.` `get_pager_start`(pager, start)

  Return the string for paging files with an offset.

  This is the ‘+N’ argument which less and more (under Unix) accept.

`IPython.core.page.` `page_more`()

`IPython.core.page.` `snip_print`(str, width=75, print_full=0, header='')

  Print a string snipping the midsection to fit in width.

  print_full: mode control:

  > - 0: only snip long strings
  > - 1: send to page() directly.
  > - 2: snip long strings and ask for full length viewing with page()

  Return 1 if snipping was necessary, 0 otherwise.