Package: pager
Python module that pages output to the screen, reads keys and
console dimensions without executing external utils.It was meant to be included in standard libraryhttp://bugs.python.org/issue8408Author:  anatoly techtonik <techtonik@gmail.com>License: Public Domain (or MIT if a license is required)Demopython -m pager <file>
<command> | pager.py     (Windows only - see issue #7)
pager.py < <file>        (Windows only)

# run manual tests that are also a demo
python -m pager --testStatus3.3 (stable)fix critical issue #6: 3.2 Broken on Linux, thanks
Calvin Spealman (@ironfroggy) for reportingreading content from stdin is Windows only feature
for now (see issue #7)3.2 (broken on Linux)abort pagination if ESC or ‘q’ keys are pressedprompt callback is now able to abort pagination by
returning False3.1 (broken on Linux)supports piped input (tested on Windows)3.0 (alpha) - API break in getch() functionreverted getch() behaviour changed in 2.0 - now
getch() again returns single charnew constants with underline for getch() keysnew getchars() function that always returns list2.2 (stable)Linux: fix regression in version 2.1 - wrong name for
_get_unix call produced NameError on this platform
(issue #6, thanks Calvin Spealman for report)2.1 (broken on Linux)split getch() into _getch_unix() and _getch_windows()
and detect correct flavor at import time (speedup)2.0 (stable) - API break in getch() functiongetch() now always returns list of characters
(previously it could return single char). This is done
to simplify the task of detecting keys from the
returned result1.4 (stable)pager.py <file>Linux: termios comments, docs and preparation for very
likely API break in getch() function1.3 (stable)Windows: Python 3 requires getwch()Windows: fix ENTER LEFT UP RIGHT DOWN ESC key codes1.2 (stable)add names for ENTER LEFT UP RIGHT DOWN ESC keysmanual tests for getch() (fixes bug #4)dumpkey() helper function to get hex dump of a value
returned by getch()1.1 (stable)Python 3 compatibilityecho() helper function for unbuffered output (in Py3
output doesn’t appear immediately on screen unless it
ends with newline)1.0 (stable)getch() now returns list of chars for special keys
(fixes bug #1 when special key skipped several pages)page() callbacks receive obligatory pagenumber paramdefault page() callback now shows page number0.2 (stable)do not insert blank line between pages0.1 (stable)shows content page by pageallows to get console/terminal dimensionsworks on Windowsworks on LinuxAPI (output)..function::page(content, [pagecallback=prompt])Outputcontentiterable, callingpagecallbackfunction after each
page with page number as a parameter.pagecallbackfunction may
return False to terminate pagination.Defaultprompt()callback shows  page number with ‘Press any key to
continue … ‘ prompt, waits for keypress and aborts if ‘q’, ESC or
Ctrl-C are pressed...function::echo(msg)Print msg to the screen without linefeed and flush the output...function::getwidth()Return width of available window in characters.  If detection fails,
return value of standard width 80.  Coordinate of the last character
on a line is -1 from returned value...function::getheight()Return available window height in characters or 25 if detection fails.
Coordinate of the last line is -1 from returned value.API (input)..function::getch()Wait for keypress, return first char generated as a result.Arrows and special keys generate sequence of chars. Usegetcharsfunction to receive all chars generated or present in buffer...function::getchars()Wait for keypress. Return list of chars generated as a result.
More than one char in result list is returned when arrows and
special keys are pressed. Returned sequences differ between
platforms, so use constants defined in this module to guess
correct keys...function::dumpkey(key)Helper to convert result ofgetch(string) orgetchars(list)
to hex string.CreditsDanny Yoo for getch()-like unbuffered character reading recipehttp://code.activestate.com/recipes/134892-getch-like-unbuffered/Calvin Spealman (@ironfroggy), issue #6ReferencesExcellent tutorials for Win32 Console by Adrian Worleyhttp://www.adrianxw.dk/SoftwareSite/index.htmlConsole Reference on MSDNhttp://msdn.microsoft.com/en-us/library/ms682087%28VS.85%29.aspxPublic Domain Curses library maintained by William McBrinehttp://pdcurses.sourceforge.net/Ioctl (input/output control) introduction from Wikipediahttp://en.wikipedia.org/wiki/IoctlLinux Programmer’s Manual - ioctls for terminals and serial lineshttp://www.kernel.org/doc/man-pages/online/pages/man4/tty_ioctl.4.html