Linux ip-148-66-134-25.ip.secureserver.net 3.10.0-1160.119.1.el7.tuxcare.els11.x86_64 #1 SMP Sun Nov 3 09:06:59 UTC 2024 x86_64
Apache
: 148.66.134.25 | : 3.137.166.61
66 Domain
8.0.30
amvm
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
BLACK DEFEND!
README
+ Create Folder
+ Create File
/
usr /
share /
doc /
python-docs-2.7.5 /
html /
library /
[ HOME SHELL ]
Name
Size
Permission
Action
2to3.html
49.27
KB
-rw-r--r--
__builtin__.html
10.26
KB
-rw-r--r--
__future__.html
13.79
KB
-rw-r--r--
__main__.html
7.05
KB
-rw-r--r--
_winreg.html
59.21
KB
-rw-r--r--
abc.html
23.9
KB
-rw-r--r--
aepack.html
13.16
KB
-rw-r--r--
aetools.html
14.91
KB
-rw-r--r--
aetypes.html
18.88
KB
-rw-r--r--
aifc.html
22.4
KB
-rw-r--r--
al.html
17.34
KB
-rw-r--r--
allos.html
33.72
KB
-rw-r--r--
anydbm.html
16.33
KB
-rw-r--r--
archiving.html
9.26
KB
-rw-r--r--
argparse.html
237.62
KB
-rw-r--r--
array.html
29.29
KB
-rw-r--r--
ast.html
34.98
KB
-rw-r--r--
asynchat.html
31.43
KB
-rw-r--r--
asyncore.html
36.51
KB
-rw-r--r--
atexit.html
16.8
KB
-rw-r--r--
audioop.html
31.36
KB
-rw-r--r--
autogil.html
8.19
KB
-rw-r--r--
base64.html
19.67
KB
-rw-r--r--
basehttpserver.html
34.04
KB
-rw-r--r--
bastion.html
11.04
KB
-rw-r--r--
bdb.html
36.68
KB
-rw-r--r--
binascii.html
20.67
KB
-rw-r--r--
binhex.html
10.58
KB
-rw-r--r--
bisect.html
23.24
KB
-rw-r--r--
bsddb.html
26.43
KB
-rw-r--r--
bz2.html
26.08
KB
-rw-r--r--
calendar.html
37.79
KB
-rw-r--r--
carbon.html
48.94
KB
-rw-r--r--
cd.html
27.96
KB
-rw-r--r--
cgi.html
49.92
KB
-rw-r--r--
cgihttpserver.html
13.1
KB
-rw-r--r--
cgitb.html
11.41
KB
-rw-r--r--
chunk.html
14.66
KB
-rw-r--r--
cmath.html
25.63
KB
-rw-r--r--
cmd.html
26.09
KB
-rw-r--r--
code.html
24.58
KB
-rw-r--r--
codecs.html
100.64
KB
-rw-r--r--
codeop.html
14.84
KB
-rw-r--r--
collections.html
133.96
KB
-rw-r--r--
colorpicker.html
7.52
KB
-rw-r--r--
colorsys.html
11.04
KB
-rw-r--r--
commands.html
14.36
KB
-rw-r--r--
compileall.html
16.83
KB
-rw-r--r--
compiler.html
67.75
KB
-rw-r--r--
configparser.html
62.13
KB
-rw-r--r--
constants.html
12.83
KB
-rw-r--r--
contextlib.html
19.39
KB
-rw-r--r--
cookie.html
39.07
KB
-rw-r--r--
cookielib.html
83.82
KB
-rw-r--r--
copy.html
12.19
KB
-rw-r--r--
copy_reg.html
13.76
KB
-rw-r--r--
crypt.html
10.04
KB
-rw-r--r--
crypto.html
7.59
KB
-rw-r--r--
csv.html
67.37
KB
-rw-r--r--
ctypes.html
238.78
KB
-rw-r--r--
curses.ascii.html
22.29
KB
-rw-r--r--
curses.html
146.63
KB
-rw-r--r--
curses.panel.html
14.39
KB
-rw-r--r--
custominterp.html
7.62
KB
-rw-r--r--
datatypes.html
16.84
KB
-rw-r--r--
datetime.html
226.59
KB
-rw-r--r--
dbhash.html
15.48
KB
-rw-r--r--
dbm.html
12.07
KB
-rw-r--r--
debug.html
10.15
KB
-rw-r--r--
decimal.html
194.44
KB
-rw-r--r--
development.html
14.17
KB
-rw-r--r--
difflib.html
84.83
KB
-rw-r--r--
dircache.html
11.41
KB
-rw-r--r--
dis.html
69.95
KB
-rw-r--r--
distutils.html
8.05
KB
-rw-r--r--
dl.html
16.33
KB
-rw-r--r--
doctest.html
165.54
KB
-rw-r--r--
docxmlrpcserver.html
16.43
KB
-rw-r--r--
dumbdbm.html
14.02
KB
-rw-r--r--
dummy_thread.html
9.43
KB
-rw-r--r--
dummy_threading.html
8.37
KB
-rw-r--r--
easydialogs.html
30.55
KB
-rw-r--r--
email-examples.html
45.65
KB
-rw-r--r--
email.charset.html
26.8
KB
-rw-r--r--
email.encoders.html
11.86
KB
-rw-r--r--
email.errors.html
15.77
KB
-rw-r--r--
email.generator.html
20.77
KB
-rw-r--r--
email.header.html
26.92
KB
-rw-r--r--
email.html
44.24
KB
-rw-r--r--
email.iterators.html
11.52
KB
-rw-r--r--
email.message.html
63.16
KB
-rw-r--r--
email.mime.html
27.93
KB
-rw-r--r--
email.parser.html
30.45
KB
-rw-r--r--
email.util.html
24.46
KB
-rw-r--r--
errno.html
37.99
KB
-rw-r--r--
exceptions.html
56.13
KB
-rw-r--r--
fcntl.html
22.67
KB
-rw-r--r--
filecmp.html
22.3
KB
-rw-r--r--
fileformats.html
9.14
KB
-rw-r--r--
fileinput.html
24.28
KB
-rw-r--r--
filesys.html
10.2
KB
-rw-r--r--
fl.html
49.92
KB
-rw-r--r--
fm.html
11.91
KB
-rw-r--r--
fnmatch.html
14.58
KB
-rw-r--r--
formatter.html
34.06
KB
-rw-r--r--
fpectl.html
16.01
KB
-rw-r--r--
fpformat.html
10.59
KB
-rw-r--r--
fractions.html
22.61
KB
-rw-r--r--
framework.html
33.34
KB
-rw-r--r--
frameworks.html
7.14
KB
-rw-r--r--
ftplib.html
43.99
KB
-rw-r--r--
functions.html
183.14
KB
-rw-r--r--
functools.html
27.17
KB
-rw-r--r--
future_builtins.html
13.04
KB
-rw-r--r--
gc.html
25.75
KB
-rw-r--r--
gdbm.html
15.96
KB
-rw-r--r--
gensuitemodule.html
11.51
KB
-rw-r--r--
getopt.html
23.66
KB
-rw-r--r--
getpass.html
10.65
KB
-rw-r--r--
gettext.html
78.76
KB
-rw-r--r--
gl.html
22.09
KB
-rw-r--r--
glob.html
13.26
KB
-rw-r--r--
grp.html
10.49
KB
-rw-r--r--
gzip.html
18.99
KB
-rw-r--r--
hashlib.html
18.2
KB
-rw-r--r--
heapq.html
31.61
KB
-rw-r--r--
hmac.html
10.46
KB
-rw-r--r--
hotshot.html
18.65
KB
-rw-r--r--
htmllib.html
25.32
KB
-rw-r--r--
htmlparser.html
39.11
KB
-rw-r--r--
httplib.html
62.95
KB
-rw-r--r--
i18n.html
9.52
KB
-rw-r--r--
ic.html
17.17
KB
-rw-r--r--
idle.html
20.9
KB
-rw-r--r--
imageop.html
14.76
KB
-rw-r--r--
imaplib.html
51.99
KB
-rw-r--r--
imgfile.html
11.71
KB
-rw-r--r--
imghdr.html
11.3
KB
-rw-r--r--
imp.html
34.34
KB
-rw-r--r--
importlib.html
8.26
KB
-rw-r--r--
imputil.html
31.81
KB
-rw-r--r--
index.html
72.78
KB
-rw-r--r--
inspect.html
50.71
KB
-rw-r--r--
internet.html
24.87
KB
-rw-r--r--
intro.html
8.93
KB
-rw-r--r--
io.html
98.13
KB
-rw-r--r--
ipc.html
13.41
KB
-rw-r--r--
itertools.html
115.91
KB
-rw-r--r--
jpeg.html
12.74
KB
-rw-r--r--
json.html
67.04
KB
-rw-r--r--
keyword.html
7.68
KB
-rw-r--r--
language.html
11.03
KB
-rw-r--r--
linecache.html
10.59
KB
-rw-r--r--
locale.html
55.14
KB
-rw-r--r--
logging.config.html
63.36
KB
-rw-r--r--
logging.handlers.html
69.64
KB
-rw-r--r--
logging.html
95.64
KB
-rw-r--r--
mac.html
21.79
KB
-rw-r--r--
macos.html
14.76
KB
-rw-r--r--
macosa.html
12.96
KB
-rw-r--r--
macostools.html
15.52
KB
-rw-r--r--
macpath.html
7.76
KB
-rw-r--r--
mailbox.html
156.75
KB
-rw-r--r--
mailcap.html
13.21
KB
-rw-r--r--
markup.html
18.77
KB
-rw-r--r--
marshal.html
17.98
KB
-rw-r--r--
math.html
39.24
KB
-rw-r--r--
md5.html
13.97
KB
-rw-r--r--
mhlib.html
21.54
KB
-rw-r--r--
mimetools.html
19.25
KB
-rw-r--r--
mimetypes.html
28.39
KB
-rw-r--r--
mimewriter.html
15.02
KB
-rw-r--r--
mimify.html
13.36
KB
-rw-r--r--
miniaeframe.html
12.2
KB
-rw-r--r--
misc.html
6.87
KB
-rw-r--r--
mm.html
9.03
KB
-rw-r--r--
mmap.html
28.36
KB
-rw-r--r--
modulefinder.html
15.31
KB
-rw-r--r--
modules.html
8.46
KB
-rw-r--r--
msilib.html
52.43
KB
-rw-r--r--
msvcrt.html
19.37
KB
-rw-r--r--
multifile.html
24.3
KB
-rw-r--r--
multiprocessing.html
365.71
KB
-rw-r--r--
mutex.html
11.23
KB
-rw-r--r--
netdata.html
16.98
KB
-rw-r--r--
netrc.html
12.3
KB
-rw-r--r--
new.html
12.12
KB
-rw-r--r--
nis.html
10.64
KB
-rw-r--r--
nntplib.html
41.92
KB
-rw-r--r--
numbers.html
37.75
KB
-rw-r--r--
numeric.html
13.55
KB
-rw-r--r--
operator.html
82
KB
-rw-r--r--
optparse.html
222.56
KB
-rw-r--r--
os.html
214.25
KB
-rw-r--r--
os.path.html
38.34
KB
-rw-r--r--
ossaudiodev.html
41.5
KB
-rw-r--r--
othergui.html
9.08
KB
-rw-r--r--
parser.html
39.36
KB
-rw-r--r--
pdb.html
33.96
KB
-rw-r--r--
persistence.html
14.87
KB
-rw-r--r--
pickle.html
102.27
KB
-rw-r--r--
pickletools.html
10.63
KB
-rw-r--r--
pipes.html
18.01
KB
-rw-r--r--
pkgutil.html
25.11
KB
-rw-r--r--
platform.html
28.37
KB
-rw-r--r--
plistlib.html
17.03
KB
-rw-r--r--
popen2.html
25.43
KB
-rw-r--r--
poplib.html
22.32
KB
-rw-r--r--
posix.html
14.41
KB
-rw-r--r--
posixfile.html
19.76
KB
-rw-r--r--
pprint.html
29.92
KB
-rw-r--r--
profile.html
63.56
KB
-rw-r--r--
pty.html
9.48
KB
-rw-r--r--
pwd.html
11.43
KB
-rw-r--r--
py_compile.html
11.12
KB
-rw-r--r--
pyclbr.html
14.71
KB
-rw-r--r--
pydoc.html
11.48
KB
-rw-r--r--
pyexpat.html
71.53
KB
-rw-r--r--
python.html
12.27
KB
-rw-r--r--
queue.html
24.22
KB
-rw-r--r--
quopri.html
11.9
KB
-rw-r--r--
random.html
37.83
KB
-rw-r--r--
re.html
134.74
KB
-rw-r--r--
readline.html
28.24
KB
-rw-r--r--
repr.html
20.43
KB
-rw-r--r--
resource.html
26.48
KB
-rw-r--r--
restricted.html
11.65
KB
-rw-r--r--
rexec.html
37.41
KB
-rw-r--r--
rfc822.html
42.22
KB
-rw-r--r--
rlcompleter.html
13.51
KB
-rw-r--r--
robotparser.html
12.27
KB
-rw-r--r--
runpy.html
19.34
KB
-rw-r--r--
sched.html
18.54
KB
-rw-r--r--
scrolledtext.html
9.32
KB
-rw-r--r--
select.html
39.67
KB
-rw-r--r--
sets.html
36.92
KB
-rw-r--r--
sgi.html
9.71
KB
-rw-r--r--
sgmllib.html
30.77
KB
-rw-r--r--
sha.html
12.09
KB
-rw-r--r--
shelve.html
27.02
KB
-rw-r--r--
shlex.html
32.1
KB
-rw-r--r--
shutil.html
40.22
KB
-rw-r--r--
signal.html
31.14
KB
-rw-r--r--
simplehttpserver.html
18.41
KB
-rw-r--r--
simplexmlrpcserver.html
31.39
KB
-rw-r--r--
site.html
23.64
KB
-rw-r--r--
smtpd.html
12.46
KB
-rw-r--r--
smtplib.html
42.13
KB
-rw-r--r--
sndhdr.html
10.02
KB
-rw-r--r--
socket.html
106.34
KB
-rw-r--r--
socketserver.html
59.83
KB
-rw-r--r--
someos.html
15.11
KB
-rw-r--r--
spwd.html
10.33
KB
-rw-r--r--
sqlite3.html
139.5
KB
-rw-r--r--
ssl.html
65.62
KB
-rw-r--r--
stat.html
32.31
KB
-rw-r--r--
statvfs.html
10.6
KB
-rw-r--r--
stdtypes.html
260.4
KB
-rw-r--r--
string.html
106.65
KB
-rw-r--r--
stringio.html
18.81
KB
-rw-r--r--
stringprep.html
16.13
KB
-rw-r--r--
strings.html
14.93
KB
-rw-r--r--
struct.html
40.88
KB
-rw-r--r--
subprocess.html
84.91
KB
-rw-r--r--
sun.html
6.84
KB
-rw-r--r--
sunau.html
27.1
KB
-rw-r--r--
sunaudio.html
17.79
KB
-rw-r--r--
symbol.html
7.66
KB
-rw-r--r--
symtable.html
22.94
KB
-rw-r--r--
sys.html
98.7
KB
-rw-r--r--
sysconfig.html
23.84
KB
-rw-r--r--
syslog.html
17.92
KB
-rw-r--r--
tabnanny.html
10.63
KB
-rw-r--r--
tarfile.html
78.68
KB
-rw-r--r--
telnetlib.html
25.48
KB
-rw-r--r--
tempfile.html
29.42
KB
-rw-r--r--
termios.html
16.01
KB
-rw-r--r--
test.html
52.62
KB
-rw-r--r--
textwrap.html
27.25
KB
-rw-r--r--
thread.html
20.47
KB
-rw-r--r--
threading.html
76.69
KB
-rw-r--r--
time.html
56.93
KB
-rw-r--r--
timeit.html
36.27
KB
-rw-r--r--
tix.html
46.96
KB
-rw-r--r--
tk.html
23.64
KB
-rw-r--r--
tkinter.html
67.67
KB
-rw-r--r--
token.html
19.62
KB
-rw-r--r--
tokenize.html
18.45
KB
-rw-r--r--
trace.html
25.54
KB
-rw-r--r--
traceback.html
33.44
KB
-rw-r--r--
ttk.html
101.75
KB
-rw-r--r--
tty.html
9.06
KB
-rw-r--r--
turtle.html
211.74
KB
-rw-r--r--
types.html
27.59
KB
-rw-r--r--
undoc.html
23.16
KB
-rw-r--r--
unicodedata.html
18.55
KB
-rw-r--r--
unittest.html
202.85
KB
-rw-r--r--
unix.html
10.55
KB
-rw-r--r--
urllib.html
58.68
KB
-rw-r--r--
urllib2.html
100.58
KB
-rw-r--r--
urlparse.html
40.41
KB
-rw-r--r--
user.html
11.83
KB
-rw-r--r--
userdict.html
29.73
KB
-rw-r--r--
uu.html
11.03
KB
-rw-r--r--
uuid.html
28.19
KB
-rw-r--r--
warnings.html
46.6
KB
-rw-r--r--
wave.html
22.22
KB
-rw-r--r--
weakref.html
36.52
KB
-rw-r--r--
webbrowser.html
23.07
KB
-rw-r--r--
whichdb.html
8.85
KB
-rw-r--r--
windows.html
9.33
KB
-rw-r--r--
winsound.html
18.75
KB
-rw-r--r--
wsgiref.html
81.04
KB
-rw-r--r--
xdrlib.html
29.94
KB
-rw-r--r--
xml.dom.html
89.04
KB
-rw-r--r--
xml.dom.minidom.html
40.42
KB
-rw-r--r--
xml.dom.pulldom.html
12.71
KB
-rw-r--r--
xml.etree.elementtree.html
93.22
KB
-rw-r--r--
xml.html
16.49
KB
-rw-r--r--
xml.sax.handler.html
38.63
KB
-rw-r--r--
xml.sax.html
20.22
KB
-rw-r--r--
xml.sax.reader.html
39.09
KB
-rw-r--r--
xml.sax.utils.html
14.26
KB
-rw-r--r--
xmlrpclib.html
60.79
KB
-rw-r--r--
zipfile.html
53.14
KB
-rw-r--r--
zipimport.html
20.42
KB
-rw-r--r--
zlib.html
25.46
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : curses.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>15.11. curses — Terminal handling for character-cell displays — Python 2.7.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '2.7.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python 2.7.5 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="top" title="Python 2.7.5 documentation" href="../index.html" /> <link rel="up" title="15. Generic Operating System Services" href="allos.html" /> <link rel="next" title="15.13. curses.ascii — Utilities for ASCII characters" href="curses.ascii.html" /> <link rel="prev" title="15.10. getpass — Portable password input" href="getpass.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <script type="text/javascript" src="../_static/copybutton.js"></script> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="curses.ascii.html" title="15.13. curses.ascii — Utilities for ASCII characters" accesskey="N">next</a> |</li> <li class="right" > <a href="getpass.html" title="15.10. getpass — Portable password input" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="allos.html" accesskey="U">15. Generic Operating System Services</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-curses"> <span id="curses-terminal-handling-for-character-cell-displays"></span><h1>15.11. <a class="reference internal" href="#module-curses" title="curses: An interface to the curses library, providing portable terminal handling. (Unix)"><tt class="xref py py-mod docutils literal"><span class="pre">curses</span></tt></a> — Terminal handling for character-cell displays<a class="headerlink" href="#module-curses" title="Permalink to this headline">¶</a></h1> <p class="versionchanged"> <span class="versionmodified">Changed in version 1.6: </span>Added support for the <tt class="docutils literal"><span class="pre">ncurses</span></tt> library and converted to a package.</p> <p>The <a class="reference internal" href="#module-curses" title="curses: An interface to the curses library, providing portable terminal handling. (Unix)"><tt class="xref py py-mod docutils literal"><span class="pre">curses</span></tt></a> module provides an interface to the curses library, the de-facto standard for portable advanced terminal handling.</p> <p>While curses is most widely used in the Unix environment, versions are available for DOS, OS/2, and possibly other systems as well. This extension module is designed to match the API of ncurses, an open-source curses library hosted on Linux and the BSD variants of Unix.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p>Since version 5.4, the ncurses library decides how to interpret non-ASCII data using the <tt class="docutils literal"><span class="pre">nl_langinfo</span></tt> function. That means that you have to call <a class="reference internal" href="locale.html#locale.setlocale" title="locale.setlocale"><tt class="xref py py-func docutils literal"><span class="pre">locale.setlocale()</span></tt></a> in the application and encode Unicode strings using one of the system’s available encodings. This example uses the system’s default encoding:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">locale</span> <span class="n">locale</span><span class="o">.</span><span class="n">setlocale</span><span class="p">(</span><span class="n">locale</span><span class="o">.</span><span class="n">LC_ALL</span><span class="p">,</span> <span class="s">''</span><span class="p">)</span> <span class="n">code</span> <span class="o">=</span> <span class="n">locale</span><span class="o">.</span><span class="n">getpreferredencoding</span><span class="p">()</span> </pre></div> </div> <p class="last">Then use <em>code</em> as the encoding for <a class="reference internal" href="stdtypes.html#str.encode" title="str.encode"><tt class="xref py py-meth docutils literal"><span class="pre">str.encode()</span></tt></a> calls.</p> </div> <div class="admonition-see-also admonition seealso"> <p class="first admonition-title">See also</p> <dl class="docutils"> <dt>Module <a class="reference internal" href="curses.ascii.html#module-curses.ascii" title="curses.ascii: Constants and set-membership functions for ASCII characters."><tt class="xref py py-mod docutils literal"><span class="pre">curses.ascii</span></tt></a></dt> <dd>Utilities for working with ASCII characters, regardless of your locale settings.</dd> <dt>Module <a class="reference internal" href="curses.panel.html#module-curses.panel" title="curses.panel: A panel stack extension that adds depth to curses windows."><tt class="xref py py-mod docutils literal"><span class="pre">curses.panel</span></tt></a></dt> <dd>A panel stack extension that adds depth to curses windows.</dd> <dt>Module <a class="reference internal" href="#module-curses.textpad" title="curses.textpad: Emacs-like input editing in a curses window."><tt class="xref py py-mod docutils literal"><span class="pre">curses.textpad</span></tt></a></dt> <dd>Editable text widget for curses supporting <strong class="program">Emacs</strong>-like bindings.</dd> <dt><a class="reference internal" href="../howto/curses.html#curses-howto"><em>Curses Programming with Python</em></a></dt> <dd>Tutorial material on using curses with Python, by Andrew Kuchling and Eric Raymond.</dd> </dl> <p class="last">The <a class="reference external" href="http://hg.python.org/cpython/file/2.7/Demo/curses/">Demo/curses/</a> directory in the Python source distribution contains some example programs using the curses bindings provided by this module.</p> </div> <div class="section" id="functions"> <span id="curses-functions"></span><h2>15.11.1. Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h2> <p>The module <a class="reference internal" href="#module-curses" title="curses: An interface to the curses library, providing portable terminal handling. (Unix)"><tt class="xref py py-mod docutils literal"><span class="pre">curses</span></tt></a> defines the following exception:</p> <dl class="exception"> <dt id="curses.error"> <em class="property">exception </em><tt class="descclassname">curses.</tt><tt class="descname">error</tt><a class="headerlink" href="#curses.error" title="Permalink to this definition">¶</a></dt> <dd><p>Exception raised when a curses library function returns an error.</p> </dd></dl> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">Whenever <em>x</em> or <em>y</em> arguments to a function or a method are optional, they default to the current cursor location. Whenever <em>attr</em> is optional, it defaults to <tt class="xref py py-const docutils literal"><span class="pre">A_NORMAL</span></tt>.</p> </div> <p>The module <a class="reference internal" href="#module-curses" title="curses: An interface to the curses library, providing portable terminal handling. (Unix)"><tt class="xref py py-mod docutils literal"><span class="pre">curses</span></tt></a> defines the following functions:</p> <dl class="function"> <dt id="curses.baudrate"> <tt class="descclassname">curses.</tt><tt class="descname">baudrate</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.baudrate" title="Permalink to this definition">¶</a></dt> <dd><p>Return the output speed of the terminal in bits per second. On software terminal emulators it will have a fixed high value. Included for historical reasons; in former times, it was used to write output loops for time delays and occasionally to change interfaces depending on the line speed.</p> </dd></dl> <dl class="function"> <dt id="curses.beep"> <tt class="descclassname">curses.</tt><tt class="descname">beep</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.beep" title="Permalink to this definition">¶</a></dt> <dd><p>Emit a short attention sound.</p> </dd></dl> <dl class="function"> <dt id="curses.can_change_color"> <tt class="descclassname">curses.</tt><tt class="descname">can_change_color</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.can_change_color" title="Permalink to this definition">¶</a></dt> <dd><p>Return <tt class="docutils literal"><span class="pre">True</span></tt> or <tt class="docutils literal"><span class="pre">False</span></tt>, depending on whether the programmer can change the colors displayed by the terminal.</p> </dd></dl> <dl class="function"> <dt id="curses.cbreak"> <tt class="descclassname">curses.</tt><tt class="descname">cbreak</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.cbreak" title="Permalink to this definition">¶</a></dt> <dd><p>Enter cbreak mode. In cbreak mode (sometimes called “rare” mode) normal tty line buffering is turned off and characters are available to be read one by one. However, unlike raw mode, special characters (interrupt, quit, suspend, and flow control) retain their effects on the tty driver and calling program. Calling first <a class="reference internal" href="#curses.raw" title="curses.raw"><tt class="xref py py-func docutils literal"><span class="pre">raw()</span></tt></a> then <a class="reference internal" href="#curses.cbreak" title="curses.cbreak"><tt class="xref py py-func docutils literal"><span class="pre">cbreak()</span></tt></a> leaves the terminal in cbreak mode.</p> </dd></dl> <dl class="function"> <dt id="curses.color_content"> <tt class="descclassname">curses.</tt><tt class="descname">color_content</tt><big>(</big><em>color_number</em><big>)</big><a class="headerlink" href="#curses.color_content" title="Permalink to this definition">¶</a></dt> <dd><p>Return the intensity of the red, green, and blue (RGB) components in the color <em>color_number</em>, which must be between <tt class="docutils literal"><span class="pre">0</span></tt> and <tt class="xref py py-const docutils literal"><span class="pre">COLORS</span></tt>. A 3-tuple is returned, containing the R,G,B values for the given color, which will be between <tt class="docutils literal"><span class="pre">0</span></tt> (no component) and <tt class="docutils literal"><span class="pre">1000</span></tt> (maximum amount of component).</p> </dd></dl> <dl class="function"> <dt id="curses.color_pair"> <tt class="descclassname">curses.</tt><tt class="descname">color_pair</tt><big>(</big><em>color_number</em><big>)</big><a class="headerlink" href="#curses.color_pair" title="Permalink to this definition">¶</a></dt> <dd><p>Return the attribute value for displaying text in the specified color. This attribute value can be combined with <tt class="xref py py-const docutils literal"><span class="pre">A_STANDOUT</span></tt>, <tt class="xref py py-const docutils literal"><span class="pre">A_REVERSE</span></tt>, and the other <tt class="xref py py-const docutils literal"><span class="pre">A_*</span></tt> attributes. <a class="reference internal" href="#curses.pair_number" title="curses.pair_number"><tt class="xref py py-func docutils literal"><span class="pre">pair_number()</span></tt></a> is the counterpart to this function.</p> </dd></dl> <dl class="function"> <dt id="curses.curs_set"> <tt class="descclassname">curses.</tt><tt class="descname">curs_set</tt><big>(</big><em>visibility</em><big>)</big><a class="headerlink" href="#curses.curs_set" title="Permalink to this definition">¶</a></dt> <dd><p>Set the cursor state. <em>visibility</em> can be set to 0, 1, or 2, for invisible, normal, or very visible. If the terminal supports the visibility requested, the previous cursor state is returned; otherwise, an exception is raised. On many terminals, the “visible” mode is an underline cursor and the “very visible” mode is a block cursor.</p> </dd></dl> <dl class="function"> <dt id="curses.def_prog_mode"> <tt class="descclassname">curses.</tt><tt class="descname">def_prog_mode</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.def_prog_mode" title="Permalink to this definition">¶</a></dt> <dd><p>Save the current terminal mode as the “program” mode, the mode when the running program is using curses. (Its counterpart is the “shell” mode, for when the program is not in curses.) Subsequent calls to <a class="reference internal" href="#curses.reset_prog_mode" title="curses.reset_prog_mode"><tt class="xref py py-func docutils literal"><span class="pre">reset_prog_mode()</span></tt></a> will restore this mode.</p> </dd></dl> <dl class="function"> <dt id="curses.def_shell_mode"> <tt class="descclassname">curses.</tt><tt class="descname">def_shell_mode</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.def_shell_mode" title="Permalink to this definition">¶</a></dt> <dd><p>Save the current terminal mode as the “shell” mode, the mode when the running program is not using curses. (Its counterpart is the “program” mode, when the program is using curses capabilities.) Subsequent calls to <a class="reference internal" href="#curses.reset_shell_mode" title="curses.reset_shell_mode"><tt class="xref py py-func docutils literal"><span class="pre">reset_shell_mode()</span></tt></a> will restore this mode.</p> </dd></dl> <dl class="function"> <dt id="curses.delay_output"> <tt class="descclassname">curses.</tt><tt class="descname">delay_output</tt><big>(</big><em>ms</em><big>)</big><a class="headerlink" href="#curses.delay_output" title="Permalink to this definition">¶</a></dt> <dd><p>Insert an <em>ms</em> millisecond pause in output.</p> </dd></dl> <dl class="function"> <dt id="curses.doupdate"> <tt class="descclassname">curses.</tt><tt class="descname">doupdate</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.doupdate" title="Permalink to this definition">¶</a></dt> <dd><p>Update the physical screen. The curses library keeps two data structures, one representing the current physical screen contents and a virtual screen representing the desired next state. The <a class="reference internal" href="#curses.doupdate" title="curses.doupdate"><tt class="xref py py-func docutils literal"><span class="pre">doupdate()</span></tt></a> ground updates the physical screen to match the virtual screen.</p> <p>The virtual screen may be updated by a <tt class="xref py py-meth docutils literal"><span class="pre">noutrefresh()</span></tt> call after write operations such as <tt class="xref py py-meth docutils literal"><span class="pre">addstr()</span></tt> have been performed on a window. The normal <tt class="xref py py-meth docutils literal"><span class="pre">refresh()</span></tt> call is simply <tt class="xref py py-meth docutils literal"><span class="pre">noutrefresh()</span></tt> followed by <a class="reference internal" href="#curses.doupdate" title="curses.doupdate"><tt class="xref py py-func docutils literal"><span class="pre">doupdate()</span></tt></a>; if you have to update multiple windows, you can speed performance and perhaps reduce screen flicker by issuing <tt class="xref py py-meth docutils literal"><span class="pre">noutrefresh()</span></tt> calls on all windows, followed by a single <a class="reference internal" href="#curses.doupdate" title="curses.doupdate"><tt class="xref py py-func docutils literal"><span class="pre">doupdate()</span></tt></a>.</p> </dd></dl> <dl class="function"> <dt id="curses.echo"> <tt class="descclassname">curses.</tt><tt class="descname">echo</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.echo" title="Permalink to this definition">¶</a></dt> <dd><p>Enter echo mode. In echo mode, each character input is echoed to the screen as it is entered.</p> </dd></dl> <dl class="function"> <dt id="curses.endwin"> <tt class="descclassname">curses.</tt><tt class="descname">endwin</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.endwin" title="Permalink to this definition">¶</a></dt> <dd><p>De-initialize the library, and return terminal to normal status.</p> </dd></dl> <dl class="function"> <dt id="curses.erasechar"> <tt class="descclassname">curses.</tt><tt class="descname">erasechar</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.erasechar" title="Permalink to this definition">¶</a></dt> <dd><p>Return the user’s current erase character. Under Unix operating systems this is a property of the controlling tty of the curses program, and is not set by the curses library itself.</p> </dd></dl> <dl class="function"> <dt id="curses.filter"> <tt class="descclassname">curses.</tt><tt class="descname">filter</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.filter" title="Permalink to this definition">¶</a></dt> <dd><p>The <a class="reference internal" href="#curses.filter" title="curses.filter"><tt class="xref py py-func docutils literal"><span class="pre">filter()</span></tt></a> routine, if used, must be called before <a class="reference internal" href="#curses.initscr" title="curses.initscr"><tt class="xref py py-func docutils literal"><span class="pre">initscr()</span></tt></a> is called. The effect is that, during those calls, <span class="target" id="index-0"></span><tt class="xref std std-envvar docutils literal"><span class="pre">LINES</span></tt> is set to 1; the capabilities clear, cup, cud, cud1, cuu1, cuu, vpa are disabled; and the home string is set to the value of cr. The effect is that the cursor is confined to the current line, and so are screen updates. This may be used for enabling character-at-a-time line editing without touching the rest of the screen.</p> </dd></dl> <dl class="function"> <dt id="curses.flash"> <tt class="descclassname">curses.</tt><tt class="descname">flash</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.flash" title="Permalink to this definition">¶</a></dt> <dd><p>Flash the screen. That is, change it to reverse-video and then change it back in a short interval. Some people prefer such as ‘visible bell’ to the audible attention signal produced by <a class="reference internal" href="#curses.beep" title="curses.beep"><tt class="xref py py-func docutils literal"><span class="pre">beep()</span></tt></a>.</p> </dd></dl> <dl class="function"> <dt id="curses.flushinp"> <tt class="descclassname">curses.</tt><tt class="descname">flushinp</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.flushinp" title="Permalink to this definition">¶</a></dt> <dd><p>Flush all input buffers. This throws away any typeahead that has been typed by the user and has not yet been processed by the program.</p> </dd></dl> <dl class="function"> <dt id="curses.getmouse"> <tt class="descclassname">curses.</tt><tt class="descname">getmouse</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.getmouse" title="Permalink to this definition">¶</a></dt> <dd><p>After <tt class="xref py py-meth docutils literal"><span class="pre">getch()</span></tt> returns <tt class="xref py py-const docutils literal"><span class="pre">KEY_MOUSE</span></tt> to signal a mouse event, this method should be call to retrieve the queued mouse event, represented as a 5-tuple <tt class="docutils literal"><span class="pre">(id,</span> <span class="pre">x,</span> <span class="pre">y,</span> <span class="pre">z,</span> <span class="pre">bstate)</span></tt>. <em>id</em> is an ID value used to distinguish multiple devices, and <em>x</em>, <em>y</em>, <em>z</em> are the event’s coordinates. (<em>z</em> is currently unused.) <em>bstate</em> is an integer value whose bits will be set to indicate the type of event, and will be the bitwise OR of one or more of the following constants, where <em>n</em> is the button number from 1 to 4: <tt class="xref py py-const docutils literal"><span class="pre">BUTTONn_PRESSED</span></tt>, <tt class="xref py py-const docutils literal"><span class="pre">BUTTONn_RELEASED</span></tt>, <tt class="xref py py-const docutils literal"><span class="pre">BUTTONn_CLICKED</span></tt>, <tt class="xref py py-const docutils literal"><span class="pre">BUTTONn_DOUBLE_CLICKED</span></tt>, <tt class="xref py py-const docutils literal"><span class="pre">BUTTONn_TRIPLE_CLICKED</span></tt>, <tt class="xref py py-const docutils literal"><span class="pre">BUTTON_SHIFT</span></tt>, <tt class="xref py py-const docutils literal"><span class="pre">BUTTON_CTRL</span></tt>, <tt class="xref py py-const docutils literal"><span class="pre">BUTTON_ALT</span></tt>.</p> </dd></dl> <dl class="function"> <dt id="curses.getsyx"> <tt class="descclassname">curses.</tt><tt class="descname">getsyx</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.getsyx" title="Permalink to this definition">¶</a></dt> <dd><p>Return the current coordinates of the virtual screen cursor in y and x. If leaveok is currently true, then -1,-1 is returned.</p> </dd></dl> <dl class="function"> <dt id="curses.getwin"> <tt class="descclassname">curses.</tt><tt class="descname">getwin</tt><big>(</big><em>file</em><big>)</big><a class="headerlink" href="#curses.getwin" title="Permalink to this definition">¶</a></dt> <dd><p>Read window related data stored in the file by an earlier <tt class="xref py py-func docutils literal"><span class="pre">putwin()</span></tt> call. The routine then creates and initializes a new window using that data, returning the new window object.</p> </dd></dl> <dl class="function"> <dt id="curses.has_colors"> <tt class="descclassname">curses.</tt><tt class="descname">has_colors</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.has_colors" title="Permalink to this definition">¶</a></dt> <dd><p>Return <tt class="docutils literal"><span class="pre">True</span></tt> if the terminal can display colors; otherwise, return <tt class="docutils literal"><span class="pre">False</span></tt>.</p> </dd></dl> <dl class="function"> <dt id="curses.has_ic"> <tt class="descclassname">curses.</tt><tt class="descname">has_ic</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.has_ic" title="Permalink to this definition">¶</a></dt> <dd><p>Return <tt class="docutils literal"><span class="pre">True</span></tt> if the terminal has insert- and delete-character capabilities. This function is included for historical reasons only, as all modern software terminal emulators have such capabilities.</p> </dd></dl> <dl class="function"> <dt id="curses.has_il"> <tt class="descclassname">curses.</tt><tt class="descname">has_il</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.has_il" title="Permalink to this definition">¶</a></dt> <dd><p>Return <tt class="docutils literal"><span class="pre">True</span></tt> if the terminal has insert- and delete-line capabilities, or can simulate them using scrolling regions. This function is included for historical reasons only, as all modern software terminal emulators have such capabilities.</p> </dd></dl> <dl class="function"> <dt id="curses.has_key"> <tt class="descclassname">curses.</tt><tt class="descname">has_key</tt><big>(</big><em>ch</em><big>)</big><a class="headerlink" href="#curses.has_key" title="Permalink to this definition">¶</a></dt> <dd><p>Take a key value <em>ch</em>, and return <tt class="docutils literal"><span class="pre">True</span></tt> if the current terminal type recognizes a key with that value.</p> </dd></dl> <dl class="function"> <dt id="curses.halfdelay"> <tt class="descclassname">curses.</tt><tt class="descname">halfdelay</tt><big>(</big><em>tenths</em><big>)</big><a class="headerlink" href="#curses.halfdelay" title="Permalink to this definition">¶</a></dt> <dd><p>Used for half-delay mode, which is similar to cbreak mode in that characters typed by the user are immediately available to the program. However, after blocking for <em>tenths</em> tenths of seconds, an exception is raised if nothing has been typed. The value of <em>tenths</em> must be a number between <tt class="docutils literal"><span class="pre">1</span></tt> and <tt class="docutils literal"><span class="pre">255</span></tt>. Use <a class="reference internal" href="#curses.nocbreak" title="curses.nocbreak"><tt class="xref py py-func docutils literal"><span class="pre">nocbreak()</span></tt></a> to leave half-delay mode.</p> </dd></dl> <dl class="function"> <dt id="curses.init_color"> <tt class="descclassname">curses.</tt><tt class="descname">init_color</tt><big>(</big><em>color_number</em>, <em>r</em>, <em>g</em>, <em>b</em><big>)</big><a class="headerlink" href="#curses.init_color" title="Permalink to this definition">¶</a></dt> <dd><p>Change the definition of a color, taking the number of the color to be changed followed by three RGB values (for the amounts of red, green, and blue components). The value of <em>color_number</em> must be between <tt class="docutils literal"><span class="pre">0</span></tt> and <tt class="xref py py-const docutils literal"><span class="pre">COLORS</span></tt>. Each of <em>r</em>, <em>g</em>, <em>b</em>, must be a value between <tt class="docutils literal"><span class="pre">0</span></tt> and <tt class="docutils literal"><span class="pre">1000</span></tt>. When <a class="reference internal" href="#curses.init_color" title="curses.init_color"><tt class="xref py py-func docutils literal"><span class="pre">init_color()</span></tt></a> is used, all occurrences of that color on the screen immediately change to the new definition. This function is a no-op on most terminals; it is active only if <a class="reference internal" href="#curses.can_change_color" title="curses.can_change_color"><tt class="xref py py-func docutils literal"><span class="pre">can_change_color()</span></tt></a> returns <tt class="docutils literal"><span class="pre">1</span></tt>.</p> </dd></dl> <dl class="function"> <dt id="curses.init_pair"> <tt class="descclassname">curses.</tt><tt class="descname">init_pair</tt><big>(</big><em>pair_number</em>, <em>fg</em>, <em>bg</em><big>)</big><a class="headerlink" href="#curses.init_pair" title="Permalink to this definition">¶</a></dt> <dd><p>Change the definition of a color-pair. It takes three arguments: the number of the color-pair to be changed, the foreground color number, and the background color number. The value of <em>pair_number</em> must be between <tt class="docutils literal"><span class="pre">1</span></tt> and <tt class="docutils literal"><span class="pre">COLOR_PAIRS</span> <span class="pre">-</span> <span class="pre">1</span></tt> (the <tt class="docutils literal"><span class="pre">0</span></tt> color pair is wired to white on black and cannot be changed). The value of <em>fg</em> and <em>bg</em> arguments must be between <tt class="docutils literal"><span class="pre">0</span></tt> and <tt class="xref py py-const docutils literal"><span class="pre">COLORS</span></tt>. If the color-pair was previously initialized, the screen is refreshed and all occurrences of that color-pair are changed to the new definition.</p> </dd></dl> <dl class="function"> <dt id="curses.initscr"> <tt class="descclassname">curses.</tt><tt class="descname">initscr</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.initscr" title="Permalink to this definition">¶</a></dt> <dd><p>Initialize the library. Return a <tt class="xref py py-class docutils literal"><span class="pre">WindowObject</span></tt> which represents the whole screen.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">If there is an error opening the terminal, the underlying curses library may cause the interpreter to exit.</p> </div> </dd></dl> <dl class="function"> <dt id="curses.is_term_resized"> <tt class="descclassname">curses.</tt><tt class="descname">is_term_resized</tt><big>(</big><em>nlines</em>, <em>ncols</em><big>)</big><a class="headerlink" href="#curses.is_term_resized" title="Permalink to this definition">¶</a></dt> <dd><p>Return <tt class="docutils literal"><span class="pre">True</span></tt> if <a class="reference internal" href="#curses.resize_term" title="curses.resize_term"><tt class="xref py py-func docutils literal"><span class="pre">resize_term()</span></tt></a> would modify the window structure, <tt class="docutils literal"><span class="pre">False</span></tt> otherwise.</p> </dd></dl> <dl class="function"> <dt id="curses.isendwin"> <tt class="descclassname">curses.</tt><tt class="descname">isendwin</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.isendwin" title="Permalink to this definition">¶</a></dt> <dd><p>Return <tt class="docutils literal"><span class="pre">True</span></tt> if <a class="reference internal" href="#curses.endwin" title="curses.endwin"><tt class="xref py py-func docutils literal"><span class="pre">endwin()</span></tt></a> has been called (that is, the curses library has been deinitialized).</p> </dd></dl> <dl class="function"> <dt id="curses.keyname"> <tt class="descclassname">curses.</tt><tt class="descname">keyname</tt><big>(</big><em>k</em><big>)</big><a class="headerlink" href="#curses.keyname" title="Permalink to this definition">¶</a></dt> <dd><p>Return the name of the key numbered <em>k</em>. The name of a key generating printable ASCII character is the key’s character. The name of a control-key combination is a two-character string consisting of a caret followed by the corresponding printable ASCII character. The name of an alt-key combination (128-255) is a string consisting of the prefix ‘M-‘ followed by the name of the corresponding ASCII character.</p> </dd></dl> <dl class="function"> <dt id="curses.killchar"> <tt class="descclassname">curses.</tt><tt class="descname">killchar</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.killchar" title="Permalink to this definition">¶</a></dt> <dd><p>Return the user’s current line kill character. Under Unix operating systems this is a property of the controlling tty of the curses program, and is not set by the curses library itself.</p> </dd></dl> <dl class="function"> <dt id="curses.longname"> <tt class="descclassname">curses.</tt><tt class="descname">longname</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.longname" title="Permalink to this definition">¶</a></dt> <dd><p>Return a string containing the terminfo long name field describing the current terminal. The maximum length of a verbose description is 128 characters. It is defined only after the call to <a class="reference internal" href="#curses.initscr" title="curses.initscr"><tt class="xref py py-func docutils literal"><span class="pre">initscr()</span></tt></a>.</p> </dd></dl> <dl class="function"> <dt id="curses.meta"> <tt class="descclassname">curses.</tt><tt class="descname">meta</tt><big>(</big><em>yes</em><big>)</big><a class="headerlink" href="#curses.meta" title="Permalink to this definition">¶</a></dt> <dd><p>If <em>yes</em> is 1, allow 8-bit characters to be input. If <em>yes</em> is 0, allow only 7-bit chars.</p> </dd></dl> <dl class="function"> <dt id="curses.mouseinterval"> <tt class="descclassname">curses.</tt><tt class="descname">mouseinterval</tt><big>(</big><em>interval</em><big>)</big><a class="headerlink" href="#curses.mouseinterval" title="Permalink to this definition">¶</a></dt> <dd><p>Set the maximum time in milliseconds that can elapse between press and release events in order for them to be recognized as a click, and return the previous interval value. The default value is 200 msec, or one fifth of a second.</p> </dd></dl> <dl class="function"> <dt id="curses.mousemask"> <tt class="descclassname">curses.</tt><tt class="descname">mousemask</tt><big>(</big><em>mousemask</em><big>)</big><a class="headerlink" href="#curses.mousemask" title="Permalink to this definition">¶</a></dt> <dd><p>Set the mouse events to be reported, and return a tuple <tt class="docutils literal"><span class="pre">(availmask,</span> <span class="pre">oldmask)</span></tt>. <em>availmask</em> indicates which of the specified mouse events can be reported; on complete failure it returns 0. <em>oldmask</em> is the previous value of the given window’s mouse event mask. If this function is never called, no mouse events are ever reported.</p> </dd></dl> <dl class="function"> <dt id="curses.napms"> <tt class="descclassname">curses.</tt><tt class="descname">napms</tt><big>(</big><em>ms</em><big>)</big><a class="headerlink" href="#curses.napms" title="Permalink to this definition">¶</a></dt> <dd><p>Sleep for <em>ms</em> milliseconds.</p> </dd></dl> <dl class="function"> <dt id="curses.newpad"> <tt class="descclassname">curses.</tt><tt class="descname">newpad</tt><big>(</big><em>nlines</em>, <em>ncols</em><big>)</big><a class="headerlink" href="#curses.newpad" title="Permalink to this definition">¶</a></dt> <dd><p>Create and return a pointer to a new pad data structure with the given number of lines and columns. A pad is returned as a window object.</p> <p>A pad is like a window, except that it is not restricted by the screen size, and is not necessarily associated with a particular part of the screen. Pads can be used when a large window is needed, and only a part of the window will be on the screen at one time. Automatic refreshes of pads (such as from scrolling or echoing of input) do not occur. The <tt class="xref py py-meth docutils literal"><span class="pre">refresh()</span></tt> and <tt class="xref py py-meth docutils literal"><span class="pre">noutrefresh()</span></tt> methods of a pad require 6 arguments to specify the part of the pad to be displayed and the location on the screen to be used for the display. The arguments are <em>pminrow</em>, <em>pmincol</em>, <em>sminrow</em>, <em>smincol</em>, <em>smaxrow</em>, <em>smaxcol</em>; the <em>p</em> arguments refer to the upper left corner of the pad region to be displayed and the <em>s</em> arguments define a clipping box on the screen within which the pad region is to be displayed.</p> </dd></dl> <dl class="function"> <dt id="curses.newwin"> <tt class="descclassname">curses.</tt><tt class="descname">newwin</tt><big>(</big><em>begin_y</em>, <em>begin_x</em><big>)</big><a class="headerlink" href="#curses.newwin" title="Permalink to this definition">¶</a></dt> <dt> <tt class="descclassname">curses.</tt><tt class="descname">newwin</tt><big>(</big><em>nlines</em>, <em>ncols</em>, <em>begin_y</em>, <em>begin_x</em><big>)</big></dt> <dd><p>Return a new window, whose left-upper corner is at <tt class="docutils literal"><span class="pre">(begin_y,</span> <span class="pre">begin_x)</span></tt>, and whose height/width is <em>nlines</em>/<em>ncols</em>.</p> <p>By default, the window will extend from the specified position to the lower right corner of the screen.</p> </dd></dl> <dl class="function"> <dt id="curses.nl"> <tt class="descclassname">curses.</tt><tt class="descname">nl</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.nl" title="Permalink to this definition">¶</a></dt> <dd><p>Enter newline mode. This mode translates the return key into newline on input, and translates newline into return and line-feed on output. Newline mode is initially on.</p> </dd></dl> <dl class="function"> <dt id="curses.nocbreak"> <tt class="descclassname">curses.</tt><tt class="descname">nocbreak</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.nocbreak" title="Permalink to this definition">¶</a></dt> <dd><p>Leave cbreak mode. Return to normal “cooked” mode with line buffering.</p> </dd></dl> <dl class="function"> <dt id="curses.noecho"> <tt class="descclassname">curses.</tt><tt class="descname">noecho</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.noecho" title="Permalink to this definition">¶</a></dt> <dd><p>Leave echo mode. Echoing of input characters is turned off.</p> </dd></dl> <dl class="function"> <dt id="curses.nonl"> <tt class="descclassname">curses.</tt><tt class="descname">nonl</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.nonl" title="Permalink to this definition">¶</a></dt> <dd><p>Leave newline mode. Disable translation of return into newline on input, and disable low-level translation of newline into newline/return on output (but this does not change the behavior of <tt class="docutils literal"><span class="pre">addch('\n')</span></tt>, which always does the equivalent of return and line feed on the virtual screen). With translation off, curses can sometimes speed up vertical motion a little; also, it will be able to detect the return key on input.</p> </dd></dl> <dl class="function"> <dt id="curses.noqiflush"> <tt class="descclassname">curses.</tt><tt class="descname">noqiflush</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.noqiflush" title="Permalink to this definition">¶</a></dt> <dd><p>When the <a class="reference internal" href="#curses.noqiflush" title="curses.noqiflush"><tt class="xref py py-func docutils literal"><span class="pre">noqiflush()</span></tt></a> routine is used, normal flush of input and output queues associated with the INTR, QUIT and SUSP characters will not be done. You may want to call <a class="reference internal" href="#curses.noqiflush" title="curses.noqiflush"><tt class="xref py py-func docutils literal"><span class="pre">noqiflush()</span></tt></a> in a signal handler if you want output to continue as though the interrupt had not occurred, after the handler exits.</p> </dd></dl> <dl class="function"> <dt id="curses.noraw"> <tt class="descclassname">curses.</tt><tt class="descname">noraw</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.noraw" title="Permalink to this definition">¶</a></dt> <dd><p>Leave raw mode. Return to normal “cooked” mode with line buffering.</p> </dd></dl> <dl class="function"> <dt id="curses.pair_content"> <tt class="descclassname">curses.</tt><tt class="descname">pair_content</tt><big>(</big><em>pair_number</em><big>)</big><a class="headerlink" href="#curses.pair_content" title="Permalink to this definition">¶</a></dt> <dd><p>Return a tuple <tt class="docutils literal"><span class="pre">(fg,</span> <span class="pre">bg)</span></tt> containing the colors for the requested color pair. The value of <em>pair_number</em> must be between <tt class="docutils literal"><span class="pre">1</span></tt> and <tt class="docutils literal"><span class="pre">COLOR_PAIRS</span> <span class="pre">-</span> <span class="pre">1</span></tt>.</p> </dd></dl> <dl class="function"> <dt id="curses.pair_number"> <tt class="descclassname">curses.</tt><tt class="descname">pair_number</tt><big>(</big><em>attr</em><big>)</big><a class="headerlink" href="#curses.pair_number" title="Permalink to this definition">¶</a></dt> <dd><p>Return the number of the color-pair set by the attribute value <em>attr</em>. <a class="reference internal" href="#curses.color_pair" title="curses.color_pair"><tt class="xref py py-func docutils literal"><span class="pre">color_pair()</span></tt></a> is the counterpart to this function.</p> </dd></dl> <dl class="function"> <dt id="curses.putp"> <tt class="descclassname">curses.</tt><tt class="descname">putp</tt><big>(</big><em>string</em><big>)</big><a class="headerlink" href="#curses.putp" title="Permalink to this definition">¶</a></dt> <dd><p>Equivalent to <tt class="docutils literal"><span class="pre">tputs(str,</span> <span class="pre">1,</span> <span class="pre">putchar)</span></tt>; emit the value of a specified terminfo capability for the current terminal. Note that the output of <a class="reference internal" href="#curses.putp" title="curses.putp"><tt class="xref py py-func docutils literal"><span class="pre">putp()</span></tt></a> always goes to standard output.</p> </dd></dl> <dl class="function"> <dt id="curses.qiflush"> <tt class="descclassname">curses.</tt><tt class="descname">qiflush</tt><big>(</big><span class="optional">[</span><em>flag</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.qiflush" title="Permalink to this definition">¶</a></dt> <dd><p>If <em>flag</em> is <tt class="docutils literal"><span class="pre">False</span></tt>, the effect is the same as calling <a class="reference internal" href="#curses.noqiflush" title="curses.noqiflush"><tt class="xref py py-func docutils literal"><span class="pre">noqiflush()</span></tt></a>. If <em>flag</em> is <tt class="docutils literal"><span class="pre">True</span></tt>, or no argument is provided, the queues will be flushed when these control characters are read.</p> </dd></dl> <dl class="function"> <dt id="curses.raw"> <tt class="descclassname">curses.</tt><tt class="descname">raw</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.raw" title="Permalink to this definition">¶</a></dt> <dd><p>Enter raw mode. In raw mode, normal line buffering and processing of interrupt, quit, suspend, and flow control keys are turned off; characters are presented to curses input functions one by one.</p> </dd></dl> <dl class="function"> <dt id="curses.reset_prog_mode"> <tt class="descclassname">curses.</tt><tt class="descname">reset_prog_mode</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.reset_prog_mode" title="Permalink to this definition">¶</a></dt> <dd><p>Restore the terminal to “program” mode, as previously saved by <a class="reference internal" href="#curses.def_prog_mode" title="curses.def_prog_mode"><tt class="xref py py-func docutils literal"><span class="pre">def_prog_mode()</span></tt></a>.</p> </dd></dl> <dl class="function"> <dt id="curses.reset_shell_mode"> <tt class="descclassname">curses.</tt><tt class="descname">reset_shell_mode</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.reset_shell_mode" title="Permalink to this definition">¶</a></dt> <dd><p>Restore the terminal to “shell” mode, as previously saved by <a class="reference internal" href="#curses.def_shell_mode" title="curses.def_shell_mode"><tt class="xref py py-func docutils literal"><span class="pre">def_shell_mode()</span></tt></a>.</p> </dd></dl> <dl class="function"> <dt id="curses.resetty"> <tt class="descclassname">curses.</tt><tt class="descname">resetty</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.resetty" title="Permalink to this definition">¶</a></dt> <dd><p>Restore the state of the terminal modes to what it was at the last call to <a class="reference internal" href="#curses.savetty" title="curses.savetty"><tt class="xref py py-func docutils literal"><span class="pre">savetty()</span></tt></a>.</p> </dd></dl> <dl class="function"> <dt id="curses.resize_term"> <tt class="descclassname">curses.</tt><tt class="descname">resize_term</tt><big>(</big><em>nlines</em>, <em>ncols</em><big>)</big><a class="headerlink" href="#curses.resize_term" title="Permalink to this definition">¶</a></dt> <dd><p>Backend function used by <a class="reference internal" href="#curses.resizeterm" title="curses.resizeterm"><tt class="xref py py-func docutils literal"><span class="pre">resizeterm()</span></tt></a>, performing most of the work; when resizing the windows, <a class="reference internal" href="#curses.resize_term" title="curses.resize_term"><tt class="xref py py-func docutils literal"><span class="pre">resize_term()</span></tt></a> blank-fills the areas that are extended. The calling application should fill in these areas with appropriate data. The <a class="reference internal" href="#curses.resize_term" title="curses.resize_term"><tt class="xref py py-func docutils literal"><span class="pre">resize_term()</span></tt></a> function attempts to resize all windows. However, due to the calling convention of pads, it is not possible to resize these without additional interaction with the application.</p> </dd></dl> <dl class="function"> <dt id="curses.resizeterm"> <tt class="descclassname">curses.</tt><tt class="descname">resizeterm</tt><big>(</big><em>nlines</em>, <em>ncols</em><big>)</big><a class="headerlink" href="#curses.resizeterm" title="Permalink to this definition">¶</a></dt> <dd><p>Resize the standard and current windows to the specified dimensions, and adjusts other bookkeeping data used by the curses library that record the window dimensions (in particular the SIGWINCH handler).</p> </dd></dl> <dl class="function"> <dt id="curses.savetty"> <tt class="descclassname">curses.</tt><tt class="descname">savetty</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.savetty" title="Permalink to this definition">¶</a></dt> <dd><p>Save the current state of the terminal modes in a buffer, usable by <a class="reference internal" href="#curses.resetty" title="curses.resetty"><tt class="xref py py-func docutils literal"><span class="pre">resetty()</span></tt></a>.</p> </dd></dl> <dl class="function"> <dt id="curses.setsyx"> <tt class="descclassname">curses.</tt><tt class="descname">setsyx</tt><big>(</big><em>y</em>, <em>x</em><big>)</big><a class="headerlink" href="#curses.setsyx" title="Permalink to this definition">¶</a></dt> <dd><p>Set the virtual screen cursor to <em>y</em>, <em>x</em>. If <em>y</em> and <em>x</em> are both -1, then leaveok is set.</p> </dd></dl> <dl class="function"> <dt id="curses.setupterm"> <tt class="descclassname">curses.</tt><tt class="descname">setupterm</tt><big>(</big><span class="optional">[</span><em>termstr</em>, <em>fd</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.setupterm" title="Permalink to this definition">¶</a></dt> <dd><p>Initialize the terminal. <em>termstr</em> is a string giving the terminal name; if omitted, the value of the <span class="target" id="index-1"></span><tt class="xref std std-envvar docutils literal"><span class="pre">TERM</span></tt> environment variable will be used. <em>fd</em> is the file descriptor to which any initialization sequences will be sent; if not supplied, the file descriptor for <tt class="docutils literal"><span class="pre">sys.stdout</span></tt> will be used.</p> </dd></dl> <dl class="function"> <dt id="curses.start_color"> <tt class="descclassname">curses.</tt><tt class="descname">start_color</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.start_color" title="Permalink to this definition">¶</a></dt> <dd><p>Must be called if the programmer wants to use colors, and before any other color manipulation routine is called. It is good practice to call this routine right after <a class="reference internal" href="#curses.initscr" title="curses.initscr"><tt class="xref py py-func docutils literal"><span class="pre">initscr()</span></tt></a>.</p> <p><a class="reference internal" href="#curses.start_color" title="curses.start_color"><tt class="xref py py-func docutils literal"><span class="pre">start_color()</span></tt></a> initializes eight basic colors (black, red, green, yellow, blue, magenta, cyan, and white), and two global variables in the <a class="reference internal" href="#module-curses" title="curses: An interface to the curses library, providing portable terminal handling. (Unix)"><tt class="xref py py-mod docutils literal"><span class="pre">curses</span></tt></a> module, <tt class="xref py py-const docutils literal"><span class="pre">COLORS</span></tt> and <tt class="xref py py-const docutils literal"><span class="pre">COLOR_PAIRS</span></tt>, containing the maximum number of colors and color-pairs the terminal can support. It also restores the colors on the terminal to the values they had when the terminal was just turned on.</p> </dd></dl> <dl class="function"> <dt id="curses.termattrs"> <tt class="descclassname">curses.</tt><tt class="descname">termattrs</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.termattrs" title="Permalink to this definition">¶</a></dt> <dd><p>Return a logical OR of all video attributes supported by the terminal. This information is useful when a curses program needs complete control over the appearance of the screen.</p> </dd></dl> <dl class="function"> <dt id="curses.termname"> <tt class="descclassname">curses.</tt><tt class="descname">termname</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.termname" title="Permalink to this definition">¶</a></dt> <dd><p>Return the value of the environment variable <span class="target" id="index-2"></span><tt class="xref std std-envvar docutils literal"><span class="pre">TERM</span></tt>, truncated to 14 characters.</p> </dd></dl> <dl class="function"> <dt id="curses.tigetflag"> <tt class="descclassname">curses.</tt><tt class="descname">tigetflag</tt><big>(</big><em>capname</em><big>)</big><a class="headerlink" href="#curses.tigetflag" title="Permalink to this definition">¶</a></dt> <dd><p>Return the value of the Boolean capability corresponding to the terminfo capability name <em>capname</em>. The value <tt class="docutils literal"><span class="pre">-1</span></tt> is returned if <em>capname</em> is not a Boolean capability, or <tt class="docutils literal"><span class="pre">0</span></tt> if it is canceled or absent from the terminal description.</p> </dd></dl> <dl class="function"> <dt id="curses.tigetnum"> <tt class="descclassname">curses.</tt><tt class="descname">tigetnum</tt><big>(</big><em>capname</em><big>)</big><a class="headerlink" href="#curses.tigetnum" title="Permalink to this definition">¶</a></dt> <dd><p>Return the value of the numeric capability corresponding to the terminfo capability name <em>capname</em>. The value <tt class="docutils literal"><span class="pre">-2</span></tt> is returned if <em>capname</em> is not a numeric capability, or <tt class="docutils literal"><span class="pre">-1</span></tt> if it is canceled or absent from the terminal description.</p> </dd></dl> <dl class="function"> <dt id="curses.tigetstr"> <tt class="descclassname">curses.</tt><tt class="descname">tigetstr</tt><big>(</big><em>capname</em><big>)</big><a class="headerlink" href="#curses.tigetstr" title="Permalink to this definition">¶</a></dt> <dd><p>Return the value of the string capability corresponding to the terminfo capability name <em>capname</em>. <tt class="docutils literal"><span class="pre">None</span></tt> is returned if <em>capname</em> is not a string capability, or is canceled or absent from the terminal description.</p> </dd></dl> <dl class="function"> <dt id="curses.tparm"> <tt class="descclassname">curses.</tt><tt class="descname">tparm</tt><big>(</big><em>str</em><span class="optional">[</span>, <em>...</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.tparm" title="Permalink to this definition">¶</a></dt> <dd><p>Instantiate the string <em>str</em> with the supplied parameters, where <em>str</em> should be a parameterized string obtained from the terminfo database. E.g. <tt class="docutils literal"><span class="pre">tparm(tigetstr("cup"),</span> <span class="pre">5,</span> <span class="pre">3)</span></tt> could result in <tt class="docutils literal"><span class="pre">'\033[6;4H'</span></tt>, the exact result depending on terminal type.</p> </dd></dl> <dl class="function"> <dt id="curses.typeahead"> <tt class="descclassname">curses.</tt><tt class="descname">typeahead</tt><big>(</big><em>fd</em><big>)</big><a class="headerlink" href="#curses.typeahead" title="Permalink to this definition">¶</a></dt> <dd><p>Specify that the file descriptor <em>fd</em> be used for typeahead checking. If <em>fd</em> is <tt class="docutils literal"><span class="pre">-1</span></tt>, then no typeahead checking is done.</p> <p>The curses library does “line-breakout optimization” by looking for typeahead periodically while updating the screen. If input is found, and it is coming from a tty, the current update is postponed until refresh or doupdate is called again, allowing faster response to commands typed in advance. This function allows specifying a different file descriptor for typeahead checking.</p> </dd></dl> <dl class="function"> <dt id="curses.unctrl"> <tt class="descclassname">curses.</tt><tt class="descname">unctrl</tt><big>(</big><em>ch</em><big>)</big><a class="headerlink" href="#curses.unctrl" title="Permalink to this definition">¶</a></dt> <dd><p>Return a string which is a printable representation of the character <em>ch</em>. Control characters are displayed as a caret followed by the character, for example as <tt class="docutils literal"><span class="pre">^C</span></tt>. Printing characters are left as they are.</p> </dd></dl> <dl class="function"> <dt id="curses.ungetch"> <tt class="descclassname">curses.</tt><tt class="descname">ungetch</tt><big>(</big><em>ch</em><big>)</big><a class="headerlink" href="#curses.ungetch" title="Permalink to this definition">¶</a></dt> <dd><p>Push <em>ch</em> so the next <tt class="xref py py-meth docutils literal"><span class="pre">getch()</span></tt> will return it.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">Only one <em>ch</em> can be pushed before <tt class="xref py py-meth docutils literal"><span class="pre">getch()</span></tt> is called.</p> </div> </dd></dl> <dl class="function"> <dt id="curses.ungetmouse"> <tt class="descclassname">curses.</tt><tt class="descname">ungetmouse</tt><big>(</big><em>id</em>, <em>x</em>, <em>y</em>, <em>z</em>, <em>bstate</em><big>)</big><a class="headerlink" href="#curses.ungetmouse" title="Permalink to this definition">¶</a></dt> <dd><p>Push a <tt class="xref py py-const docutils literal"><span class="pre">KEY_MOUSE</span></tt> event onto the input queue, associating the given state data with it.</p> </dd></dl> <dl class="function"> <dt id="curses.use_env"> <tt class="descclassname">curses.</tt><tt class="descname">use_env</tt><big>(</big><em>flag</em><big>)</big><a class="headerlink" href="#curses.use_env" title="Permalink to this definition">¶</a></dt> <dd><p>If used, this function should be called before <a class="reference internal" href="#curses.initscr" title="curses.initscr"><tt class="xref py py-func docutils literal"><span class="pre">initscr()</span></tt></a> or newterm are called. When <em>flag</em> is <tt class="docutils literal"><span class="pre">False</span></tt>, the values of lines and columns specified in the terminfo database will be used, even if environment variables <span class="target" id="index-3"></span><tt class="xref std std-envvar docutils literal"><span class="pre">LINES</span></tt> and <span class="target" id="index-4"></span><tt class="xref std std-envvar docutils literal"><span class="pre">COLUMNS</span></tt> (used by default) are set, or if curses is running in a window (in which case default behavior would be to use the window size if <span class="target" id="index-5"></span><tt class="xref std std-envvar docutils literal"><span class="pre">LINES</span></tt> and <span class="target" id="index-6"></span><tt class="xref std std-envvar docutils literal"><span class="pre">COLUMNS</span></tt> are not set).</p> </dd></dl> <dl class="function"> <dt id="curses.use_default_colors"> <tt class="descclassname">curses.</tt><tt class="descname">use_default_colors</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.use_default_colors" title="Permalink to this definition">¶</a></dt> <dd><p>Allow use of default values for colors on terminals supporting this feature. Use this to support transparency in your application. The default color is assigned to the color number -1. After calling this function, <tt class="docutils literal"><span class="pre">init_pair(x,</span> <span class="pre">curses.COLOR_RED,</span> <span class="pre">-1)</span></tt> initializes, for instance, color pair <em>x</em> to a red foreground color on the default background.</p> </dd></dl> <dl class="function"> <dt id="curses.wrapper"> <tt class="descclassname">curses.</tt><tt class="descname">wrapper</tt><big>(</big><em>func</em>, <em>...</em><big>)</big><a class="headerlink" href="#curses.wrapper" title="Permalink to this definition">¶</a></dt> <dd><p>Initialize curses and call another callable object, <em>func</em>, which should be the rest of your curses-using application. If the application raises an exception, this function will restore the terminal to a sane state before re-raising the exception and generating a traceback. The callable object <em>func</em> is then passed the main window ‘stdscr’ as its first argument, followed by any other arguments passed to <a class="reference internal" href="#curses.wrapper" title="curses.wrapper"><tt class="xref py py-func docutils literal"><span class="pre">wrapper()</span></tt></a>. Before calling <em>func</em>, <a class="reference internal" href="#curses.wrapper" title="curses.wrapper"><tt class="xref py py-func docutils literal"><span class="pre">wrapper()</span></tt></a> turns on cbreak mode, turns off echo, enables the terminal keypad, and initializes colors if the terminal has color support. On exit (whether normally or by exception) it restores cooked mode, turns on echo, and disables the terminal keypad.</p> </dd></dl> </div> <div class="section" id="window-objects"> <span id="curses-window-objects"></span><h2>15.11.2. Window Objects<a class="headerlink" href="#window-objects" title="Permalink to this headline">¶</a></h2> <p>Window objects, as returned by <a class="reference internal" href="#curses.initscr" title="curses.initscr"><tt class="xref py py-func docutils literal"><span class="pre">initscr()</span></tt></a> and <a class="reference internal" href="#curses.newwin" title="curses.newwin"><tt class="xref py py-func docutils literal"><span class="pre">newwin()</span></tt></a> above, have the following methods:</p> <dl class="method"> <dt id="curses.window.addch"> <tt class="descclassname">window.</tt><tt class="descname">addch</tt><big>(</big><em>ch</em><span class="optional">[</span>, <em>attr</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.addch" title="Permalink to this definition">¶</a></dt> <dt> <tt class="descclassname">window.</tt><tt class="descname">addch</tt><big>(</big><em>y</em>, <em>x</em>, <em>ch</em><span class="optional">[</span>, <em>attr</em><span class="optional">]</span><big>)</big></dt> <dd><div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">A <em>character</em> means a C character (an ASCII code), rather than a Python character (a string of length 1). (This note is true whenever the documentation mentions a character.) The built-in <a class="reference internal" href="functions.html#ord" title="ord"><tt class="xref py py-func docutils literal"><span class="pre">ord()</span></tt></a> is handy for conveying strings to codes.</p> </div> <p>Paint character <em>ch</em> at <tt class="docutils literal"><span class="pre">(y,</span> <span class="pre">x)</span></tt> with attributes <em>attr</em>, overwriting any character previously painter at that location. By default, the character position and attributes are the current settings for the window object.</p> </dd></dl> <dl class="method"> <dt id="curses.window.addnstr"> <tt class="descclassname">window.</tt><tt class="descname">addnstr</tt><big>(</big><em>str</em>, <em>n</em><span class="optional">[</span>, <em>attr</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.addnstr" title="Permalink to this definition">¶</a></dt> <dt> <tt class="descclassname">window.</tt><tt class="descname">addnstr</tt><big>(</big><em>y</em>, <em>x</em>, <em>str</em>, <em>n</em><span class="optional">[</span>, <em>attr</em><span class="optional">]</span><big>)</big></dt> <dd><p>Paint at most <em>n</em> characters of the string <em>str</em> at <tt class="docutils literal"><span class="pre">(y,</span> <span class="pre">x)</span></tt> with attributes <em>attr</em>, overwriting anything previously on the display.</p> </dd></dl> <dl class="method"> <dt id="curses.window.addstr"> <tt class="descclassname">window.</tt><tt class="descname">addstr</tt><big>(</big><em>str</em><span class="optional">[</span>, <em>attr</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.addstr" title="Permalink to this definition">¶</a></dt> <dt> <tt class="descclassname">window.</tt><tt class="descname">addstr</tt><big>(</big><em>y</em>, <em>x</em>, <em>str</em><span class="optional">[</span>, <em>attr</em><span class="optional">]</span><big>)</big></dt> <dd><p>Paint the string <em>str</em> at <tt class="docutils literal"><span class="pre">(y,</span> <span class="pre">x)</span></tt> with attributes <em>attr</em>, overwriting anything previously on the display.</p> </dd></dl> <dl class="method"> <dt id="curses.window.attroff"> <tt class="descclassname">window.</tt><tt class="descname">attroff</tt><big>(</big><em>attr</em><big>)</big><a class="headerlink" href="#curses.window.attroff" title="Permalink to this definition">¶</a></dt> <dd><p>Remove attribute <em>attr</em> from the “background” set applied to all writes to the current window.</p> </dd></dl> <dl class="method"> <dt id="curses.window.attron"> <tt class="descclassname">window.</tt><tt class="descname">attron</tt><big>(</big><em>attr</em><big>)</big><a class="headerlink" href="#curses.window.attron" title="Permalink to this definition">¶</a></dt> <dd><p>Add attribute <em>attr</em> from the “background” set applied to all writes to the current window.</p> </dd></dl> <dl class="method"> <dt id="curses.window.attrset"> <tt class="descclassname">window.</tt><tt class="descname">attrset</tt><big>(</big><em>attr</em><big>)</big><a class="headerlink" href="#curses.window.attrset" title="Permalink to this definition">¶</a></dt> <dd><p>Set the “background” set of attributes to <em>attr</em>. This set is initially 0 (no attributes).</p> </dd></dl> <dl class="method"> <dt id="curses.window.bkgd"> <tt class="descclassname">window.</tt><tt class="descname">bkgd</tt><big>(</big><em>ch</em><span class="optional">[</span>, <em>attr</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.bkgd" title="Permalink to this definition">¶</a></dt> <dd><p>Set the background property of the window to the character <em>ch</em>, with attributes <em>attr</em>. The change is then applied to every character position in that window:</p> <ul class="simple"> <li>The attribute of every character in the window is changed to the new background attribute.</li> <li>Wherever the former background character appears, it is changed to the new background character.</li> </ul> </dd></dl> <dl class="method"> <dt id="curses.window.bkgdset"> <tt class="descclassname">window.</tt><tt class="descname">bkgdset</tt><big>(</big><em>ch</em><span class="optional">[</span>, <em>attr</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.bkgdset" title="Permalink to this definition">¶</a></dt> <dd><p>Set the window’s background. A window’s background consists of a character and any combination of attributes. The attribute part of the background is combined (OR’ed) with all non-blank characters that are written into the window. Both the character and attribute parts of the background are combined with the blank characters. The background becomes a property of the character and moves with the character through any scrolling and insert/delete line/character operations.</p> </dd></dl> <dl class="method"> <dt id="curses.window.border"> <tt class="descclassname">window.</tt><tt class="descname">border</tt><big>(</big><span class="optional">[</span><em>ls</em><span class="optional">[</span>, <em>rs</em><span class="optional">[</span>, <em>ts</em><span class="optional">[</span>, <em>bs</em><span class="optional">[</span>, <em>tl</em><span class="optional">[</span>, <em>tr</em><span class="optional">[</span>, <em>bl</em><span class="optional">[</span>, <em>br</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.border" title="Permalink to this definition">¶</a></dt> <dd><p>Draw a border around the edges of the window. Each parameter specifies the character to use for a specific part of the border; see the table below for more details. The characters can be specified as integers or as one-character strings.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">A <tt class="docutils literal"><span class="pre">0</span></tt> value for any parameter will cause the default character to be used for that parameter. Keyword parameters can <em>not</em> be used. The defaults are listed in this table:</p> </div> <table border="1" class="docutils"> <colgroup> <col width="20%" /> <col width="38%" /> <col width="42%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Parameter</th> <th class="head">Description</th> <th class="head">Default value</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><em>ls</em></td> <td>Left side</td> <td><tt class="xref py py-const docutils literal"><span class="pre">ACS_VLINE</span></tt></td> </tr> <tr class="row-odd"><td><em>rs</em></td> <td>Right side</td> <td><tt class="xref py py-const docutils literal"><span class="pre">ACS_VLINE</span></tt></td> </tr> <tr class="row-even"><td><em>ts</em></td> <td>Top</td> <td><tt class="xref py py-const docutils literal"><span class="pre">ACS_HLINE</span></tt></td> </tr> <tr class="row-odd"><td><em>bs</em></td> <td>Bottom</td> <td><tt class="xref py py-const docutils literal"><span class="pre">ACS_HLINE</span></tt></td> </tr> <tr class="row-even"><td><em>tl</em></td> <td>Upper-left corner</td> <td><tt class="xref py py-const docutils literal"><span class="pre">ACS_ULCORNER</span></tt></td> </tr> <tr class="row-odd"><td><em>tr</em></td> <td>Upper-right corner</td> <td><tt class="xref py py-const docutils literal"><span class="pre">ACS_URCORNER</span></tt></td> </tr> <tr class="row-even"><td><em>bl</em></td> <td>Bottom-left corner</td> <td><tt class="xref py py-const docutils literal"><span class="pre">ACS_LLCORNER</span></tt></td> </tr> <tr class="row-odd"><td><em>br</em></td> <td>Bottom-right corner</td> <td><tt class="xref py py-const docutils literal"><span class="pre">ACS_LRCORNER</span></tt></td> </tr> </tbody> </table> </dd></dl> <dl class="method"> <dt id="curses.window.box"> <tt class="descclassname">window.</tt><tt class="descname">box</tt><big>(</big><span class="optional">[</span><em>vertch</em>, <em>horch</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.box" title="Permalink to this definition">¶</a></dt> <dd><p>Similar to <a class="reference internal" href="#curses.window.border" title="curses.window.border"><tt class="xref py py-meth docutils literal"><span class="pre">border()</span></tt></a>, but both <em>ls</em> and <em>rs</em> are <em>vertch</em> and both <em>ts</em> and <em>bs</em> are <em>horch</em>. The default corner characters are always used by this function.</p> </dd></dl> <dl class="method"> <dt id="curses.window.chgat"> <tt class="descclassname">window.</tt><tt class="descname">chgat</tt><big>(</big><em>attr</em><big>)</big><a class="headerlink" href="#curses.window.chgat" title="Permalink to this definition">¶</a></dt> <dt> <tt class="descclassname">window.</tt><tt class="descname">chgat</tt><big>(</big><em>num</em>, <em>attr</em><big>)</big></dt> <dt> <tt class="descclassname">window.</tt><tt class="descname">chgat</tt><big>(</big><em>y</em>, <em>x</em>, <em>attr</em><big>)</big></dt> <dt> <tt class="descclassname">window.</tt><tt class="descname">chgat</tt><big>(</big><em>y</em>, <em>x</em>, <em>num</em>, <em>attr</em><big>)</big></dt> <dd><p>Set the attributes of <em>num</em> characters at the current cursor position, or at position <tt class="docutils literal"><span class="pre">(y,</span> <span class="pre">x)</span></tt> if supplied. If no value of <em>num</em> is given or <em>num</em> = -1, the attribute will be set on all the characters to the end of the line. This function does not move the cursor. The changed line will be touched using the <a class="reference internal" href="#curses.window.touchline" title="curses.window.touchline"><tt class="xref py py-meth docutils literal"><span class="pre">touchline()</span></tt></a> method so that the contents will be redisplayed by the next window refresh.</p> </dd></dl> <dl class="method"> <dt id="curses.window.clear"> <tt class="descclassname">window.</tt><tt class="descname">clear</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.clear" title="Permalink to this definition">¶</a></dt> <dd><p>Like <a class="reference internal" href="#curses.window.erase" title="curses.window.erase"><tt class="xref py py-meth docutils literal"><span class="pre">erase()</span></tt></a>, but also cause the whole window to be repainted upon next call to <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><tt class="xref py py-meth docutils literal"><span class="pre">refresh()</span></tt></a>.</p> </dd></dl> <dl class="method"> <dt id="curses.window.clearok"> <tt class="descclassname">window.</tt><tt class="descname">clearok</tt><big>(</big><em>yes</em><big>)</big><a class="headerlink" href="#curses.window.clearok" title="Permalink to this definition">¶</a></dt> <dd><p>If <em>yes</em> is 1, the next call to <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><tt class="xref py py-meth docutils literal"><span class="pre">refresh()</span></tt></a> will clear the window completely.</p> </dd></dl> <dl class="method"> <dt id="curses.window.clrtobot"> <tt class="descclassname">window.</tt><tt class="descname">clrtobot</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.clrtobot" title="Permalink to this definition">¶</a></dt> <dd><p>Erase from cursor to the end of the window: all lines below the cursor are deleted, and then the equivalent of <a class="reference internal" href="#curses.window.clrtoeol" title="curses.window.clrtoeol"><tt class="xref py py-meth docutils literal"><span class="pre">clrtoeol()</span></tt></a> is performed.</p> </dd></dl> <dl class="method"> <dt id="curses.window.clrtoeol"> <tt class="descclassname">window.</tt><tt class="descname">clrtoeol</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.clrtoeol" title="Permalink to this definition">¶</a></dt> <dd><p>Erase from cursor to the end of the line.</p> </dd></dl> <dl class="method"> <dt id="curses.window.cursyncup"> <tt class="descclassname">window.</tt><tt class="descname">cursyncup</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.cursyncup" title="Permalink to this definition">¶</a></dt> <dd><p>Update the current cursor position of all the ancestors of the window to reflect the current cursor position of the window.</p> </dd></dl> <dl class="method"> <dt id="curses.window.delch"> <tt class="descclassname">window.</tt><tt class="descname">delch</tt><big>(</big><span class="optional">[</span><em>y</em>, <em>x</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.delch" title="Permalink to this definition">¶</a></dt> <dd><p>Delete any character at <tt class="docutils literal"><span class="pre">(y,</span> <span class="pre">x)</span></tt>.</p> </dd></dl> <dl class="method"> <dt id="curses.window.deleteln"> <tt class="descclassname">window.</tt><tt class="descname">deleteln</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.deleteln" title="Permalink to this definition">¶</a></dt> <dd><p>Delete the line under the cursor. All following lines are moved up by one line.</p> </dd></dl> <dl class="method"> <dt id="curses.window.derwin"> <tt class="descclassname">window.</tt><tt class="descname">derwin</tt><big>(</big><em>begin_y</em>, <em>begin_x</em><big>)</big><a class="headerlink" href="#curses.window.derwin" title="Permalink to this definition">¶</a></dt> <dt> <tt class="descclassname">window.</tt><tt class="descname">derwin</tt><big>(</big><em>nlines</em>, <em>ncols</em>, <em>begin_y</em>, <em>begin_x</em><big>)</big></dt> <dd><p>An abbreviation for “derive window”, <a class="reference internal" href="#curses.window.derwin" title="curses.window.derwin"><tt class="xref py py-meth docutils literal"><span class="pre">derwin()</span></tt></a> is the same as calling <a class="reference internal" href="#curses.window.subwin" title="curses.window.subwin"><tt class="xref py py-meth docutils literal"><span class="pre">subwin()</span></tt></a>, except that <em>begin_y</em> and <em>begin_x</em> are relative to the origin of the window, rather than relative to the entire screen. Return a window object for the derived window.</p> </dd></dl> <dl class="method"> <dt id="curses.window.echochar"> <tt class="descclassname">window.</tt><tt class="descname">echochar</tt><big>(</big><em>ch</em><span class="optional">[</span>, <em>attr</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.echochar" title="Permalink to this definition">¶</a></dt> <dd><p>Add character <em>ch</em> with attribute <em>attr</em>, and immediately call <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><tt class="xref py py-meth docutils literal"><span class="pre">refresh()</span></tt></a> on the window.</p> </dd></dl> <dl class="method"> <dt id="curses.window.enclose"> <tt class="descclassname">window.</tt><tt class="descname">enclose</tt><big>(</big><em>y</em>, <em>x</em><big>)</big><a class="headerlink" href="#curses.window.enclose" title="Permalink to this definition">¶</a></dt> <dd><p>Test whether the given pair of screen-relative character-cell coordinates are enclosed by the given window, returning <tt class="docutils literal"><span class="pre">True</span></tt> or <tt class="docutils literal"><span class="pre">False</span></tt>. It is useful for determining what subset of the screen windows enclose the location of a mouse event.</p> </dd></dl> <dl class="method"> <dt id="curses.window.erase"> <tt class="descclassname">window.</tt><tt class="descname">erase</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.erase" title="Permalink to this definition">¶</a></dt> <dd><p>Clear the window.</p> </dd></dl> <dl class="method"> <dt id="curses.window.getbegyx"> <tt class="descclassname">window.</tt><tt class="descname">getbegyx</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.getbegyx" title="Permalink to this definition">¶</a></dt> <dd><p>Return a tuple <tt class="docutils literal"><span class="pre">(y,</span> <span class="pre">x)</span></tt> of co-ordinates of upper-left corner.</p> </dd></dl> <dl class="method"> <dt id="curses.window.getbkgd"> <tt class="descclassname">window.</tt><tt class="descname">getbkgd</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.getbkgd" title="Permalink to this definition">¶</a></dt> <dd><p>Return the given window’s current background character/attribute pair.</p> </dd></dl> <dl class="method"> <dt id="curses.window.getch"> <tt class="descclassname">window.</tt><tt class="descname">getch</tt><big>(</big><span class="optional">[</span><em>y</em>, <em>x</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.getch" title="Permalink to this definition">¶</a></dt> <dd><p>Get a character. Note that the integer returned does <em>not</em> have to be in ASCII range: function keys, keypad keys and so on return numbers higher than 256. In no-delay mode, -1 is returned if there is no input, else <a class="reference internal" href="#curses.window.getch" title="curses.window.getch"><tt class="xref py py-func docutils literal"><span class="pre">getch()</span></tt></a> waits until a key is pressed.</p> </dd></dl> <dl class="method"> <dt id="curses.window.getkey"> <tt class="descclassname">window.</tt><tt class="descname">getkey</tt><big>(</big><span class="optional">[</span><em>y</em>, <em>x</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.getkey" title="Permalink to this definition">¶</a></dt> <dd><p>Get a character, returning a string instead of an integer, as <a class="reference internal" href="#curses.window.getch" title="curses.window.getch"><tt class="xref py py-meth docutils literal"><span class="pre">getch()</span></tt></a> does. Function keys, keypad keys and so on return a multibyte string containing the key name. In no-delay mode, an exception is raised if there is no input.</p> </dd></dl> <dl class="method"> <dt id="curses.window.getmaxyx"> <tt class="descclassname">window.</tt><tt class="descname">getmaxyx</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.getmaxyx" title="Permalink to this definition">¶</a></dt> <dd><p>Return a tuple <tt class="docutils literal"><span class="pre">(y,</span> <span class="pre">x)</span></tt> of the height and width of the window.</p> </dd></dl> <dl class="method"> <dt id="curses.window.getparyx"> <tt class="descclassname">window.</tt><tt class="descname">getparyx</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.getparyx" title="Permalink to this definition">¶</a></dt> <dd><p>Return the beginning coordinates of this window relative to its parent window into two integer variables y and x. Return <tt class="docutils literal"><span class="pre">-1,</span> <span class="pre">-1</span></tt> if this window has no parent.</p> </dd></dl> <dl class="method"> <dt id="curses.window.getstr"> <tt class="descclassname">window.</tt><tt class="descname">getstr</tt><big>(</big><span class="optional">[</span><em>y</em>, <em>x</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.getstr" title="Permalink to this definition">¶</a></dt> <dd><p>Read a string from the user, with primitive line editing capacity.</p> </dd></dl> <dl class="method"> <dt id="curses.window.getyx"> <tt class="descclassname">window.</tt><tt class="descname">getyx</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.getyx" title="Permalink to this definition">¶</a></dt> <dd><p>Return a tuple <tt class="docutils literal"><span class="pre">(y,</span> <span class="pre">x)</span></tt> of current cursor position relative to the window’s upper-left corner.</p> </dd></dl> <dl class="method"> <dt id="curses.window.hline"> <tt class="descclassname">window.</tt><tt class="descname">hline</tt><big>(</big><em>ch</em>, <em>n</em><big>)</big><a class="headerlink" href="#curses.window.hline" title="Permalink to this definition">¶</a></dt> <dt> <tt class="descclassname">window.</tt><tt class="descname">hline</tt><big>(</big><em>y</em>, <em>x</em>, <em>ch</em>, <em>n</em><big>)</big></dt> <dd><p>Display a horizontal line starting at <tt class="docutils literal"><span class="pre">(y,</span> <span class="pre">x)</span></tt> with length <em>n</em> consisting of the character <em>ch</em>.</p> </dd></dl> <dl class="method"> <dt id="curses.window.idcok"> <tt class="descclassname">window.</tt><tt class="descname">idcok</tt><big>(</big><em>flag</em><big>)</big><a class="headerlink" href="#curses.window.idcok" title="Permalink to this definition">¶</a></dt> <dd><p>If <em>flag</em> is <tt class="docutils literal"><span class="pre">False</span></tt>, curses no longer considers using the hardware insert/delete character feature of the terminal; if <em>flag</em> is <tt class="docutils literal"><span class="pre">True</span></tt>, use of character insertion and deletion is enabled. When curses is first initialized, use of character insert/delete is enabled by default.</p> </dd></dl> <dl class="method"> <dt id="curses.window.idlok"> <tt class="descclassname">window.</tt><tt class="descname">idlok</tt><big>(</big><em>yes</em><big>)</big><a class="headerlink" href="#curses.window.idlok" title="Permalink to this definition">¶</a></dt> <dd><p>If called with <em>yes</em> equal to 1, <a class="reference internal" href="#module-curses" title="curses: An interface to the curses library, providing portable terminal handling. (Unix)"><tt class="xref py py-mod docutils literal"><span class="pre">curses</span></tt></a> will try and use hardware line editing facilities. Otherwise, line insertion/deletion are disabled.</p> </dd></dl> <dl class="method"> <dt id="curses.window.immedok"> <tt class="descclassname">window.</tt><tt class="descname">immedok</tt><big>(</big><em>flag</em><big>)</big><a class="headerlink" href="#curses.window.immedok" title="Permalink to this definition">¶</a></dt> <dd><p>If <em>flag</em> is <tt class="docutils literal"><span class="pre">True</span></tt>, any change in the window image automatically causes the window to be refreshed; you no longer have to call <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><tt class="xref py py-meth docutils literal"><span class="pre">refresh()</span></tt></a> yourself. However, it may degrade performance considerably, due to repeated calls to wrefresh. This option is disabled by default.</p> </dd></dl> <dl class="method"> <dt id="curses.window.inch"> <tt class="descclassname">window.</tt><tt class="descname">inch</tt><big>(</big><span class="optional">[</span><em>y</em>, <em>x</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.inch" title="Permalink to this definition">¶</a></dt> <dd><p>Return the character at the given position in the window. The bottom 8 bits are the character proper, and upper bits are the attributes.</p> </dd></dl> <dl class="method"> <dt id="curses.window.insch"> <tt class="descclassname">window.</tt><tt class="descname">insch</tt><big>(</big><em>ch</em><span class="optional">[</span>, <em>attr</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.insch" title="Permalink to this definition">¶</a></dt> <dt> <tt class="descclassname">window.</tt><tt class="descname">insch</tt><big>(</big><em>y</em>, <em>x</em>, <em>ch</em><span class="optional">[</span>, <em>attr</em><span class="optional">]</span><big>)</big></dt> <dd><p>Paint character <em>ch</em> at <tt class="docutils literal"><span class="pre">(y,</span> <span class="pre">x)</span></tt> with attributes <em>attr</em>, moving the line from position <em>x</em> right by one character.</p> </dd></dl> <dl class="method"> <dt id="curses.window.insdelln"> <tt class="descclassname">window.</tt><tt class="descname">insdelln</tt><big>(</big><em>nlines</em><big>)</big><a class="headerlink" href="#curses.window.insdelln" title="Permalink to this definition">¶</a></dt> <dd><p>Insert <em>nlines</em> lines into the specified window above the current line. The <em>nlines</em> bottom lines are lost. For negative <em>nlines</em>, delete <em>nlines</em> lines starting with the one under the cursor, and move the remaining lines up. The bottom <em>nlines</em> lines are cleared. The current cursor position remains the same.</p> </dd></dl> <dl class="method"> <dt id="curses.window.insertln"> <tt class="descclassname">window.</tt><tt class="descname">insertln</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.insertln" title="Permalink to this definition">¶</a></dt> <dd><p>Insert a blank line under the cursor. All following lines are moved down by one line.</p> </dd></dl> <dl class="method"> <dt id="curses.window.insnstr"> <tt class="descclassname">window.</tt><tt class="descname">insnstr</tt><big>(</big><em>str</em>, <em>n</em><span class="optional">[</span>, <em>attr</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.insnstr" title="Permalink to this definition">¶</a></dt> <dt> <tt class="descclassname">window.</tt><tt class="descname">insnstr</tt><big>(</big><em>y</em>, <em>x</em>, <em>str</em>, <em>n</em><span class="optional">[</span>, <em>attr</em><span class="optional">]</span><big>)</big></dt> <dd><p>Insert a character string (as many characters as will fit on the line) before the character under the cursor, up to <em>n</em> characters. If <em>n</em> is zero or negative, the entire string is inserted. All characters to the right of the cursor are shifted right, with the rightmost characters on the line being lost. The cursor position does not change (after moving to <em>y</em>, <em>x</em>, if specified).</p> </dd></dl> <dl class="method"> <dt id="curses.window.insstr"> <tt class="descclassname">window.</tt><tt class="descname">insstr</tt><big>(</big><em>str</em><span class="optional">[</span>, <em>attr</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.insstr" title="Permalink to this definition">¶</a></dt> <dt> <tt class="descclassname">window.</tt><tt class="descname">insstr</tt><big>(</big><em>y</em>, <em>x</em>, <em>str</em><span class="optional">[</span>, <em>attr</em><span class="optional">]</span><big>)</big></dt> <dd><p>Insert a character string (as many characters as will fit on the line) before the character under the cursor. All characters to the right of the cursor are shifted right, with the rightmost characters on the line being lost. The cursor position does not change (after moving to <em>y</em>, <em>x</em>, if specified).</p> </dd></dl> <dl class="method"> <dt id="curses.window.instr"> <tt class="descclassname">window.</tt><tt class="descname">instr</tt><big>(</big><span class="optional">[</span><em>n</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.instr" title="Permalink to this definition">¶</a></dt> <dt> <tt class="descclassname">window.</tt><tt class="descname">instr</tt><big>(</big><em>y</em>, <em>x</em><span class="optional">[</span>, <em>n</em><span class="optional">]</span><big>)</big></dt> <dd><p>Return a string of characters, extracted from the window starting at the current cursor position, or at <em>y</em>, <em>x</em> if specified. Attributes are stripped from the characters. If <em>n</em> is specified, <a class="reference internal" href="#curses.window.instr" title="curses.window.instr"><tt class="xref py py-meth docutils literal"><span class="pre">instr()</span></tt></a> returns a string at most <em>n</em> characters long (exclusive of the trailing NUL).</p> </dd></dl> <dl class="method"> <dt id="curses.window.is_linetouched"> <tt class="descclassname">window.</tt><tt class="descname">is_linetouched</tt><big>(</big><em>line</em><big>)</big><a class="headerlink" href="#curses.window.is_linetouched" title="Permalink to this definition">¶</a></dt> <dd><p>Return <tt class="docutils literal"><span class="pre">True</span></tt> if the specified line was modified since the last call to <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><tt class="xref py py-meth docutils literal"><span class="pre">refresh()</span></tt></a>; otherwise return <tt class="docutils literal"><span class="pre">False</span></tt>. Raise a <a class="reference internal" href="#curses.error" title="curses.error"><tt class="xref py py-exc docutils literal"><span class="pre">curses.error</span></tt></a> exception if <em>line</em> is not valid for the given window.</p> </dd></dl> <dl class="method"> <dt id="curses.window.is_wintouched"> <tt class="descclassname">window.</tt><tt class="descname">is_wintouched</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.is_wintouched" title="Permalink to this definition">¶</a></dt> <dd><p>Return <tt class="docutils literal"><span class="pre">True</span></tt> if the specified window was modified since the last call to <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><tt class="xref py py-meth docutils literal"><span class="pre">refresh()</span></tt></a>; otherwise return <tt class="docutils literal"><span class="pre">False</span></tt>.</p> </dd></dl> <dl class="method"> <dt id="curses.window.keypad"> <tt class="descclassname">window.</tt><tt class="descname">keypad</tt><big>(</big><em>yes</em><big>)</big><a class="headerlink" href="#curses.window.keypad" title="Permalink to this definition">¶</a></dt> <dd><p>If <em>yes</em> is 1, escape sequences generated by some keys (keypad, function keys) will be interpreted by <a class="reference internal" href="#module-curses" title="curses: An interface to the curses library, providing portable terminal handling. (Unix)"><tt class="xref py py-mod docutils literal"><span class="pre">curses</span></tt></a>. If <em>yes</em> is 0, escape sequences will be left as is in the input stream.</p> </dd></dl> <dl class="method"> <dt id="curses.window.leaveok"> <tt class="descclassname">window.</tt><tt class="descname">leaveok</tt><big>(</big><em>yes</em><big>)</big><a class="headerlink" href="#curses.window.leaveok" title="Permalink to this definition">¶</a></dt> <dd><p>If <em>yes</em> is 1, cursor is left where it is on update, instead of being at “cursor position.” This reduces cursor movement where possible. If possible the cursor will be made invisible.</p> <p>If <em>yes</em> is 0, cursor will always be at “cursor position” after an update.</p> </dd></dl> <dl class="method"> <dt id="curses.window.move"> <tt class="descclassname">window.</tt><tt class="descname">move</tt><big>(</big><em>new_y</em>, <em>new_x</em><big>)</big><a class="headerlink" href="#curses.window.move" title="Permalink to this definition">¶</a></dt> <dd><p>Move cursor to <tt class="docutils literal"><span class="pre">(new_y,</span> <span class="pre">new_x)</span></tt>.</p> </dd></dl> <dl class="method"> <dt id="curses.window.mvderwin"> <tt class="descclassname">window.</tt><tt class="descname">mvderwin</tt><big>(</big><em>y</em>, <em>x</em><big>)</big><a class="headerlink" href="#curses.window.mvderwin" title="Permalink to this definition">¶</a></dt> <dd><p>Move the window inside its parent window. The screen-relative parameters of the window are not changed. This routine is used to display different parts of the parent window at the same physical position on the screen.</p> </dd></dl> <dl class="method"> <dt id="curses.window.mvwin"> <tt class="descclassname">window.</tt><tt class="descname">mvwin</tt><big>(</big><em>new_y</em>, <em>new_x</em><big>)</big><a class="headerlink" href="#curses.window.mvwin" title="Permalink to this definition">¶</a></dt> <dd><p>Move the window so its upper-left corner is at <tt class="docutils literal"><span class="pre">(new_y,</span> <span class="pre">new_x)</span></tt>.</p> </dd></dl> <dl class="method"> <dt id="curses.window.nodelay"> <tt class="descclassname">window.</tt><tt class="descname">nodelay</tt><big>(</big><em>yes</em><big>)</big><a class="headerlink" href="#curses.window.nodelay" title="Permalink to this definition">¶</a></dt> <dd><p>If <em>yes</em> is <tt class="docutils literal"><span class="pre">1</span></tt>, <a class="reference internal" href="#curses.window.getch" title="curses.window.getch"><tt class="xref py py-meth docutils literal"><span class="pre">getch()</span></tt></a> will be non-blocking.</p> </dd></dl> <dl class="method"> <dt id="curses.window.notimeout"> <tt class="descclassname">window.</tt><tt class="descname">notimeout</tt><big>(</big><em>yes</em><big>)</big><a class="headerlink" href="#curses.window.notimeout" title="Permalink to this definition">¶</a></dt> <dd><p>If <em>yes</em> is <tt class="docutils literal"><span class="pre">1</span></tt>, escape sequences will not be timed out.</p> <p>If <em>yes</em> is <tt class="docutils literal"><span class="pre">0</span></tt>, after a few milliseconds, an escape sequence will not be interpreted, and will be left in the input stream as is.</p> </dd></dl> <dl class="method"> <dt id="curses.window.noutrefresh"> <tt class="descclassname">window.</tt><tt class="descname">noutrefresh</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.noutrefresh" title="Permalink to this definition">¶</a></dt> <dd><p>Mark for refresh but wait. This function updates the data structure representing the desired state of the window, but does not force an update of the physical screen. To accomplish that, call <a class="reference internal" href="#curses.doupdate" title="curses.doupdate"><tt class="xref py py-func docutils literal"><span class="pre">doupdate()</span></tt></a>.</p> </dd></dl> <dl class="method"> <dt id="curses.window.overlay"> <tt class="descclassname">window.</tt><tt class="descname">overlay</tt><big>(</big><em>destwin</em><span class="optional">[</span>, <em>sminrow</em>, <em>smincol</em>, <em>dminrow</em>, <em>dmincol</em>, <em>dmaxrow</em>, <em>dmaxcol</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.overlay" title="Permalink to this definition">¶</a></dt> <dd><p>Overlay the window on top of <em>destwin</em>. The windows need not be the same size, only the overlapping region is copied. This copy is non-destructive, which means that the current background character does not overwrite the old contents of <em>destwin</em>.</p> <p>To get fine-grained control over the copied region, the second form of <a class="reference internal" href="#curses.window.overlay" title="curses.window.overlay"><tt class="xref py py-meth docutils literal"><span class="pre">overlay()</span></tt></a> can be used. <em>sminrow</em> and <em>smincol</em> are the upper-left coordinates of the source window, and the other variables mark a rectangle in the destination window.</p> </dd></dl> <dl class="method"> <dt id="curses.window.overwrite"> <tt class="descclassname">window.</tt><tt class="descname">overwrite</tt><big>(</big><em>destwin</em><span class="optional">[</span>, <em>sminrow</em>, <em>smincol</em>, <em>dminrow</em>, <em>dmincol</em>, <em>dmaxrow</em>, <em>dmaxcol</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.overwrite" title="Permalink to this definition">¶</a></dt> <dd><p>Overwrite the window on top of <em>destwin</em>. The windows need not be the same size, in which case only the overlapping region is copied. This copy is destructive, which means that the current background character overwrites the old contents of <em>destwin</em>.</p> <p>To get fine-grained control over the copied region, the second form of <a class="reference internal" href="#curses.window.overwrite" title="curses.window.overwrite"><tt class="xref py py-meth docutils literal"><span class="pre">overwrite()</span></tt></a> can be used. <em>sminrow</em> and <em>smincol</em> are the upper-left coordinates of the source window, the other variables mark a rectangle in the destination window.</p> </dd></dl> <dl class="method"> <dt id="curses.window.putwin"> <tt class="descclassname">window.</tt><tt class="descname">putwin</tt><big>(</big><em>file</em><big>)</big><a class="headerlink" href="#curses.window.putwin" title="Permalink to this definition">¶</a></dt> <dd><p>Write all data associated with the window into the provided file object. This information can be later retrieved using the <a class="reference internal" href="#curses.getwin" title="curses.getwin"><tt class="xref py py-func docutils literal"><span class="pre">getwin()</span></tt></a> function.</p> </dd></dl> <dl class="method"> <dt id="curses.window.redrawln"> <tt class="descclassname">window.</tt><tt class="descname">redrawln</tt><big>(</big><em>beg</em>, <em>num</em><big>)</big><a class="headerlink" href="#curses.window.redrawln" title="Permalink to this definition">¶</a></dt> <dd><p>Indicate that the <em>num</em> screen lines, starting at line <em>beg</em>, are corrupted and should be completely redrawn on the next <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><tt class="xref py py-meth docutils literal"><span class="pre">refresh()</span></tt></a> call.</p> </dd></dl> <dl class="method"> <dt id="curses.window.redrawwin"> <tt class="descclassname">window.</tt><tt class="descname">redrawwin</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.redrawwin" title="Permalink to this definition">¶</a></dt> <dd><p>Touch the entire window, causing it to be completely redrawn on the next <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><tt class="xref py py-meth docutils literal"><span class="pre">refresh()</span></tt></a> call.</p> </dd></dl> <dl class="method"> <dt id="curses.window.refresh"> <tt class="descclassname">window.</tt><tt class="descname">refresh</tt><big>(</big><span class="optional">[</span><em>pminrow</em>, <em>pmincol</em>, <em>sminrow</em>, <em>smincol</em>, <em>smaxrow</em>, <em>smaxcol</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.refresh" title="Permalink to this definition">¶</a></dt> <dd><p>Update the display immediately (sync actual screen with previous drawing/deleting methods).</p> <p>The 6 optional arguments can only be specified when the window is a pad created with <a class="reference internal" href="#curses.newpad" title="curses.newpad"><tt class="xref py py-func docutils literal"><span class="pre">newpad()</span></tt></a>. The additional parameters are needed to indicate what part of the pad and screen are involved. <em>pminrow</em> and <em>pmincol</em> specify the upper left-hand corner of the rectangle to be displayed in the pad. <em>sminrow</em>, <em>smincol</em>, <em>smaxrow</em>, and <em>smaxcol</em> specify the edges of the rectangle to be displayed on the screen. The lower right-hand corner of the rectangle to be displayed in the pad is calculated from the screen coordinates, since the rectangles must be the same size. Both rectangles must be entirely contained within their respective structures. Negative values of <em>pminrow</em>, <em>pmincol</em>, <em>sminrow</em>, or <em>smincol</em> are treated as if they were zero.</p> </dd></dl> <dl class="method"> <dt id="curses.window.resize"> <tt class="descclassname">window.</tt><tt class="descname">resize</tt><big>(</big><em>nlines</em>, <em>ncols</em><big>)</big><a class="headerlink" href="#curses.window.resize" title="Permalink to this definition">¶</a></dt> <dd><p>Reallocate storage for a curses window to adjust its dimensions to the specified values. If either dimension is larger than the current values, the window’s data is filled with blanks that have the current background rendition (as set by <a class="reference internal" href="#curses.window.bkgdset" title="curses.window.bkgdset"><tt class="xref py py-meth docutils literal"><span class="pre">bkgdset()</span></tt></a>) merged into them.</p> </dd></dl> <dl class="method"> <dt id="curses.window.scroll"> <tt class="descclassname">window.</tt><tt class="descname">scroll</tt><big>(</big><span class="optional">[</span><em>lines=1</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.scroll" title="Permalink to this definition">¶</a></dt> <dd><p>Scroll the screen or scrolling region upward by <em>lines</em> lines.</p> </dd></dl> <dl class="method"> <dt id="curses.window.scrollok"> <tt class="descclassname">window.</tt><tt class="descname">scrollok</tt><big>(</big><em>flag</em><big>)</big><a class="headerlink" href="#curses.window.scrollok" title="Permalink to this definition">¶</a></dt> <dd><p>Control what happens when the cursor of a window is moved off the edge of the window or scrolling region, either as a result of a newline action on the bottom line, or typing the last character of the last line. If <em>flag</em> is false, the cursor is left on the bottom line. If <em>flag</em> is true, the window is scrolled up one line. Note that in order to get the physical scrolling effect on the terminal, it is also necessary to call <a class="reference internal" href="#curses.window.idlok" title="curses.window.idlok"><tt class="xref py py-meth docutils literal"><span class="pre">idlok()</span></tt></a>.</p> </dd></dl> <dl class="method"> <dt id="curses.window.setscrreg"> <tt class="descclassname">window.</tt><tt class="descname">setscrreg</tt><big>(</big><em>top</em>, <em>bottom</em><big>)</big><a class="headerlink" href="#curses.window.setscrreg" title="Permalink to this definition">¶</a></dt> <dd><p>Set the scrolling region from line <em>top</em> to line <em>bottom</em>. All scrolling actions will take place in this region.</p> </dd></dl> <dl class="method"> <dt id="curses.window.standend"> <tt class="descclassname">window.</tt><tt class="descname">standend</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.standend" title="Permalink to this definition">¶</a></dt> <dd><p>Turn off the standout attribute. On some terminals this has the side effect of turning off all attributes.</p> </dd></dl> <dl class="method"> <dt id="curses.window.standout"> <tt class="descclassname">window.</tt><tt class="descname">standout</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.standout" title="Permalink to this definition">¶</a></dt> <dd><p>Turn on attribute <em>A_STANDOUT</em>.</p> </dd></dl> <dl class="method"> <dt id="curses.window.subpad"> <tt class="descclassname">window.</tt><tt class="descname">subpad</tt><big>(</big><em>begin_y</em>, <em>begin_x</em><big>)</big><a class="headerlink" href="#curses.window.subpad" title="Permalink to this definition">¶</a></dt> <dt> <tt class="descclassname">window.</tt><tt class="descname">subpad</tt><big>(</big><em>nlines</em>, <em>ncols</em>, <em>begin_y</em>, <em>begin_x</em><big>)</big></dt> <dd><p>Return a sub-window, whose upper-left corner is at <tt class="docutils literal"><span class="pre">(begin_y,</span> <span class="pre">begin_x)</span></tt>, and whose width/height is <em>ncols</em>/<em>nlines</em>.</p> </dd></dl> <dl class="method"> <dt id="curses.window.subwin"> <tt class="descclassname">window.</tt><tt class="descname">subwin</tt><big>(</big><em>begin_y</em>, <em>begin_x</em><big>)</big><a class="headerlink" href="#curses.window.subwin" title="Permalink to this definition">¶</a></dt> <dt> <tt class="descclassname">window.</tt><tt class="descname">subwin</tt><big>(</big><em>nlines</em>, <em>ncols</em>, <em>begin_y</em>, <em>begin_x</em><big>)</big></dt> <dd><p>Return a sub-window, whose upper-left corner is at <tt class="docutils literal"><span class="pre">(begin_y,</span> <span class="pre">begin_x)</span></tt>, and whose width/height is <em>ncols</em>/<em>nlines</em>.</p> <p>By default, the sub-window will extend from the specified position to the lower right corner of the window.</p> </dd></dl> <dl class="method"> <dt id="curses.window.syncdown"> <tt class="descclassname">window.</tt><tt class="descname">syncdown</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.syncdown" title="Permalink to this definition">¶</a></dt> <dd><p>Touch each location in the window that has been touched in any of its ancestor windows. This routine is called by <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><tt class="xref py py-meth docutils literal"><span class="pre">refresh()</span></tt></a>, so it should almost never be necessary to call it manually.</p> </dd></dl> <dl class="method"> <dt id="curses.window.syncok"> <tt class="descclassname">window.</tt><tt class="descname">syncok</tt><big>(</big><em>flag</em><big>)</big><a class="headerlink" href="#curses.window.syncok" title="Permalink to this definition">¶</a></dt> <dd><p>If called with <em>flag</em> set to <tt class="docutils literal"><span class="pre">True</span></tt>, then <a class="reference internal" href="#curses.window.syncup" title="curses.window.syncup"><tt class="xref py py-meth docutils literal"><span class="pre">syncup()</span></tt></a> is called automatically whenever there is a change in the window.</p> </dd></dl> <dl class="method"> <dt id="curses.window.syncup"> <tt class="descclassname">window.</tt><tt class="descname">syncup</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.syncup" title="Permalink to this definition">¶</a></dt> <dd><p>Touch all locations in ancestors of the window that have been changed in the window.</p> </dd></dl> <dl class="method"> <dt id="curses.window.timeout"> <tt class="descclassname">window.</tt><tt class="descname">timeout</tt><big>(</big><em>delay</em><big>)</big><a class="headerlink" href="#curses.window.timeout" title="Permalink to this definition">¶</a></dt> <dd><p>Set blocking or non-blocking read behavior for the window. If <em>delay</em> is negative, blocking read is used (which will wait indefinitely for input). If <em>delay</em> is zero, then non-blocking read is used, and -1 will be returned by <a class="reference internal" href="#curses.window.getch" title="curses.window.getch"><tt class="xref py py-meth docutils literal"><span class="pre">getch()</span></tt></a> if no input is waiting. If <em>delay</em> is positive, then <a class="reference internal" href="#curses.window.getch" title="curses.window.getch"><tt class="xref py py-meth docutils literal"><span class="pre">getch()</span></tt></a> will block for <em>delay</em> milliseconds, and return -1 if there is still no input at the end of that time.</p> </dd></dl> <dl class="method"> <dt id="curses.window.touchline"> <tt class="descclassname">window.</tt><tt class="descname">touchline</tt><big>(</big><em>start</em>, <em>count</em><span class="optional">[</span>, <em>changed</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.window.touchline" title="Permalink to this definition">¶</a></dt> <dd><p>Pretend <em>count</em> lines have been changed, starting with line <em>start</em>. If <em>changed</em> is supplied, it specifies whether the affected lines are marked as having been changed (<em>changed</em>=1) or unchanged (<em>changed</em>=0).</p> </dd></dl> <dl class="method"> <dt id="curses.window.touchwin"> <tt class="descclassname">window.</tt><tt class="descname">touchwin</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.touchwin" title="Permalink to this definition">¶</a></dt> <dd><p>Pretend the whole window has been changed, for purposes of drawing optimizations.</p> </dd></dl> <dl class="method"> <dt id="curses.window.untouchwin"> <tt class="descclassname">window.</tt><tt class="descname">untouchwin</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.window.untouchwin" title="Permalink to this definition">¶</a></dt> <dd><p>Mark all lines in the window as unchanged since the last call to <a class="reference internal" href="#curses.window.refresh" title="curses.window.refresh"><tt class="xref py py-meth docutils literal"><span class="pre">refresh()</span></tt></a>.</p> </dd></dl> <dl class="method"> <dt id="curses.window.vline"> <tt class="descclassname">window.</tt><tt class="descname">vline</tt><big>(</big><em>ch</em>, <em>n</em><big>)</big><a class="headerlink" href="#curses.window.vline" title="Permalink to this definition">¶</a></dt> <dt> <tt class="descclassname">window.</tt><tt class="descname">vline</tt><big>(</big><em>y</em>, <em>x</em>, <em>ch</em>, <em>n</em><big>)</big></dt> <dd><p>Display a vertical line starting at <tt class="docutils literal"><span class="pre">(y,</span> <span class="pre">x)</span></tt> with length <em>n</em> consisting of the character <em>ch</em>.</p> </dd></dl> </div> <div class="section" id="constants"> <h2>15.11.3. Constants<a class="headerlink" href="#constants" title="Permalink to this headline">¶</a></h2> <p>The <a class="reference internal" href="#module-curses" title="curses: An interface to the curses library, providing portable terminal handling. (Unix)"><tt class="xref py py-mod docutils literal"><span class="pre">curses</span></tt></a> module defines the following data members:</p> <dl class="data"> <dt id="curses.ERR"> <tt class="descclassname">curses.</tt><tt class="descname">ERR</tt><a class="headerlink" href="#curses.ERR" title="Permalink to this definition">¶</a></dt> <dd><p>Some curses routines that return an integer, such as <tt class="xref py py-func docutils literal"><span class="pre">getch()</span></tt>, return <a class="reference internal" href="#curses.ERR" title="curses.ERR"><tt class="xref py py-const docutils literal"><span class="pre">ERR</span></tt></a> upon failure.</p> </dd></dl> <dl class="data"> <dt id="curses.OK"> <tt class="descclassname">curses.</tt><tt class="descname">OK</tt><a class="headerlink" href="#curses.OK" title="Permalink to this definition">¶</a></dt> <dd><p>Some curses routines that return an integer, such as <a class="reference internal" href="#curses.napms" title="curses.napms"><tt class="xref py py-func docutils literal"><span class="pre">napms()</span></tt></a>, return <a class="reference internal" href="#curses.OK" title="curses.OK"><tt class="xref py py-const docutils literal"><span class="pre">OK</span></tt></a> upon success.</p> </dd></dl> <dl class="data"> <dt id="curses.version"> <tt class="descclassname">curses.</tt><tt class="descname">version</tt><a class="headerlink" href="#curses.version" title="Permalink to this definition">¶</a></dt> <dd><p>A string representing the current version of the module. Also available as <tt class="xref py py-const docutils literal"><span class="pre">__version__</span></tt>.</p> </dd></dl> <p>Several constants are available to specify character cell attributes:</p> <table border="1" class="docutils"> <colgroup> <col width="37%" /> <col width="63%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Attribute</th> <th class="head">Meaning</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">A_ALTCHARSET</span></tt></td> <td>Alternate character set mode.</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">A_BLINK</span></tt></td> <td>Blink mode.</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">A_BOLD</span></tt></td> <td>Bold mode.</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">A_DIM</span></tt></td> <td>Dim mode.</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">A_NORMAL</span></tt></td> <td>Normal attribute.</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">A_REVERSE</span></tt></td> <td>Reverse background and foreground colors.</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">A_STANDOUT</span></tt></td> <td>Standout mode.</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">A_UNDERLINE</span></tt></td> <td>Underline mode.</td> </tr> </tbody> </table> <p>Keys are referred to by integer constants with names starting with <tt class="docutils literal"><span class="pre">KEY_</span></tt>. The exact keycaps available are system dependent.</p> <table border="1" class="docutils"> <colgroup> <col width="30%" /> <col width="70%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Key constant</th> <th class="head">Key</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_MIN</span></tt></td> <td>Minimum key value</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_BREAK</span></tt></td> <td>Break key (unreliable)</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_DOWN</span></tt></td> <td>Down-arrow</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_UP</span></tt></td> <td>Up-arrow</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_LEFT</span></tt></td> <td>Left-arrow</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_RIGHT</span></tt></td> <td>Right-arrow</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_HOME</span></tt></td> <td>Home key (upward+left arrow)</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_BACKSPACE</span></tt></td> <td>Backspace (unreliable)</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_F0</span></tt></td> <td>Function keys. Up to 64 function keys are supported.</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_Fn</span></tt></td> <td>Value of function key <em>n</em></td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_DL</span></tt></td> <td>Delete line</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_IL</span></tt></td> <td>Insert line</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_DC</span></tt></td> <td>Delete character</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_IC</span></tt></td> <td>Insert char or enter insert mode</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_EIC</span></tt></td> <td>Exit insert char mode</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_CLEAR</span></tt></td> <td>Clear screen</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_EOS</span></tt></td> <td>Clear to end of screen</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_EOL</span></tt></td> <td>Clear to end of line</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_SF</span></tt></td> <td>Scroll 1 line forward</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_SR</span></tt></td> <td>Scroll 1 line backward (reverse)</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_NPAGE</span></tt></td> <td>Next page</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_PPAGE</span></tt></td> <td>Previous page</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_STAB</span></tt></td> <td>Set tab</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_CTAB</span></tt></td> <td>Clear tab</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_CATAB</span></tt></td> <td>Clear all tabs</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_ENTER</span></tt></td> <td>Enter or send (unreliable)</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_SRESET</span></tt></td> <td>Soft (partial) reset (unreliable)</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_RESET</span></tt></td> <td>Reset or hard reset (unreliable)</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_PRINT</span></tt></td> <td>Print</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_LL</span></tt></td> <td>Home down or bottom (lower left)</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_A1</span></tt></td> <td>Upper left of keypad</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_A3</span></tt></td> <td>Upper right of keypad</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_B2</span></tt></td> <td>Center of keypad</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_C1</span></tt></td> <td>Lower left of keypad</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_C3</span></tt></td> <td>Lower right of keypad</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_BTAB</span></tt></td> <td>Back tab</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_BEG</span></tt></td> <td>Beg (beginning)</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_CANCEL</span></tt></td> <td>Cancel</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_CLOSE</span></tt></td> <td>Close</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_COMMAND</span></tt></td> <td>Cmd (command)</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_COPY</span></tt></td> <td>Copy</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_CREATE</span></tt></td> <td>Create</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_END</span></tt></td> <td>End</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_EXIT</span></tt></td> <td>Exit</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_FIND</span></tt></td> <td>Find</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_HELP</span></tt></td> <td>Help</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_MARK</span></tt></td> <td>Mark</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_MESSAGE</span></tt></td> <td>Message</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_MOVE</span></tt></td> <td>Move</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_NEXT</span></tt></td> <td>Next</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_OPEN</span></tt></td> <td>Open</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_OPTIONS</span></tt></td> <td>Options</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_PREVIOUS</span></tt></td> <td>Prev (previous)</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_REDO</span></tt></td> <td>Redo</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_REFERENCE</span></tt></td> <td>Ref (reference)</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_REFRESH</span></tt></td> <td>Refresh</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_REPLACE</span></tt></td> <td>Replace</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_RESTART</span></tt></td> <td>Restart</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_RESUME</span></tt></td> <td>Resume</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_SAVE</span></tt></td> <td>Save</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_SBEG</span></tt></td> <td>Shifted Beg (beginning)</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_SCANCEL</span></tt></td> <td>Shifted Cancel</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_SCOMMAND</span></tt></td> <td>Shifted Command</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_SCOPY</span></tt></td> <td>Shifted Copy</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_SCREATE</span></tt></td> <td>Shifted Create</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_SDC</span></tt></td> <td>Shifted Delete char</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_SDL</span></tt></td> <td>Shifted Delete line</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_SELECT</span></tt></td> <td>Select</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_SEND</span></tt></td> <td>Shifted End</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_SEOL</span></tt></td> <td>Shifted Clear line</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_SEXIT</span></tt></td> <td>Shifted Dxit</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_SFIND</span></tt></td> <td>Shifted Find</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_SHELP</span></tt></td> <td>Shifted Help</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_SHOME</span></tt></td> <td>Shifted Home</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_SIC</span></tt></td> <td>Shifted Input</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_SLEFT</span></tt></td> <td>Shifted Left arrow</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_SMESSAGE</span></tt></td> <td>Shifted Message</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_SMOVE</span></tt></td> <td>Shifted Move</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_SNEXT</span></tt></td> <td>Shifted Next</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_SOPTIONS</span></tt></td> <td>Shifted Options</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_SPREVIOUS</span></tt></td> <td>Shifted Prev</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_SPRINT</span></tt></td> <td>Shifted Print</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_SREDO</span></tt></td> <td>Shifted Redo</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_SREPLACE</span></tt></td> <td>Shifted Replace</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_SRIGHT</span></tt></td> <td>Shifted Right arrow</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_SRSUME</span></tt></td> <td>Shifted Resume</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_SSAVE</span></tt></td> <td>Shifted Save</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_SSUSPEND</span></tt></td> <td>Shifted Suspend</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_SUNDO</span></tt></td> <td>Shifted Undo</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_SUSPEND</span></tt></td> <td>Suspend</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_UNDO</span></tt></td> <td>Undo</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_MOUSE</span></tt></td> <td>Mouse event has occurred</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">KEY_RESIZE</span></tt></td> <td>Terminal resize event</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">KEY_MAX</span></tt></td> <td>Maximum key value</td> </tr> </tbody> </table> <p>On VT100s and their software emulations, such as X terminal emulators, there are normally at least four function keys (<tt class="xref py py-const docutils literal"><span class="pre">KEY_F1</span></tt>, <tt class="xref py py-const docutils literal"><span class="pre">KEY_F2</span></tt>, <tt class="xref py py-const docutils literal"><span class="pre">KEY_F3</span></tt>, <tt class="xref py py-const docutils literal"><span class="pre">KEY_F4</span></tt>) available, and the arrow keys mapped to <tt class="xref py py-const docutils literal"><span class="pre">KEY_UP</span></tt>, <tt class="xref py py-const docutils literal"><span class="pre">KEY_DOWN</span></tt>, <tt class="xref py py-const docutils literal"><span class="pre">KEY_LEFT</span></tt> and <tt class="xref py py-const docutils literal"><span class="pre">KEY_RIGHT</span></tt> in the obvious way. If your machine has a PC keyboard, it is safe to expect arrow keys and twelve function keys (older PC keyboards may have only ten function keys); also, the following keypad mappings are standard:</p> <table border="1" class="docutils"> <colgroup> <col width="62%" /> <col width="38%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Keycap</th> <th class="head">Constant</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><tt class="kbd docutils literal"><span class="pre">Insert</span></tt></td> <td>KEY_IC</td> </tr> <tr class="row-odd"><td><tt class="kbd docutils literal"><span class="pre">Delete</span></tt></td> <td>KEY_DC</td> </tr> <tr class="row-even"><td><tt class="kbd docutils literal"><span class="pre">Home</span></tt></td> <td>KEY_HOME</td> </tr> <tr class="row-odd"><td><tt class="kbd docutils literal"><span class="pre">End</span></tt></td> <td>KEY_END</td> </tr> <tr class="row-even"><td><tt class="kbd docutils literal"><span class="pre">Page</span> <span class="pre">Up</span></tt></td> <td>KEY_NPAGE</td> </tr> <tr class="row-odd"><td><tt class="kbd docutils literal"><span class="pre">Page</span> <span class="pre">Down</span></tt></td> <td>KEY_PPAGE</td> </tr> </tbody> </table> <p>The following table lists characters from the alternate character set. These are inherited from the VT100 terminal, and will generally be available on software emulations such as X terminals. When there is no graphic available, curses falls back on a crude printable ASCII approximation.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">These are available only after <a class="reference internal" href="#curses.initscr" title="curses.initscr"><tt class="xref py py-func docutils literal"><span class="pre">initscr()</span></tt></a> has been called.</p> </div> <table border="1" class="docutils"> <colgroup> <col width="30%" /> <col width="70%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">ACS code</th> <th class="head">Meaning</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_BBSS</span></tt></td> <td>alternate name for upper right corner</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_BLOCK</span></tt></td> <td>solid square block</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_BOARD</span></tt></td> <td>board of squares</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_BSBS</span></tt></td> <td>alternate name for horizontal line</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_BSSB</span></tt></td> <td>alternate name for upper left corner</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_BSSS</span></tt></td> <td>alternate name for top tee</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_BTEE</span></tt></td> <td>bottom tee</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_BULLET</span></tt></td> <td>bullet</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_CKBOARD</span></tt></td> <td>checker board (stipple)</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_DARROW</span></tt></td> <td>arrow pointing down</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_DEGREE</span></tt></td> <td>degree symbol</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_DIAMOND</span></tt></td> <td>diamond</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_GEQUAL</span></tt></td> <td>greater-than-or-equal-to</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_HLINE</span></tt></td> <td>horizontal line</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_LANTERN</span></tt></td> <td>lantern symbol</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_LARROW</span></tt></td> <td>left arrow</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_LEQUAL</span></tt></td> <td>less-than-or-equal-to</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_LLCORNER</span></tt></td> <td>lower left-hand corner</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_LRCORNER</span></tt></td> <td>lower right-hand corner</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_LTEE</span></tt></td> <td>left tee</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_NEQUAL</span></tt></td> <td>not-equal sign</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_PI</span></tt></td> <td>letter pi</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_PLMINUS</span></tt></td> <td>plus-or-minus sign</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_PLUS</span></tt></td> <td>big plus sign</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_RARROW</span></tt></td> <td>right arrow</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_RTEE</span></tt></td> <td>right tee</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_S1</span></tt></td> <td>scan line 1</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_S3</span></tt></td> <td>scan line 3</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_S7</span></tt></td> <td>scan line 7</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_S9</span></tt></td> <td>scan line 9</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_SBBS</span></tt></td> <td>alternate name for lower right corner</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_SBSB</span></tt></td> <td>alternate name for vertical line</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_SBSS</span></tt></td> <td>alternate name for right tee</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_SSBB</span></tt></td> <td>alternate name for lower left corner</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_SSBS</span></tt></td> <td>alternate name for bottom tee</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_SSSB</span></tt></td> <td>alternate name for left tee</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_SSSS</span></tt></td> <td>alternate name for crossover or big plus</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_STERLING</span></tt></td> <td>pound sterling</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_TTEE</span></tt></td> <td>top tee</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_UARROW</span></tt></td> <td>up arrow</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_ULCORNER</span></tt></td> <td>upper left corner</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">ACS_URCORNER</span></tt></td> <td>upper right corner</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">ACS_VLINE</span></tt></td> <td>vertical line</td> </tr> </tbody> </table> <p>The following table lists the predefined colors:</p> <table border="1" class="docutils"> <colgroup> <col width="40%" /> <col width="60%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Constant</th> <th class="head">Color</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">COLOR_BLACK</span></tt></td> <td>Black</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">COLOR_BLUE</span></tt></td> <td>Blue</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">COLOR_CYAN</span></tt></td> <td>Cyan (light greenish blue)</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">COLOR_GREEN</span></tt></td> <td>Green</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">COLOR_MAGENTA</span></tt></td> <td>Magenta (purplish red)</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">COLOR_RED</span></tt></td> <td>Red</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">COLOR_WHITE</span></tt></td> <td>White</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">COLOR_YELLOW</span></tt></td> <td>Yellow</td> </tr> </tbody> </table> </div> </div> <div class="section" id="module-curses.textpad"> <span id="curses-textpad-text-input-widget-for-curses-programs"></span><h1>15.12. <a class="reference internal" href="#module-curses.textpad" title="curses.textpad: Emacs-like input editing in a curses window."><tt class="xref py py-mod docutils literal"><span class="pre">curses.textpad</span></tt></a> — Text input widget for curses programs<a class="headerlink" href="#module-curses.textpad" title="Permalink to this headline">¶</a></h1> <p class="versionadded"> <span class="versionmodified">New in version 1.6.</span></p> <p>The <a class="reference internal" href="#module-curses.textpad" title="curses.textpad: Emacs-like input editing in a curses window."><tt class="xref py py-mod docutils literal"><span class="pre">curses.textpad</span></tt></a> module provides a <a class="reference internal" href="#curses.textpad.Textbox" title="curses.textpad.Textbox"><tt class="xref py py-class docutils literal"><span class="pre">Textbox</span></tt></a> class that handles elementary text editing in a curses window, supporting a set of keybindings resembling those of Emacs (thus, also of Netscape Navigator, BBedit 6.x, FrameMaker, and many other programs). The module also provides a rectangle-drawing function useful for framing text boxes or for other purposes.</p> <p>The module <a class="reference internal" href="#module-curses.textpad" title="curses.textpad: Emacs-like input editing in a curses window."><tt class="xref py py-mod docutils literal"><span class="pre">curses.textpad</span></tt></a> defines the following function:</p> <dl class="function"> <dt id="curses.textpad.rectangle"> <tt class="descclassname">curses.textpad.</tt><tt class="descname">rectangle</tt><big>(</big><em>win</em>, <em>uly</em>, <em>ulx</em>, <em>lry</em>, <em>lrx</em><big>)</big><a class="headerlink" href="#curses.textpad.rectangle" title="Permalink to this definition">¶</a></dt> <dd><p>Draw a rectangle. The first argument must be a window object; the remaining arguments are coordinates relative to that window. The second and third arguments are the y and x coordinates of the upper left hand corner of the rectangle to be drawn; the fourth and fifth arguments are the y and x coordinates of the lower right hand corner. The rectangle will be drawn using VT100/IBM PC forms characters on terminals that make this possible (including xterm and most other software terminal emulators). Otherwise it will be drawn with ASCII dashes, vertical bars, and plus signs.</p> </dd></dl> <div class="section" id="textbox-objects"> <span id="curses-textpad-objects"></span><h2>15.12.1. Textbox objects<a class="headerlink" href="#textbox-objects" title="Permalink to this headline">¶</a></h2> <p>You can instantiate a <a class="reference internal" href="#curses.textpad.Textbox" title="curses.textpad.Textbox"><tt class="xref py py-class docutils literal"><span class="pre">Textbox</span></tt></a> object as follows:</p> <dl class="class"> <dt id="curses.textpad.Textbox"> <em class="property">class </em><tt class="descclassname">curses.textpad.</tt><tt class="descname">Textbox</tt><big>(</big><em>win</em><big>)</big><a class="headerlink" href="#curses.textpad.Textbox" title="Permalink to this definition">¶</a></dt> <dd><p>Return a textbox widget object. The <em>win</em> argument should be a curses <tt class="xref py py-class docutils literal"><span class="pre">WindowObject</span></tt> in which the textbox is to be contained. The edit cursor of the textbox is initially located at the upper left hand corner of the containing window, with coordinates <tt class="docutils literal"><span class="pre">(0,</span> <span class="pre">0)</span></tt>. The instance’s <a class="reference internal" href="#curses.textpad.Textbox.stripspaces" title="curses.textpad.Textbox.stripspaces"><tt class="xref py py-attr docutils literal"><span class="pre">stripspaces</span></tt></a> flag is initially on.</p> <p><a class="reference internal" href="#curses.textpad.Textbox" title="curses.textpad.Textbox"><tt class="xref py py-class docutils literal"><span class="pre">Textbox</span></tt></a> objects have the following methods:</p> <dl class="method"> <dt id="curses.textpad.Textbox.edit"> <tt class="descname">edit</tt><big>(</big><span class="optional">[</span><em>validator</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#curses.textpad.Textbox.edit" title="Permalink to this definition">¶</a></dt> <dd><p>This is the entry point you will normally use. It accepts editing keystrokes until one of the termination keystrokes is entered. If <em>validator</em> is supplied, it must be a function. It will be called for each keystroke entered with the keystroke as a parameter; command dispatch is done on the result. This method returns the window contents as a string; whether blanks in the window are included is affected by the <a class="reference internal" href="#curses.textpad.Textbox.stripspaces" title="curses.textpad.Textbox.stripspaces"><tt class="xref py py-attr docutils literal"><span class="pre">stripspaces</span></tt></a> attribute.</p> </dd></dl> <dl class="method"> <dt id="curses.textpad.Textbox.do_command"> <tt class="descname">do_command</tt><big>(</big><em>ch</em><big>)</big><a class="headerlink" href="#curses.textpad.Textbox.do_command" title="Permalink to this definition">¶</a></dt> <dd><p>Process a single command keystroke. Here are the supported special keystrokes:</p> <table border="1" class="docutils"> <colgroup> <col width="30%" /> <col width="70%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Keystroke</th> <th class="head">Action</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><tt class="kbd docutils literal"><span class="pre">Control-A</span></tt></td> <td>Go to left edge of window.</td> </tr> <tr class="row-odd"><td><tt class="kbd docutils literal"><span class="pre">Control-B</span></tt></td> <td>Cursor left, wrapping to previous line if appropriate.</td> </tr> <tr class="row-even"><td><tt class="kbd docutils literal"><span class="pre">Control-D</span></tt></td> <td>Delete character under cursor.</td> </tr> <tr class="row-odd"><td><tt class="kbd docutils literal"><span class="pre">Control-E</span></tt></td> <td>Go to right edge (stripspaces off) or end of line (stripspaces on).</td> </tr> <tr class="row-even"><td><tt class="kbd docutils literal"><span class="pre">Control-F</span></tt></td> <td>Cursor right, wrapping to next line when appropriate.</td> </tr> <tr class="row-odd"><td><tt class="kbd docutils literal"><span class="pre">Control-G</span></tt></td> <td>Terminate, returning the window contents.</td> </tr> <tr class="row-even"><td><tt class="kbd docutils literal"><span class="pre">Control-H</span></tt></td> <td>Delete character backward.</td> </tr> <tr class="row-odd"><td><tt class="kbd docutils literal"><span class="pre">Control-J</span></tt></td> <td>Terminate if the window is 1 line, otherwise insert newline.</td> </tr> <tr class="row-even"><td><tt class="kbd docutils literal"><span class="pre">Control-K</span></tt></td> <td>If line is blank, delete it, otherwise clear to end of line.</td> </tr> <tr class="row-odd"><td><tt class="kbd docutils literal"><span class="pre">Control-L</span></tt></td> <td>Refresh screen.</td> </tr> <tr class="row-even"><td><tt class="kbd docutils literal"><span class="pre">Control-N</span></tt></td> <td>Cursor down; move down one line.</td> </tr> <tr class="row-odd"><td><tt class="kbd docutils literal"><span class="pre">Control-O</span></tt></td> <td>Insert a blank line at cursor location.</td> </tr> <tr class="row-even"><td><tt class="kbd docutils literal"><span class="pre">Control-P</span></tt></td> <td>Cursor up; move up one line.</td> </tr> </tbody> </table> <p>Move operations do nothing if the cursor is at an edge where the movement is not possible. The following synonyms are supported where possible:</p> <table border="1" class="docutils"> <colgroup> <col width="57%" /> <col width="43%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Constant</th> <th class="head">Keystroke</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">KEY_LEFT</span></tt></td> <td><tt class="kbd docutils literal"><span class="pre">Control-B</span></tt></td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">KEY_RIGHT</span></tt></td> <td><tt class="kbd docutils literal"><span class="pre">Control-F</span></tt></td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">KEY_UP</span></tt></td> <td><tt class="kbd docutils literal"><span class="pre">Control-P</span></tt></td> </tr> <tr class="row-odd"><td><tt class="xref py py-const docutils literal"><span class="pre">KEY_DOWN</span></tt></td> <td><tt class="kbd docutils literal"><span class="pre">Control-N</span></tt></td> </tr> <tr class="row-even"><td><tt class="xref py py-const docutils literal"><span class="pre">KEY_BACKSPACE</span></tt></td> <td><tt class="kbd docutils literal"><span class="pre">Control-h</span></tt></td> </tr> </tbody> </table> <p>All other keystrokes are treated as a command to insert the given character and move right (with line wrapping).</p> </dd></dl> <dl class="method"> <dt id="curses.textpad.Textbox.gather"> <tt class="descname">gather</tt><big>(</big><big>)</big><a class="headerlink" href="#curses.textpad.Textbox.gather" title="Permalink to this definition">¶</a></dt> <dd><p>Return the window contents as a string; whether blanks in the window are included is affected by the <a class="reference internal" href="#curses.textpad.Textbox.stripspaces" title="curses.textpad.Textbox.stripspaces"><tt class="xref py py-attr docutils literal"><span class="pre">stripspaces</span></tt></a> member.</p> </dd></dl> <dl class="attribute"> <dt id="curses.textpad.Textbox.stripspaces"> <tt class="descname">stripspaces</tt><a class="headerlink" href="#curses.textpad.Textbox.stripspaces" title="Permalink to this definition">¶</a></dt> <dd><p>This attribute is a flag which controls the interpretation of blanks in the window. When it is on, trailing blanks on each line are ignored; any cursor motion that would land the cursor on a trailing blank goes to the end of that line instead, and trailing blanks are stripped when the window contents are gathered.</p> </dd></dl> </dd></dl> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../contents.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">15.11. <tt class="docutils literal"><span class="pre">curses</span></tt> — Terminal handling for character-cell displays</a><ul> <li><a class="reference internal" href="#functions">15.11.1. Functions</a></li> <li><a class="reference internal" href="#window-objects">15.11.2. Window Objects</a></li> <li><a class="reference internal" href="#constants">15.11.3. Constants</a></li> </ul> </li> <li><a class="reference internal" href="#module-curses.textpad">15.12. <tt class="docutils literal"><span class="pre">curses.textpad</span></tt> — Text input widget for curses programs</a><ul> <li><a class="reference internal" href="#textbox-objects">15.12.1. Textbox objects</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="getpass.html" title="previous chapter">15.10. <tt class="docutils literal"><span class="pre">getpass</span></tt> — Portable password input</a></p> <h4>Next topic</h4> <p class="topless"><a href="curses.ascii.html" title="next chapter">15.13. <tt class="docutils literal"><span class="pre">curses.ascii</span></tt> — Utilities for ASCII characters</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li><a href="../_sources/library/curses.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="curses.ascii.html" title="15.13. curses.ascii — Utilities for ASCII characters" >next</a> |</li> <li class="right" > <a href="getpass.html" title="15.10. getpass — Portable password input" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="allos.html" >15. Generic Operating System Services</a> »</li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 1990-2019, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="http://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Jul 03, 2019. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>
Close