blob: 8d047be487ea77c4a7a8dc0dba3570236ae3c690 [file] [log] [blame]
Fred Drakea4070ce1999-06-21 21:13:09 +00001\section{\module{curses} ---
Eric S. Raymond68996602000-07-24 03:28:40 +00002 Screen painting and input handling for character-cell terminals}
Fred Drakea4070ce1999-06-21 21:13:09 +00003
4\declaremodule{extension}{curses}
5\sectionauthor{Moshe Zadka}{mzadka@geocities.com}
Eric S. Raymond68996602000-07-24 03:28:40 +00006\sectionauthor{Eric Raymond}{esr@thyrsus.com}
Fred Drakea4070ce1999-06-21 21:13:09 +00007\modulesynopsis{An interface to the curses library.}
8
9The \module{curses} module provides an interface to the curses \UNIX{}
10library, the de-facto standard for portable advanced terminal
11handling.
12
13While curses is most widely used in the \UNIX{} environment, versions
Eric S. Raymond68996602000-07-24 03:28:40 +000014are available for DOS, OS/2, and possibly other systems as well. This
15extension module is designed to match the API of ncurses, an
16open-source curses library hosted on Linux and the BSD variants of
17Unix.
Fred Drakea4070ce1999-06-21 21:13:09 +000018
19\begin{seealso}
Fred Drake5c529d32000-06-28 22:11:40 +000020 \seemodule{curses.ascii}{Utilities for working with \ASCII{}
21 characters, regardless of your locale
22 settings.}
Eric S. Raymond68996602000-07-24 03:28:40 +000023 \seemodule{curses.textbox}{Editable text widget for curses supporting
Fred Drakee1b304d2000-07-24 19:35:52 +000024 Emacs-like bindings.}
Fred Drakea4070ce1999-06-21 21:13:09 +000025 \seetext{Tutorial material on using curses with Python is available
Fred Drake37f15741999-11-10 16:21:37 +000026 on the Python Web site as Andrew Kuchling's
27\citetitle[http://www.python.org/doc/howto/curses/curses.html]{Curses
Fred Drakea4070ce1999-06-21 21:13:09 +000028 Programming with Python}, at
29 \url{http://www.python.org/doc/howto/curses/curses.html}.}
30\end{seealso}
31
32
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000033\subsection{Functions \label{curses-functions}}
Fred Drakea4070ce1999-06-21 21:13:09 +000034
35The module \module{curses} defines the following exception:
36\begin{excdesc}{error}
37Curses function returned an error status.
38\end{excdesc}
39
Fred Drake0bccd731999-06-23 17:28:01 +000040\strong{Note:} Whenever \var{x} or \var{y} arguments to a function
41or a method are optional, they default to the current cursor location.
42Whenever \var{attr} is optional, it defaults to \constant{A_NORMAL}.
43
Fred Drakea4070ce1999-06-21 21:13:09 +000044The module \module{curses} defines the following functions:
45
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000046\begin{funcdesc}{baudrate}{}
Eric S. Raymond68996602000-07-24 03:28:40 +000047Returns the output speed of the terminal in bits per second. On
48software terminal emulators it will have a fixed high value.
49Included for historical reasons; in former times, it was used to
50write output loops for time delays and occasionally to change
51interfaces depending on the line speed.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000052\end{funcdesc}
53
54\begin{funcdesc}{beep}{}
Eric S. Raymond68996602000-07-24 03:28:40 +000055Emit a short attention sound.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000056\end{funcdesc}
57
58\begin{funcdesc}{can_change_color}{}
59Returns true or false, depending on whether the programmer can change
60the colors displayed by the terminal.
61\end{funcdesc}
62
63\begin{funcdesc}{cbreak}{}
Eric S. Raymond68996602000-07-24 03:28:40 +000064Enter cbreak mode. In cbreak mode (sometimes called ``rare'' mode)
65normal tty line buffering is turned off and characters are available
66to be read one by one. However, unlike raw mode, special characters
67(interrupt, quit, suspend, and flow control) retain their effects on
68the tty driver and calling program. Calling first \function{raw()}
69then \function{cbreak()} leaves the terminal in cbreak mode.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000070\end{funcdesc}
71
72\begin{funcdesc}{color_content}{color_number}
73Returns the intensity of the red, green, and blue (RGB) components in
74the color \var{color_number}, which must be between 0 and COLORS. A
753-tuple is returned, containing the R,G,B values for the given color,
76which will be between 0 (no component) and 1000 (maximum amount of
77component).
78\end{funcdesc}
79
80\begin{funcdesc}{color_pair}{color_number}
81Returns the attribute value for displaying text in the specified
82color. This attribute value can be combined with
83\constant{A_STANDOUT}, \constant{A_REVERSE}, and the other
84\constant{A_*} attributes. \function{pair_number()} is the counterpart to this function.
85\end{funcdesc}
86
87\begin{funcdesc}{curs_set}{visibility}
88Sets the cursor state. \var{visibility} can be set to 0, 1, or 2, for
89invisible, normal, or very visible. If the terminal supports the
90visibility requested, the previous cursor state is returned;
Eric S. Raymond68996602000-07-24 03:28:40 +000091otherwise, an exception is raised. On many terminals, the ``visible''
92mode is an underline cursor and the ``very visible'' mode is a block cursor.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000093\end{funcdesc}
94
95\begin{funcdesc}{def_prog_mode}{}
96Saves the current terminal mode as the ``program'' mode, the mode when
97the running program is using curses. (Its counterpart is the
98``shell'' mode, for when the program is not in curses.) Subsequent calls
99to \function{reset_prog_mode()} will restore this mode.
100\end{funcdesc}
101
102\begin{funcdesc}{def_shell_mode}{}
103Saves the current terminal mode as the ``shell'' mode, the mode when
104the running program is not using curses. (Its counterpart is the
105``program'' mode, when the program is using curses capabilities.)
106Subsequent calls
107to \function{reset_shell_mode()} will restore this mode.
108\end{funcdesc}
109
110\begin{funcdesc}{delay_output}{ms}
111Inserts an \var{ms} millisecond pause in output.
112\end{funcdesc}
113
114\begin{funcdesc}{doupdate}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000115Update the physical screen. The curses library keeps two data
116structures, one representing the current physical screen contents
117and a virtual screen representing the desired next state. The
118\function{doupdate()} ground updates the physical screen to match the
119virtual screen.
120
121The virtual screen may be updated by a \method{noutrefresh()} call
122after write operations such as \method{addstr()} have been performed
123on a window. The normal \method{refresh()} call is simply
124\method{noutrefresh()} followed by \function{doupdate()}; if you have
125to update multiple windows, you can speed performance and perhaps
126reduce screen flicker by issuing \method{noutrefresh()} calls on
127all windows, followed by a single \function{doupdate()}.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000128\end{funcdesc}
129
130\begin{funcdesc}{echo}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000131Enter echo mode. In echo mode, each character input is echoed to the
132screen as it is entered.
Fred Drakea4070ce1999-06-21 21:13:09 +0000133\end{funcdesc}
134
135\begin{funcdesc}{endwin}{}
136De-initialize the library, and return terminal to normal status.
137\end{funcdesc}
138
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000139\begin{funcdesc}{erasechar}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000140Returns the user's current erase character. Under Unix operating
141systems this is a property of the controlling tty of the curses
142program, and is not set by the curses library itself.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000143\end{funcdesc}
144
145\begin{funcdesc}{filter}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000146The \function{filter()} routine, if used, must be called before
147\function{initscr()} is called. The effect is that, during those
148calls, LINES is set to 1; the capabilities clear, cup, cud, cud1,
149cuu1, cuu, vpa are disabled; and the home string is set to the value of cr.
150The effect is that the cursor is confined to the current line, and so
151are screen updates. This may be used for enabling cgaracter-at-a-time
152line editing without touching the rest of the screen.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000153\end{funcdesc}
154
155\begin{funcdesc}{flash}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000156Flash the screen. That is, change it to reverse-video and then change
157it back in a short interval. Some people prefer such as `visible bell'
158to the audible attention signal produced by \function{beep()}.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000159\end{funcdesc}
160
161\begin{funcdesc}{flushinp}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000162Flush all input buffers. This throws away any typeahead that has
163been typed by the user and has not yet been processed by the program.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000164\end{funcdesc}
165
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000166\begin{funcdesc}{getmouse}{}
167After \method{getch()} returns \constant{KEY_MOUSE} to signal a mouse
168event, this method should be call to retrieve the queued mouse event,
169represented as a 5-tuple
170\code{(\var{id}, \var{x}, \var{y}, \var{z}, \var{bstate})}.
171\var{id} is an ID value used to distinguish multiple devices,
172and \var{x}, \var{y}, \var{z} are the event's coordinates. (\var{z}
173is currently unused.). \var{bstate} is an integer value whose bits
174will be set to indicate the type of event, and will be the bitwise OR
175of one or more of the following constants, where \var{n} is the button
176number from 1 to 4:
177\constant{BUTTON\var{n}_PRESSED},
178\constant{BUTTON\var{n}_RELEASED},
179\constant{BUTTON\var{n}_CLICKED},
180\constant{BUTTON\var{n}_DOUBLE_CLICKED},
181\constant{BUTTON\var{n}_TRIPLE_CLICKED},
182\constant{BUTTON_SHIFT},
183\constant{BUTTON_CTRL},
184\constant{BUTTON_ALT}.
185\end{funcdesc}
186
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000187\begin{funcdesc}{getsyx}{}
188Returns the current coordinates of the virtual screen cursor in y and
189x. If leaveok is currently true, then -1,-1 is returned.
190\end{funcdesc}
191
192\begin{funcdesc}{getwin}{file}
193Reads window related data stored in the file by an earlier
194\function{putwin()} call. The routine then creates and initializes a
195new window using that data, returning the new window object.
196\end{funcdesc}
197
198\begin{funcdesc}{has_colors}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000199Returns true if the terminal can display colors; otherwise, it
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000200returns false.
201\end{funcdesc}
202
203\begin{funcdesc}{has_ic}{}
204Returns true if the terminal has insert- and delete- character
Eric S. Raymond68996602000-07-24 03:28:40 +0000205capabilities. This function is included for historical reasons only,
206as all modern software terminal emulators have such capabilities.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000207\end{funcdesc}
208
209\begin{funcdesc}{has_il}{}
210Returns true if the terminal has insert- and
211delete-line capabilities, or can simulate them using
Eric S. Raymond68996602000-07-24 03:28:40 +0000212scrolling regions. This function is included for historical reasons only,
213as all modern software terminal emulators have such capabilities.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000214\end{funcdesc}
215
216\begin{funcdesc}{has_key}{ch}
217Takes a key value \var{ch}, and returns true if the current terminal
218type recognizes a key with that value.
219\end{funcdesc}
220
221\begin{funcdesc}{halfdelay}{tenths}
222Used for half-delay mode, which is similar to cbreak mode in that
223characters typed by the user are immediately available to the program.
224However, after blocking for \var{tenths} tenths of seconds, an
225exception is raised if nothing has been typed. The value of
Eric S. Raymond68996602000-07-24 03:28:40 +0000226\var{tenths} must be a number between 1 and 255. Use \function{nocbreak()} to
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000227leave half-delay mode.
228\end{funcdesc}
229
230\begin{funcdesc}{init_color}{color_number, r, g, b}
231Changes the definition of a color, taking the number of the color to
232be changed followed by three RGB values (for the amounts of red,
233green, and blue components). The value of \var{color_number} must be
234between 0 and COLORS. Each of \var{r}, \var{g}, \var{b}, must be a
235value between 0 and 1000. When \function{init_color()} is used, all
236occurrences of that color on the screen immediately change to the new
Eric S. Raymond68996602000-07-24 03:28:40 +0000237definition. This function is a no-op on most terminals; it is active
238only if \function{can_change_color()} returns 1.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000239\end{funcdesc}
240
241\begin{funcdesc}{init_pair}{pair_number, fg, bg}
242Changes the definition of a color-pair. It takes three arguments: the
243number of the color-pair to be changed, the foreground color number,
244and the background color number. The value of \var{pair_number} must
245be between 1 and COLOR_PAIRS-1 (the 0 color pair is wired to white on
246black and cannot be changed). The value of \var{fg} and \var{bg}
247arguments must be between 0 and COLORS. If the color-pair was
248previously initialized, the screen is refreshed and all occurrences of
249that color-pair are changed to the new definition.
250\end{funcdesc}
251
252\begin{funcdesc}{initscr}{}
253Initialize the library. Returns a \class{WindowObject} which represents
254the whole screen.
255\end{funcdesc}
256
Fred Drakea4070ce1999-06-21 21:13:09 +0000257\begin{funcdesc}{isendwin}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000258Returns true if \function{endwin()} has been called (that is, the
259curses library has been deinitialized).
Fred Drakea4070ce1999-06-21 21:13:09 +0000260\end{funcdesc}
261
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000262\begin{funcdesc}{keyname}{k}
Eric S. Raymond68996602000-07-24 03:28:40 +0000263Return the name of the key numbered \var{k}. The name of a key
264generating printable ASCII character is the key's character. The name
265of a control-key combination is a two-character string consisting of a
266caret followed by the corresponding printable ASCII character. The
267name of an alt-key combination (128-255) is a string consisting of the
268prefix `M-' followed by the name of the corresponding ASCII character.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000269\end{funcdesc}
270
271\begin{funcdesc}{killchar}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000272Returns the user's current line kill character. Under Unix operating
273systems this is a property of the controlling tty of the curses
274program, and is not set by the curses library itself.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000275\end{funcdesc}
276
277\begin{funcdesc}{longname}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000278Returns a string containing the terminfo long name field describing the current
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000279terminal. The maximum length of a verbose description is 128
280characters. It is defined only after the call to
281\function{initscr()}.
282\end{funcdesc}
283
284\begin{funcdesc}{meta}{yes}
Eric S. Raymond68996602000-07-24 03:28:40 +0000285If \var{yes} is 1, allow 8-bit characters to be input. If \var{yes} is 0,
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000286allow only 7-bit chars.
287\end{funcdesc}
288
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000289\begin{funcdesc}{mouseinterval}{interval}
Thomas Woutersf8316632000-07-16 19:01:10 +0000290Sets the maximum time in milliseconds that can elapse between press and
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000291release events in order for them to be recognized as a click, and
292returns the previous interval value. The default value is 200 msec,
293or one fifth of a second.
294\end{funcdesc}
295
296\begin{funcdesc}{mousemask}{mousemask}
297Sets the mouse events to be reported, and returns a tuple
298\code{(\var{availmask}, \var{oldmask})}.
299\var{availmask} indicates which of the
300specified mouse events can be reported; on complete failure it returns
3010. \var{oldmask} is the previous value of the given window's mouse
302event mask. If this function is never called, no mouse events are
303ever reported.
304\end{funcdesc}
305
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000306\begin{funcdesc}{newpad}{nlines, ncols}
307Creates and returns a pointer to a new pad data structure with the
308given number of lines and columns. A pad is returned as a
309window object.
310
Eric S. Raymond68996602000-07-24 03:28:40 +0000311A pad is like a window, except that it is not restricted by the screen
312size, and is not necessarily associated with a particular part of the
313screen. Pads can be used when a large window is needed, and only a
314part of the window will be on the screen at one time. Automatic
315refreshes of pads (e.g., from scrolling or echoing of input) do not
316occur. The \method{refresh()} and \method{noutrefresh()} methods of a
317pad require 6 arguments to specify the part of the pad to be
318displayed and the location on the screen to be used for the display.
319The arguments are pminrow, pmincol, sminrow, smincol, smaxrow,
320smaxcol; the p arguments refer to the upper left corner of the the pad
321region to be displayed and the s arguments define a clipping box on
322the screen within which the pad region is to be displayed.
Fred Drakea4070ce1999-06-21 21:13:09 +0000323\end{funcdesc}
324
325\begin{funcdesc}{newwin}{\optional{nlines, ncols,} begin_y, begin_x}
326Return a new window, whose left-upper corner is at
327\code{(\var{begin_y}, \var{begin_x})}, and whose height/width is
Fred Drake0bccd731999-06-23 17:28:01 +0000328\var{nlines}/\var{ncols}.
329
330By default, the window will extend from the
Fred Drakea4070ce1999-06-21 21:13:09 +0000331specified position to the lower right corner of the screen.
332\end{funcdesc}
333
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000334\begin{funcdesc}{nl}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000335Enter newline mode. This mode translates the return key into newline
336on input, and translates newline into return and line-feed on output.
337Newline mode is initially on.
Fred Drakea4070ce1999-06-21 21:13:09 +0000338\end{funcdesc}
339
340\begin{funcdesc}{nocbreak}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000341Leave cbreak mode. Return to normal ``cooked'' mode with line buffering.
Fred Drakea4070ce1999-06-21 21:13:09 +0000342\end{funcdesc}
343
Fred Drakea4070ce1999-06-21 21:13:09 +0000344\begin{funcdesc}{noecho}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000345Leave echo mode. Echoing of input characters is turned off,
Fred Drakea4070ce1999-06-21 21:13:09 +0000346\end{funcdesc}
347
Fred Drakea4070ce1999-06-21 21:13:09 +0000348\begin{funcdesc}{nonl}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000349Leave newline mode. Disable translation of return into newline on
350input, and disable low-level translation of newline into
351newline/return on output (but this does not change the behavior of
Fred Drakee1b304d2000-07-24 19:35:52 +0000352\code{addch('\e n')}, which always does the equivalent of return and
353line feed on the virtual screen). With translation off, curses can
354sometimes speed up vertical motion a little; also, it will be able to
355detect the return key on input.
Fred Drakea4070ce1999-06-21 21:13:09 +0000356\end{funcdesc}
357
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000358\begin{funcdesc}{noqiflush}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000359When the noqiflush routine is used, normal flush of input and
360output queues associated with the INTR, QUIT and SUSP
361characters will not be done. You may want to call
362\function{noqiflush()} in a signal handler if you want output
363to continue as though the interrupt had not occurred, after the
364handler exits.
Fred Drakea4070ce1999-06-21 21:13:09 +0000365\end{funcdesc}
366
367\begin{funcdesc}{noraw}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000368Leave raw mode. Return to normal ``cooked'' mode with line buffering.
Fred Drakea4070ce1999-06-21 21:13:09 +0000369\end{funcdesc}
370
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000371\begin{funcdesc}{pair_content}{pair_number}
372Returns a tuple \var{(fg,bg)} containing the colors for the requested
373color pair. The value of \var{pair_number} must be between 0 and
374COLOR_PAIRS-1.
Fred Drakea4070ce1999-06-21 21:13:09 +0000375\end{funcdesc}
376
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000377\begin{funcdesc}{pair_number}{attr}
378Returns the number of the color-pair set by the attribute value \var{attr}.
379\function{color_pair()} is the counterpart to this function.
Fred Drakea4070ce1999-06-21 21:13:09 +0000380\end{funcdesc}
381
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000382\begin{funcdesc}{putp}{string}
Eric S. Raymond68996602000-07-24 03:28:40 +0000383Equivalent to \code{tputs(str, 1, putchar)}; emits the value of a
384specified terminfo capability for the current terminal. Note that the
385output of putp always goes to standard output.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000386\end{funcdesc}
387
388\begin{funcdesc}{qiflush}{ \optional{flag} }
389If \var{flag} is false, the effect is the same as calling
390\function{noqiflush()}. If \var{flag} is true, or no argument is
391provided, the queues will be flushed when these control characters are
392read.
393\end{funcdesc}
394
395\begin{funcdesc}{raw}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000396Enter raw mode. In raw mode, normal line buffering and
397processing of interrupt, quit, suspend, and flow control keys are
398turned off; characters are presented to curses input functions one
399by one.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000400\end{funcdesc}
401
402\begin{funcdesc}{reset_prog_mode}{}
403Restores the terminal to ``program'' mode, as previously saved
404by \function{def_prog_mode()}.
405\end{funcdesc}
406
407\begin{funcdesc}{reset_shell_mode}{}
408Restores the terminal to ``shell'' mode, as previously saved
409by \function{def_shell_mode()}.
410\end{funcdesc}
411
412\begin{funcdesc}{setsyx}{y, x}
413Sets the virtual screen cursor to \var{y}, \var{x}.
414If \var{y} and \var{x} are both -1, then leaveok is set.
415\end{funcdesc}
416
417\begin{funcdesc}{start_color}{}
418Must be called if the programmer wants to use colors, and before any
419other color manipulation routine is called. It is good
420practice to call this routine right after \function{initscr()}.
421
422\function{start_color()} initializes eight basic colors (black, red,
423green, yellow, blue, magenta, cyan, and white), and two global
424variables in the \module{curses} module, COLORS and COLOR_PAIRS,
425containing the maximum number of colors and color-pairs the terminal
426can support. It also restores the colors on the terminal to the
427values they had when the terminal was just turned on.
428\end{funcdesc}
429
430\begin{funcdesc}{termattrs}{}
431Returns a logical OR of all video attributes supported by the
432terminal. This information is useful when a curses program needs
433complete control over the appearance of the screen.
434\end{funcdesc}
435
436\begin{funcdesc}{termname}{}
437Returns the value of the environment variable TERM, truncated to 14
438characters.
439\end{funcdesc}
440
Andrew M. Kuchling1962fb52000-07-26 02:59:13 +0000441\begin{funcdesc}{tigetflag}{capname}
442Returns the value of the Boolean capability corresponding to the
443terminfo capability name \var{capname}. The value -1 is returned if
444\var{capname} is not a Boolean capability, or 0 if it is canceled or
445absent from the terminal description.
446\end{funcdesc}
447
448\begin{funcdesc}{tigetnum}{capname}
449Returns the value of the numeric capability corresponding to the
450terminfo capability name \var{capname}. The value -2 is returned if
451\var{capname} is not a numeric capability, or -1 if it is canceled or absent
452from the terminal description.
453\end{funcdesc}
454
455\begin{funcdesc}{tigetstr}{capname}
456Returns the value of the string capability corresponding to the
457terminfo capability name \var{capname}. \code{None} is returned if
458\var{capname} is not a string capability, or is canceled or absent
459from the terminal description.
460\end{funcdesc}
461
Andrew M. Kuchlingd24ff442000-06-21 01:42:51 +0000462\begin{funcdesc}{typeahead}{fd}
463Specifies that the file descriptor \var{fd} be used for typeahead
464checking. If \var{fd} is -1, then no typeahead checking is done.
465
466The curses library does ``line-breakout optimization'' by looking for
467typeahead periodically while updating the screen. If input is found,
468and it is coming from a tty, the current update is postponed until
469refresh or doupdate is called again, allowing faster response to
470commands typed in advance. This function allows specifying a different
471file descriptor for typeahead checking.
472\end{funcdesc}
473
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000474\begin{funcdesc}{unctrl}{ch}
475Returns a string which is a printable representation of the character
476\var{ch}. Control characters are displayed as a caret followed by the
477character, for example as \verb|^C|. Printing characters are left as they
478are.
479\end{funcdesc}
480
481\begin{funcdesc}{ungetch}{ch}
482Push \var{ch} so the next \method{getch()} will return it.
483\strong{Note:} only one \var{ch} can be pushed before \method{getch()}
484is called.
485\end{funcdesc}
486
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000487\begin{funcdesc}{ungetmouse}{id, x, y, z, bstate}
488Push a \constant{KEY_MOUSE} event onto the input queue, associating
489the given state data with it.
490\end{funcdesc}
491
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000492\begin{funcdesc}{use_env}{flag}
493If used, this function should be called before \function{initscr} or
494newterm are called. When \var{flag} is false, the values of
495lines and columns specified in the terminfo database will be
496used, even if environment variables LINES and COLUMNS (used by
497default) are set, or if curses is running in a window (in which
498case default behavior would be to use the window size if LINES
499and COLUMNS are not set).
500\end{funcdesc}
Fred Drakea4070ce1999-06-21 21:13:09 +0000501
502\subsection{Window Objects \label{curses-window-objects}}
503
504Window objects, as returned by \function{initscr()} and
505\function{newwin()} above, have the
506following methods:
507
Fred Drakea4070ce1999-06-21 21:13:09 +0000508\begin{methoddesc}{addch}{\optional{y, x,} ch\optional{, attr}}
509\strong{Note:} A \emph{character} means a C character (i.e., an
510\ASCII{} code), rather then a Python character (a string of length 1).
511(This note is true whenever the documentation mentions a character.)
Eric S. Raymond68996602000-07-24 03:28:40 +0000512The builtin \function{ord()} is handy for conveying strings to codes.
Fred Drakea4070ce1999-06-21 21:13:09 +0000513
514Paint character \var{ch} at \code{(\var{y}, \var{x})} with attributes
515\var{attr}, overwriting any character previously painter at that
516location. By default, the character position and attributes are the
517current settings for the window object.
518\end{methoddesc}
519
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000520\begin{methoddesc}{addnstr}{\optional{y, x,} str, n\optional{, attr}}
521Paint at most \var{n} characters of the
522string \var{str} at \code{(\var{y}, \var{x})} with attributes
Fred Drake0bccd731999-06-23 17:28:01 +0000523\var{attr}, overwriting anything previously on the display.
Fred Drakea4070ce1999-06-21 21:13:09 +0000524\end{methoddesc}
525
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000526\begin{methoddesc}{addstr}{\optional{y, x,} str\optional{, attr}}
527Paint the string \var{str} at \code{(\var{y}, \var{x})} with attributes
528\var{attr}, overwriting anything previously on the display.
Fred Drakea4070ce1999-06-21 21:13:09 +0000529\end{methoddesc}
530
531\begin{methoddesc}{attroff}{attr}
Eric S. Raymond68996602000-07-24 03:28:40 +0000532Remove attribute \var{attr} from the ``background'' set applied to all
533writes to the current window.
Fred Drakea4070ce1999-06-21 21:13:09 +0000534\end{methoddesc}
535
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000536\begin{methoddesc}{attron}{attr}
Eric S. Raymond68996602000-07-24 03:28:40 +0000537Add attribute \var{attr} from the ``background'' set applied to all
538writes to the current window.
Fred Drakea4070ce1999-06-21 21:13:09 +0000539\end{methoddesc}
540
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000541\begin{methoddesc}{attrset}{attr}
Eric S. Raymond68996602000-07-24 03:28:40 +0000542Set the ``background'' set of attributes to \var{attr}. This set is
543initially 0 (no attributes).
Fred Drakea4070ce1999-06-21 21:13:09 +0000544\end{methoddesc}
545
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000546\begin{methoddesc}{bkgd}{ch\optional{, attr}}
547Sets the background property of the window to the character \var{ch},
548with attributes \var{attr}. The change is then applied to every
549character position in that window:
550\begin{itemize}
551\item The attribute of every character in the window is
552 changed to the new background attribute.
553
554\item Wherever the former background character appears,
555it is changed to the new background character.
556\end{itemize}
557
558\end{methoddesc}
559
560\begin{methoddesc}{bkgdset}{ch\optional{, attr}}
561Sets the window's background. A window's background consists of a
562character and any combination of attributes. The attribute part of
563the background is combined (OR'ed) with all non-blank characters that
564are written into the window. Both the character and attribute parts
565of the background are combined with the blank characters. The
566background becomes a property of the character and moves with the
567character through any scrolling and insert/delete line/character
568operations.
Fred Drakea4070ce1999-06-21 21:13:09 +0000569\end{methoddesc}
570
Fred Drake0bccd731999-06-23 17:28:01 +0000571\begin{methoddesc}{border}{\optional{ls\optional{, rs\optional{, ts\optional{,
572 bs\optional{, tl\optional{, tr\optional{,
573 bl\optional{, br}}}}}}}}}
574Draw a border around the edges of the window. Each parameter specifies
575the character to use for a specific part of the border; see the table
576below for more details. The characters must be specified as integers;
577using one-character strings will cause \exception{TypeError} to be
578raised.
579
580\strong{Note:} A \code{0} value for any parameter will cause the
581default character to be used for that parameter. Keyword parameters
582can \emph{not} be used. The defaults are listed in this table:
583
584\begin{tableiii}{l|l|l}{var}{Parameter}{Description}{Default value}
585 \lineiii{ls}{Left side}{\constant{ACS_VLINE}}
586 \lineiii{rs}{Right side}{\constant{ACS_VLINE}}
587 \lineiii{ts}{Top}{\constant{ACS_HLINE}}
588 \lineiii{bs}{Bottom}{\constant{ACS_HLINE}}
589 \lineiii{tl}{Upper-left corner}{\constant{ACS_ULCORNER}}
590 \lineiii{tr}{Upper-right corner}{\constant{ACS_URCORNER}}
591 \lineiii{bl}{Bottom-left corner}{\constant{ACS_BLCORNER}}
592 \lineiii{br}{Bottom-right corner}{\constant{ACS_BRCORNER}}
593\end{tableiii}
Fred Drakea4070ce1999-06-21 21:13:09 +0000594\end{methoddesc}
595
Fred Drake0bccd731999-06-23 17:28:01 +0000596\begin{methoddesc}{box}{\optional{vertch, horch}}
597Similar to \method{border()}, but both \var{ls} and \var{rs} are
598\var{vertch} and both \var{ts} and {bs} are \var{horch}. The default
599corner characters are always used by this function.
Fred Drakea4070ce1999-06-21 21:13:09 +0000600\end{methoddesc}
601
Fred Drakea4070ce1999-06-21 21:13:09 +0000602\begin{methoddesc}{clear}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000603Like \method{erase()}, but also causes the whole window to be repainted
Fred Drakea4070ce1999-06-21 21:13:09 +0000604upon next call to \method{refresh()}.
605\end{methoddesc}
606
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000607\begin{methoddesc}{clearok}{yes}
608If \var{yes} is 1, the next call to \method{refresh()}
Eric S. Raymond68996602000-07-24 03:28:40 +0000609will clear the window completely.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000610\end{methoddesc}
611
Fred Drakea4070ce1999-06-21 21:13:09 +0000612\begin{methoddesc}{clrtobot}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000613Erase from cursor to the end of the window: all lines below the cursor
Fred Drakea4070ce1999-06-21 21:13:09 +0000614are deleted, and then the equivalent of \method{clrtoeol()} is performed.
615\end{methoddesc}
616
617\begin{methoddesc}{clrtoeol}{}
618Erase from cursor to the end of the line.
619\end{methoddesc}
620
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000621\begin{methoddesc}{cursyncup}{}
622Updates the current cursor position of all the ancestors of the window
623to reflect the current cursor position of the window.
Fred Drakea4070ce1999-06-21 21:13:09 +0000624\end{methoddesc}
625
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000626\begin{methoddesc}{delch}{\optional{x, y}}
627Delete any character at \code{(\var{y}, \var{x})}.
Fred Drakea4070ce1999-06-21 21:13:09 +0000628\end{methoddesc}
629
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000630\begin{methoddesc}{deleteln}{}
631Delete the line under the cursor. All following lines are moved up
632by 1 line.
633\end{methoddesc}
634
635\begin{methoddesc}{derwin}{\optional{nlines, ncols,} begin_y, begin_y}
636An abbreviation for ``derive window'', \method{derwin()} is the same
637as calling \method{subwin()}, except that \var{begin_y} and
638\var{begin_x} are relative to the origin of the window, rather than
639relative to the entire screen. Returns a window object for the
640derived window.
641\end{methoddesc}
642
643\begin{methoddesc}{echochar}{ch\optional{, attr}}
644Add character \var{ch} with attribute \var{attr}, and immediately
Eric S. Raymond68996602000-07-24 03:28:40 +0000645call \method{refresh} on the window.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000646\end{methoddesc}
647
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000648\begin{methoddesc}{enclose}{y, x}
649Tests whether the given pair of screen-relative character-cell
650coordinates are enclosed by the given window, returning true or
651false. It is useful for determining what subset of the screen
652windows enclose the location of a mouse event.
653\end{methoddesc}
654
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000655\begin{methoddesc}{erase}{}
656Clear the window.
657\end{methoddesc}
658
659\begin{methoddesc}{getbegyx}{}
660Return a tuple \code{(\var{y}, \var{x})} of co-ordinates of upper-left
661corner.
Fred Drakea4070ce1999-06-21 21:13:09 +0000662\end{methoddesc}
663
664\begin{methoddesc}{getch}{\optional{x, y}}
665Get a character. Note that the integer returned does \emph{not} have to
666be in \ASCII{} range: function keys, keypad keys and so on return numbers
667higher then 256. In no-delay mode, an exception is raised if there is
668no input.
669\end{methoddesc}
670
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000671\begin{methoddesc}{getkey}{\optional{x, y}}
672Get a character, returning a string instead of an integer, as
673\method{getch()} does. Function keys, keypad keys and so on return a
674multibyte string containing the key name. In no-delay mode, an
675exception is raised if there is no input.
676\end{methoddesc}
677
678\begin{methoddesc}{getmaxyx}{}
679Return a tuple \code{(\var{y}, \var{x})} of the height and width of
680the window.
681\end{methoddesc}
682
683\begin{methoddesc}{getparyx}{}
684Returns the beginning coordinates of this window relative to its
685parent window into two integer variables y and x. Returns
686\code{-1,-1} if this window has no parent.
687\end{methoddesc}
688
Fred Drakea4070ce1999-06-21 21:13:09 +0000689\begin{methoddesc}{getstr}{\optional{x, y}}
690Read a string from the user, with primitive line editing capacity.
691\end{methoddesc}
692
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000693\begin{methoddesc}{getyx}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000694Return a tuple \code{(\var{y}, \var{x})} of current cursor position
695relative to the window's upper-left corner.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000696\end{methoddesc}
697
698\begin{methoddesc}{hline}{\optional{y, x,} ch, n}
699Display a horizontal line starting at \code{(\var{y}, \var{x})} with
700length \var{n} consisting of the character \var{ch}.
701\end{methoddesc}
702
703\begin{methoddesc}{idcok}{flag}
704If \var{flag} is false, curses no longer considers using the hardware
705insert/delete character feature of the terminal; if \var{flag} is
706true, use of character insertion and deletion is enabled. When curses
707is first initialized, use of character insert/delete is enabled by
708default.
709\end{methoddesc}
710
711\begin{methoddesc}{idlok}{yes}
712If called with \var{yes} equal to 1, \module{curses} will try and use
713hardware line editing facilities. Otherwise, line insertion/deletion
714are disabled.
715\end{methoddesc}
716
717\begin{methoddesc}{immedok}{flag}
718If \var{flag} is true, any change in the window image
719automatically causes the window to be refreshed; you no longer
720have to call \method{refresh()} yourself. However, it may
721degrade performance considerably, due to repeated calls to
722wrefresh. This option is disabled by default.
723\end{methoddesc}
724
Fred Drakea4070ce1999-06-21 21:13:09 +0000725\begin{methoddesc}{inch}{\optional{x, y}}
726Return the character at the given position in the window. The bottom
7278 bits are the character proper, and upper bits are the attributes.
728\end{methoddesc}
729
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000730\begin{methoddesc}{insch}{\optional{y, x,} ch\optional{, attr}}
731Paint character \var{ch} at \code{(\var{y}, \var{x})} with attributes
732\var{attr}, moving the line from position \var{x} right by one
733character.
Fred Drakea4070ce1999-06-21 21:13:09 +0000734\end{methoddesc}
735
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000736\begin{methoddesc}{insdelln}{nlines}
737Inserts \var{nlines} lines into the specified window above the current
738line. The \var{nlines} bottom lines are lost. For negative
739\var{nlines}, delete \var{nlines} lines starting with the one under
740the cursor, and move the remaining lines up. The bottom \var{nlines}
741lines are cleared. The current cursor position remains the same.
742\end{methoddesc}
743
744\begin{methoddesc}{insertln}{}
745Insert a blank line under the cursor. All following lines are moved
746down by 1 line.
747\end{methoddesc}
748
749\begin{methoddesc}{insnstr}{\optional{y, x, } str, n \optional{, attr}}
750Insert a character string (as many characters as will fit on the line)
751before the character under the cursor, up to \var{n} characters.
752If \var{n} is zero or negative,
753the entire string is inserted.
754All characters to the right of
755the cursor are shifted right, with the the rightmost characters on the
756line being lost. The cursor position does not change (after moving to
757\var{y}, \var{x}, if specified).
758\end{methoddesc}
759
760\begin{methoddesc}{insstr}{\optional{y, x, } str \optional{, attr}}
761Insert a character string (as many characters as will fit on the line)
762before the character under the cursor. All characters to the right of
763the cursor are shifted right, with the the rightmost characters on the
764line being lost. The cursor position does not change (after moving to
765\var{y}, \var{x}, if specified).
766\end{methoddesc}
767
768\begin{methoddesc}{instr}{\optional{y, x} \optional{, n}}
769Returns a string of characters, extracted from the window starting at
770the current cursor position, or at \var{y}, \var{x} if specified.
771Attributes are stripped from the characters. If \var{n} is specified,
772\method{instr()} returns return a string at most \var{n} characters
773long (exclusive of the trailing NUL).
774\end{methoddesc}
775
776\begin{methoddesc}{is_linetouched}{\var{line}}
777Returns true if the specified line was modified since the last call to
778\method{refresh()}; otherwise returns false. Raises a
779\exception{curses.error} exception if \var{line} is not valid
780for the given window.
781\end{methoddesc}
782
783\begin{methoddesc}{is_wintouched}{}
784Returns true if the specified window was modified since the last call to
785\method{refresh()}; otherwise returns false.
786\end{methoddesc}
787
788\begin{methoddesc}{keypad}{yes}
789If \var{yes} is 1, escape sequences generated by some keys (keypad,
790function keys) will be interpreted by \module{curses}.
791If \var{yes} is 0, escape sequences will be left as is in the input
792stream.
Fred Drakea4070ce1999-06-21 21:13:09 +0000793\end{methoddesc}
794
795\begin{methoddesc}{leaveok}{yes}
Eric S. Raymond68996602000-07-24 03:28:40 +0000796If \var{yes} is 1, cursor is left where it is on update, instead of
797being at ``cursor position.'' This reduces cursor movement where
798possible. If possible the cursor will be made invisible.
Fred Drakea4070ce1999-06-21 21:13:09 +0000799
Eric S. Raymond68996602000-07-24 03:28:40 +0000800If \var{yes} is 0, cursor will always be at ``cursor position'' after
801an update.
Fred Drakea4070ce1999-06-21 21:13:09 +0000802\end{methoddesc}
803
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000804\begin{methoddesc}{move}{new_y, new_x}
805Move cursor to \code{(\var{new_y}, \var{new_x})}.
Fred Drakea4070ce1999-06-21 21:13:09 +0000806\end{methoddesc}
807
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000808\begin{methoddesc}{mvderwin}{y, x}
809Moves the window inside its parent window. The screen-relative
810parameters of the window are not changed. This routine is used to
811display different parts of the parent window at the same physical
812position on the screen.
813\end{methoddesc}
Fred Drakea4070ce1999-06-21 21:13:09 +0000814
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000815\begin{methoddesc}{mvwin}{new_y, new_x}
816Move the window so its upper-left corner is at \code{(\var{new_y}, \var{new_x})}.
Fred Drakea4070ce1999-06-21 21:13:09 +0000817\end{methoddesc}
818
819\begin{methoddesc}{nodelay}{yes}
820If \var{yes} is 1, \method{getch()} will be non-blocking.
821\end{methoddesc}
822
823\begin{methoddesc}{notimeout}{yes}
824If \var{yes} is 1, escape sequences will not be timed out.
825
826If \var{yes} is 0, after a few milliseconds, an escape sequence will
827not be interpreted, and will be left in the input stream as is.
828\end{methoddesc}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000829
830\begin{methoddesc}{noutrefresh}{}
831Mark for refresh but wait.
832\end{methoddesc}
833
834\begin{methoddesc}{putwin}{file}
835Writes all data associated with the window into the provided file
836object. This information can be later retrieved using the
837\function{getwin()} function.
838
839\end{methoddesc}
840
841\begin{methoddesc}{redrawln}{beg, num}
842Indicates that the \var{num} screen lines, starting at line \var{beg},
843are corrupted and should be completely redrawn on the next
844\method{refresh()} call.
845\end{methoddesc}
846
847\begin{methoddesc}{redrawwin}{}
848Touches the entire window, causing it to be completely redrawn on the
849next \method{refresh()} call.
850\end{methoddesc}
851
852\begin{methoddesc}{refresh}{ \optional{pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol} }
853Update the display immediately (sync actual screen with previous
854drawing/deleting methods).
855
856The 6 optional arguments can only be specified when the window is a
857pad created with \function{newpad()}. The additional parameters are
858needed to indicate what part of the pad and screen are involved.
859\var{pminrow} and \var{pmincol} specify the upper left-hand corner of the
860rectangle to be displayed in the pad. \var{sminrow}, \var{smincol},
861\var{smaxrow}, and \var{smaxcol} specify the edges of the rectangle to be displayed on the screen. The lower right-hand corner of the
862rectangle to be displayed in the pad is calculated from the screen
863coordinates, since the rectangles must be the same size. Both
864rectangles must be entirely contained within their respective
865structures. Negative values of \var{pminrow}, \var{pmincol},
866\var{sminrow}, or \var{smincol} are treated as if they were zero.
867\end{methoddesc}
868
869\begin{methoddesc}{scroll}{\optional{lines\code{ = 1}}}
870Scroll the screen upward by \var{lines} lines.
871\end{methoddesc}
872
873\begin{methoddesc}{scrollok}{flag}
874Controls what happens when the cursor of a window is moved off the
Eric S. Raymond68996602000-07-24 03:28:40 +0000875edge of the window or scrolling region, either as a result of a
876newline action on the bottom line, or typing the last character
877of the last line. If \var{flag} is false, the cursor is left
878on the bottom line. If \var{flag} is true, the window is
879scrolled up one line. Note that in order to get the physical
880scrolling effect on the terminal, it is also necessary to call
881\method{idlok()}.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000882\end{methoddesc}
883
884\begin{methoddesc}{setscrreg}{top, bottom}
885Set the scrolling region from line \var{top} to line \var{bottom}. All
886scrolling actions will take place in this region.
887\end{methoddesc}
888
889\begin{methoddesc}{standend}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000890Turn off the standout attribute. On some terminals this has the
891side effect of turning off all attributes.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000892\end{methoddesc}
893
894\begin{methoddesc}{standout}{}
895Turn on attribute \var{A_STANDOUT}.
896\end{methoddesc}
897
898\begin{methoddesc}{subpad}{\optional{nlines, ncols,} begin_y, begin_y}
899Return a sub-window, whose upper-left corner is at
900\code{(\var{begin_y}, \var{begin_x})}, and whose width/height is
901\var{ncols}/\var{nlines}.
902\end{methoddesc}
903
904\begin{methoddesc}{subwin}{\optional{nlines, ncols,} begin_y, begin_y}
905Return a sub-window, whose upper-left corner is at
906\code{(\var{begin_y}, \var{begin_x})}, and whose width/height is
907\var{ncols}/\var{nlines}.
908
909By default, the sub-window will extend from the
910specified position to the lower right corner of the window.
911\end{methoddesc}
912
913\begin{methoddesc}{syncdown}{}
914Touches each location in the window that has been touched in any of
915its ancestor windows. This routine is called by \method{refresh()},
916so it should almost never be necessary to call it manually.
917\end{methoddesc}
918
919\begin{methoddesc}{syncok}{flag}
920If called with \var{flag} set to true, then \method{syncup()} is
921called automatically whenever there is a change in the window.
922\end{methoddesc}
923
924\begin{methoddesc}{syncup}{}
925Touches all locations in ancestors of the window that have been changed in
926the window.
927\end{methoddesc}
928
Andrew M. Kuchlingd24ff442000-06-21 01:42:51 +0000929\begin{methoddesc}{timeout}{delay}
Thomas Woutersf8316632000-07-16 19:01:10 +0000930Sets blocking or non-blocking read behavior for the window. If
Andrew M. Kuchlingd24ff442000-06-21 01:42:51 +0000931\var{delay} is negative, blocking read is used, which will wait
932indefinitely for input). If \var{delay} is zero, then non-blocking
933read is used, and -1 will be returned by \method{getch()} if no input
934is waiting. If \var{delay} is positive, then \method{getch()} will
935block for \var{delay} milliseconds, and return -1 if there is still no
936input at the end of that time.
937\end{methoddesc}
938
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000939\begin{methoddesc}{touchline}{start, count}
940Pretend \var{count} lines have been changed, starting with line
941\var{start}.
942\end{methoddesc}
943
944\begin{methoddesc}{touchwin}{}
945Pretend the whole window has been changed, for purposes of drawing
946optimizations.
947\end{methoddesc}
948
949\begin{methoddesc}{untouchwin}{}
950Marks all lines in the window as unchanged since the last call to
951\method{refresh()}.
952\end{methoddesc}
953
954\begin{methoddesc}{vline}{\optional{y, x,} ch, n}
955Display a vertical line starting at \code{(\var{y}, \var{x})} with
956length \var{n} consisting of the character \var{ch}.
957\end{methoddesc}
958
959\subsection{Constants}
960
961The \module{curses} module defines the following data members:
962
963\begin{datadesc}{version}
964A string representing the current version of the module.
965Also available as \constant{__version__}.
966\end{datadesc}
967
968
969\begin{tableii}{c|l}{code}{Attribute}{Meaning}
970 \lineii{A_ALTCHARSET}{Alternate character set mode.}
971 \lineii{A_BLINK}{Blink mode.}
972 \lineii{A_BOLD}{Bold mode.}
973 \lineii{A_DIM}{Dim mode.}
974 \lineii{A_NORMAL}{Normal attribute.}
975 \lineii{A_STANDOUT}{Standout mode.}
976 \lineii{A_UNDERLINE}{Underline mode.}
977\end{tableii}
978
979Keys are referred to by integer constants with names starting with
980\code{KEY_}. The exact names available are system dependent.
981
982% XXX this table is far too large!
983% XXX should this table be alphabetized?
984
985\begin{tableii}{c|l}{code}{Key constant}{Key}
986 \lineii{KEY_MIN}{Minimum key value}
987 \lineii{KEY_BREAK}{ Break key (unreliable) }
988 \lineii{KEY_DOWN}{ Down-arrow }
989 \lineii{KEY_UP}{ Up-arrow }
990 \lineii{KEY_LEFT}{ Left-arrow }
991 \lineii{KEY_RIGHT}{ Right-arrow }
992 \lineii{KEY_HOME}{ Home key (upward+left arrow) }
993 \lineii{KEY_BACKSPACE}{ Backspace (unreliable) }
994 \lineii{KEY_F0}{ Function keys. Up to 64 function keys are supported. }
995 \lineii{KEY_F\var{n}}{ Value of function key \var{n} }
996 \lineii{KEY_DL}{ Delete line }
997 \lineii{KEY_IL}{ Insert line }
998 \lineii{KEY_DC}{ Delete character }
999 \lineii{KEY_IC}{ Insert char or enter insert mode }
1000 \lineii{KEY_EIC}{ Exit insert char mode }
1001 \lineii{KEY_CLEAR}{ Clear screen }
1002 \lineii{KEY_EOS}{ Clear to end of screen }
1003 \lineii{KEY_EOL}{ Clear to end of line }
1004 \lineii{KEY_SF}{ Scroll 1 line forward }
1005 \lineii{KEY_SR}{ Scroll 1 line backward (reverse) }
1006 \lineii{KEY_NPAGE}{ Next page }
1007 \lineii{KEY_PPAGE}{ Previous page }
1008 \lineii{KEY_STAB}{ Set tab }
1009 \lineii{KEY_CTAB}{ Clear tab }
1010 \lineii{KEY_CATAB}{ Clear all tabs }
1011 \lineii{KEY_ENTER}{ Enter or send (unreliable) }
1012 \lineii{KEY_SRESET}{ Soft (partial) reset (unreliable) }
1013 \lineii{KEY_RESET}{ Reset or hard reset (unreliable) }
1014 \lineii{KEY_PRINT}{ Print }
1015 \lineii{KEY_LL}{ Home down or bottom (lower left) }
1016 \lineii{KEY_A1}{ Upper left of keypad }
1017 \lineii{KEY_A3}{ Upper right of keypad }
1018 \lineii{KEY_B2}{ Center of keypad }
1019 \lineii{KEY_C1}{ Lower left of keypad }
1020 \lineii{KEY_C3}{ Lower right of keypad }
1021 \lineii{KEY_BTAB}{ Back tab }
1022 \lineii{KEY_BEG}{ Beg (beginning) }
1023 \lineii{KEY_CANCEL}{ Cancel }
1024 \lineii{KEY_CLOSE}{ Close }
1025 \lineii{KEY_COMMAND}{ Cmd (command) }
1026 \lineii{KEY_COPY}{ Copy }
1027 \lineii{KEY_CREATE}{ Create }
1028 \lineii{KEY_END}{ End }
1029 \lineii{KEY_EXIT}{ Exit }
1030 \lineii{KEY_FIND}{ Find }
1031 \lineii{KEY_HELP}{ Help }
1032 \lineii{KEY_MARK}{ Mark }
1033 \lineii{KEY_MESSAGE}{ Message }
1034 \lineii{KEY_MOVE}{ Move }
1035 \lineii{KEY_NEXT}{ Next }
1036 \lineii{KEY_OPEN}{ Open }
1037 \lineii{KEY_OPTIONS}{ Options }
1038 \lineii{KEY_PREVIOUS}{ Prev (previous) }
1039 \lineii{KEY_REDO}{ Redo }
1040 \lineii{KEY_REFERENCE}{ Ref (reference) }
1041 \lineii{KEY_REFRESH}{ Refresh }
1042 \lineii{KEY_REPLACE}{ Replace }
1043 \lineii{KEY_RESTART}{ Restart }
1044 \lineii{KEY_RESUME}{ Resume }
1045 \lineii{KEY_SAVE}{ Save }
1046 \lineii{KEY_SBEG}{ Shifted Beg (beginning) }
1047 \lineii{KEY_SCANCEL}{ Shifted Cancel }
1048 \lineii{KEY_SCOMMAND}{ Shifted Command }
1049 \lineii{KEY_SCOPY}{ Shifted Copy }
1050 \lineii{KEY_SCREATE}{ Shifted Create }
1051 \lineii{KEY_SDC}{ Shifted Delete char }
1052 \lineii{KEY_SDL}{ Shifted Delete line }
1053 \lineii{KEY_SELECT}{ Select }
1054 \lineii{KEY_SEND}{ Shifted End }
1055 \lineii{KEY_SEOL}{ Shifted Clear line }
1056 \lineii{KEY_SEXIT}{ Shifted Dxit }
1057 \lineii{KEY_SFIND}{ Shifted Find }
1058 \lineii{KEY_SHELP}{ Shifted Help }
1059 \lineii{KEY_SHOME}{ Shifted Home }
1060 \lineii{KEY_SIC}{ Shifted Input }
1061 \lineii{KEY_SLEFT}{ Shifted Left arrow }
1062 \lineii{KEY_SMESSAGE}{ Shifted Message }
1063 \lineii{KEY_SMOVE}{ Shifted Move }
1064 \lineii{KEY_SNEXT}{ Shifted Next }
1065 \lineii{KEY_SOPTIONS}{ Shifted Options }
1066 \lineii{KEY_SPREVIOUS}{ Shifted Prev }
1067 \lineii{KEY_SPRINT}{ Shifted Print }
1068 \lineii{KEY_SREDO}{ Shifted Redo }
1069 \lineii{KEY_SREPLACE}{ Shifted Replace }
1070 \lineii{KEY_SRIGHT}{ Shifted Right arrow }
1071 \lineii{KEY_SRSUME}{ Shifted Resume }
1072 \lineii{KEY_SSAVE}{ Shifted Save }
1073 \lineii{KEY_SSUSPEND}{ Shifted Suspend }
1074 \lineii{KEY_SUNDO}{ Shifted Undo }
1075 \lineii{KEY_SUSPEND}{ Suspend }
1076 \lineii{KEY_UNDO}{ Undo }
1077 \lineii{KEY_MOUSE}{ Mouse event has occurred }
1078 \lineii{KEY_RESIZE}{ Terminal resize event }
1079 \lineii{KEY_MAX}{Maximum key value}
1080\end{tableii}
1081
1082The following table lists characters from the alternate character set.
1083\strong{Note:} These are available only after \function{initscr()} has
1084been called.
1085
1086\begin{tableii}{c|l}{code}{ACS code}{Meaning}
1087 \lineii{ACS_BBSS}{}
Eric S. Raymond68996602000-07-24 03:28:40 +00001088 \lineii{ACS_BLOCK}{solid square block}
1089 \lineii{ACS_BOARD}{board of squares}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001090 \lineii{ACS_BSBS}{}
1091 \lineii{ACS_BSSB}{}
1092 \lineii{ACS_BSSS}{}
Eric S. Raymond68996602000-07-24 03:28:40 +00001093 \lineii{ACS_BTEE}{bottom tee}
1094 \lineii{ACS_BULLET}{bullet}
1095 \lineii{ACS_CKBOARD}{checker board (stipple)}
1096 \lineii{ACS_DARROW}{arrow pointing down}
1097 \lineii{ACS_DEGREE}{degree symbol}
1098 \lineii{ACS_DIAMOND}{diamond}
1099 \lineii{ACS_GEQUAL}{greater-than-or-equal-to}
1100 \lineii{ACS_HLINE}{horizontal line}
1101 \lineii{ACS_LANTERN}{lantern symbol}
1102 \lineii{ACS_LARROW}{left arrow}
1103 \lineii{ACS_LEQUAL}{less-than-or-equal-to}
1104 \lineii{ACS_LLCORNER}{lower left-hand corner}
1105 \lineii{ACS_LRCORNER}{lower right-hand corner}
1106 \lineii{ACS_LTEE}{left tee}
1107 \lineii{ACS_NEQUAL}{not-equal sign}
1108 \lineii{ACS_PI}{letter pi}
1109 \lineii{ACS_PLMINUS}{plus-or-minus sign}
1110 \lineii{ACS_PLUS}{plus sign}
1111 \lineii{ACS_RARROW}{right arrow}
1112 \lineii{ACS_RTEE}{right tee}
1113 \lineii{ACS_S1}{scan line 1}
1114 \lineii{ACS_S3}{scan line 3}
1115 \lineii{ACS_S7}{scan line 7}
1116 \lineii{ACS_S9}{scan line 9}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001117 \lineii{ACS_SBBS}{}
1118 \lineii{ACS_SBSB}{}
1119 \lineii{ACS_SBSS}{}
1120 \lineii{ACS_SSBB}{}
1121 \lineii{ACS_SSBS}{}
1122 \lineii{ACS_SSSB}{}
1123 \lineii{ACS_SSSS}{}
Eric S. Raymond68996602000-07-24 03:28:40 +00001124 \lineii{ACS_STERLING}{pound sterling}
1125 \lineii{ACS_TTEE}{top tee}
1126 \lineii{ACS_UARROW}{up arrow}
1127 \lineii{ACS_ULCORNER}{upper left corner}
1128 \lineii{ACS_URCORNER}{upper right corner}
1129 \lineii{ACS_VLINE}{vertical line}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001130\end{tableii}
1131
1132The following table lists the predefined colors:
1133
1134\begin{tableii}{c|l}{code}{Constant}{Color}
1135 \lineii{COLOR_BLACK}{Black}
1136 \lineii{COLOR_BLUE}{Blue}
1137 \lineii{COLOR_CYAN}{Cyan (light greenish blue)}
1138 \lineii{COLOR_GREEN}{Green}
1139 \lineii{COLOR_MAGENTA}{Magenta (purplish red)}
1140 \lineii{COLOR_RED}{Red}
1141 \lineii{COLOR_WHITE}{White}
1142 \lineii{COLOR_YELLOW}{Yellow}
1143\end{tableii}
1144