term

An enhanced version of the tty module
Download

term Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • Stefan H. Holek
  • Publisher web site:
  • http://plone.org/products/cmftestcase

term Tags


term Description

term 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 Contentssetraw(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.Examplesfrom term import getyxprint 'The cursor is in line %d column %d' % getyx()You may also want to look at the source code of getyx.CaveatThe 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.Product's homepage


term Related Software