blob: e3e94ad1fda53e690c5df306ee1600f6afe245a7 [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
Eric S. Raymond5a007692000-08-04 07:35:41 +00004\declaremodule{standard}{curses}
Fred Drakea4070ce1999-06-21 21:13:09 +00005\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.}
Fred Drake2e06c202000-10-06 20:01:23 +00008
9\versionchanged[Added support for the \code{ncurses} library and
10 converted to a package]{1.6}
Fred Drakea4070ce1999-06-21 21:13:09 +000011
Fred Draked79c33a2000-09-25 14:14:30 +000012The \module{curses} module provides an interface to the curses
Fred Drakea4070ce1999-06-21 21:13:09 +000013library, the de-facto standard for portable advanced terminal
14handling.
15
16While curses is most widely used in the \UNIX{} environment, versions
Eric S. Raymond68996602000-07-24 03:28:40 +000017are available for DOS, OS/2, and possibly other systems as well. This
18extension module is designed to match the API of ncurses, an
19open-source curses library hosted on Linux and the BSD variants of
Fred Draked79c33a2000-09-25 14:14:30 +000020\UNIX.
Fred Drakea4070ce1999-06-21 21:13:09 +000021
22\begin{seealso}
Fred Drake5c529d32000-06-28 22:11:40 +000023 \seemodule{curses.ascii}{Utilities for working with \ASCII{}
24 characters, regardless of your locale
25 settings.}
Eric S. Raymond5a007692000-08-04 07:35:41 +000026 \seemodule{curses.textpad}{Editable text widget for curses supporting
Fred Drakeec4b2af2000-08-09 14:34:48 +000027 \program{Emacs}-like bindings.}
28 \seemodule{curses.wrapper}{Convenience function to ensure proper
29 terminal setup and resetting on
30 application entry and exit.}
Fred Draked79c33a2000-09-25 14:14:30 +000031 \seetitle[http://www.python.org/doc/howto/curses/curses.html]{Curses
32 Programming with Python}{Tutorial material on using curses
33 with Python, by Andrew Kuchling, is available on the
34 Python Web site.}
Fred Drakea4070ce1999-06-21 21:13:09 +000035\end{seealso}
36
37
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000038\subsection{Functions \label{curses-functions}}
Fred Drakea4070ce1999-06-21 21:13:09 +000039
40The module \module{curses} defines the following exception:
Fred Drakeec4b2af2000-08-09 14:34:48 +000041
Fred Drakea4070ce1999-06-21 21:13:09 +000042\begin{excdesc}{error}
Fred Drakeec4b2af2000-08-09 14:34:48 +000043Exception raised when a curses library function returns an error.
Fred Drakea4070ce1999-06-21 21:13:09 +000044\end{excdesc}
45
Fred Drake0bccd731999-06-23 17:28:01 +000046\strong{Note:} Whenever \var{x} or \var{y} arguments to a function
47or a method are optional, they default to the current cursor location.
48Whenever \var{attr} is optional, it defaults to \constant{A_NORMAL}.
49
Fred Drakea4070ce1999-06-21 21:13:09 +000050The module \module{curses} defines the following functions:
51
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000052\begin{funcdesc}{baudrate}{}
Eric S. Raymond68996602000-07-24 03:28:40 +000053Returns the output speed of the terminal in bits per second. On
54software terminal emulators it will have a fixed high value.
55Included for historical reasons; in former times, it was used to
56write output loops for time delays and occasionally to change
57interfaces depending on the line speed.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000058\end{funcdesc}
59
60\begin{funcdesc}{beep}{}
Eric S. Raymond68996602000-07-24 03:28:40 +000061Emit a short attention sound.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000062\end{funcdesc}
63
64\begin{funcdesc}{can_change_color}{}
65Returns true or false, depending on whether the programmer can change
66the colors displayed by the terminal.
67\end{funcdesc}
68
69\begin{funcdesc}{cbreak}{}
Eric S. Raymond68996602000-07-24 03:28:40 +000070Enter cbreak mode. In cbreak mode (sometimes called ``rare'' mode)
71normal tty line buffering is turned off and characters are available
72to be read one by one. However, unlike raw mode, special characters
73(interrupt, quit, suspend, and flow control) retain their effects on
74the tty driver and calling program. Calling first \function{raw()}
75then \function{cbreak()} leaves the terminal in cbreak mode.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000076\end{funcdesc}
77
78\begin{funcdesc}{color_content}{color_number}
79Returns the intensity of the red, green, and blue (RGB) components in
80the color \var{color_number}, which must be between 0 and COLORS. A
813-tuple is returned, containing the R,G,B values for the given color,
82which will be between 0 (no component) and 1000 (maximum amount of
83component).
84\end{funcdesc}
85
86\begin{funcdesc}{color_pair}{color_number}
87Returns the attribute value for displaying text in the specified
88color. This attribute value can be combined with
89\constant{A_STANDOUT}, \constant{A_REVERSE}, and the other
90\constant{A_*} attributes. \function{pair_number()} is the counterpart to this function.
91\end{funcdesc}
92
93\begin{funcdesc}{curs_set}{visibility}
94Sets the cursor state. \var{visibility} can be set to 0, 1, or 2, for
95invisible, normal, or very visible. If the terminal supports the
96visibility requested, the previous cursor state is returned;
Eric S. Raymond68996602000-07-24 03:28:40 +000097otherwise, an exception is raised. On many terminals, the ``visible''
98mode is an underline cursor and the ``very visible'' mode is a block cursor.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000099\end{funcdesc}
100
101\begin{funcdesc}{def_prog_mode}{}
102Saves the current terminal mode as the ``program'' mode, the mode when
103the running program is using curses. (Its counterpart is the
104``shell'' mode, for when the program is not in curses.) Subsequent calls
105to \function{reset_prog_mode()} will restore this mode.
106\end{funcdesc}
107
108\begin{funcdesc}{def_shell_mode}{}
109Saves the current terminal mode as the ``shell'' mode, the mode when
110the running program is not using curses. (Its counterpart is the
111``program'' mode, when the program is using curses capabilities.)
112Subsequent calls
113to \function{reset_shell_mode()} will restore this mode.
114\end{funcdesc}
115
116\begin{funcdesc}{delay_output}{ms}
117Inserts an \var{ms} millisecond pause in output.
118\end{funcdesc}
119
120\begin{funcdesc}{doupdate}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000121Update the physical screen. The curses library keeps two data
122structures, one representing the current physical screen contents
123and a virtual screen representing the desired next state. The
124\function{doupdate()} ground updates the physical screen to match the
125virtual screen.
126
127The virtual screen may be updated by a \method{noutrefresh()} call
128after write operations such as \method{addstr()} have been performed
129on a window. The normal \method{refresh()} call is simply
130\method{noutrefresh()} followed by \function{doupdate()}; if you have
131to update multiple windows, you can speed performance and perhaps
132reduce screen flicker by issuing \method{noutrefresh()} calls on
133all windows, followed by a single \function{doupdate()}.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000134\end{funcdesc}
135
136\begin{funcdesc}{echo}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000137Enter echo mode. In echo mode, each character input is echoed to the
138screen as it is entered.
Fred Drakea4070ce1999-06-21 21:13:09 +0000139\end{funcdesc}
140
141\begin{funcdesc}{endwin}{}
142De-initialize the library, and return terminal to normal status.
143\end{funcdesc}
144
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000145\begin{funcdesc}{erasechar}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000146Returns the user's current erase character. Under Unix operating
147systems this is a property of the controlling tty of the curses
148program, and is not set by the curses library itself.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000149\end{funcdesc}
150
151\begin{funcdesc}{filter}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000152The \function{filter()} routine, if used, must be called before
153\function{initscr()} is called. The effect is that, during those
154calls, LINES is set to 1; the capabilities clear, cup, cud, cud1,
155cuu1, cuu, vpa are disabled; and the home string is set to the value of cr.
156The effect is that the cursor is confined to the current line, and so
157are screen updates. This may be used for enabling cgaracter-at-a-time
158line editing without touching the rest of the screen.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000159\end{funcdesc}
160
161\begin{funcdesc}{flash}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000162Flash the screen. That is, change it to reverse-video and then change
163it back in a short interval. Some people prefer such as `visible bell'
164to the audible attention signal produced by \function{beep()}.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000165\end{funcdesc}
166
167\begin{funcdesc}{flushinp}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000168Flush all input buffers. This throws away any typeahead that has
169been typed by the user and has not yet been processed by the program.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000170\end{funcdesc}
171
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000172\begin{funcdesc}{getmouse}{}
173After \method{getch()} returns \constant{KEY_MOUSE} to signal a mouse
174event, this method should be call to retrieve the queued mouse event,
175represented as a 5-tuple
176\code{(\var{id}, \var{x}, \var{y}, \var{z}, \var{bstate})}.
177\var{id} is an ID value used to distinguish multiple devices,
178and \var{x}, \var{y}, \var{z} are the event's coordinates. (\var{z}
179is currently unused.). \var{bstate} is an integer value whose bits
180will be set to indicate the type of event, and will be the bitwise OR
181of one or more of the following constants, where \var{n} is the button
182number from 1 to 4:
183\constant{BUTTON\var{n}_PRESSED},
184\constant{BUTTON\var{n}_RELEASED},
185\constant{BUTTON\var{n}_CLICKED},
186\constant{BUTTON\var{n}_DOUBLE_CLICKED},
187\constant{BUTTON\var{n}_TRIPLE_CLICKED},
188\constant{BUTTON_SHIFT},
189\constant{BUTTON_CTRL},
190\constant{BUTTON_ALT}.
191\end{funcdesc}
192
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000193\begin{funcdesc}{getsyx}{}
194Returns the current coordinates of the virtual screen cursor in y and
195x. If leaveok is currently true, then -1,-1 is returned.
196\end{funcdesc}
197
198\begin{funcdesc}{getwin}{file}
199Reads window related data stored in the file by an earlier
200\function{putwin()} call. The routine then creates and initializes a
201new window using that data, returning the new window object.
202\end{funcdesc}
203
204\begin{funcdesc}{has_colors}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000205Returns true if the terminal can display colors; otherwise, it
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000206returns false.
207\end{funcdesc}
208
209\begin{funcdesc}{has_ic}{}
210Returns true if the terminal has insert- and delete- character
Eric S. Raymond68996602000-07-24 03:28:40 +0000211capabilities. This function is included for historical reasons only,
212as all modern software terminal emulators have such capabilities.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000213\end{funcdesc}
214
215\begin{funcdesc}{has_il}{}
216Returns true if the terminal has insert- and
217delete-line capabilities, or can simulate them using
Eric S. Raymond68996602000-07-24 03:28:40 +0000218scrolling regions. This function is included for historical reasons only,
219as all modern software terminal emulators have such capabilities.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000220\end{funcdesc}
221
222\begin{funcdesc}{has_key}{ch}
223Takes a key value \var{ch}, and returns true if the current terminal
224type recognizes a key with that value.
225\end{funcdesc}
226
227\begin{funcdesc}{halfdelay}{tenths}
228Used for half-delay mode, which is similar to cbreak mode in that
229characters typed by the user are immediately available to the program.
230However, after blocking for \var{tenths} tenths of seconds, an
231exception is raised if nothing has been typed. The value of
Eric S. Raymond68996602000-07-24 03:28:40 +0000232\var{tenths} must be a number between 1 and 255. Use \function{nocbreak()} to
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000233leave half-delay mode.
234\end{funcdesc}
235
236\begin{funcdesc}{init_color}{color_number, r, g, b}
237Changes the definition of a color, taking the number of the color to
238be changed followed by three RGB values (for the amounts of red,
239green, and blue components). The value of \var{color_number} must be
240between 0 and COLORS. Each of \var{r}, \var{g}, \var{b}, must be a
241value between 0 and 1000. When \function{init_color()} is used, all
242occurrences of that color on the screen immediately change to the new
Eric S. Raymond68996602000-07-24 03:28:40 +0000243definition. This function is a no-op on most terminals; it is active
244only if \function{can_change_color()} returns 1.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000245\end{funcdesc}
246
247\begin{funcdesc}{init_pair}{pair_number, fg, bg}
248Changes the definition of a color-pair. It takes three arguments: the
249number of the color-pair to be changed, the foreground color number,
250and the background color number. The value of \var{pair_number} must
251be between 1 and COLOR_PAIRS-1 (the 0 color pair is wired to white on
252black and cannot be changed). The value of \var{fg} and \var{bg}
253arguments must be between 0 and COLORS. If the color-pair was
254previously initialized, the screen is refreshed and all occurrences of
255that color-pair are changed to the new definition.
256\end{funcdesc}
257
258\begin{funcdesc}{initscr}{}
259Initialize the library. Returns a \class{WindowObject} which represents
260the whole screen.
261\end{funcdesc}
262
Fred Drakea4070ce1999-06-21 21:13:09 +0000263\begin{funcdesc}{isendwin}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000264Returns true if \function{endwin()} has been called (that is, the
265curses library has been deinitialized).
Fred Drakea4070ce1999-06-21 21:13:09 +0000266\end{funcdesc}
267
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000268\begin{funcdesc}{keyname}{k}
Eric S. Raymond68996602000-07-24 03:28:40 +0000269Return the name of the key numbered \var{k}. The name of a key
270generating printable ASCII character is the key's character. The name
271of a control-key combination is a two-character string consisting of a
272caret followed by the corresponding printable ASCII character. The
273name of an alt-key combination (128-255) is a string consisting of the
274prefix `M-' followed by the name of the corresponding ASCII character.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000275\end{funcdesc}
276
277\begin{funcdesc}{killchar}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000278Returns the user's current line kill character. Under Unix operating
279systems this is a property of the controlling tty of the curses
280program, and is not set by the curses library itself.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000281\end{funcdesc}
282
283\begin{funcdesc}{longname}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000284Returns a string containing the terminfo long name field describing the current
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000285terminal. The maximum length of a verbose description is 128
286characters. It is defined only after the call to
287\function{initscr()}.
288\end{funcdesc}
289
290\begin{funcdesc}{meta}{yes}
Eric S. Raymond68996602000-07-24 03:28:40 +0000291If \var{yes} is 1, allow 8-bit characters to be input. If \var{yes} is 0,
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000292allow only 7-bit chars.
293\end{funcdesc}
294
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000295\begin{funcdesc}{mouseinterval}{interval}
Thomas Woutersf8316632000-07-16 19:01:10 +0000296Sets the maximum time in milliseconds that can elapse between press and
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000297release events in order for them to be recognized as a click, and
298returns the previous interval value. The default value is 200 msec,
299or one fifth of a second.
300\end{funcdesc}
301
302\begin{funcdesc}{mousemask}{mousemask}
303Sets the mouse events to be reported, and returns a tuple
304\code{(\var{availmask}, \var{oldmask})}.
305\var{availmask} indicates which of the
306specified mouse events can be reported; on complete failure it returns
3070. \var{oldmask} is the previous value of the given window's mouse
308event mask. If this function is never called, no mouse events are
309ever reported.
310\end{funcdesc}
311
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000312\begin{funcdesc}{newpad}{nlines, ncols}
313Creates and returns a pointer to a new pad data structure with the
314given number of lines and columns. A pad is returned as a
315window object.
316
Eric S. Raymond68996602000-07-24 03:28:40 +0000317A pad is like a window, except that it is not restricted by the screen
318size, and is not necessarily associated with a particular part of the
319screen. Pads can be used when a large window is needed, and only a
320part of the window will be on the screen at one time. Automatic
321refreshes of pads (e.g., from scrolling or echoing of input) do not
322occur. The \method{refresh()} and \method{noutrefresh()} methods of a
323pad require 6 arguments to specify the part of the pad to be
324displayed and the location on the screen to be used for the display.
325The arguments are pminrow, pmincol, sminrow, smincol, smaxrow,
326smaxcol; the p arguments refer to the upper left corner of the the pad
327region to be displayed and the s arguments define a clipping box on
328the screen within which the pad region is to be displayed.
Fred Drakea4070ce1999-06-21 21:13:09 +0000329\end{funcdesc}
330
331\begin{funcdesc}{newwin}{\optional{nlines, ncols,} begin_y, begin_x}
332Return a new window, whose left-upper corner is at
333\code{(\var{begin_y}, \var{begin_x})}, and whose height/width is
Fred Drake0bccd731999-06-23 17:28:01 +0000334\var{nlines}/\var{ncols}.
335
336By default, the window will extend from the
Fred Drakea4070ce1999-06-21 21:13:09 +0000337specified position to the lower right corner of the screen.
338\end{funcdesc}
339
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000340\begin{funcdesc}{nl}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000341Enter newline mode. This mode translates the return key into newline
342on input, and translates newline into return and line-feed on output.
343Newline mode is initially on.
Fred Drakea4070ce1999-06-21 21:13:09 +0000344\end{funcdesc}
345
346\begin{funcdesc}{nocbreak}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000347Leave cbreak mode. Return to normal ``cooked'' mode with line buffering.
Fred Drakea4070ce1999-06-21 21:13:09 +0000348\end{funcdesc}
349
Fred Drakea4070ce1999-06-21 21:13:09 +0000350\begin{funcdesc}{noecho}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000351Leave echo mode. Echoing of input characters is turned off,
Fred Drakea4070ce1999-06-21 21:13:09 +0000352\end{funcdesc}
353
Fred Drakea4070ce1999-06-21 21:13:09 +0000354\begin{funcdesc}{nonl}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000355Leave newline mode. Disable translation of return into newline on
356input, and disable low-level translation of newline into
357newline/return on output (but this does not change the behavior of
Fred Drakee1b304d2000-07-24 19:35:52 +0000358\code{addch('\e n')}, which always does the equivalent of return and
359line feed on the virtual screen). With translation off, curses can
360sometimes speed up vertical motion a little; also, it will be able to
361detect the return key on input.
Fred Drakea4070ce1999-06-21 21:13:09 +0000362\end{funcdesc}
363
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000364\begin{funcdesc}{noqiflush}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000365When the noqiflush routine is used, normal flush of input and
366output queues associated with the INTR, QUIT and SUSP
367characters will not be done. You may want to call
368\function{noqiflush()} in a signal handler if you want output
369to continue as though the interrupt had not occurred, after the
370handler exits.
Fred Drakea4070ce1999-06-21 21:13:09 +0000371\end{funcdesc}
372
373\begin{funcdesc}{noraw}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000374Leave raw mode. Return to normal ``cooked'' mode with line buffering.
Fred Drakea4070ce1999-06-21 21:13:09 +0000375\end{funcdesc}
376
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000377\begin{funcdesc}{pair_content}{pair_number}
378Returns a tuple \var{(fg,bg)} containing the colors for the requested
379color pair. The value of \var{pair_number} must be between 0 and
380COLOR_PAIRS-1.
Fred Drakea4070ce1999-06-21 21:13:09 +0000381\end{funcdesc}
382
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000383\begin{funcdesc}{pair_number}{attr}
384Returns the number of the color-pair set by the attribute value \var{attr}.
385\function{color_pair()} is the counterpart to this function.
Fred Drakea4070ce1999-06-21 21:13:09 +0000386\end{funcdesc}
387
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000388\begin{funcdesc}{putp}{string}
Eric S. Raymond68996602000-07-24 03:28:40 +0000389Equivalent to \code{tputs(str, 1, putchar)}; emits the value of a
390specified terminfo capability for the current terminal. Note that the
391output of putp always goes to standard output.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000392\end{funcdesc}
393
394\begin{funcdesc}{qiflush}{ \optional{flag} }
395If \var{flag} is false, the effect is the same as calling
396\function{noqiflush()}. If \var{flag} is true, or no argument is
397provided, the queues will be flushed when these control characters are
398read.
399\end{funcdesc}
400
401\begin{funcdesc}{raw}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000402Enter raw mode. In raw mode, normal line buffering and
403processing of interrupt, quit, suspend, and flow control keys are
404turned off; characters are presented to curses input functions one
405by one.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000406\end{funcdesc}
407
408\begin{funcdesc}{reset_prog_mode}{}
409Restores the terminal to ``program'' mode, as previously saved
410by \function{def_prog_mode()}.
411\end{funcdesc}
412
413\begin{funcdesc}{reset_shell_mode}{}
414Restores the terminal to ``shell'' mode, as previously saved
415by \function{def_shell_mode()}.
416\end{funcdesc}
417
418\begin{funcdesc}{setsyx}{y, x}
419Sets the virtual screen cursor to \var{y}, \var{x}.
420If \var{y} and \var{x} are both -1, then leaveok is set.
421\end{funcdesc}
422
423\begin{funcdesc}{start_color}{}
424Must be called if the programmer wants to use colors, and before any
425other color manipulation routine is called. It is good
426practice to call this routine right after \function{initscr()}.
427
428\function{start_color()} initializes eight basic colors (black, red,
429green, yellow, blue, magenta, cyan, and white), and two global
430variables in the \module{curses} module, COLORS and COLOR_PAIRS,
431containing the maximum number of colors and color-pairs the terminal
432can support. It also restores the colors on the terminal to the
433values they had when the terminal was just turned on.
434\end{funcdesc}
435
436\begin{funcdesc}{termattrs}{}
437Returns a logical OR of all video attributes supported by the
438terminal. This information is useful when a curses program needs
439complete control over the appearance of the screen.
440\end{funcdesc}
441
442\begin{funcdesc}{termname}{}
443Returns the value of the environment variable TERM, truncated to 14
444characters.
445\end{funcdesc}
446
Andrew M. Kuchling1962fb52000-07-26 02:59:13 +0000447\begin{funcdesc}{tigetflag}{capname}
448Returns the value of the Boolean capability corresponding to the
449terminfo capability name \var{capname}. The value -1 is returned if
450\var{capname} is not a Boolean capability, or 0 if it is canceled or
451absent from the terminal description.
452\end{funcdesc}
453
454\begin{funcdesc}{tigetnum}{capname}
455Returns the value of the numeric capability corresponding to the
456terminfo capability name \var{capname}. The value -2 is returned if
457\var{capname} is not a numeric capability, or -1 if it is canceled or absent
458from the terminal description.
459\end{funcdesc}
460
461\begin{funcdesc}{tigetstr}{capname}
462Returns the value of the string capability corresponding to the
463terminfo capability name \var{capname}. \code{None} is returned if
464\var{capname} is not a string capability, or is canceled or absent
465from the terminal description.
466\end{funcdesc}
467
Andrew M. Kuchlingd24ff442000-06-21 01:42:51 +0000468\begin{funcdesc}{typeahead}{fd}
469Specifies that the file descriptor \var{fd} be used for typeahead
470checking. If \var{fd} is -1, then no typeahead checking is done.
471
472The curses library does ``line-breakout optimization'' by looking for
473typeahead periodically while updating the screen. If input is found,
474and it is coming from a tty, the current update is postponed until
475refresh or doupdate is called again, allowing faster response to
476commands typed in advance. This function allows specifying a different
477file descriptor for typeahead checking.
478\end{funcdesc}
479
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000480\begin{funcdesc}{unctrl}{ch}
481Returns a string which is a printable representation of the character
482\var{ch}. Control characters are displayed as a caret followed by the
483character, for example as \verb|^C|. Printing characters are left as they
484are.
485\end{funcdesc}
486
487\begin{funcdesc}{ungetch}{ch}
488Push \var{ch} so the next \method{getch()} will return it.
489\strong{Note:} only one \var{ch} can be pushed before \method{getch()}
490is called.
491\end{funcdesc}
492
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000493\begin{funcdesc}{ungetmouse}{id, x, y, z, bstate}
494Push a \constant{KEY_MOUSE} event onto the input queue, associating
495the given state data with it.
496\end{funcdesc}
497
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000498\begin{funcdesc}{use_env}{flag}
499If used, this function should be called before \function{initscr} or
500newterm are called. When \var{flag} is false, the values of
501lines and columns specified in the terminfo database will be
502used, even if environment variables LINES and COLUMNS (used by
503default) are set, or if curses is running in a window (in which
504case default behavior would be to use the window size if LINES
505and COLUMNS are not set).
506\end{funcdesc}
Fred Drakea4070ce1999-06-21 21:13:09 +0000507
508\subsection{Window Objects \label{curses-window-objects}}
509
510Window objects, as returned by \function{initscr()} and
511\function{newwin()} above, have the
512following methods:
513
Fred Drakea4070ce1999-06-21 21:13:09 +0000514\begin{methoddesc}{addch}{\optional{y, x,} ch\optional{, attr}}
515\strong{Note:} A \emph{character} means a C character (i.e., an
516\ASCII{} code), rather then a Python character (a string of length 1).
517(This note is true whenever the documentation mentions a character.)
Eric S. Raymond68996602000-07-24 03:28:40 +0000518The builtin \function{ord()} is handy for conveying strings to codes.
Fred Drakea4070ce1999-06-21 21:13:09 +0000519
520Paint character \var{ch} at \code{(\var{y}, \var{x})} with attributes
521\var{attr}, overwriting any character previously painter at that
522location. By default, the character position and attributes are the
523current settings for the window object.
524\end{methoddesc}
525
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000526\begin{methoddesc}{addnstr}{\optional{y, x,} str, n\optional{, attr}}
527Paint at most \var{n} characters of the
528string \var{str} at \code{(\var{y}, \var{x})} with attributes
Fred Drake0bccd731999-06-23 17:28:01 +0000529\var{attr}, overwriting anything previously on the display.
Fred Drakea4070ce1999-06-21 21:13:09 +0000530\end{methoddesc}
531
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000532\begin{methoddesc}{addstr}{\optional{y, x,} str\optional{, attr}}
533Paint the string \var{str} at \code{(\var{y}, \var{x})} with attributes
534\var{attr}, overwriting anything previously on the display.
Fred Drakea4070ce1999-06-21 21:13:09 +0000535\end{methoddesc}
536
537\begin{methoddesc}{attroff}{attr}
Eric S. Raymond68996602000-07-24 03:28:40 +0000538Remove attribute \var{attr} from the ``background'' set applied to all
539writes to the current window.
Fred Drakea4070ce1999-06-21 21:13:09 +0000540\end{methoddesc}
541
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000542\begin{methoddesc}{attron}{attr}
Eric S. Raymond68996602000-07-24 03:28:40 +0000543Add attribute \var{attr} from the ``background'' set applied to all
544writes to the current window.
Fred Drakea4070ce1999-06-21 21:13:09 +0000545\end{methoddesc}
546
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000547\begin{methoddesc}{attrset}{attr}
Eric S. Raymond68996602000-07-24 03:28:40 +0000548Set the ``background'' set of attributes to \var{attr}. This set is
549initially 0 (no attributes).
Fred Drakea4070ce1999-06-21 21:13:09 +0000550\end{methoddesc}
551
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000552\begin{methoddesc}{bkgd}{ch\optional{, attr}}
553Sets the background property of the window to the character \var{ch},
554with attributes \var{attr}. The change is then applied to every
555character position in that window:
556\begin{itemize}
Eric S. Raymondb924bd42000-07-27 21:10:02 +0000557\item
558The attribute of every character in the window is
559changed to the new background attribute.
560\item
561Wherever the former background character appears,
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000562it is changed to the new background character.
563\end{itemize}
564
565\end{methoddesc}
566
567\begin{methoddesc}{bkgdset}{ch\optional{, attr}}
568Sets the window's background. A window's background consists of a
569character and any combination of attributes. The attribute part of
570the background is combined (OR'ed) with all non-blank characters that
571are written into the window. Both the character and attribute parts
572of the background are combined with the blank characters. The
573background becomes a property of the character and moves with the
574character through any scrolling and insert/delete line/character
575operations.
Fred Drakea4070ce1999-06-21 21:13:09 +0000576\end{methoddesc}
577
Fred Drake0bccd731999-06-23 17:28:01 +0000578\begin{methoddesc}{border}{\optional{ls\optional{, rs\optional{, ts\optional{,
579 bs\optional{, tl\optional{, tr\optional{,
580 bl\optional{, br}}}}}}}}}
581Draw a border around the edges of the window. Each parameter specifies
582the character to use for a specific part of the border; see the table
583below for more details. The characters must be specified as integers;
584using one-character strings will cause \exception{TypeError} to be
585raised.
586
587\strong{Note:} A \code{0} value for any parameter will cause the
588default character to be used for that parameter. Keyword parameters
589can \emph{not} be used. The defaults are listed in this table:
590
591\begin{tableiii}{l|l|l}{var}{Parameter}{Description}{Default value}
592 \lineiii{ls}{Left side}{\constant{ACS_VLINE}}
593 \lineiii{rs}{Right side}{\constant{ACS_VLINE}}
594 \lineiii{ts}{Top}{\constant{ACS_HLINE}}
595 \lineiii{bs}{Bottom}{\constant{ACS_HLINE}}
596 \lineiii{tl}{Upper-left corner}{\constant{ACS_ULCORNER}}
597 \lineiii{tr}{Upper-right corner}{\constant{ACS_URCORNER}}
598 \lineiii{bl}{Bottom-left corner}{\constant{ACS_BLCORNER}}
599 \lineiii{br}{Bottom-right corner}{\constant{ACS_BRCORNER}}
600\end{tableiii}
Fred Drakea4070ce1999-06-21 21:13:09 +0000601\end{methoddesc}
602
Fred Drake0bccd731999-06-23 17:28:01 +0000603\begin{methoddesc}{box}{\optional{vertch, horch}}
604Similar to \method{border()}, but both \var{ls} and \var{rs} are
605\var{vertch} and both \var{ts} and {bs} are \var{horch}. The default
606corner characters are always used by this function.
Fred Drakea4070ce1999-06-21 21:13:09 +0000607\end{methoddesc}
608
Fred Drakea4070ce1999-06-21 21:13:09 +0000609\begin{methoddesc}{clear}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000610Like \method{erase()}, but also causes the whole window to be repainted
Fred Drakea4070ce1999-06-21 21:13:09 +0000611upon next call to \method{refresh()}.
612\end{methoddesc}
613
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000614\begin{methoddesc}{clearok}{yes}
615If \var{yes} is 1, the next call to \method{refresh()}
Eric S. Raymond68996602000-07-24 03:28:40 +0000616will clear the window completely.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000617\end{methoddesc}
618
Fred Drakea4070ce1999-06-21 21:13:09 +0000619\begin{methoddesc}{clrtobot}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000620Erase from cursor to the end of the window: all lines below the cursor
Fred Drakea4070ce1999-06-21 21:13:09 +0000621are deleted, and then the equivalent of \method{clrtoeol()} is performed.
622\end{methoddesc}
623
624\begin{methoddesc}{clrtoeol}{}
625Erase from cursor to the end of the line.
626\end{methoddesc}
627
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000628\begin{methoddesc}{cursyncup}{}
629Updates the current cursor position of all the ancestors of the window
630to reflect the current cursor position of the window.
Fred Drakea4070ce1999-06-21 21:13:09 +0000631\end{methoddesc}
632
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000633\begin{methoddesc}{delch}{\optional{x, y}}
634Delete any character at \code{(\var{y}, \var{x})}.
Fred Drakea4070ce1999-06-21 21:13:09 +0000635\end{methoddesc}
636
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000637\begin{methoddesc}{deleteln}{}
638Delete the line under the cursor. All following lines are moved up
639by 1 line.
640\end{methoddesc}
641
642\begin{methoddesc}{derwin}{\optional{nlines, ncols,} begin_y, begin_y}
643An abbreviation for ``derive window'', \method{derwin()} is the same
644as calling \method{subwin()}, except that \var{begin_y} and
645\var{begin_x} are relative to the origin of the window, rather than
646relative to the entire screen. Returns a window object for the
647derived window.
648\end{methoddesc}
649
650\begin{methoddesc}{echochar}{ch\optional{, attr}}
651Add character \var{ch} with attribute \var{attr}, and immediately
Eric S. Raymond68996602000-07-24 03:28:40 +0000652call \method{refresh} on the window.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000653\end{methoddesc}
654
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000655\begin{methoddesc}{enclose}{y, x}
656Tests whether the given pair of screen-relative character-cell
657coordinates are enclosed by the given window, returning true or
658false. It is useful for determining what subset of the screen
659windows enclose the location of a mouse event.
660\end{methoddesc}
661
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000662\begin{methoddesc}{erase}{}
663Clear the window.
664\end{methoddesc}
665
666\begin{methoddesc}{getbegyx}{}
667Return a tuple \code{(\var{y}, \var{x})} of co-ordinates of upper-left
668corner.
Fred Drakea4070ce1999-06-21 21:13:09 +0000669\end{methoddesc}
670
671\begin{methoddesc}{getch}{\optional{x, y}}
672Get a character. Note that the integer returned does \emph{not} have to
673be in \ASCII{} range: function keys, keypad keys and so on return numbers
674higher then 256. In no-delay mode, an exception is raised if there is
675no input.
676\end{methoddesc}
677
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000678\begin{methoddesc}{getkey}{\optional{x, y}}
679Get a character, returning a string instead of an integer, as
680\method{getch()} does. Function keys, keypad keys and so on return a
681multibyte string containing the key name. In no-delay mode, an
682exception is raised if there is no input.
683\end{methoddesc}
684
685\begin{methoddesc}{getmaxyx}{}
686Return a tuple \code{(\var{y}, \var{x})} of the height and width of
687the window.
688\end{methoddesc}
689
690\begin{methoddesc}{getparyx}{}
691Returns the beginning coordinates of this window relative to its
692parent window into two integer variables y and x. Returns
693\code{-1,-1} if this window has no parent.
694\end{methoddesc}
695
Fred Drakea4070ce1999-06-21 21:13:09 +0000696\begin{methoddesc}{getstr}{\optional{x, y}}
697Read a string from the user, with primitive line editing capacity.
698\end{methoddesc}
699
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000700\begin{methoddesc}{getyx}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000701Return a tuple \code{(\var{y}, \var{x})} of current cursor position
702relative to the window's upper-left corner.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000703\end{methoddesc}
704
705\begin{methoddesc}{hline}{\optional{y, x,} ch, n}
706Display a horizontal line starting at \code{(\var{y}, \var{x})} with
707length \var{n} consisting of the character \var{ch}.
708\end{methoddesc}
709
710\begin{methoddesc}{idcok}{flag}
711If \var{flag} is false, curses no longer considers using the hardware
712insert/delete character feature of the terminal; if \var{flag} is
713true, use of character insertion and deletion is enabled. When curses
714is first initialized, use of character insert/delete is enabled by
715default.
716\end{methoddesc}
717
718\begin{methoddesc}{idlok}{yes}
719If called with \var{yes} equal to 1, \module{curses} will try and use
720hardware line editing facilities. Otherwise, line insertion/deletion
721are disabled.
722\end{methoddesc}
723
724\begin{methoddesc}{immedok}{flag}
725If \var{flag} is true, any change in the window image
726automatically causes the window to be refreshed; you no longer
727have to call \method{refresh()} yourself. However, it may
728degrade performance considerably, due to repeated calls to
729wrefresh. This option is disabled by default.
730\end{methoddesc}
731
Fred Drakea4070ce1999-06-21 21:13:09 +0000732\begin{methoddesc}{inch}{\optional{x, y}}
733Return the character at the given position in the window. The bottom
7348 bits are the character proper, and upper bits are the attributes.
735\end{methoddesc}
736
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000737\begin{methoddesc}{insch}{\optional{y, x,} ch\optional{, attr}}
738Paint character \var{ch} at \code{(\var{y}, \var{x})} with attributes
739\var{attr}, moving the line from position \var{x} right by one
740character.
Fred Drakea4070ce1999-06-21 21:13:09 +0000741\end{methoddesc}
742
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000743\begin{methoddesc}{insdelln}{nlines}
744Inserts \var{nlines} lines into the specified window above the current
745line. The \var{nlines} bottom lines are lost. For negative
746\var{nlines}, delete \var{nlines} lines starting with the one under
747the cursor, and move the remaining lines up. The bottom \var{nlines}
748lines are cleared. The current cursor position remains the same.
749\end{methoddesc}
750
751\begin{methoddesc}{insertln}{}
752Insert a blank line under the cursor. All following lines are moved
753down by 1 line.
754\end{methoddesc}
755
756\begin{methoddesc}{insnstr}{\optional{y, x, } str, n \optional{, attr}}
757Insert a character string (as many characters as will fit on the line)
758before the character under the cursor, up to \var{n} characters.
759If \var{n} is zero or negative,
760the entire string is inserted.
761All characters to the right of
762the cursor are shifted right, with the the rightmost characters on the
763line being lost. The cursor position does not change (after moving to
764\var{y}, \var{x}, if specified).
765\end{methoddesc}
766
767\begin{methoddesc}{insstr}{\optional{y, x, } str \optional{, attr}}
768Insert a character string (as many characters as will fit on the line)
769before the character under the cursor. All characters to the right of
770the cursor are shifted right, with the the rightmost characters on the
771line being lost. The cursor position does not change (after moving to
772\var{y}, \var{x}, if specified).
773\end{methoddesc}
774
775\begin{methoddesc}{instr}{\optional{y, x} \optional{, n}}
776Returns a string of characters, extracted from the window starting at
777the current cursor position, or at \var{y}, \var{x} if specified.
778Attributes are stripped from the characters. If \var{n} is specified,
779\method{instr()} returns return a string at most \var{n} characters
780long (exclusive of the trailing NUL).
781\end{methoddesc}
782
783\begin{methoddesc}{is_linetouched}{\var{line}}
784Returns true if the specified line was modified since the last call to
785\method{refresh()}; otherwise returns false. Raises a
786\exception{curses.error} exception if \var{line} is not valid
787for the given window.
788\end{methoddesc}
789
790\begin{methoddesc}{is_wintouched}{}
791Returns true if the specified window was modified since the last call to
792\method{refresh()}; otherwise returns false.
793\end{methoddesc}
794
795\begin{methoddesc}{keypad}{yes}
796If \var{yes} is 1, escape sequences generated by some keys (keypad,
797function keys) will be interpreted by \module{curses}.
798If \var{yes} is 0, escape sequences will be left as is in the input
799stream.
Fred Drakea4070ce1999-06-21 21:13:09 +0000800\end{methoddesc}
801
802\begin{methoddesc}{leaveok}{yes}
Eric S. Raymond68996602000-07-24 03:28:40 +0000803If \var{yes} is 1, cursor is left where it is on update, instead of
804being at ``cursor position.'' This reduces cursor movement where
805possible. If possible the cursor will be made invisible.
Fred Drakea4070ce1999-06-21 21:13:09 +0000806
Eric S. Raymond68996602000-07-24 03:28:40 +0000807If \var{yes} is 0, cursor will always be at ``cursor position'' after
808an update.
Fred Drakea4070ce1999-06-21 21:13:09 +0000809\end{methoddesc}
810
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000811\begin{methoddesc}{move}{new_y, new_x}
812Move cursor to \code{(\var{new_y}, \var{new_x})}.
Fred Drakea4070ce1999-06-21 21:13:09 +0000813\end{methoddesc}
814
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000815\begin{methoddesc}{mvderwin}{y, x}
816Moves the window inside its parent window. The screen-relative
817parameters of the window are not changed. This routine is used to
818display different parts of the parent window at the same physical
819position on the screen.
820\end{methoddesc}
Fred Drakea4070ce1999-06-21 21:13:09 +0000821
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000822\begin{methoddesc}{mvwin}{new_y, new_x}
823Move the window so its upper-left corner is at \code{(\var{new_y}, \var{new_x})}.
Fred Drakea4070ce1999-06-21 21:13:09 +0000824\end{methoddesc}
825
826\begin{methoddesc}{nodelay}{yes}
827If \var{yes} is 1, \method{getch()} will be non-blocking.
828\end{methoddesc}
829
830\begin{methoddesc}{notimeout}{yes}
831If \var{yes} is 1, escape sequences will not be timed out.
832
833If \var{yes} is 0, after a few milliseconds, an escape sequence will
834not be interpreted, and will be left in the input stream as is.
835\end{methoddesc}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000836
837\begin{methoddesc}{noutrefresh}{}
Eric S. Raymond65983372000-08-09 21:49:31 +0000838Mark for refresh but wait. This function updates the data structure
839representing the desired state of the window, but does not force
840an update of the physical screen.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000841\end{methoddesc}
842
843\begin{methoddesc}{putwin}{file}
844Writes all data associated with the window into the provided file
845object. This information can be later retrieved using the
846\function{getwin()} function.
847
848\end{methoddesc}
849
850\begin{methoddesc}{redrawln}{beg, num}
851Indicates that the \var{num} screen lines, starting at line \var{beg},
852are corrupted and should be completely redrawn on the next
853\method{refresh()} call.
854\end{methoddesc}
855
856\begin{methoddesc}{redrawwin}{}
857Touches the entire window, causing it to be completely redrawn on the
858next \method{refresh()} call.
859\end{methoddesc}
860
861\begin{methoddesc}{refresh}{ \optional{pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol} }
862Update the display immediately (sync actual screen with previous
863drawing/deleting methods).
864
865The 6 optional arguments can only be specified when the window is a
866pad created with \function{newpad()}. The additional parameters are
867needed to indicate what part of the pad and screen are involved.
868\var{pminrow} and \var{pmincol} specify the upper left-hand corner of the
869rectangle to be displayed in the pad. \var{sminrow}, \var{smincol},
870\var{smaxrow}, and \var{smaxcol} specify the edges of the rectangle to be displayed on the screen. The lower right-hand corner of the
871rectangle to be displayed in the pad is calculated from the screen
872coordinates, since the rectangles must be the same size. Both
873rectangles must be entirely contained within their respective
874structures. Negative values of \var{pminrow}, \var{pmincol},
875\var{sminrow}, or \var{smincol} are treated as if they were zero.
876\end{methoddesc}
877
878\begin{methoddesc}{scroll}{\optional{lines\code{ = 1}}}
879Scroll the screen upward by \var{lines} lines.
880\end{methoddesc}
881
882\begin{methoddesc}{scrollok}{flag}
883Controls what happens when the cursor of a window is moved off the
Eric S. Raymond68996602000-07-24 03:28:40 +0000884edge of the window or scrolling region, either as a result of a
885newline action on the bottom line, or typing the last character
886of the last line. If \var{flag} is false, the cursor is left
887on the bottom line. If \var{flag} is true, the window is
888scrolled up one line. Note that in order to get the physical
889scrolling effect on the terminal, it is also necessary to call
890\method{idlok()}.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000891\end{methoddesc}
892
893\begin{methoddesc}{setscrreg}{top, bottom}
894Set the scrolling region from line \var{top} to line \var{bottom}. All
895scrolling actions will take place in this region.
896\end{methoddesc}
897
898\begin{methoddesc}{standend}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000899Turn off the standout attribute. On some terminals this has the
900side effect of turning off all attributes.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000901\end{methoddesc}
902
903\begin{methoddesc}{standout}{}
904Turn on attribute \var{A_STANDOUT}.
905\end{methoddesc}
906
907\begin{methoddesc}{subpad}{\optional{nlines, ncols,} begin_y, begin_y}
908Return a sub-window, whose upper-left corner is at
909\code{(\var{begin_y}, \var{begin_x})}, and whose width/height is
910\var{ncols}/\var{nlines}.
911\end{methoddesc}
912
913\begin{methoddesc}{subwin}{\optional{nlines, ncols,} begin_y, begin_y}
914Return a sub-window, whose upper-left corner is at
915\code{(\var{begin_y}, \var{begin_x})}, and whose width/height is
916\var{ncols}/\var{nlines}.
917
918By default, the sub-window will extend from the
919specified position to the lower right corner of the window.
920\end{methoddesc}
921
922\begin{methoddesc}{syncdown}{}
923Touches each location in the window that has been touched in any of
924its ancestor windows. This routine is called by \method{refresh()},
925so it should almost never be necessary to call it manually.
926\end{methoddesc}
927
928\begin{methoddesc}{syncok}{flag}
929If called with \var{flag} set to true, then \method{syncup()} is
930called automatically whenever there is a change in the window.
931\end{methoddesc}
932
933\begin{methoddesc}{syncup}{}
934Touches all locations in ancestors of the window that have been changed in
935the window.
936\end{methoddesc}
937
Andrew M. Kuchlingd24ff442000-06-21 01:42:51 +0000938\begin{methoddesc}{timeout}{delay}
Thomas Woutersf8316632000-07-16 19:01:10 +0000939Sets blocking or non-blocking read behavior for the window. If
Andrew M. Kuchlingd24ff442000-06-21 01:42:51 +0000940\var{delay} is negative, blocking read is used, which will wait
941indefinitely for input). If \var{delay} is zero, then non-blocking
942read is used, and -1 will be returned by \method{getch()} if no input
943is waiting. If \var{delay} is positive, then \method{getch()} will
944block for \var{delay} milliseconds, and return -1 if there is still no
945input at the end of that time.
946\end{methoddesc}
947
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000948\begin{methoddesc}{touchline}{start, count}
949Pretend \var{count} lines have been changed, starting with line
950\var{start}.
951\end{methoddesc}
952
953\begin{methoddesc}{touchwin}{}
954Pretend the whole window has been changed, for purposes of drawing
955optimizations.
956\end{methoddesc}
957
958\begin{methoddesc}{untouchwin}{}
959Marks all lines in the window as unchanged since the last call to
960\method{refresh()}.
961\end{methoddesc}
962
963\begin{methoddesc}{vline}{\optional{y, x,} ch, n}
964Display a vertical line starting at \code{(\var{y}, \var{x})} with
965length \var{n} consisting of the character \var{ch}.
966\end{methoddesc}
967
968\subsection{Constants}
969
970The \module{curses} module defines the following data members:
971
972\begin{datadesc}{version}
973A string representing the current version of the module.
974Also available as \constant{__version__}.
975\end{datadesc}
976
Fred Drakeec4b2af2000-08-09 14:34:48 +0000977Several constants are available to specify character cell attributes:
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000978
Fred Drakeec4b2af2000-08-09 14:34:48 +0000979\begin{tableii}{l|l}{code}{Attribute}{Meaning}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000980 \lineii{A_ALTCHARSET}{Alternate character set mode.}
981 \lineii{A_BLINK}{Blink mode.}
982 \lineii{A_BOLD}{Bold mode.}
983 \lineii{A_DIM}{Dim mode.}
984 \lineii{A_NORMAL}{Normal attribute.}
985 \lineii{A_STANDOUT}{Standout mode.}
986 \lineii{A_UNDERLINE}{Underline mode.}
987\end{tableii}
988
989Keys are referred to by integer constants with names starting with
Fred Drakeec4b2af2000-08-09 14:34:48 +0000990\samp{KEY_}. The exact keycaps available are system dependent.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000991
992% XXX this table is far too large!
993% XXX should this table be alphabetized?
994
Fred Drake1bf4e932000-09-21 16:04:08 +0000995\begin{longtableii}{l|l}{code}{Key constant}{Key}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000996 \lineii{KEY_MIN}{Minimum key value}
997 \lineii{KEY_BREAK}{ Break key (unreliable) }
998 \lineii{KEY_DOWN}{ Down-arrow }
999 \lineii{KEY_UP}{ Up-arrow }
1000 \lineii{KEY_LEFT}{ Left-arrow }
1001 \lineii{KEY_RIGHT}{ Right-arrow }
1002 \lineii{KEY_HOME}{ Home key (upward+left arrow) }
1003 \lineii{KEY_BACKSPACE}{ Backspace (unreliable) }
1004 \lineii{KEY_F0}{ Function keys. Up to 64 function keys are supported. }
1005 \lineii{KEY_F\var{n}}{ Value of function key \var{n} }
1006 \lineii{KEY_DL}{ Delete line }
1007 \lineii{KEY_IL}{ Insert line }
1008 \lineii{KEY_DC}{ Delete character }
1009 \lineii{KEY_IC}{ Insert char or enter insert mode }
1010 \lineii{KEY_EIC}{ Exit insert char mode }
1011 \lineii{KEY_CLEAR}{ Clear screen }
1012 \lineii{KEY_EOS}{ Clear to end of screen }
1013 \lineii{KEY_EOL}{ Clear to end of line }
1014 \lineii{KEY_SF}{ Scroll 1 line forward }
1015 \lineii{KEY_SR}{ Scroll 1 line backward (reverse) }
1016 \lineii{KEY_NPAGE}{ Next page }
1017 \lineii{KEY_PPAGE}{ Previous page }
1018 \lineii{KEY_STAB}{ Set tab }
1019 \lineii{KEY_CTAB}{ Clear tab }
1020 \lineii{KEY_CATAB}{ Clear all tabs }
1021 \lineii{KEY_ENTER}{ Enter or send (unreliable) }
1022 \lineii{KEY_SRESET}{ Soft (partial) reset (unreliable) }
1023 \lineii{KEY_RESET}{ Reset or hard reset (unreliable) }
1024 \lineii{KEY_PRINT}{ Print }
1025 \lineii{KEY_LL}{ Home down or bottom (lower left) }
1026 \lineii{KEY_A1}{ Upper left of keypad }
1027 \lineii{KEY_A3}{ Upper right of keypad }
1028 \lineii{KEY_B2}{ Center of keypad }
1029 \lineii{KEY_C1}{ Lower left of keypad }
1030 \lineii{KEY_C3}{ Lower right of keypad }
1031 \lineii{KEY_BTAB}{ Back tab }
1032 \lineii{KEY_BEG}{ Beg (beginning) }
1033 \lineii{KEY_CANCEL}{ Cancel }
1034 \lineii{KEY_CLOSE}{ Close }
1035 \lineii{KEY_COMMAND}{ Cmd (command) }
1036 \lineii{KEY_COPY}{ Copy }
1037 \lineii{KEY_CREATE}{ Create }
1038 \lineii{KEY_END}{ End }
1039 \lineii{KEY_EXIT}{ Exit }
1040 \lineii{KEY_FIND}{ Find }
1041 \lineii{KEY_HELP}{ Help }
1042 \lineii{KEY_MARK}{ Mark }
1043 \lineii{KEY_MESSAGE}{ Message }
1044 \lineii{KEY_MOVE}{ Move }
1045 \lineii{KEY_NEXT}{ Next }
1046 \lineii{KEY_OPEN}{ Open }
1047 \lineii{KEY_OPTIONS}{ Options }
1048 \lineii{KEY_PREVIOUS}{ Prev (previous) }
1049 \lineii{KEY_REDO}{ Redo }
1050 \lineii{KEY_REFERENCE}{ Ref (reference) }
1051 \lineii{KEY_REFRESH}{ Refresh }
1052 \lineii{KEY_REPLACE}{ Replace }
1053 \lineii{KEY_RESTART}{ Restart }
1054 \lineii{KEY_RESUME}{ Resume }
1055 \lineii{KEY_SAVE}{ Save }
1056 \lineii{KEY_SBEG}{ Shifted Beg (beginning) }
1057 \lineii{KEY_SCANCEL}{ Shifted Cancel }
1058 \lineii{KEY_SCOMMAND}{ Shifted Command }
1059 \lineii{KEY_SCOPY}{ Shifted Copy }
1060 \lineii{KEY_SCREATE}{ Shifted Create }
1061 \lineii{KEY_SDC}{ Shifted Delete char }
1062 \lineii{KEY_SDL}{ Shifted Delete line }
1063 \lineii{KEY_SELECT}{ Select }
1064 \lineii{KEY_SEND}{ Shifted End }
1065 \lineii{KEY_SEOL}{ Shifted Clear line }
1066 \lineii{KEY_SEXIT}{ Shifted Dxit }
1067 \lineii{KEY_SFIND}{ Shifted Find }
1068 \lineii{KEY_SHELP}{ Shifted Help }
1069 \lineii{KEY_SHOME}{ Shifted Home }
1070 \lineii{KEY_SIC}{ Shifted Input }
1071 \lineii{KEY_SLEFT}{ Shifted Left arrow }
1072 \lineii{KEY_SMESSAGE}{ Shifted Message }
1073 \lineii{KEY_SMOVE}{ Shifted Move }
1074 \lineii{KEY_SNEXT}{ Shifted Next }
1075 \lineii{KEY_SOPTIONS}{ Shifted Options }
1076 \lineii{KEY_SPREVIOUS}{ Shifted Prev }
1077 \lineii{KEY_SPRINT}{ Shifted Print }
1078 \lineii{KEY_SREDO}{ Shifted Redo }
1079 \lineii{KEY_SREPLACE}{ Shifted Replace }
1080 \lineii{KEY_SRIGHT}{ Shifted Right arrow }
1081 \lineii{KEY_SRSUME}{ Shifted Resume }
1082 \lineii{KEY_SSAVE}{ Shifted Save }
1083 \lineii{KEY_SSUSPEND}{ Shifted Suspend }
1084 \lineii{KEY_SUNDO}{ Shifted Undo }
1085 \lineii{KEY_SUSPEND}{ Suspend }
1086 \lineii{KEY_UNDO}{ Undo }
1087 \lineii{KEY_MOUSE}{ Mouse event has occurred }
1088 \lineii{KEY_RESIZE}{ Terminal resize event }
1089 \lineii{KEY_MAX}{Maximum key value}
Fred Drake1bf4e932000-09-21 16:04:08 +00001090\end{longtableii}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001091
Fred Drakeec4b2af2000-08-09 14:34:48 +00001092On VT100s and their software emulations, such as X terminal emulators,
1093there are normally at least four function keys (\constant{KEY_F1},
1094\constant{KEY_F2}, \constant{KEY_F3}, \constant{KEY_F4}) available,
1095and the arrow keys mapped to \constant{KEY_UP}, \constant{KEY_DOWN},
1096\constant{KEY_LEFT} and \constant{KEY_RIGHT} in the obvious way. If
1097your machine has a PC keybboard, it is safe to expect arrow keys and
1098twelve function keys (older PC keyboards may have only ten function
1099keys); also, the following keypad mappings are standard:
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001100
Fred Drakeec4b2af2000-08-09 14:34:48 +00001101\begin{tableii}{l|l}{kbd}{Keycap}{Constant}
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001102 \lineii{Insert}{KEY_IC}
1103 \lineii{Delete}{KEY_DC}
1104 \lineii{Home}{KEY_HOME}
1105 \lineii{End}{KEY_END}
1106 \lineii{Page Up}{KEY_NPAGE}
1107 \lineii{Page Down}{KEY_PPAGE}
1108\end{tableii}
1109
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001110The following table lists characters from the alternate character set.
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001111These are inherited from the VT100 terminal, and will generally be
1112available on software emulations such as X terminals. When there
1113is no graphic available, curses falls back on a crude printable ASCII
1114approximation.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001115\strong{Note:} These are available only after \function{initscr()} has
1116been called.
1117
Fred Drake1bf4e932000-09-21 16:04:08 +00001118\begin{longtableii}{l|l}{code}{ACS code}{Meaning}
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001119 \lineii{ACS_BBSS}{alternate name for upper right corner}
Eric S. Raymond68996602000-07-24 03:28:40 +00001120 \lineii{ACS_BLOCK}{solid square block}
1121 \lineii{ACS_BOARD}{board of squares}
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001122 \lineii{ACS_BSBS}{alternate name for horizontal line}
1123 \lineii{ACS_BSSB}{alternate name for upper left corner}
1124 \lineii{ACS_BSSS}{alternate name for top tee}
Eric S. Raymond68996602000-07-24 03:28:40 +00001125 \lineii{ACS_BTEE}{bottom tee}
1126 \lineii{ACS_BULLET}{bullet}
1127 \lineii{ACS_CKBOARD}{checker board (stipple)}
1128 \lineii{ACS_DARROW}{arrow pointing down}
1129 \lineii{ACS_DEGREE}{degree symbol}
1130 \lineii{ACS_DIAMOND}{diamond}
1131 \lineii{ACS_GEQUAL}{greater-than-or-equal-to}
1132 \lineii{ACS_HLINE}{horizontal line}
1133 \lineii{ACS_LANTERN}{lantern symbol}
1134 \lineii{ACS_LARROW}{left arrow}
1135 \lineii{ACS_LEQUAL}{less-than-or-equal-to}
1136 \lineii{ACS_LLCORNER}{lower left-hand corner}
1137 \lineii{ACS_LRCORNER}{lower right-hand corner}
1138 \lineii{ACS_LTEE}{left tee}
1139 \lineii{ACS_NEQUAL}{not-equal sign}
1140 \lineii{ACS_PI}{letter pi}
1141 \lineii{ACS_PLMINUS}{plus-or-minus sign}
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001142 \lineii{ACS_PLUS}{big plus sign}
Eric S. Raymond68996602000-07-24 03:28:40 +00001143 \lineii{ACS_RARROW}{right arrow}
1144 \lineii{ACS_RTEE}{right tee}
1145 \lineii{ACS_S1}{scan line 1}
1146 \lineii{ACS_S3}{scan line 3}
1147 \lineii{ACS_S7}{scan line 7}
1148 \lineii{ACS_S9}{scan line 9}
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001149 \lineii{ACS_SBBS}{alternate name for lower right corner}
1150 \lineii{ACS_SBSB}{alternate name for vertical line}
1151 \lineii{ACS_SBSS}{alternate name for right tee}
1152 \lineii{ACS_SSBB}{alternate name for lower left corner}
1153 \lineii{ACS_SSBS}{alternate name for bottom tee}
1154 \lineii{ACS_SSSB}{alternate name for left tee}
1155 \lineii{ACS_SSSS}{alternate name for crossover or big plus}
Eric S. Raymond68996602000-07-24 03:28:40 +00001156 \lineii{ACS_STERLING}{pound sterling}
1157 \lineii{ACS_TTEE}{top tee}
1158 \lineii{ACS_UARROW}{up arrow}
1159 \lineii{ACS_ULCORNER}{upper left corner}
1160 \lineii{ACS_URCORNER}{upper right corner}
1161 \lineii{ACS_VLINE}{vertical line}
Fred Drake1bf4e932000-09-21 16:04:08 +00001162\end{longtableii}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001163
1164The following table lists the predefined colors:
1165
Fred Drakeec4b2af2000-08-09 14:34:48 +00001166\begin{tableii}{l|l}{code}{Constant}{Color}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001167 \lineii{COLOR_BLACK}{Black}
1168 \lineii{COLOR_BLUE}{Blue}
1169 \lineii{COLOR_CYAN}{Cyan (light greenish blue)}
1170 \lineii{COLOR_GREEN}{Green}
1171 \lineii{COLOR_MAGENTA}{Magenta (purplish red)}
1172 \lineii{COLOR_RED}{Red}
1173 \lineii{COLOR_WHITE}{White}
1174 \lineii{COLOR_YELLOW}{Yellow}
1175\end{tableii}
1176
Eric S. Raymond5a007692000-08-04 07:35:41 +00001177\section{\module{curses.textpad} ---
1178 Text input widget for curses programs}
1179
1180\declaremodule{standard}{curses.textpad}
1181\sectionauthor{Eric Raymond}{esr@thyrsus.com}
1182\moduleauthor{Eric Raymond}{esr@thyrsus.com}
1183\modulesynopsis{Emacs-like input editing in a curses window.}
1184\versionadded{1.6}
1185
1186The \module{curses.textpad} module provides a \class{Textbox} class
1187that handles elementary text editing in a curses window, supporting a
1188set of keybindings resembling those of Emacs (thus, also of Netscape
1189Navigator, BBedit 6.x, FrameMaker, and many other programs). The
1190module also provides a rectangle-drawing function useful for framing
1191text boxes or for other purposes.
1192
Fred Drakeec4b2af2000-08-09 14:34:48 +00001193The module \module{curses.textpad} defines the following function:
Eric S. Raymond5a007692000-08-04 07:35:41 +00001194
1195\begin{funcdesc}{rectangle}{win, uly, ulx, lry, lrx}
1196Draw a rectangle. The first argument must be a window object; the
1197remaining arguments are coordinates relative to that window. The
1198second and third arguments are the y and x coordinates of the upper
1199left hand corner of the rectangle To be drawn; the fourth and fifth
1200arguments are the y and x coordinates of the lower right hand corner.
1201The rectangle will be drawn using VT100/IBM PC forms characters on
1202terminals that make this possible (including xterm and most other
1203software terminal emulators). Otherwise it will be drawn with ASCII
1204dashes, vertical bars, and plus signs.
1205\end{funcdesc}
1206
Fred Drakeec4b2af2000-08-09 14:34:48 +00001207
Eric S. Raymond5a007692000-08-04 07:35:41 +00001208\subsection{Textbox objects \label{curses-textpad-objects}}
1209
1210You can instantiate a \class{Textbox} object as follows:
1211
Fred Drakeec4b2af2000-08-09 14:34:48 +00001212\begin{classdesc}{Textbox}{win}
1213Return a textbox widget object. The \var{win} argument should be a
1214curses \class{WindowObject} in which the textbox is to be contained.
1215The edit cursor of the textbox is initially located at the upper left
1216hand corner of the containin window, with coordinates \code{(0, 0)}.
1217The instance's \member{stripspaces} flag is initially on.
Eric S. Raymond5a007692000-08-04 07:35:41 +00001218\end{classdesc}
1219
Fred Drakeec4b2af2000-08-09 14:34:48 +00001220\class{Textbox} objects have the following methods:
Eric S. Raymond5a007692000-08-04 07:35:41 +00001221
Fred Drakeec4b2af2000-08-09 14:34:48 +00001222\begin{methoddesc}{edit}{\optional{validator}}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001223This is the entry point you will normally use. It accepts editing
Fred Drakeec4b2af2000-08-09 14:34:48 +00001224keystrokes until one of the termination keystrokes is entered. If
1225\var{validator} is supplied, it must be a function. It will be called
1226for each keystroke entered with the keystroke as a parameter; command
1227dispatch is done on the result. This method returns the window
1228contents as a string; whether blanks in the window are included is
1229affected by the \member{stripspaces} member.
Eric S. Raymond5a007692000-08-04 07:35:41 +00001230\end{methoddesc}
1231
1232\begin{methoddesc}{do_command}{ch}
1233Process a single command keystroke. Here are the supported special
1234keystrokes:
1235
Fred Drakeec4b2af2000-08-09 14:34:48 +00001236\begin{tableii}{l|l}{kbd}{Keystroke}{Action}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001237 \lineii{Ctrl-A}{Go to left edge of window.}
1238 \lineii{Ctrl-B}{Cursor left, wrapping to previous line if appropriate.}
1239 \lineii{Ctrl-D}{Delete character under cursor.}
1240 \lineii{Ctrl-E}{Go to right edge (stripspaces off) or end of line (stripspaces on).}
1241 \lineii{Ctrl-F}{Cursor right, wrapping to next line when appropriate.}
1242 \lineii{Ctrl-G}{Terminate, returning the window contents.}
1243 \lineii{Ctrl-H}{Delete character backward.}
1244 \lineii{Ctrl-J}{Terminate if the window is 1 line, otherwise insert newline.}
1245 \lineii{Ctrl-K}{If line is blank, delete it, otherwise clear to end of line.}
1246 \lineii{Ctrl-L}{Refresh screen.}
1247 \lineii{Ctrl-N}{Cursor down; move down one line.}
1248 \lineii{Ctrl-O}{Insert a blank line at cursor location.}
1249 \lineii{Ctrl-P}{Cursor up; move up one line.}
1250\end{tableii}
1251
1252Move operations do nothing if the cursor is at an edge where the
1253movement is not possible. The following synonyms are supported where
Fred Drakeec4b2af2000-08-09 14:34:48 +00001254possible:
1255
1256\begin{tableii}{l|l}{constant}{Constant}{Keystroke}
1257 \lineii{KEY_LEFT}{\kbd{Ctrl-B}}
1258 \lineii{KEY_RIGHT}{\kbd{Ctrl-F}}
1259 \lineii{KEY_UP}{\kbd{Ctrl-P}}
1260 \lineii{KEY_DOWN}{\kbd{Ctrl-N}}
1261 \lineii{KEY_BACKSPACE}{\kbd{Ctrl-h}}
1262\end{tableii}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001263
1264All other keystrokes are treated as a command to insert the given
1265character and move right (with line wrapping).
1266\end{methoddesc}
1267
1268\begin{methoddesc}{gather}{}
1269This method returns the window contents as a string; whether blanks in
1270the window are included is affected by the \member{stripspaces}
1271member.
1272\end{methoddesc}
1273
Fred Drakeec4b2af2000-08-09 14:34:48 +00001274\begin{memberdesc}{stripspaces}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001275This data member is a flag which controls the interpretation of blanks in
1276the window. When it is on, trailing blanks on each line are ignored;
1277any cursor motion that would land the cursor on a trailing blank goes
1278to the end of that line instead, and trailing blanks are stripped when
1279the window contents is gathered.
Fred Drakeec4b2af2000-08-09 14:34:48 +00001280\end{memberdesc}
1281
Eric S. Raymond5a007692000-08-04 07:35:41 +00001282
1283\section{\module{curses.wrapper} ---
Fred Drakeec4b2af2000-08-09 14:34:48 +00001284 Terminal handler for curses programs}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001285
1286\declaremodule{standard}{curses.wrapper}
1287\sectionauthor{Eric Raymond}{esr@thyrsus.com}
1288\moduleauthor{Eric Raymond}{esr@thyrsus.com}
Fred Drakeec4b2af2000-08-09 14:34:48 +00001289\modulesynopsis{Terminal configuration wrapper for curses programs.}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001290\versionadded{1.6}
1291
1292This module supplies one function, \function{wrapper()}, which runs
1293another function which should be the rest of your curses-using
1294application. If the application raises an exception,
1295\function{wrapper()} will restore the terminal to a sane state before
1296passing it further up the stack and generating a traceback.
1297
Fred Drakeec4b2af2000-08-09 14:34:48 +00001298\begin{funcdesc}{wrapper}{func, \moreargs}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001299Wrapper function that initializes curses and calls another function,
Fred Drakeec4b2af2000-08-09 14:34:48 +00001300\var{func}, restoring normal keyboard/screen behavior on error.
1301The callable object \var{func} is then passed the main window 'stdscr'
Eric S. Raymond5a007692000-08-04 07:35:41 +00001302as its first argument, followed by any other arguments passed to
1303\function{wrapper()}.
1304\end{funcdesc}
1305
Eric S. Raymond1ebd3f62000-08-09 21:11:07 +00001306Before calling the hook function, \function{wrapper()} turns on cbreak
1307mode, turns off echo, enables the terminal keypad, and initializes
1308colors if the terminal has color support. On exit (whether normally
1309or by exception) it restores cooked mode, turns on echo, and disables
1310the terminal keypad.
Eric S. Raymond5a007692000-08-04 07:35:41 +00001311