Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install term

How to install term

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install term
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
2.0 Available View build log
2.0 Available View build log
Windows (64-bit)
2.0 Available View build log
2.0 Available View build log
Mac OS X (10.5+)
2.0 Available View build log
2.0 Available View build log
Linux (32-bit)
2.0 Available View build log
2.0 Available View build log
Linux (64-bit)
2.0 Available View build log
2.0 Available View build log
2.0 Available View build log
 
License
GPL or PSF
Dependencies
Depended by
Imports
Lastest release
version 2.0 on May 23rd, 2012

Overview

The term package is an enhanced version of the standard library's tty module. It provides context managers for temporarily switching the terminal to raw or cbreak mode and allows to retrieve the cursor position without having to resort to curses.

Package Contents
setraw(fd, when=TCSAFLUSH, min=1, time=0)
Put the terminal in raw mode.
setcbreak(fd, when=TCSAFLUSH, min=1, time=0)
Put the terminal in cbreak mode.
rawmode(fd, when=TCSAFLUSH, min=1, time=0)
Context manager to put the terminal in raw mode.
cbreakmode(fd, when=TCSAFLUSH, min=1, time=0)
Context manager to put the terminal in cbreak mode.
opentty(bufsize=1)
Context manager returning an rw stream connected to /dev/tty. The stream is None if the device could not be opened.
getyx()
Return the cursor position as 1-based (line, col) tuple. line and col are 0 if the terminal does not support DSR 6.
Examples
from term import getyx

print 'The cursor is in line %d column %d' % getyx()

You may also want to look at the source code of getyx.

Caveat

The terminal must be in canonical mode before any of the functions and context managers can be used. They are not meant for switching between, say, raw and cbreak modes. Nesting context managers of the same type is ok though.

Changelog

2.0 - 2012-04-27
  • Open /dev/tty in binary mode under Python 3. [stefan]
  • Disable buffering if the device is not seekable. [stefan]
  • Remove getmaxyx since it cannot be implemented reliably. [stefan]
  • Support Python 2.5. [stefan]
  • Change license to GPL or PSF to avoid relicensing of PSF code. [stefan]
1.0 - 2012-04-11
  • Initial release. [stefan]

Subscribe to package updates

Last updated May 23rd, 2012

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.