blob: d0ba2a3f1c1bb9bb0abea0bee55dde0a0e0c9d40 [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
24 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
352addch('\n') which always does the equivalent of return and line feed
353on the virtual screen). With translation off, curses can sometimes speed
354up vertical motion a little; also, it will be able to detect the
355return 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. Kuchlingd24ff442000-06-21 01:42:51 +0000441\begin{funcdesc}{typeahead}{fd}
442Specifies that the file descriptor \var{fd} be used for typeahead
443checking. If \var{fd} is -1, then no typeahead checking is done.
444
445The curses library does ``line-breakout optimization'' by looking for
446typeahead periodically while updating the screen. If input is found,
447and it is coming from a tty, the current update is postponed until
448refresh or doupdate is called again, allowing faster response to
449commands typed in advance. This function allows specifying a different
450file descriptor for typeahead checking.
451\end{funcdesc}
452
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000453\begin{funcdesc}{unctrl}{ch}
454Returns a string which is a printable representation of the character
455\var{ch}. Control characters are displayed as a caret followed by the
456character, for example as \verb|^C|. Printing characters are left as they
457are.
458\end{funcdesc}
459
460\begin{funcdesc}{ungetch}{ch}
461Push \var{ch} so the next \method{getch()} will return it.
462\strong{Note:} only one \var{ch} can be pushed before \method{getch()}
463is called.
464\end{funcdesc}
465
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000466\begin{funcdesc}{ungetmouse}{id, x, y, z, bstate}
467Push a \constant{KEY_MOUSE} event onto the input queue, associating
468the given state data with it.
469\end{funcdesc}
470
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000471\begin{funcdesc}{use_env}{flag}
472If used, this function should be called before \function{initscr} or
473newterm are called. When \var{flag} is false, the values of
474lines and columns specified in the terminfo database will be
475used, even if environment variables LINES and COLUMNS (used by
476default) are set, or if curses is running in a window (in which
477case default behavior would be to use the window size if LINES
478and COLUMNS are not set).
479\end{funcdesc}
Fred Drakea4070ce1999-06-21 21:13:09 +0000480
481\subsection{Window Objects \label{curses-window-objects}}
482
483Window objects, as returned by \function{initscr()} and
484\function{newwin()} above, have the
485following methods:
486
Fred Drakea4070ce1999-06-21 21:13:09 +0000487\begin{methoddesc}{addch}{\optional{y, x,} ch\optional{, attr}}
488\strong{Note:} A \emph{character} means a C character (i.e., an
489\ASCII{} code), rather then a Python character (a string of length 1).
490(This note is true whenever the documentation mentions a character.)
Eric S. Raymond68996602000-07-24 03:28:40 +0000491The builtin \function{ord()} is handy for conveying strings to codes.
Fred Drakea4070ce1999-06-21 21:13:09 +0000492
493Paint character \var{ch} at \code{(\var{y}, \var{x})} with attributes
494\var{attr}, overwriting any character previously painter at that
495location. By default, the character position and attributes are the
496current settings for the window object.
497\end{methoddesc}
498
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000499\begin{methoddesc}{addnstr}{\optional{y, x,} str, n\optional{, attr}}
500Paint at most \var{n} characters of the
501string \var{str} at \code{(\var{y}, \var{x})} with attributes
Fred Drake0bccd731999-06-23 17:28:01 +0000502\var{attr}, overwriting anything previously on the display.
Fred Drakea4070ce1999-06-21 21:13:09 +0000503\end{methoddesc}
504
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000505\begin{methoddesc}{addstr}{\optional{y, x,} str\optional{, attr}}
506Paint the string \var{str} at \code{(\var{y}, \var{x})} with attributes
507\var{attr}, overwriting anything previously on the display.
Fred Drakea4070ce1999-06-21 21:13:09 +0000508\end{methoddesc}
509
510\begin{methoddesc}{attroff}{attr}
Eric S. Raymond68996602000-07-24 03:28:40 +0000511Remove attribute \var{attr} from the ``background'' set applied to all
512writes to the current window.
Fred Drakea4070ce1999-06-21 21:13:09 +0000513\end{methoddesc}
514
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000515\begin{methoddesc}{attron}{attr}
Eric S. Raymond68996602000-07-24 03:28:40 +0000516Add attribute \var{attr} from the ``background'' set applied to all
517writes to the current window.
Fred Drakea4070ce1999-06-21 21:13:09 +0000518\end{methoddesc}
519
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000520\begin{methoddesc}{attrset}{attr}
Eric S. Raymond68996602000-07-24 03:28:40 +0000521Set the ``background'' set of attributes to \var{attr}. This set is
522initially 0 (no attributes).
Fred Drakea4070ce1999-06-21 21:13:09 +0000523\end{methoddesc}
524
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000525\begin{methoddesc}{bkgd}{ch\optional{, attr}}
526Sets the background property of the window to the character \var{ch},
527with attributes \var{attr}. The change is then applied to every
528character position in that window:
529\begin{itemize}
530\item The attribute of every character in the window is
531 changed to the new background attribute.
532
533\item Wherever the former background character appears,
534it is changed to the new background character.
535\end{itemize}
536
537\end{methoddesc}
538
539\begin{methoddesc}{bkgdset}{ch\optional{, attr}}
540Sets the window's background. A window's background consists of a
541character and any combination of attributes. The attribute part of
542the background is combined (OR'ed) with all non-blank characters that
543are written into the window. Both the character and attribute parts
544of the background are combined with the blank characters. The
545background becomes a property of the character and moves with the
546character through any scrolling and insert/delete line/character
547operations.
Fred Drakea4070ce1999-06-21 21:13:09 +0000548\end{methoddesc}
549
Fred Drake0bccd731999-06-23 17:28:01 +0000550\begin{methoddesc}{border}{\optional{ls\optional{, rs\optional{, ts\optional{,
551 bs\optional{, tl\optional{, tr\optional{,
552 bl\optional{, br}}}}}}}}}
553Draw a border around the edges of the window. Each parameter specifies
554the character to use for a specific part of the border; see the table
555below for more details. The characters must be specified as integers;
556using one-character strings will cause \exception{TypeError} to be
557raised.
558
559\strong{Note:} A \code{0} value for any parameter will cause the
560default character to be used for that parameter. Keyword parameters
561can \emph{not} be used. The defaults are listed in this table:
562
563\begin{tableiii}{l|l|l}{var}{Parameter}{Description}{Default value}
564 \lineiii{ls}{Left side}{\constant{ACS_VLINE}}
565 \lineiii{rs}{Right side}{\constant{ACS_VLINE}}
566 \lineiii{ts}{Top}{\constant{ACS_HLINE}}
567 \lineiii{bs}{Bottom}{\constant{ACS_HLINE}}
568 \lineiii{tl}{Upper-left corner}{\constant{ACS_ULCORNER}}
569 \lineiii{tr}{Upper-right corner}{\constant{ACS_URCORNER}}
570 \lineiii{bl}{Bottom-left corner}{\constant{ACS_BLCORNER}}
571 \lineiii{br}{Bottom-right corner}{\constant{ACS_BRCORNER}}
572\end{tableiii}
Fred Drakea4070ce1999-06-21 21:13:09 +0000573\end{methoddesc}
574
Fred Drake0bccd731999-06-23 17:28:01 +0000575\begin{methoddesc}{box}{\optional{vertch, horch}}
576Similar to \method{border()}, but both \var{ls} and \var{rs} are
577\var{vertch} and both \var{ts} and {bs} are \var{horch}. The default
578corner characters are always used by this function.
Fred Drakea4070ce1999-06-21 21:13:09 +0000579\end{methoddesc}
580
Fred Drakea4070ce1999-06-21 21:13:09 +0000581\begin{methoddesc}{clear}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000582Like \method{erase()}, but also causes the whole window to be repainted
Fred Drakea4070ce1999-06-21 21:13:09 +0000583upon next call to \method{refresh()}.
584\end{methoddesc}
585
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000586\begin{methoddesc}{clearok}{yes}
587If \var{yes} is 1, the next call to \method{refresh()}
Eric S. Raymond68996602000-07-24 03:28:40 +0000588will clear the window completely.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000589\end{methoddesc}
590
Fred Drakea4070ce1999-06-21 21:13:09 +0000591\begin{methoddesc}{clrtobot}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000592Erase from cursor to the end of the window: all lines below the cursor
Fred Drakea4070ce1999-06-21 21:13:09 +0000593are deleted, and then the equivalent of \method{clrtoeol()} is performed.
594\end{methoddesc}
595
596\begin{methoddesc}{clrtoeol}{}
597Erase from cursor to the end of the line.
598\end{methoddesc}
599
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000600\begin{methoddesc}{cursyncup}{}
601Updates the current cursor position of all the ancestors of the window
602to reflect the current cursor position of the window.
Fred Drakea4070ce1999-06-21 21:13:09 +0000603\end{methoddesc}
604
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000605\begin{methoddesc}{delch}{\optional{x, y}}
606Delete any character at \code{(\var{y}, \var{x})}.
Fred Drakea4070ce1999-06-21 21:13:09 +0000607\end{methoddesc}
608
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000609\begin{methoddesc}{deleteln}{}
610Delete the line under the cursor. All following lines are moved up
611by 1 line.
612\end{methoddesc}
613
614\begin{methoddesc}{derwin}{\optional{nlines, ncols,} begin_y, begin_y}
615An abbreviation for ``derive window'', \method{derwin()} is the same
616as calling \method{subwin()}, except that \var{begin_y} and
617\var{begin_x} are relative to the origin of the window, rather than
618relative to the entire screen. Returns a window object for the
619derived window.
620\end{methoddesc}
621
622\begin{methoddesc}{echochar}{ch\optional{, attr}}
623Add character \var{ch} with attribute \var{attr}, and immediately
Eric S. Raymond68996602000-07-24 03:28:40 +0000624call \method{refresh} on the window.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000625\end{methoddesc}
626
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000627\begin{methoddesc}{enclose}{y, x}
628Tests whether the given pair of screen-relative character-cell
629coordinates are enclosed by the given window, returning true or
630false. It is useful for determining what subset of the screen
631windows enclose the location of a mouse event.
632\end{methoddesc}
633
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000634\begin{methoddesc}{erase}{}
635Clear the window.
636\end{methoddesc}
637
638\begin{methoddesc}{getbegyx}{}
639Return a tuple \code{(\var{y}, \var{x})} of co-ordinates of upper-left
640corner.
Fred Drakea4070ce1999-06-21 21:13:09 +0000641\end{methoddesc}
642
643\begin{methoddesc}{getch}{\optional{x, y}}
644Get a character. Note that the integer returned does \emph{not} have to
645be in \ASCII{} range: function keys, keypad keys and so on return numbers
646higher then 256. In no-delay mode, an exception is raised if there is
647no input.
648\end{methoddesc}
649
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000650\begin{methoddesc}{getkey}{\optional{x, y}}
651Get a character, returning a string instead of an integer, as
652\method{getch()} does. Function keys, keypad keys and so on return a
653multibyte string containing the key name. In no-delay mode, an
654exception is raised if there is no input.
655\end{methoddesc}
656
657\begin{methoddesc}{getmaxyx}{}
658Return a tuple \code{(\var{y}, \var{x})} of the height and width of
659the window.
660\end{methoddesc}
661
662\begin{methoddesc}{getparyx}{}
663Returns the beginning coordinates of this window relative to its
664parent window into two integer variables y and x. Returns
665\code{-1,-1} if this window has no parent.
666\end{methoddesc}
667
Fred Drakea4070ce1999-06-21 21:13:09 +0000668\begin{methoddesc}{getstr}{\optional{x, y}}
669Read a string from the user, with primitive line editing capacity.
670\end{methoddesc}
671
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000672\begin{methoddesc}{getyx}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000673Return a tuple \code{(\var{y}, \var{x})} of current cursor position
674relative to the window's upper-left corner.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000675\end{methoddesc}
676
677\begin{methoddesc}{hline}{\optional{y, x,} ch, n}
678Display a horizontal line starting at \code{(\var{y}, \var{x})} with
679length \var{n} consisting of the character \var{ch}.
680\end{methoddesc}
681
682\begin{methoddesc}{idcok}{flag}
683If \var{flag} is false, curses no longer considers using the hardware
684insert/delete character feature of the terminal; if \var{flag} is
685true, use of character insertion and deletion is enabled. When curses
686is first initialized, use of character insert/delete is enabled by
687default.
688\end{methoddesc}
689
690\begin{methoddesc}{idlok}{yes}
691If called with \var{yes} equal to 1, \module{curses} will try and use
692hardware line editing facilities. Otherwise, line insertion/deletion
693are disabled.
694\end{methoddesc}
695
696\begin{methoddesc}{immedok}{flag}
697If \var{flag} is true, any change in the window image
698automatically causes the window to be refreshed; you no longer
699have to call \method{refresh()} yourself. However, it may
700degrade performance considerably, due to repeated calls to
701wrefresh. This option is disabled by default.
702\end{methoddesc}
703
Fred Drakea4070ce1999-06-21 21:13:09 +0000704\begin{methoddesc}{inch}{\optional{x, y}}
705Return the character at the given position in the window. The bottom
7068 bits are the character proper, and upper bits are the attributes.
707\end{methoddesc}
708
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000709\begin{methoddesc}{insch}{\optional{y, x,} ch\optional{, attr}}
710Paint character \var{ch} at \code{(\var{y}, \var{x})} with attributes
711\var{attr}, moving the line from position \var{x} right by one
712character.
Fred Drakea4070ce1999-06-21 21:13:09 +0000713\end{methoddesc}
714
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000715\begin{methoddesc}{insdelln}{nlines}
716Inserts \var{nlines} lines into the specified window above the current
717line. The \var{nlines} bottom lines are lost. For negative
718\var{nlines}, delete \var{nlines} lines starting with the one under
719the cursor, and move the remaining lines up. The bottom \var{nlines}
720lines are cleared. The current cursor position remains the same.
721\end{methoddesc}
722
723\begin{methoddesc}{insertln}{}
724Insert a blank line under the cursor. All following lines are moved
725down by 1 line.
726\end{methoddesc}
727
728\begin{methoddesc}{insnstr}{\optional{y, x, } str, n \optional{, attr}}
729Insert a character string (as many characters as will fit on the line)
730before the character under the cursor, up to \var{n} characters.
731If \var{n} is zero or negative,
732the entire string is inserted.
733All characters to the right of
734the cursor are shifted right, with the the rightmost characters on the
735line being lost. The cursor position does not change (after moving to
736\var{y}, \var{x}, if specified).
737\end{methoddesc}
738
739\begin{methoddesc}{insstr}{\optional{y, x, } str \optional{, attr}}
740Insert a character string (as many characters as will fit on the line)
741before the character under the cursor. All characters to the right of
742the cursor are shifted right, with the the rightmost characters on the
743line being lost. The cursor position does not change (after moving to
744\var{y}, \var{x}, if specified).
745\end{methoddesc}
746
747\begin{methoddesc}{instr}{\optional{y, x} \optional{, n}}
748Returns a string of characters, extracted from the window starting at
749the current cursor position, or at \var{y}, \var{x} if specified.
750Attributes are stripped from the characters. If \var{n} is specified,
751\method{instr()} returns return a string at most \var{n} characters
752long (exclusive of the trailing NUL).
753\end{methoddesc}
754
755\begin{methoddesc}{is_linetouched}{\var{line}}
756Returns true if the specified line was modified since the last call to
757\method{refresh()}; otherwise returns false. Raises a
758\exception{curses.error} exception if \var{line} is not valid
759for the given window.
760\end{methoddesc}
761
762\begin{methoddesc}{is_wintouched}{}
763Returns true if the specified window was modified since the last call to
764\method{refresh()}; otherwise returns false.
765\end{methoddesc}
766
767\begin{methoddesc}{keypad}{yes}
768If \var{yes} is 1, escape sequences generated by some keys (keypad,
769function keys) will be interpreted by \module{curses}.
770If \var{yes} is 0, escape sequences will be left as is in the input
771stream.
Fred Drakea4070ce1999-06-21 21:13:09 +0000772\end{methoddesc}
773
774\begin{methoddesc}{leaveok}{yes}
Eric S. Raymond68996602000-07-24 03:28:40 +0000775If \var{yes} is 1, cursor is left where it is on update, instead of
776being at ``cursor position.'' This reduces cursor movement where
777possible. If possible the cursor will be made invisible.
Fred Drakea4070ce1999-06-21 21:13:09 +0000778
Eric S. Raymond68996602000-07-24 03:28:40 +0000779If \var{yes} is 0, cursor will always be at ``cursor position'' after
780an update.
Fred Drakea4070ce1999-06-21 21:13:09 +0000781\end{methoddesc}
782
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000783\begin{methoddesc}{move}{new_y, new_x}
784Move cursor to \code{(\var{new_y}, \var{new_x})}.
Fred Drakea4070ce1999-06-21 21:13:09 +0000785\end{methoddesc}
786
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000787\begin{methoddesc}{mvderwin}{y, x}
788Moves the window inside its parent window. The screen-relative
789parameters of the window are not changed. This routine is used to
790display different parts of the parent window at the same physical
791position on the screen.
792\end{methoddesc}
Fred Drakea4070ce1999-06-21 21:13:09 +0000793
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000794\begin{methoddesc}{mvwin}{new_y, new_x}
795Move the window so its upper-left corner is at \code{(\var{new_y}, \var{new_x})}.
Fred Drakea4070ce1999-06-21 21:13:09 +0000796\end{methoddesc}
797
798\begin{methoddesc}{nodelay}{yes}
799If \var{yes} is 1, \method{getch()} will be non-blocking.
800\end{methoddesc}
801
802\begin{methoddesc}{notimeout}{yes}
803If \var{yes} is 1, escape sequences will not be timed out.
804
805If \var{yes} is 0, after a few milliseconds, an escape sequence will
806not be interpreted, and will be left in the input stream as is.
807\end{methoddesc}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000808
809\begin{methoddesc}{noutrefresh}{}
810Mark for refresh but wait.
811\end{methoddesc}
812
813\begin{methoddesc}{putwin}{file}
814Writes all data associated with the window into the provided file
815object. This information can be later retrieved using the
816\function{getwin()} function.
817
818\end{methoddesc}
819
820\begin{methoddesc}{redrawln}{beg, num}
821Indicates that the \var{num} screen lines, starting at line \var{beg},
822are corrupted and should be completely redrawn on the next
823\method{refresh()} call.
824\end{methoddesc}
825
826\begin{methoddesc}{redrawwin}{}
827Touches the entire window, causing it to be completely redrawn on the
828next \method{refresh()} call.
829\end{methoddesc}
830
831\begin{methoddesc}{refresh}{ \optional{pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol} }
832Update the display immediately (sync actual screen with previous
833drawing/deleting methods).
834
835The 6 optional arguments can only be specified when the window is a
836pad created with \function{newpad()}. The additional parameters are
837needed to indicate what part of the pad and screen are involved.
838\var{pminrow} and \var{pmincol} specify the upper left-hand corner of the
839rectangle to be displayed in the pad. \var{sminrow}, \var{smincol},
840\var{smaxrow}, and \var{smaxcol} specify the edges of the rectangle to be displayed on the screen. The lower right-hand corner of the
841rectangle to be displayed in the pad is calculated from the screen
842coordinates, since the rectangles must be the same size. Both
843rectangles must be entirely contained within their respective
844structures. Negative values of \var{pminrow}, \var{pmincol},
845\var{sminrow}, or \var{smincol} are treated as if they were zero.
846\end{methoddesc}
847
848\begin{methoddesc}{scroll}{\optional{lines\code{ = 1}}}
849Scroll the screen upward by \var{lines} lines.
850\end{methoddesc}
851
852\begin{methoddesc}{scrollok}{flag}
853Controls what happens when the cursor of a window is moved off the
Eric S. Raymond68996602000-07-24 03:28:40 +0000854edge of the window or scrolling region, either as a result of a
855newline action on the bottom line, or typing the last character
856of the last line. If \var{flag} is false, the cursor is left
857on the bottom line. If \var{flag} is true, the window is
858scrolled up one line. Note that in order to get the physical
859scrolling effect on the terminal, it is also necessary to call
860\method{idlok()}.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000861\end{methoddesc}
862
863\begin{methoddesc}{setscrreg}{top, bottom}
864Set the scrolling region from line \var{top} to line \var{bottom}. All
865scrolling actions will take place in this region.
866\end{methoddesc}
867
868\begin{methoddesc}{standend}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000869Turn off the standout attribute. On some terminals this has the
870side effect of turning off all attributes.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000871\end{methoddesc}
872
873\begin{methoddesc}{standout}{}
874Turn on attribute \var{A_STANDOUT}.
875\end{methoddesc}
876
877\begin{methoddesc}{subpad}{\optional{nlines, ncols,} begin_y, begin_y}
878Return a sub-window, whose upper-left corner is at
879\code{(\var{begin_y}, \var{begin_x})}, and whose width/height is
880\var{ncols}/\var{nlines}.
881\end{methoddesc}
882
883\begin{methoddesc}{subwin}{\optional{nlines, ncols,} begin_y, begin_y}
884Return a sub-window, whose upper-left corner is at
885\code{(\var{begin_y}, \var{begin_x})}, and whose width/height is
886\var{ncols}/\var{nlines}.
887
888By default, the sub-window will extend from the
889specified position to the lower right corner of the window.
890\end{methoddesc}
891
892\begin{methoddesc}{syncdown}{}
893Touches each location in the window that has been touched in any of
894its ancestor windows. This routine is called by \method{refresh()},
895so it should almost never be necessary to call it manually.
896\end{methoddesc}
897
898\begin{methoddesc}{syncok}{flag}
899If called with \var{flag} set to true, then \method{syncup()} is
900called automatically whenever there is a change in the window.
901\end{methoddesc}
902
903\begin{methoddesc}{syncup}{}
904Touches all locations in ancestors of the window that have been changed in
905the window.
906\end{methoddesc}
907
Andrew M. Kuchlingd24ff442000-06-21 01:42:51 +0000908\begin{methoddesc}{timeout}{delay}
Thomas Woutersf8316632000-07-16 19:01:10 +0000909Sets blocking or non-blocking read behavior for the window. If
Andrew M. Kuchlingd24ff442000-06-21 01:42:51 +0000910\var{delay} is negative, blocking read is used, which will wait
911indefinitely for input). If \var{delay} is zero, then non-blocking
912read is used, and -1 will be returned by \method{getch()} if no input
913is waiting. If \var{delay} is positive, then \method{getch()} will
914block for \var{delay} milliseconds, and return -1 if there is still no
915input at the end of that time.
916\end{methoddesc}
917
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000918\begin{methoddesc}{touchline}{start, count}
919Pretend \var{count} lines have been changed, starting with line
920\var{start}.
921\end{methoddesc}
922
923\begin{methoddesc}{touchwin}{}
924Pretend the whole window has been changed, for purposes of drawing
925optimizations.
926\end{methoddesc}
927
928\begin{methoddesc}{untouchwin}{}
929Marks all lines in the window as unchanged since the last call to
930\method{refresh()}.
931\end{methoddesc}
932
933\begin{methoddesc}{vline}{\optional{y, x,} ch, n}
934Display a vertical line starting at \code{(\var{y}, \var{x})} with
935length \var{n} consisting of the character \var{ch}.
936\end{methoddesc}
937
938\subsection{Constants}
939
940The \module{curses} module defines the following data members:
941
942\begin{datadesc}{version}
943A string representing the current version of the module.
944Also available as \constant{__version__}.
945\end{datadesc}
946
947
948\begin{tableii}{c|l}{code}{Attribute}{Meaning}
949 \lineii{A_ALTCHARSET}{Alternate character set mode.}
950 \lineii{A_BLINK}{Blink mode.}
951 \lineii{A_BOLD}{Bold mode.}
952 \lineii{A_DIM}{Dim mode.}
953 \lineii{A_NORMAL}{Normal attribute.}
954 \lineii{A_STANDOUT}{Standout mode.}
955 \lineii{A_UNDERLINE}{Underline mode.}
956\end{tableii}
957
958Keys are referred to by integer constants with names starting with
959\code{KEY_}. The exact names available are system dependent.
960
961% XXX this table is far too large!
962% XXX should this table be alphabetized?
963
964\begin{tableii}{c|l}{code}{Key constant}{Key}
965 \lineii{KEY_MIN}{Minimum key value}
966 \lineii{KEY_BREAK}{ Break key (unreliable) }
967 \lineii{KEY_DOWN}{ Down-arrow }
968 \lineii{KEY_UP}{ Up-arrow }
969 \lineii{KEY_LEFT}{ Left-arrow }
970 \lineii{KEY_RIGHT}{ Right-arrow }
971 \lineii{KEY_HOME}{ Home key (upward+left arrow) }
972 \lineii{KEY_BACKSPACE}{ Backspace (unreliable) }
973 \lineii{KEY_F0}{ Function keys. Up to 64 function keys are supported. }
974 \lineii{KEY_F\var{n}}{ Value of function key \var{n} }
975 \lineii{KEY_DL}{ Delete line }
976 \lineii{KEY_IL}{ Insert line }
977 \lineii{KEY_DC}{ Delete character }
978 \lineii{KEY_IC}{ Insert char or enter insert mode }
979 \lineii{KEY_EIC}{ Exit insert char mode }
980 \lineii{KEY_CLEAR}{ Clear screen }
981 \lineii{KEY_EOS}{ Clear to end of screen }
982 \lineii{KEY_EOL}{ Clear to end of line }
983 \lineii{KEY_SF}{ Scroll 1 line forward }
984 \lineii{KEY_SR}{ Scroll 1 line backward (reverse) }
985 \lineii{KEY_NPAGE}{ Next page }
986 \lineii{KEY_PPAGE}{ Previous page }
987 \lineii{KEY_STAB}{ Set tab }
988 \lineii{KEY_CTAB}{ Clear tab }
989 \lineii{KEY_CATAB}{ Clear all tabs }
990 \lineii{KEY_ENTER}{ Enter or send (unreliable) }
991 \lineii{KEY_SRESET}{ Soft (partial) reset (unreliable) }
992 \lineii{KEY_RESET}{ Reset or hard reset (unreliable) }
993 \lineii{KEY_PRINT}{ Print }
994 \lineii{KEY_LL}{ Home down or bottom (lower left) }
995 \lineii{KEY_A1}{ Upper left of keypad }
996 \lineii{KEY_A3}{ Upper right of keypad }
997 \lineii{KEY_B2}{ Center of keypad }
998 \lineii{KEY_C1}{ Lower left of keypad }
999 \lineii{KEY_C3}{ Lower right of keypad }
1000 \lineii{KEY_BTAB}{ Back tab }
1001 \lineii{KEY_BEG}{ Beg (beginning) }
1002 \lineii{KEY_CANCEL}{ Cancel }
1003 \lineii{KEY_CLOSE}{ Close }
1004 \lineii{KEY_COMMAND}{ Cmd (command) }
1005 \lineii{KEY_COPY}{ Copy }
1006 \lineii{KEY_CREATE}{ Create }
1007 \lineii{KEY_END}{ End }
1008 \lineii{KEY_EXIT}{ Exit }
1009 \lineii{KEY_FIND}{ Find }
1010 \lineii{KEY_HELP}{ Help }
1011 \lineii{KEY_MARK}{ Mark }
1012 \lineii{KEY_MESSAGE}{ Message }
1013 \lineii{KEY_MOVE}{ Move }
1014 \lineii{KEY_NEXT}{ Next }
1015 \lineii{KEY_OPEN}{ Open }
1016 \lineii{KEY_OPTIONS}{ Options }
1017 \lineii{KEY_PREVIOUS}{ Prev (previous) }
1018 \lineii{KEY_REDO}{ Redo }
1019 \lineii{KEY_REFERENCE}{ Ref (reference) }
1020 \lineii{KEY_REFRESH}{ Refresh }
1021 \lineii{KEY_REPLACE}{ Replace }
1022 \lineii{KEY_RESTART}{ Restart }
1023 \lineii{KEY_RESUME}{ Resume }
1024 \lineii{KEY_SAVE}{ Save }
1025 \lineii{KEY_SBEG}{ Shifted Beg (beginning) }
1026 \lineii{KEY_SCANCEL}{ Shifted Cancel }
1027 \lineii{KEY_SCOMMAND}{ Shifted Command }
1028 \lineii{KEY_SCOPY}{ Shifted Copy }
1029 \lineii{KEY_SCREATE}{ Shifted Create }
1030 \lineii{KEY_SDC}{ Shifted Delete char }
1031 \lineii{KEY_SDL}{ Shifted Delete line }
1032 \lineii{KEY_SELECT}{ Select }
1033 \lineii{KEY_SEND}{ Shifted End }
1034 \lineii{KEY_SEOL}{ Shifted Clear line }
1035 \lineii{KEY_SEXIT}{ Shifted Dxit }
1036 \lineii{KEY_SFIND}{ Shifted Find }
1037 \lineii{KEY_SHELP}{ Shifted Help }
1038 \lineii{KEY_SHOME}{ Shifted Home }
1039 \lineii{KEY_SIC}{ Shifted Input }
1040 \lineii{KEY_SLEFT}{ Shifted Left arrow }
1041 \lineii{KEY_SMESSAGE}{ Shifted Message }
1042 \lineii{KEY_SMOVE}{ Shifted Move }
1043 \lineii{KEY_SNEXT}{ Shifted Next }
1044 \lineii{KEY_SOPTIONS}{ Shifted Options }
1045 \lineii{KEY_SPREVIOUS}{ Shifted Prev }
1046 \lineii{KEY_SPRINT}{ Shifted Print }
1047 \lineii{KEY_SREDO}{ Shifted Redo }
1048 \lineii{KEY_SREPLACE}{ Shifted Replace }
1049 \lineii{KEY_SRIGHT}{ Shifted Right arrow }
1050 \lineii{KEY_SRSUME}{ Shifted Resume }
1051 \lineii{KEY_SSAVE}{ Shifted Save }
1052 \lineii{KEY_SSUSPEND}{ Shifted Suspend }
1053 \lineii{KEY_SUNDO}{ Shifted Undo }
1054 \lineii{KEY_SUSPEND}{ Suspend }
1055 \lineii{KEY_UNDO}{ Undo }
1056 \lineii{KEY_MOUSE}{ Mouse event has occurred }
1057 \lineii{KEY_RESIZE}{ Terminal resize event }
1058 \lineii{KEY_MAX}{Maximum key value}
1059\end{tableii}
1060
1061The following table lists characters from the alternate character set.
1062\strong{Note:} These are available only after \function{initscr()} has
1063been called.
1064
1065\begin{tableii}{c|l}{code}{ACS code}{Meaning}
1066 \lineii{ACS_BBSS}{}
Eric S. Raymond68996602000-07-24 03:28:40 +00001067 \lineii{ACS_BLOCK}{solid square block}
1068 \lineii{ACS_BOARD}{board of squares}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001069 \lineii{ACS_BSBS}{}
1070 \lineii{ACS_BSSB}{}
1071 \lineii{ACS_BSSS}{}
Eric S. Raymond68996602000-07-24 03:28:40 +00001072 \lineii{ACS_BTEE}{bottom tee}
1073 \lineii{ACS_BULLET}{bullet}
1074 \lineii{ACS_CKBOARD}{checker board (stipple)}
1075 \lineii{ACS_DARROW}{arrow pointing down}
1076 \lineii{ACS_DEGREE}{degree symbol}
1077 \lineii{ACS_DIAMOND}{diamond}
1078 \lineii{ACS_GEQUAL}{greater-than-or-equal-to}
1079 \lineii{ACS_HLINE}{horizontal line}
1080 \lineii{ACS_LANTERN}{lantern symbol}
1081 \lineii{ACS_LARROW}{left arrow}
1082 \lineii{ACS_LEQUAL}{less-than-or-equal-to}
1083 \lineii{ACS_LLCORNER}{lower left-hand corner}
1084 \lineii{ACS_LRCORNER}{lower right-hand corner}
1085 \lineii{ACS_LTEE}{left tee}
1086 \lineii{ACS_NEQUAL}{not-equal sign}
1087 \lineii{ACS_PI}{letter pi}
1088 \lineii{ACS_PLMINUS}{plus-or-minus sign}
1089 \lineii{ACS_PLUS}{plus sign}
1090 \lineii{ACS_RARROW}{right arrow}
1091 \lineii{ACS_RTEE}{right tee}
1092 \lineii{ACS_S1}{scan line 1}
1093 \lineii{ACS_S3}{scan line 3}
1094 \lineii{ACS_S7}{scan line 7}
1095 \lineii{ACS_S9}{scan line 9}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001096 \lineii{ACS_SBBS}{}
1097 \lineii{ACS_SBSB}{}
1098 \lineii{ACS_SBSS}{}
1099 \lineii{ACS_SSBB}{}
1100 \lineii{ACS_SSBS}{}
1101 \lineii{ACS_SSSB}{}
1102 \lineii{ACS_SSSS}{}
Eric S. Raymond68996602000-07-24 03:28:40 +00001103 \lineii{ACS_STERLING}{pound sterling}
1104 \lineii{ACS_TTEE}{top tee}
1105 \lineii{ACS_UARROW}{up arrow}
1106 \lineii{ACS_ULCORNER}{upper left corner}
1107 \lineii{ACS_URCORNER}{upper right corner}
1108 \lineii{ACS_VLINE}{vertical line}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001109\end{tableii}
1110
1111The following table lists the predefined colors:
1112
1113\begin{tableii}{c|l}{code}{Constant}{Color}
1114 \lineii{COLOR_BLACK}{Black}
1115 \lineii{COLOR_BLUE}{Blue}
1116 \lineii{COLOR_CYAN}{Cyan (light greenish blue)}
1117 \lineii{COLOR_GREEN}{Green}
1118 \lineii{COLOR_MAGENTA}{Magenta (purplish red)}
1119 \lineii{COLOR_RED}{Red}
1120 \lineii{COLOR_WHITE}{White}
1121 \lineii{COLOR_YELLOW}{Yellow}
1122\end{tableii}
1123