mirror of
https://github.com/python/cpython.git
synced 2026-02-26 09:01:08 +00:00
svn+ssh://pythondev@svn.python.org/python/trunk ........ r60980 | georg.brandl | 2008-02-23 16:02:28 +0100 (Sat, 23 Feb 2008) | 2 lines #1492: allow overriding BaseHTTPServer's content type for error messages. ........ r60982 | georg.brandl | 2008-02-23 16:06:25 +0100 (Sat, 23 Feb 2008) | 2 lines #2165: fix test_logging failure on some machines. ........ r60983 | facundo.batista | 2008-02-23 16:07:35 +0100 (Sat, 23 Feb 2008) | 6 lines Issue 1089358. Adds the siginterrupt() function, that is just a wrapper around the system call with the same name. Also added test cases, doc changes and NEWS entry. Thanks Jason and Ralf Schmitt. ........ r60984 | georg.brandl | 2008-02-23 16:11:18 +0100 (Sat, 23 Feb 2008) | 2 lines #2067: file.__exit__() now calls subclasses' close() method. ........ r60985 | georg.brandl | 2008-02-23 16:19:54 +0100 (Sat, 23 Feb 2008) | 2 lines More difflib examples. Written for GHOP by Josip Dzolonga. ........ r60987 | andrew.kuchling | 2008-02-23 16:41:51 +0100 (Sat, 23 Feb 2008) | 1 line #2072: correct documentation for .rpc_paths ........ r60988 | georg.brandl | 2008-02-23 16:43:48 +0100 (Sat, 23 Feb 2008) | 2 lines #2161: Fix opcode name. ........ r60989 | andrew.kuchling | 2008-02-23 16:49:35 +0100 (Sat, 23 Feb 2008) | 2 lines #1119331: ncurses will just call exit() if the terminal name isn't found. Call setupterm() first so that we get a Python exception instead of just existing. ........
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
"""curses
|
|
|
|
The main package for curses support for Python. Normally used by importing
|
|
the package, and perhaps a particular module inside it.
|
|
|
|
import curses
|
|
from curses import textpad
|
|
curses.initwin()
|
|
...
|
|
|
|
"""
|
|
|
|
__revision__ = "$Id$"
|
|
|
|
from _curses import *
|
|
from curses.wrapper import wrapper
|
|
import os as _os
|
|
|
|
# Some constants, most notably the ACS_* ones, are only added to the C
|
|
# _curses module's dictionary after initscr() is called. (Some
|
|
# versions of SGI's curses don't define values for those constants
|
|
# until initscr() has been called.) This wrapper function calls the
|
|
# underlying C initscr(), and then copies the constants from the
|
|
# _curses module to the curses package's dictionary. Don't do 'from
|
|
# curses import *' if you'll be needing the ACS_* constants.
|
|
|
|
def initscr():
|
|
import _curses, curses
|
|
# we call setupterm() here because it raises an error
|
|
# instead of calling exit() in error cases.
|
|
setupterm(term=_os.environ.get("TERM", "unknown"))
|
|
stdscr = _curses.initscr()
|
|
for key, value in _curses.__dict__.items():
|
|
if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'):
|
|
setattr(curses, key, value)
|
|
|
|
return stdscr
|
|
|
|
# This is a similar wrapper for start_color(), which adds the COLORS and
|
|
# COLOR_PAIRS variables which are only available after start_color() is
|
|
# called.
|
|
|
|
def start_color():
|
|
import _curses, curses
|
|
retval = _curses.start_color()
|
|
if hasattr(_curses, 'COLORS'):
|
|
curses.COLORS = _curses.COLORS
|
|
if hasattr(_curses, 'COLOR_PAIRS'):
|
|
curses.COLOR_PAIRS = _curses.COLOR_PAIRS
|
|
return retval
|
|
|
|
# Import Python has_key() implementation if _curses doesn't contain has_key()
|
|
|
|
try:
|
|
has_key
|
|
except NameError:
|
|
from has_key import has_key
|