Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / lib / curses-functions.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="curses-window-objects.html" />
13<link rel="prev" href="module-curses.html" />
14<link rel="parent" href="module-curses.html" />
15<link rel="next" href="curses-window-objects.html" />
16<meta name='aesop' content='information' />
17<title>6.15.1 Functions </title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="6.15 curses "
25 href="module-curses.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="6.15 curses "
28 href="module-curses.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="6.15.2 Window Objects"
31 href="curses-window-objects.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python Library Reference</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="module-curses.html">6.15 curses </A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="module-curses.html">6.15 curses </A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="curses-window-objects.html">6.15.2 Window Objects</A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H2><A NAME="SECTION0081510000000000000000"></A><A NAME="curses-functions"></A>
56<BR>
576.15.1 Functions
58</H2>
59
60<P>
61The module <tt class="module">curses</tt> defines the following exception:
62
63<P>
64<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-2001' xml:id='l2h-2001' class="exception">error</tt></b></dt>
65<dd>
66Exception raised when a curses library function returns an error.
67</dd></dl>
68
69<P>
70<span class="note"><b class="label">Note:</b>
71Whenever <var>x</var> or <var>y</var> arguments to a function
72or a method are optional, they default to the current cursor location.
73Whenever <var>attr</var> is optional, it defaults to <tt class="constant">A_NORMAL</tt>.</span>
74
75<P>
76The module <tt class="module">curses</tt> defines the following functions:
77
78<P>
79<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
80 <td><nobr><b><tt id='l2h-2002' xml:id='l2h-2002' class="function">baudrate</tt></b>(</nobr></td>
81 <td><var></var>)</td></tr></table></dt>
82<dd>
83Returns the output speed of the terminal in bits per second. On
84software terminal emulators it will have a fixed high value.
85Included for historical reasons; in former times, it was used to
86write output loops for time delays and occasionally to change
87interfaces depending on the line speed.
88</dl>
89
90<P>
91<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
92 <td><nobr><b><tt id='l2h-2003' xml:id='l2h-2003' class="function">beep</tt></b>(</nobr></td>
93 <td><var></var>)</td></tr></table></dt>
94<dd>
95Emit a short attention sound.
96</dl>
97
98<P>
99<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
100 <td><nobr><b><tt id='l2h-2004' xml:id='l2h-2004' class="function">can_change_color</tt></b>(</nobr></td>
101 <td><var></var>)</td></tr></table></dt>
102<dd>
103Returns true or false, depending on whether the programmer can change
104the colors displayed by the terminal.
105</dl>
106
107<P>
108<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
109 <td><nobr><b><tt id='l2h-2005' xml:id='l2h-2005' class="function">cbreak</tt></b>(</nobr></td>
110 <td><var></var>)</td></tr></table></dt>
111<dd>
112Enter cbreak mode. In cbreak mode (sometimes called ``rare'' mode)
113normal tty line buffering is turned off and characters are available
114to be read one by one. However, unlike raw mode, special characters
115(interrupt, quit, suspend, and flow control) retain their effects on
116the tty driver and calling program. Calling first <tt class="function">raw()</tt>
117then <tt class="function">cbreak()</tt> leaves the terminal in cbreak mode.
118</dl>
119
120<P>
121<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
122 <td><nobr><b><tt id='l2h-2006' xml:id='l2h-2006' class="function">color_content</tt></b>(</nobr></td>
123 <td><var>color_number</var>)</td></tr></table></dt>
124<dd>
125Returns the intensity of the red, green, and blue (RGB) components in
126the color <var>color_number</var>, which must be between <code>0</code> and
127<tt class="constant">COLORS</tt>. A 3-tuple is returned, containing the R,G,B values
128for the given color, which will be between <code>0</code> (no component) and
129<code>1000</code> (maximum amount of component).
130</dl>
131
132<P>
133<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
134 <td><nobr><b><tt id='l2h-2007' xml:id='l2h-2007' class="function">color_pair</tt></b>(</nobr></td>
135 <td><var>color_number</var>)</td></tr></table></dt>
136<dd>
137Returns the attribute value for displaying text in the specified
138color. This attribute value can be combined with
139<tt class="constant">A_STANDOUT</tt>, <tt class="constant">A_REVERSE</tt>, and the other
140<tt class="constant">A_*</tt> attributes. <tt class="function">pair_number()</tt> is the
141counterpart to this function.
142</dl>
143
144<P>
145<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
146 <td><nobr><b><tt id='l2h-2008' xml:id='l2h-2008' class="function">curs_set</tt></b>(</nobr></td>
147 <td><var>visibility</var>)</td></tr></table></dt>
148<dd>
149Sets the cursor state. <var>visibility</var> can be set to 0, 1, or 2, for
150invisible, normal, or very visible. If the terminal supports the
151visibility requested, the previous cursor state is returned;
152otherwise, an exception is raised. On many terminals, the ``visible''
153mode is an underline cursor and the ``very visible'' mode is a block cursor.
154</dl>
155
156<P>
157<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
158 <td><nobr><b><tt id='l2h-2009' xml:id='l2h-2009' class="function">def_prog_mode</tt></b>(</nobr></td>
159 <td><var></var>)</td></tr></table></dt>
160<dd>
161Saves the current terminal mode as the ``program'' mode, the mode when
162the running program is using curses. (Its counterpart is the
163``shell'' mode, for when the program is not in curses.) Subsequent calls
164to <tt class="function">reset_prog_mode()</tt> will restore this mode.
165</dl>
166
167<P>
168<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
169 <td><nobr><b><tt id='l2h-2010' xml:id='l2h-2010' class="function">def_shell_mode</tt></b>(</nobr></td>
170 <td><var></var>)</td></tr></table></dt>
171<dd>
172Saves the current terminal mode as the ``shell'' mode, the mode when
173the running program is not using curses. (Its counterpart is the
174``program'' mode, when the program is using curses capabilities.)
175Subsequent calls
176to <tt class="function">reset_shell_mode()</tt> will restore this mode.
177</dl>
178
179<P>
180<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
181 <td><nobr><b><tt id='l2h-2011' xml:id='l2h-2011' class="function">delay_output</tt></b>(</nobr></td>
182 <td><var>ms</var>)</td></tr></table></dt>
183<dd>
184Inserts an <var>ms</var> millisecond pause in output.
185</dl>
186
187<P>
188<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
189 <td><nobr><b><tt id='l2h-2012' xml:id='l2h-2012' class="function">doupdate</tt></b>(</nobr></td>
190 <td><var></var>)</td></tr></table></dt>
191<dd>
192Update the physical screen. The curses library keeps two data
193structures, one representing the current physical screen contents
194and a virtual screen representing the desired next state. The
195<tt class="function">doupdate()</tt> ground updates the physical screen to match the
196virtual screen.
197
198<P>
199The virtual screen may be updated by a <tt class="method">noutrefresh()</tt> call
200after write operations such as <tt class="method">addstr()</tt> have been performed
201on a window. The normal <tt class="method">refresh()</tt> call is simply
202<tt class="method">noutrefresh()</tt> followed by <tt class="function">doupdate()</tt>; if you have
203to update multiple windows, you can speed performance and perhaps
204reduce screen flicker by issuing <tt class="method">noutrefresh()</tt> calls on
205all windows, followed by a single <tt class="function">doupdate()</tt>.
206</dl>
207
208<P>
209<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
210 <td><nobr><b><tt id='l2h-2013' xml:id='l2h-2013' class="function">echo</tt></b>(</nobr></td>
211 <td><var></var>)</td></tr></table></dt>
212<dd>
213Enter echo mode. In echo mode, each character input is echoed to the
214screen as it is entered.
215</dl>
216
217<P>
218<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
219 <td><nobr><b><tt id='l2h-2014' xml:id='l2h-2014' class="function">endwin</tt></b>(</nobr></td>
220 <td><var></var>)</td></tr></table></dt>
221<dd>
222De-initialize the library, and return terminal to normal status.
223</dl>
224
225<P>
226<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
227 <td><nobr><b><tt id='l2h-2015' xml:id='l2h-2015' class="function">erasechar</tt></b>(</nobr></td>
228 <td><var></var>)</td></tr></table></dt>
229<dd>
230Returns the user's current erase character. Under <span class="Unix">Unix</span> operating
231systems this is a property of the controlling tty of the curses
232program, and is not set by the curses library itself.
233</dl>
234
235<P>
236<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
237 <td><nobr><b><tt id='l2h-2016' xml:id='l2h-2016' class="function">filter</tt></b>(</nobr></td>
238 <td><var></var>)</td></tr></table></dt>
239<dd>
240The <tt class="function">filter()</tt> routine, if used, must be called before
241<tt class="function">initscr()</tt> is called. The effect is that, during those
242calls, LINES is set to 1; the capabilities clear, cup, cud, cud1,
243cuu1, cuu, vpa are disabled; and the home string is set to the value of cr.
244The effect is that the cursor is confined to the current line, and so
245are screen updates. This may be used for enabling character-at-a-time
246line editing without touching the rest of the screen.
247</dl>
248
249<P>
250<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
251 <td><nobr><b><tt id='l2h-2017' xml:id='l2h-2017' class="function">flash</tt></b>(</nobr></td>
252 <td><var></var>)</td></tr></table></dt>
253<dd>
254Flash the screen. That is, change it to reverse-video and then change
255it back in a short interval. Some people prefer such as `visible bell'
256to the audible attention signal produced by <tt class="function">beep()</tt>.
257</dl>
258
259<P>
260<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
261 <td><nobr><b><tt id='l2h-2018' xml:id='l2h-2018' class="function">flushinp</tt></b>(</nobr></td>
262 <td><var></var>)</td></tr></table></dt>
263<dd>
264Flush all input buffers. This throws away any typeahead that has
265been typed by the user and has not yet been processed by the program.
266</dl>
267
268<P>
269<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
270 <td><nobr><b><tt id='l2h-2019' xml:id='l2h-2019' class="function">getmouse</tt></b>(</nobr></td>
271 <td><var></var>)</td></tr></table></dt>
272<dd>
273After <tt class="method">getch()</tt> returns <tt class="constant">KEY_MOUSE</tt> to signal a mouse
274event, this method should be call to retrieve the queued mouse event,
275represented as a 5-tuple
276<code>(<var>id</var>, <var>x</var>, <var>y</var>, <var>z</var>, <var>bstate</var>)</code>.
277<var>id</var> is an ID value used to distinguish multiple devices,
278and <var>x</var>, <var>y</var>, <var>z</var> are the event's coordinates. (<var>z</var>
279is currently unused.). <var>bstate</var> is an integer value whose bits
280will be set to indicate the type of event, and will be the bitwise OR
281of one or more of the following constants, where <var>n</var> is the button
282number from 1 to 4:
283<tt class="constant">BUTTON<var>n</var>_PRESSED</tt>,
284<tt class="constant">BUTTON<var>n</var>_RELEASED</tt>,
285<tt class="constant">BUTTON<var>n</var>_CLICKED</tt>,
286<tt class="constant">BUTTON<var>n</var>_DOUBLE_CLICKED</tt>,
287<tt class="constant">BUTTON<var>n</var>_TRIPLE_CLICKED</tt>,
288<tt class="constant">BUTTON_SHIFT</tt>,
289<tt class="constant">BUTTON_CTRL</tt>,
290<tt class="constant">BUTTON_ALT</tt>.
291</dl>
292
293<P>
294<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
295 <td><nobr><b><tt id='l2h-2020' xml:id='l2h-2020' class="function">getsyx</tt></b>(</nobr></td>
296 <td><var></var>)</td></tr></table></dt>
297<dd>
298Returns the current coordinates of the virtual screen cursor in y and
299x. If leaveok is currently true, then -1,-1 is returned.
300</dl>
301
302<P>
303<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
304 <td><nobr><b><tt id='l2h-2021' xml:id='l2h-2021' class="function">getwin</tt></b>(</nobr></td>
305 <td><var>file</var>)</td></tr></table></dt>
306<dd>
307Reads window related data stored in the file by an earlier
308<tt class="function">putwin()</tt> call. The routine then creates and initializes a
309new window using that data, returning the new window object.
310</dl>
311
312<P>
313<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
314 <td><nobr><b><tt id='l2h-2022' xml:id='l2h-2022' class="function">has_colors</tt></b>(</nobr></td>
315 <td><var></var>)</td></tr></table></dt>
316<dd>
317Returns true if the terminal can display colors; otherwise, it
318returns false.
319</dl>
320
321<P>
322<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
323 <td><nobr><b><tt id='l2h-2023' xml:id='l2h-2023' class="function">has_ic</tt></b>(</nobr></td>
324 <td><var></var>)</td></tr></table></dt>
325<dd>
326Returns true if the terminal has insert- and delete- character
327capabilities. This function is included for historical reasons only,
328as all modern software terminal emulators have such capabilities.
329</dl>
330
331<P>
332<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
333 <td><nobr><b><tt id='l2h-2024' xml:id='l2h-2024' class="function">has_il</tt></b>(</nobr></td>
334 <td><var></var>)</td></tr></table></dt>
335<dd>
336Returns true if the terminal has insert- and
337delete-line capabilities, or can simulate them using
338scrolling regions. This function is included for historical reasons only,
339as all modern software terminal emulators have such capabilities.
340</dl>
341
342<P>
343<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
344 <td><nobr><b><tt id='l2h-2025' xml:id='l2h-2025' class="function">has_key</tt></b>(</nobr></td>
345 <td><var>ch</var>)</td></tr></table></dt>
346<dd>
347Takes a key value <var>ch</var>, and returns true if the current terminal
348type recognizes a key with that value.
349</dl>
350
351<P>
352<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
353 <td><nobr><b><tt id='l2h-2026' xml:id='l2h-2026' class="function">halfdelay</tt></b>(</nobr></td>
354 <td><var>tenths</var>)</td></tr></table></dt>
355<dd>
356Used for half-delay mode, which is similar to cbreak mode in that
357characters typed by the user are immediately available to the program.
358However, after blocking for <var>tenths</var> tenths of seconds, an
359exception is raised if nothing has been typed. The value of
360<var>tenths</var> must be a number between 1 and 255. Use
361<tt class="function">nocbreak()</tt> to leave half-delay mode.
362</dl>
363
364<P>
365<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
366 <td><nobr><b><tt id='l2h-2027' xml:id='l2h-2027' class="function">init_color</tt></b>(</nobr></td>
367 <td><var>color_number, r, g, b</var>)</td></tr></table></dt>
368<dd>
369Changes the definition of a color, taking the number of the color to
370be changed followed by three RGB values (for the amounts of red,
371green, and blue components). The value of <var>color_number</var> must be
372between <code>0</code> and <tt class="constant">COLORS</tt>. Each of <var>r</var>, <var>g</var>,
373<var>b</var>, must be a value between <code>0</code> and <code>1000</code>. When
374<tt class="function">init_color()</tt> is used, all occurrences of that color on the
375screen immediately change to the new definition. This function is a
376no-op on most terminals; it is active only if
377<tt class="function">can_change_color()</tt> returns <code>1</code>.
378</dl>
379
380<P>
381<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
382 <td><nobr><b><tt id='l2h-2028' xml:id='l2h-2028' class="function">init_pair</tt></b>(</nobr></td>
383 <td><var>pair_number, fg, bg</var>)</td></tr></table></dt>
384<dd>
385Changes the definition of a color-pair. It takes three arguments: the
386number of the color-pair to be changed, the foreground color number,
387and the background color number. The value of <var>pair_number</var> must
388be between <code>1</code> and <code>COLOR_PAIRS - 1</code> (the <code>0</code> color
389pair is wired to white on black and cannot be changed). The value of
390<var>fg</var> and <var>bg</var> arguments must be between <code>0</code> and
391<tt class="constant">COLORS</tt>. If the color-pair was previously initialized, the
392screen is refreshed and all occurrences of that color-pair are changed
393to the new definition.
394</dl>
395
396<P>
397<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
398 <td><nobr><b><tt id='l2h-2029' xml:id='l2h-2029' class="function">initscr</tt></b>(</nobr></td>
399 <td><var></var>)</td></tr></table></dt>
400<dd>
401Initialize the library. Returns a <tt class="class">WindowObject</tt> which represents
402the whole screen. <span class="note"><b class="label">Note:</b>
403If there is an error opening the terminal,
404the underlying curses library may cause the interpreter to exit.</span>
405</dl>
406
407<P>
408<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
409 <td><nobr><b><tt id='l2h-2030' xml:id='l2h-2030' class="function">isendwin</tt></b>(</nobr></td>
410 <td><var></var>)</td></tr></table></dt>
411<dd>
412Returns true if <tt class="function">endwin()</tt> has been called (that is, the
413curses library has been deinitialized).
414</dl>
415
416<P>
417<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
418 <td><nobr><b><tt id='l2h-2031' xml:id='l2h-2031' class="function">keyname</tt></b>(</nobr></td>
419 <td><var>k</var>)</td></tr></table></dt>
420<dd>
421Return the name of the key numbered <var>k</var>. The name of a key
422generating printable ASCII character is the key's character. The name
423of a control-key combination is a two-character string consisting of a
424caret followed by the corresponding printable ASCII character. The
425name of an alt-key combination (128-255) is a string consisting of the
426prefix `M-' followed by the name of the corresponding ASCII character.
427</dl>
428
429<P>
430<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
431 <td><nobr><b><tt id='l2h-2032' xml:id='l2h-2032' class="function">killchar</tt></b>(</nobr></td>
432 <td><var></var>)</td></tr></table></dt>
433<dd>
434Returns the user's current line kill character. Under <span class="Unix">Unix</span> operating
435systems this is a property of the controlling tty of the curses
436program, and is not set by the curses library itself.
437</dl>
438
439<P>
440<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
441 <td><nobr><b><tt id='l2h-2033' xml:id='l2h-2033' class="function">longname</tt></b>(</nobr></td>
442 <td><var></var>)</td></tr></table></dt>
443<dd>
444Returns a string containing the terminfo long name field describing the current
445terminal. The maximum length of a verbose description is 128
446characters. It is defined only after the call to
447<tt class="function">initscr()</tt>.
448</dl>
449
450<P>
451<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
452 <td><nobr><b><tt id='l2h-2034' xml:id='l2h-2034' class="function">meta</tt></b>(</nobr></td>
453 <td><var>yes</var>)</td></tr></table></dt>
454<dd>
455If <var>yes</var> is 1, allow 8-bit characters to be input. If <var>yes</var> is 0,
456allow only 7-bit chars.
457</dl>
458
459<P>
460<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
461 <td><nobr><b><tt id='l2h-2035' xml:id='l2h-2035' class="function">mouseinterval</tt></b>(</nobr></td>
462 <td><var>interval</var>)</td></tr></table></dt>
463<dd>
464Sets the maximum time in milliseconds that can elapse between press and
465release events in order for them to be recognized as a click, and
466returns the previous interval value. The default value is 200 msec,
467or one fifth of a second.
468</dl>
469
470<P>
471<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
472 <td><nobr><b><tt id='l2h-2036' xml:id='l2h-2036' class="function">mousemask</tt></b>(</nobr></td>
473 <td><var>mousemask</var>)</td></tr></table></dt>
474<dd>
475Sets the mouse events to be reported, and returns a tuple
476<code>(<var>availmask</var>, <var>oldmask</var>)</code>.
477<var>availmask</var> indicates which of the
478specified mouse events can be reported; on complete failure it returns
4790. <var>oldmask</var> is the previous value of the given window's mouse
480event mask. If this function is never called, no mouse events are
481ever reported.
482</dl>
483
484<P>
485<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
486 <td><nobr><b><tt id='l2h-2037' xml:id='l2h-2037' class="function">napms</tt></b>(</nobr></td>
487 <td><var>ms</var>)</td></tr></table></dt>
488<dd>
489Sleep for <var>ms</var> milliseconds.
490</dl>
491
492<P>
493<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
494 <td><nobr><b><tt id='l2h-2038' xml:id='l2h-2038' class="function">newpad</tt></b>(</nobr></td>
495 <td><var>nlines, ncols</var>)</td></tr></table></dt>
496<dd>
497Creates and returns a pointer to a new pad data structure with the
498given number of lines and columns. A pad is returned as a
499window object.
500
501<P>
502A pad is like a window, except that it is not restricted by the screen
503size, and is not necessarily associated with a particular part of the
504screen. Pads can be used when a large window is needed, and only a
505part of the window will be on the screen at one time. Automatic
506refreshes of pads (such as from scrolling or echoing of input) do not
507occur. The <tt class="method">refresh()</tt> and <tt class="method">noutrefresh()</tt> methods of a
508pad require 6 arguments to specify the part of the pad to be
509displayed and the location on the screen to be used for the display.
510The arguments are pminrow, pmincol, sminrow, smincol, smaxrow,
511smaxcol; the p arguments refer to the upper left corner of the pad
512region to be displayed and the s arguments define a clipping box on
513the screen within which the pad region is to be displayed.
514</dl>
515
516<P>
517<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
518 <td><nobr><b><tt id='l2h-2039' xml:id='l2h-2039' class="function">newwin</tt></b>(</nobr></td>
519 <td><var></var><big>[</big><var>nlines, ncols,</var><big>]</big><var> begin_y, begin_x</var>)</td></tr></table></dt>
520<dd>
521Return a new window, whose left-upper corner is at
522<code>(<var>begin_y</var>, <var>begin_x</var>)</code>, and whose height/width is
523<var>nlines</var>/<var>ncols</var>.
524
525<P>
526By default, the window will extend from the
527specified position to the lower right corner of the screen.
528</dl>
529
530<P>
531<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
532 <td><nobr><b><tt id='l2h-2040' xml:id='l2h-2040' class="function">nl</tt></b>(</nobr></td>
533 <td><var></var>)</td></tr></table></dt>
534<dd>
535Enter newline mode. This mode translates the return key into newline
536on input, and translates newline into return and line-feed on output.
537Newline mode is initially on.
538</dl>
539
540<P>
541<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
542 <td><nobr><b><tt id='l2h-2041' xml:id='l2h-2041' class="function">nocbreak</tt></b>(</nobr></td>
543 <td><var></var>)</td></tr></table></dt>
544<dd>
545Leave cbreak mode. Return to normal ``cooked'' mode with line buffering.
546</dl>
547
548<P>
549<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
550 <td><nobr><b><tt id='l2h-2042' xml:id='l2h-2042' class="function">noecho</tt></b>(</nobr></td>
551 <td><var></var>)</td></tr></table></dt>
552<dd>
553Leave echo mode. Echoing of input characters is turned off.
554</dl>
555
556<P>
557<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
558 <td><nobr><b><tt id='l2h-2043' xml:id='l2h-2043' class="function">nonl</tt></b>(</nobr></td>
559 <td><var></var>)</td></tr></table></dt>
560<dd>
561Leave newline mode. Disable translation of return into newline on
562input, and disable low-level translation of newline into
563newline/return on output (but this does not change the behavior of
564<code>addch('&#92;n')</code>, which always does the equivalent of return and
565line feed on the virtual screen). With translation off, curses can
566sometimes speed up vertical motion a little; also, it will be able to
567detect the return key on input.
568</dl>
569
570<P>
571<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
572 <td><nobr><b><tt id='l2h-2044' xml:id='l2h-2044' class="function">noqiflush</tt></b>(</nobr></td>
573 <td><var></var>)</td></tr></table></dt>
574<dd>
575When the noqiflush routine is used, normal flush of input and
576output queues associated with the INTR, QUIT and SUSP
577characters will not be done. You may want to call
578<tt class="function">noqiflush()</tt> in a signal handler if you want output
579to continue as though the interrupt had not occurred, after the
580handler exits.
581</dl>
582
583<P>
584<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
585 <td><nobr><b><tt id='l2h-2045' xml:id='l2h-2045' class="function">noraw</tt></b>(</nobr></td>
586 <td><var></var>)</td></tr></table></dt>
587<dd>
588Leave raw mode. Return to normal ``cooked'' mode with line buffering.
589</dl>
590
591<P>
592<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
593 <td><nobr><b><tt id='l2h-2046' xml:id='l2h-2046' class="function">pair_content</tt></b>(</nobr></td>
594 <td><var>pair_number</var>)</td></tr></table></dt>
595<dd>
596Returns a tuple <code>(<var>fg</var>, <var>bg</var>)</code> containing the colors for
597the requested color pair. The value of <var>pair_number</var> must be
598between <code>1</code> and <code><tt class="constant">COLOR_PAIRS</tt> - 1</code>.
599</dl>
600
601<P>
602<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
603 <td><nobr><b><tt id='l2h-2047' xml:id='l2h-2047' class="function">pair_number</tt></b>(</nobr></td>
604 <td><var>attr</var>)</td></tr></table></dt>
605<dd>
606Returns the number of the color-pair set by the attribute value
607<var>attr</var>. <tt class="function">color_pair()</tt> is the counterpart to this
608function.
609</dl>
610
611<P>
612<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
613 <td><nobr><b><tt id='l2h-2048' xml:id='l2h-2048' class="function">putp</tt></b>(</nobr></td>
614 <td><var>string</var>)</td></tr></table></dt>
615<dd>
616Equivalent to <code>tputs(str, 1, putchar)</code>; emits the value of a
617specified terminfo capability for the current terminal. Note that the
618output of putp always goes to standard output.
619</dl>
620
621<P>
622<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
623 <td><nobr><b><tt id='l2h-2049' xml:id='l2h-2049' class="function">qiflush</tt></b>(</nobr></td>
624 <td><var> </var><big>[</big><var>flag</var><big>]</big><var> </var>)</td></tr></table></dt>
625<dd>
626If <var>flag</var> is false, the effect is the same as calling
627<tt class="function">noqiflush()</tt>. If <var>flag</var> is true, or no argument is
628provided, the queues will be flushed when these control characters are
629read.
630</dl>
631
632<P>
633<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
634 <td><nobr><b><tt id='l2h-2050' xml:id='l2h-2050' class="function">raw</tt></b>(</nobr></td>
635 <td><var></var>)</td></tr></table></dt>
636<dd>
637Enter raw mode. In raw mode, normal line buffering and
638processing of interrupt, quit, suspend, and flow control keys are
639turned off; characters are presented to curses input functions one
640by one.
641</dl>
642
643<P>
644<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
645 <td><nobr><b><tt id='l2h-2051' xml:id='l2h-2051' class="function">reset_prog_mode</tt></b>(</nobr></td>
646 <td><var></var>)</td></tr></table></dt>
647<dd>
648Restores the terminal to ``program'' mode, as previously saved
649by <tt class="function">def_prog_mode()</tt>.
650</dl>
651
652<P>
653<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
654 <td><nobr><b><tt id='l2h-2052' xml:id='l2h-2052' class="function">reset_shell_mode</tt></b>(</nobr></td>
655 <td><var></var>)</td></tr></table></dt>
656<dd>
657Restores the terminal to ``shell'' mode, as previously saved
658by <tt class="function">def_shell_mode()</tt>.
659</dl>
660
661<P>
662<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
663 <td><nobr><b><tt id='l2h-2053' xml:id='l2h-2053' class="function">setsyx</tt></b>(</nobr></td>
664 <td><var>y, x</var>)</td></tr></table></dt>
665<dd>
666Sets the virtual screen cursor to <var>y</var>, <var>x</var>.
667If <var>y</var> and <var>x</var> are both -1, then leaveok is set.
668</dl>
669
670<P>
671<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
672 <td><nobr><b><tt id='l2h-2054' xml:id='l2h-2054' class="function">setupterm</tt></b>(</nobr></td>
673 <td><var></var><big>[</big><var>termstr, fd</var><big>]</big><var></var>)</td></tr></table></dt>
674<dd>
675Initializes the terminal. <var>termstr</var> is a string giving the
676terminal name; if omitted, the value of the TERM environment variable
677will be used. <var>fd</var> is the file descriptor to which any
678initialization sequences will be sent; if not supplied, the file
679descriptor for <code>sys.stdout</code> will be used.
680</dl>
681
682<P>
683<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
684 <td><nobr><b><tt id='l2h-2055' xml:id='l2h-2055' class="function">start_color</tt></b>(</nobr></td>
685 <td><var></var>)</td></tr></table></dt>
686<dd>
687Must be called if the programmer wants to use colors, and before any
688other color manipulation routine is called. It is good
689practice to call this routine right after <tt class="function">initscr()</tt>.
690
691<P>
692<tt class="function">start_color()</tt> initializes eight basic colors (black, red,
693green, yellow, blue, magenta, cyan, and white), and two global
694variables in the <tt class="module">curses</tt> module, <tt class="constant">COLORS</tt> and
695<tt class="constant">COLOR_PAIRS</tt>, containing the maximum number of colors and
696color-pairs the terminal can support. It also restores the colors on
697the terminal to the values they had when the terminal was just turned
698on.
699</dl>
700
701<P>
702<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
703 <td><nobr><b><tt id='l2h-2056' xml:id='l2h-2056' class="function">termattrs</tt></b>(</nobr></td>
704 <td><var></var>)</td></tr></table></dt>
705<dd>
706Returns a logical OR of all video attributes supported by the
707terminal. This information is useful when a curses program needs
708complete control over the appearance of the screen.
709</dl>
710
711<P>
712<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
713 <td><nobr><b><tt id='l2h-2057' xml:id='l2h-2057' class="function">termname</tt></b>(</nobr></td>
714 <td><var></var>)</td></tr></table></dt>
715<dd>
716Returns the value of the environment variable TERM, truncated to 14
717characters.
718</dl>
719
720<P>
721<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
722 <td><nobr><b><tt id='l2h-2058' xml:id='l2h-2058' class="function">tigetflag</tt></b>(</nobr></td>
723 <td><var>capname</var>)</td></tr></table></dt>
724<dd>
725Returns the value of the Boolean capability corresponding to the
726terminfo capability name <var>capname</var>. The value <code>-1</code> is
727returned if <var>capname</var> is not a Boolean capability, or <code>0</code> if
728it is canceled or absent from the terminal description.
729</dl>
730
731<P>
732<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
733 <td><nobr><b><tt id='l2h-2059' xml:id='l2h-2059' class="function">tigetnum</tt></b>(</nobr></td>
734 <td><var>capname</var>)</td></tr></table></dt>
735<dd>
736Returns the value of the numeric capability corresponding to the
737terminfo capability name <var>capname</var>. The value <code>-2</code> is
738returned if <var>capname</var> is not a numeric capability, or <code>-1</code> if
739it is canceled or absent from the terminal description.
740</dl>
741
742<P>
743<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
744 <td><nobr><b><tt id='l2h-2060' xml:id='l2h-2060' class="function">tigetstr</tt></b>(</nobr></td>
745 <td><var>capname</var>)</td></tr></table></dt>
746<dd>
747Returns the value of the string capability corresponding to the
748terminfo capability name <var>capname</var>. <code>None</code> is returned if
749<var>capname</var> is not a string capability, or is canceled or absent
750from the terminal description.
751</dl>
752
753<P>
754<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
755 <td><nobr><b><tt id='l2h-2061' xml:id='l2h-2061' class="function">tparm</tt></b>(</nobr></td>
756 <td><var>str</var><big>[</big><var>,...</var><big>]</big><var></var>)</td></tr></table></dt>
757<dd>
758Instantiates the string <var>str</var> with the supplied parameters, where
759<var>str</var> should be a parameterized string obtained from the terminfo
760database. E.g. <code>tparm(tigetstr("cup"), 5, 3)</code> could result in
761<code>'&#92;033[6;4H'</code>, the exact result depending on terminal type.
762</dl>
763
764<P>
765<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
766 <td><nobr><b><tt id='l2h-2062' xml:id='l2h-2062' class="function">typeahead</tt></b>(</nobr></td>
767 <td><var>fd</var>)</td></tr></table></dt>
768<dd>
769Specifies that the file descriptor <var>fd</var> be used for typeahead
770checking. If <var>fd</var> is <code>-1</code>, then no typeahead checking is
771done.
772
773<P>
774The curses library does ``line-breakout optimization'' by looking for
775typeahead periodically while updating the screen. If input is found,
776and it is coming from a tty, the current update is postponed until
777refresh or doupdate is called again, allowing faster response to
778commands typed in advance. This function allows specifying a different
779file descriptor for typeahead checking.
780</dl>
781
782<P>
783<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
784 <td><nobr><b><tt id='l2h-2063' xml:id='l2h-2063' class="function">unctrl</tt></b>(</nobr></td>
785 <td><var>ch</var>)</td></tr></table></dt>
786<dd>
787Returns a string which is a printable representation of the character
788<var>ch</var>. Control characters are displayed as a caret followed by the
789character, for example as <code>^C</code>. Printing
790characters are left as they are.
791</dl>
792
793<P>
794<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
795 <td><nobr><b><tt id='l2h-2064' xml:id='l2h-2064' class="function">ungetch</tt></b>(</nobr></td>
796 <td><var>ch</var>)</td></tr></table></dt>
797<dd>
798Push <var>ch</var> so the next <tt class="method">getch()</tt> will return it.
799<span class="note"><b class="label">Note:</b>
800Only one <var>ch</var> can be pushed before <tt class="method">getch()</tt>
801is called.</span>
802</dl>
803
804<P>
805<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
806 <td><nobr><b><tt id='l2h-2065' xml:id='l2h-2065' class="function">ungetmouse</tt></b>(</nobr></td>
807 <td><var>id, x, y, z, bstate</var>)</td></tr></table></dt>
808<dd>
809Push a <tt class="constant">KEY_MOUSE</tt> event onto the input queue, associating
810the given state data with it.
811</dl>
812
813<P>
814<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
815 <td><nobr><b><tt id='l2h-2066' xml:id='l2h-2066' class="function">use_env</tt></b>(</nobr></td>
816 <td><var>flag</var>)</td></tr></table></dt>
817<dd>
818If used, this function should be called before <tt class="function">initscr()</tt> or
819newterm are called. When <var>flag</var> is false, the values of
820lines and columns specified in the terminfo database will be
821used, even if environment variables <a class="envvar" id='l2h-2068' xml:id='l2h-2068'>LINES</a> and
822<a class="envvar" id='l2h-2069' xml:id='l2h-2069'>COLUMNS</a> (used by default) are set, or if curses is running in
823a window (in which case default behavior would be to use the window
824size if <a class="envvar" id='l2h-2070' xml:id='l2h-2070'>LINES</a> and <a class="envvar" id='l2h-2071' xml:id='l2h-2071'>COLUMNS</a> are not set).
825</dl>
826
827<P>
828<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
829 <td><nobr><b><tt id='l2h-2067' xml:id='l2h-2067' class="function">use_default_colors</tt></b>(</nobr></td>
830 <td><var></var>)</td></tr></table></dt>
831<dd>
832Allow use of default values for colors on terminals supporting this
833feature. Use this to support transparency in your
834application. The default color is assigned to the color number -1.
835After calling this function,
836<code>init_pair(x, curses.COLOR_RED, -1)</code> initializes, for instance,
837color pair <var>x</var> to a red foreground color on the default background.
838</dl>
839
840<P>
841
842<DIV CLASS="navigation">
843<div class='online-navigation'>
844<p></p><hr />
845<table align="center" width="100%" cellpadding="0" cellspacing="2">
846<tr>
847<td class='online-navigation'><a rel="prev" title="6.15 curses "
848 href="module-curses.html"><img src='../icons/previous.png'
849 border='0' height='32' alt='Previous Page' width='32' /></A></td>
850<td class='online-navigation'><a rel="parent" title="6.15 curses "
851 href="module-curses.html"><img src='../icons/up.png'
852 border='0' height='32' alt='Up One Level' width='32' /></A></td>
853<td class='online-navigation'><a rel="next" title="6.15.2 Window Objects"
854 href="curses-window-objects.html"><img src='../icons/next.png'
855 border='0' height='32' alt='Next Page' width='32' /></A></td>
856<td align="center" width="100%">Python Library Reference</td>
857<td class='online-navigation'><a rel="contents" title="Table of Contents"
858 href="contents.html"><img src='../icons/contents.png'
859 border='0' height='32' alt='Contents' width='32' /></A></td>
860<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
861 border='0' height='32' alt='Module Index' width='32' /></a></td>
862<td class='online-navigation'><a rel="index" title="Index"
863 href="genindex.html"><img src='../icons/index.png'
864 border='0' height='32' alt='Index' width='32' /></A></td>
865</tr></table>
866<div class='online-navigation'>
867<b class="navlabel">Previous:</b>
868<a class="sectref" rel="prev" href="module-curses.html">6.15 curses </A>
869<b class="navlabel">Up:</b>
870<a class="sectref" rel="parent" href="module-curses.html">6.15 curses </A>
871<b class="navlabel">Next:</b>
872<a class="sectref" rel="next" href="curses-window-objects.html">6.15.2 Window Objects</A>
873</div>
874</div>
875<hr />
876<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
877</DIV>
878<!--End of Navigation Panel-->
879<ADDRESS>
880See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
881</ADDRESS>
882</BODY>
883</HTML>