blob: d5a8c2b7aa2d9b616bc7c8df163f0ff95ad9aaf0 [file] [log] [blame]
Fred Drakea4070ce1999-06-21 21:13:09 +00001\section{\module{curses} ---
Fred Drakef8ca7d82000-10-10 17:03:45 +00002 Terminal handling for character-cell displays}
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 Drakef8ca7d82000-10-10 17:03:45 +00007\modulesynopsis{An interface to the curses library, providing portable
8 terminal handling.}
Fred Drake2e06c202000-10-06 20:01:23 +00009
10\versionchanged[Added support for the \code{ncurses} library and
11 converted to a package]{1.6}
Fred Drakea4070ce1999-06-21 21:13:09 +000012
Fred Draked79c33a2000-09-25 14:14:30 +000013The \module{curses} module provides an interface to the curses
Fred Drakea4070ce1999-06-21 21:13:09 +000014library, the de-facto standard for portable advanced terminal
15handling.
16
17While curses is most widely used in the \UNIX{} environment, versions
Eric S. Raymond68996602000-07-24 03:28:40 +000018are available for DOS, OS/2, and possibly other systems as well. This
19extension module is designed to match the API of ncurses, an
20open-source curses library hosted on Linux and the BSD variants of
Fred Draked79c33a2000-09-25 14:14:30 +000021\UNIX.
Fred Drakea4070ce1999-06-21 21:13:09 +000022
23\begin{seealso}
Fred Drake5c529d32000-06-28 22:11:40 +000024 \seemodule{curses.ascii}{Utilities for working with \ASCII{}
25 characters, regardless of your locale
26 settings.}
Eric S. Raymond5a007692000-08-04 07:35:41 +000027 \seemodule{curses.textpad}{Editable text widget for curses supporting
Fred Drakeec4b2af2000-08-09 14:34:48 +000028 \program{Emacs}-like bindings.}
29 \seemodule{curses.wrapper}{Convenience function to ensure proper
30 terminal setup and resetting on
31 application entry and exit.}
Fred Draked79c33a2000-09-25 14:14:30 +000032 \seetitle[http://www.python.org/doc/howto/curses/curses.html]{Curses
33 Programming with Python}{Tutorial material on using curses
34 with Python, by Andrew Kuchling, is available on the
35 Python Web site.}
Fred Drakea4070ce1999-06-21 21:13:09 +000036\end{seealso}
37
38
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000039\subsection{Functions \label{curses-functions}}
Fred Drakea4070ce1999-06-21 21:13:09 +000040
41The module \module{curses} defines the following exception:
Fred Drakeec4b2af2000-08-09 14:34:48 +000042
Fred Drakea4070ce1999-06-21 21:13:09 +000043\begin{excdesc}{error}
Fred Drakeec4b2af2000-08-09 14:34:48 +000044Exception raised when a curses library function returns an error.
Fred Drakea4070ce1999-06-21 21:13:09 +000045\end{excdesc}
46
Fred Drake0bccd731999-06-23 17:28:01 +000047\strong{Note:} Whenever \var{x} or \var{y} arguments to a function
48or a method are optional, they default to the current cursor location.
49Whenever \var{attr} is optional, it defaults to \constant{A_NORMAL}.
50
Fred Drakea4070ce1999-06-21 21:13:09 +000051The module \module{curses} defines the following functions:
52
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000053\begin{funcdesc}{baudrate}{}
Eric S. Raymond68996602000-07-24 03:28:40 +000054Returns the output speed of the terminal in bits per second. On
55software terminal emulators it will have a fixed high value.
56Included for historical reasons; in former times, it was used to
57write output loops for time delays and occasionally to change
58interfaces depending on the line speed.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000059\end{funcdesc}
60
61\begin{funcdesc}{beep}{}
Eric S. Raymond68996602000-07-24 03:28:40 +000062Emit a short attention sound.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000063\end{funcdesc}
64
65\begin{funcdesc}{can_change_color}{}
66Returns true or false, depending on whether the programmer can change
67the colors displayed by the terminal.
68\end{funcdesc}
69
70\begin{funcdesc}{cbreak}{}
Eric S. Raymond68996602000-07-24 03:28:40 +000071Enter cbreak mode. In cbreak mode (sometimes called ``rare'' mode)
72normal tty line buffering is turned off and characters are available
73to be read one by one. However, unlike raw mode, special characters
74(interrupt, quit, suspend, and flow control) retain their effects on
75the tty driver and calling program. Calling first \function{raw()}
76then \function{cbreak()} leaves the terminal in cbreak mode.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000077\end{funcdesc}
78
79\begin{funcdesc}{color_content}{color_number}
80Returns the intensity of the red, green, and blue (RGB) components in
81the color \var{color_number}, which must be between 0 and COLORS. A
823-tuple is returned, containing the R,G,B values for the given color,
83which will be between 0 (no component) and 1000 (maximum amount of
84component).
85\end{funcdesc}
86
87\begin{funcdesc}{color_pair}{color_number}
88Returns the attribute value for displaying text in the specified
89color. This attribute value can be combined with
90\constant{A_STANDOUT}, \constant{A_REVERSE}, and the other
91\constant{A_*} attributes. \function{pair_number()} is the counterpart to this function.
92\end{funcdesc}
93
94\begin{funcdesc}{curs_set}{visibility}
95Sets the cursor state. \var{visibility} can be set to 0, 1, or 2, for
96invisible, normal, or very visible. If the terminal supports the
97visibility requested, the previous cursor state is returned;
Eric S. Raymond68996602000-07-24 03:28:40 +000098otherwise, an exception is raised. On many terminals, the ``visible''
99mode is an underline cursor and the ``very visible'' mode is a block cursor.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000100\end{funcdesc}
101
102\begin{funcdesc}{def_prog_mode}{}
103Saves the current terminal mode as the ``program'' mode, the mode when
104the running program is using curses. (Its counterpart is the
105``shell'' mode, for when the program is not in curses.) Subsequent calls
106to \function{reset_prog_mode()} will restore this mode.
107\end{funcdesc}
108
109\begin{funcdesc}{def_shell_mode}{}
110Saves the current terminal mode as the ``shell'' mode, the mode when
111the running program is not using curses. (Its counterpart is the
112``program'' mode, when the program is using curses capabilities.)
113Subsequent calls
114to \function{reset_shell_mode()} will restore this mode.
115\end{funcdesc}
116
117\begin{funcdesc}{delay_output}{ms}
118Inserts an \var{ms} millisecond pause in output.
119\end{funcdesc}
120
121\begin{funcdesc}{doupdate}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000122Update the physical screen. The curses library keeps two data
123structures, one representing the current physical screen contents
124and a virtual screen representing the desired next state. The
125\function{doupdate()} ground updates the physical screen to match the
126virtual screen.
127
128The virtual screen may be updated by a \method{noutrefresh()} call
129after write operations such as \method{addstr()} have been performed
130on a window. The normal \method{refresh()} call is simply
131\method{noutrefresh()} followed by \function{doupdate()}; if you have
132to update multiple windows, you can speed performance and perhaps
133reduce screen flicker by issuing \method{noutrefresh()} calls on
134all windows, followed by a single \function{doupdate()}.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000135\end{funcdesc}
136
137\begin{funcdesc}{echo}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000138Enter echo mode. In echo mode, each character input is echoed to the
139screen as it is entered.
Fred Drakea4070ce1999-06-21 21:13:09 +0000140\end{funcdesc}
141
142\begin{funcdesc}{endwin}{}
143De-initialize the library, and return terminal to normal status.
144\end{funcdesc}
145
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000146\begin{funcdesc}{erasechar}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000147Returns the user's current erase character. Under Unix operating
148systems this is a property of the controlling tty of the curses
149program, and is not set by the curses library itself.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000150\end{funcdesc}
151
152\begin{funcdesc}{filter}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000153The \function{filter()} routine, if used, must be called before
154\function{initscr()} is called. The effect is that, during those
155calls, LINES is set to 1; the capabilities clear, cup, cud, cud1,
156cuu1, cuu, vpa are disabled; and the home string is set to the value of cr.
157The effect is that the cursor is confined to the current line, and so
158are screen updates. This may be used for enabling cgaracter-at-a-time
159line editing without touching the rest of the screen.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000160\end{funcdesc}
161
162\begin{funcdesc}{flash}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000163Flash the screen. That is, change it to reverse-video and then change
164it back in a short interval. Some people prefer such as `visible bell'
165to the audible attention signal produced by \function{beep()}.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000166\end{funcdesc}
167
168\begin{funcdesc}{flushinp}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000169Flush all input buffers. This throws away any typeahead that has
170been typed by the user and has not yet been processed by the program.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000171\end{funcdesc}
172
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000173\begin{funcdesc}{getmouse}{}
174After \method{getch()} returns \constant{KEY_MOUSE} to signal a mouse
175event, this method should be call to retrieve the queued mouse event,
176represented as a 5-tuple
177\code{(\var{id}, \var{x}, \var{y}, \var{z}, \var{bstate})}.
178\var{id} is an ID value used to distinguish multiple devices,
179and \var{x}, \var{y}, \var{z} are the event's coordinates. (\var{z}
180is currently unused.). \var{bstate} is an integer value whose bits
181will be set to indicate the type of event, and will be the bitwise OR
182of one or more of the following constants, where \var{n} is the button
183number from 1 to 4:
184\constant{BUTTON\var{n}_PRESSED},
185\constant{BUTTON\var{n}_RELEASED},
186\constant{BUTTON\var{n}_CLICKED},
187\constant{BUTTON\var{n}_DOUBLE_CLICKED},
188\constant{BUTTON\var{n}_TRIPLE_CLICKED},
189\constant{BUTTON_SHIFT},
190\constant{BUTTON_CTRL},
191\constant{BUTTON_ALT}.
192\end{funcdesc}
193
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000194\begin{funcdesc}{getsyx}{}
195Returns the current coordinates of the virtual screen cursor in y and
196x. If leaveok is currently true, then -1,-1 is returned.
197\end{funcdesc}
198
199\begin{funcdesc}{getwin}{file}
200Reads window related data stored in the file by an earlier
201\function{putwin()} call. The routine then creates and initializes a
202new window using that data, returning the new window object.
203\end{funcdesc}
204
205\begin{funcdesc}{has_colors}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000206Returns true if the terminal can display colors; otherwise, it
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000207returns false.
208\end{funcdesc}
209
210\begin{funcdesc}{has_ic}{}
211Returns true if the terminal has insert- and delete- character
Eric S. Raymond68996602000-07-24 03:28:40 +0000212capabilities. 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_il}{}
217Returns true if the terminal has insert- and
218delete-line capabilities, or can simulate them using
Eric S. Raymond68996602000-07-24 03:28:40 +0000219scrolling regions. This function is included for historical reasons only,
220as all modern software terminal emulators have such capabilities.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000221\end{funcdesc}
222
223\begin{funcdesc}{has_key}{ch}
224Takes a key value \var{ch}, and returns true if the current terminal
225type recognizes a key with that value.
226\end{funcdesc}
227
228\begin{funcdesc}{halfdelay}{tenths}
229Used for half-delay mode, which is similar to cbreak mode in that
230characters typed by the user are immediately available to the program.
231However, after blocking for \var{tenths} tenths of seconds, an
232exception is raised if nothing has been typed. The value of
Eric S. Raymond68996602000-07-24 03:28:40 +0000233\var{tenths} must be a number between 1 and 255. Use \function{nocbreak()} to
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000234leave half-delay mode.
235\end{funcdesc}
236
237\begin{funcdesc}{init_color}{color_number, r, g, b}
238Changes the definition of a color, taking the number of the color to
239be changed followed by three RGB values (for the amounts of red,
240green, and blue components). The value of \var{color_number} must be
241between 0 and COLORS. Each of \var{r}, \var{g}, \var{b}, must be a
242value between 0 and 1000. When \function{init_color()} is used, all
243occurrences of that color on the screen immediately change to the new
Eric S. Raymond68996602000-07-24 03:28:40 +0000244definition. This function is a no-op on most terminals; it is active
245only if \function{can_change_color()} returns 1.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000246\end{funcdesc}
247
248\begin{funcdesc}{init_pair}{pair_number, fg, bg}
249Changes the definition of a color-pair. It takes three arguments: the
250number of the color-pair to be changed, the foreground color number,
251and the background color number. The value of \var{pair_number} must
252be between 1 and COLOR_PAIRS-1 (the 0 color pair is wired to white on
253black and cannot be changed). The value of \var{fg} and \var{bg}
254arguments must be between 0 and COLORS. If the color-pair was
255previously initialized, the screen is refreshed and all occurrences of
256that color-pair are changed to the new definition.
257\end{funcdesc}
258
259\begin{funcdesc}{initscr}{}
260Initialize the library. Returns a \class{WindowObject} which represents
261the whole screen.
262\end{funcdesc}
263
Fred Drakea4070ce1999-06-21 21:13:09 +0000264\begin{funcdesc}{isendwin}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000265Returns true if \function{endwin()} has been called (that is, the
266curses library has been deinitialized).
Fred Drakea4070ce1999-06-21 21:13:09 +0000267\end{funcdesc}
268
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000269\begin{funcdesc}{keyname}{k}
Eric S. Raymond68996602000-07-24 03:28:40 +0000270Return the name of the key numbered \var{k}. The name of a key
271generating printable ASCII character is the key's character. The name
272of a control-key combination is a two-character string consisting of a
273caret followed by the corresponding printable ASCII character. The
274name of an alt-key combination (128-255) is a string consisting of the
275prefix `M-' followed by the name of the corresponding ASCII character.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000276\end{funcdesc}
277
278\begin{funcdesc}{killchar}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000279Returns the user's current line kill character. Under Unix operating
280systems this is a property of the controlling tty of the curses
281program, and is not set by the curses library itself.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000282\end{funcdesc}
283
284\begin{funcdesc}{longname}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000285Returns a string containing the terminfo long name field describing the current
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000286terminal. The maximum length of a verbose description is 128
287characters. It is defined only after the call to
288\function{initscr()}.
289\end{funcdesc}
290
291\begin{funcdesc}{meta}{yes}
Eric S. Raymond68996602000-07-24 03:28:40 +0000292If \var{yes} is 1, allow 8-bit characters to be input. If \var{yes} is 0,
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000293allow only 7-bit chars.
294\end{funcdesc}
295
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000296\begin{funcdesc}{mouseinterval}{interval}
Thomas Woutersf8316632000-07-16 19:01:10 +0000297Sets the maximum time in milliseconds that can elapse between press and
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000298release events in order for them to be recognized as a click, and
299returns the previous interval value. The default value is 200 msec,
300or one fifth of a second.
301\end{funcdesc}
302
303\begin{funcdesc}{mousemask}{mousemask}
304Sets the mouse events to be reported, and returns a tuple
305\code{(\var{availmask}, \var{oldmask})}.
306\var{availmask} indicates which of the
307specified mouse events can be reported; on complete failure it returns
3080. \var{oldmask} is the previous value of the given window's mouse
309event mask. If this function is never called, no mouse events are
310ever reported.
311\end{funcdesc}
312
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000313\begin{funcdesc}{newpad}{nlines, ncols}
314Creates and returns a pointer to a new pad data structure with the
315given number of lines and columns. A pad is returned as a
316window object.
317
Eric S. Raymond68996602000-07-24 03:28:40 +0000318A pad is like a window, except that it is not restricted by the screen
319size, and is not necessarily associated with a particular part of the
320screen. Pads can be used when a large window is needed, and only a
321part of the window will be on the screen at one time. Automatic
322refreshes of pads (e.g., from scrolling or echoing of input) do not
323occur. The \method{refresh()} and \method{noutrefresh()} methods of a
324pad require 6 arguments to specify the part of the pad to be
325displayed and the location on the screen to be used for the display.
326The arguments are pminrow, pmincol, sminrow, smincol, smaxrow,
327smaxcol; the p arguments refer to the upper left corner of the the pad
328region to be displayed and the s arguments define a clipping box on
329the screen within which the pad region is to be displayed.
Fred Drakea4070ce1999-06-21 21:13:09 +0000330\end{funcdesc}
331
332\begin{funcdesc}{newwin}{\optional{nlines, ncols,} begin_y, begin_x}
333Return a new window, whose left-upper corner is at
334\code{(\var{begin_y}, \var{begin_x})}, and whose height/width is
Fred Drake0bccd731999-06-23 17:28:01 +0000335\var{nlines}/\var{ncols}.
336
337By default, the window will extend from the
Fred Drakea4070ce1999-06-21 21:13:09 +0000338specified position to the lower right corner of the screen.
339\end{funcdesc}
340
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000341\begin{funcdesc}{nl}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000342Enter newline mode. This mode translates the return key into newline
343on input, and translates newline into return and line-feed on output.
344Newline mode is initially on.
Fred Drakea4070ce1999-06-21 21:13:09 +0000345\end{funcdesc}
346
347\begin{funcdesc}{nocbreak}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000348Leave cbreak mode. Return to normal ``cooked'' mode with line buffering.
Fred Drakea4070ce1999-06-21 21:13:09 +0000349\end{funcdesc}
350
Fred Drakea4070ce1999-06-21 21:13:09 +0000351\begin{funcdesc}{noecho}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000352Leave echo mode. Echoing of input characters is turned off,
Fred Drakea4070ce1999-06-21 21:13:09 +0000353\end{funcdesc}
354
Fred Drakea4070ce1999-06-21 21:13:09 +0000355\begin{funcdesc}{nonl}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000356Leave newline mode. Disable translation of return into newline on
357input, and disable low-level translation of newline into
358newline/return on output (but this does not change the behavior of
Fred Drakee1b304d2000-07-24 19:35:52 +0000359\code{addch('\e n')}, which always does the equivalent of return and
360line feed on the virtual screen). With translation off, curses can
361sometimes speed up vertical motion a little; also, it will be able to
362detect the return key on input.
Fred Drakea4070ce1999-06-21 21:13:09 +0000363\end{funcdesc}
364
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000365\begin{funcdesc}{noqiflush}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000366When the noqiflush routine is used, normal flush of input and
367output queues associated with the INTR, QUIT and SUSP
368characters will not be done. You may want to call
369\function{noqiflush()} in a signal handler if you want output
370to continue as though the interrupt had not occurred, after the
371handler exits.
Fred Drakea4070ce1999-06-21 21:13:09 +0000372\end{funcdesc}
373
374\begin{funcdesc}{noraw}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000375Leave raw mode. Return to normal ``cooked'' mode with line buffering.
Fred Drakea4070ce1999-06-21 21:13:09 +0000376\end{funcdesc}
377
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000378\begin{funcdesc}{pair_content}{pair_number}
379Returns a tuple \var{(fg,bg)} containing the colors for the requested
380color pair. The value of \var{pair_number} must be between 0 and
381COLOR_PAIRS-1.
Fred Drakea4070ce1999-06-21 21:13:09 +0000382\end{funcdesc}
383
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000384\begin{funcdesc}{pair_number}{attr}
385Returns the number of the color-pair set by the attribute value \var{attr}.
386\function{color_pair()} is the counterpart to this function.
Fred Drakea4070ce1999-06-21 21:13:09 +0000387\end{funcdesc}
388
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000389\begin{funcdesc}{putp}{string}
Eric S. Raymond68996602000-07-24 03:28:40 +0000390Equivalent to \code{tputs(str, 1, putchar)}; emits the value of a
391specified terminfo capability for the current terminal. Note that the
392output of putp always goes to standard output.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000393\end{funcdesc}
394
395\begin{funcdesc}{qiflush}{ \optional{flag} }
396If \var{flag} is false, the effect is the same as calling
397\function{noqiflush()}. If \var{flag} is true, or no argument is
398provided, the queues will be flushed when these control characters are
399read.
400\end{funcdesc}
401
402\begin{funcdesc}{raw}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000403Enter raw mode. In raw mode, normal line buffering and
404processing of interrupt, quit, suspend, and flow control keys are
405turned off; characters are presented to curses input functions one
406by one.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000407\end{funcdesc}
408
409\begin{funcdesc}{reset_prog_mode}{}
410Restores the terminal to ``program'' mode, as previously saved
411by \function{def_prog_mode()}.
412\end{funcdesc}
413
414\begin{funcdesc}{reset_shell_mode}{}
415Restores the terminal to ``shell'' mode, as previously saved
416by \function{def_shell_mode()}.
417\end{funcdesc}
418
419\begin{funcdesc}{setsyx}{y, x}
420Sets the virtual screen cursor to \var{y}, \var{x}.
421If \var{y} and \var{x} are both -1, then leaveok is set.
422\end{funcdesc}
423
424\begin{funcdesc}{start_color}{}
425Must be called if the programmer wants to use colors, and before any
426other color manipulation routine is called. It is good
427practice to call this routine right after \function{initscr()}.
428
429\function{start_color()} initializes eight basic colors (black, red,
430green, yellow, blue, magenta, cyan, and white), and two global
431variables in the \module{curses} module, COLORS and COLOR_PAIRS,
432containing the maximum number of colors and color-pairs the terminal
433can support. It also restores the colors on the terminal to the
434values they had when the terminal was just turned on.
435\end{funcdesc}
436
437\begin{funcdesc}{termattrs}{}
438Returns a logical OR of all video attributes supported by the
439terminal. This information is useful when a curses program needs
440complete control over the appearance of the screen.
441\end{funcdesc}
442
443\begin{funcdesc}{termname}{}
444Returns the value of the environment variable TERM, truncated to 14
445characters.
446\end{funcdesc}
447
Andrew M. Kuchling1962fb52000-07-26 02:59:13 +0000448\begin{funcdesc}{tigetflag}{capname}
449Returns the value of the Boolean capability corresponding to the
450terminfo capability name \var{capname}. The value -1 is returned if
451\var{capname} is not a Boolean capability, or 0 if it is canceled or
452absent from the terminal description.
453\end{funcdesc}
454
455\begin{funcdesc}{tigetnum}{capname}
456Returns the value of the numeric capability corresponding to the
457terminfo capability name \var{capname}. The value -2 is returned if
458\var{capname} is not a numeric capability, or -1 if it is canceled or absent
459from the terminal description.
460\end{funcdesc}
461
462\begin{funcdesc}{tigetstr}{capname}
463Returns the value of the string capability corresponding to the
464terminfo capability name \var{capname}. \code{None} is returned if
465\var{capname} is not a string capability, or is canceled or absent
466from the terminal description.
467\end{funcdesc}
468
Andrew M. Kuchlingd24ff442000-06-21 01:42:51 +0000469\begin{funcdesc}{typeahead}{fd}
470Specifies that the file descriptor \var{fd} be used for typeahead
471checking. If \var{fd} is -1, then no typeahead checking is done.
472
473The curses library does ``line-breakout optimization'' by looking for
474typeahead periodically while updating the screen. If input is found,
475and it is coming from a tty, the current update is postponed until
476refresh or doupdate is called again, allowing faster response to
477commands typed in advance. This function allows specifying a different
478file descriptor for typeahead checking.
479\end{funcdesc}
480
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000481\begin{funcdesc}{unctrl}{ch}
482Returns a string which is a printable representation of the character
483\var{ch}. Control characters are displayed as a caret followed by the
484character, for example as \verb|^C|. Printing characters are left as they
485are.
486\end{funcdesc}
487
488\begin{funcdesc}{ungetch}{ch}
489Push \var{ch} so the next \method{getch()} will return it.
490\strong{Note:} only one \var{ch} can be pushed before \method{getch()}
491is called.
492\end{funcdesc}
493
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000494\begin{funcdesc}{ungetmouse}{id, x, y, z, bstate}
495Push a \constant{KEY_MOUSE} event onto the input queue, associating
496the given state data with it.
497\end{funcdesc}
498
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000499\begin{funcdesc}{use_env}{flag}
500If used, this function should be called before \function{initscr} or
501newterm are called. When \var{flag} is false, the values of
502lines and columns specified in the terminfo database will be
503used, even if environment variables LINES and COLUMNS (used by
504default) are set, or if curses is running in a window (in which
505case default behavior would be to use the window size if LINES
506and COLUMNS are not set).
507\end{funcdesc}
Fred Drakea4070ce1999-06-21 21:13:09 +0000508
509\subsection{Window Objects \label{curses-window-objects}}
510
511Window objects, as returned by \function{initscr()} and
512\function{newwin()} above, have the
513following methods:
514
Fred Drakea4070ce1999-06-21 21:13:09 +0000515\begin{methoddesc}{addch}{\optional{y, x,} ch\optional{, attr}}
516\strong{Note:} A \emph{character} means a C character (i.e., an
517\ASCII{} code), rather then a Python character (a string of length 1).
518(This note is true whenever the documentation mentions a character.)
Eric S. Raymond68996602000-07-24 03:28:40 +0000519The builtin \function{ord()} is handy for conveying strings to codes.
Fred Drakea4070ce1999-06-21 21:13:09 +0000520
521Paint character \var{ch} at \code{(\var{y}, \var{x})} with attributes
522\var{attr}, overwriting any character previously painter at that
523location. By default, the character position and attributes are the
524current settings for the window object.
525\end{methoddesc}
526
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000527\begin{methoddesc}{addnstr}{\optional{y, x,} str, n\optional{, attr}}
528Paint at most \var{n} characters of the
529string \var{str} at \code{(\var{y}, \var{x})} with attributes
Fred Drake0bccd731999-06-23 17:28:01 +0000530\var{attr}, overwriting anything previously on the display.
Fred Drakea4070ce1999-06-21 21:13:09 +0000531\end{methoddesc}
532
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000533\begin{methoddesc}{addstr}{\optional{y, x,} str\optional{, attr}}
534Paint the string \var{str} at \code{(\var{y}, \var{x})} with attributes
535\var{attr}, overwriting anything previously on the display.
Fred Drakea4070ce1999-06-21 21:13:09 +0000536\end{methoddesc}
537
538\begin{methoddesc}{attroff}{attr}
Eric S. Raymond68996602000-07-24 03:28:40 +0000539Remove attribute \var{attr} from the ``background'' set applied to all
540writes to the current window.
Fred Drakea4070ce1999-06-21 21:13:09 +0000541\end{methoddesc}
542
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000543\begin{methoddesc}{attron}{attr}
Eric S. Raymond68996602000-07-24 03:28:40 +0000544Add attribute \var{attr} from the ``background'' set applied to all
545writes to the current window.
Fred Drakea4070ce1999-06-21 21:13:09 +0000546\end{methoddesc}
547
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000548\begin{methoddesc}{attrset}{attr}
Eric S. Raymond68996602000-07-24 03:28:40 +0000549Set the ``background'' set of attributes to \var{attr}. This set is
550initially 0 (no attributes).
Fred Drakea4070ce1999-06-21 21:13:09 +0000551\end{methoddesc}
552
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000553\begin{methoddesc}{bkgd}{ch\optional{, attr}}
554Sets the background property of the window to the character \var{ch},
555with attributes \var{attr}. The change is then applied to every
556character position in that window:
557\begin{itemize}
Eric S. Raymondb924bd42000-07-27 21:10:02 +0000558\item
559The attribute of every character in the window is
560changed to the new background attribute.
561\item
562Wherever the former background character appears,
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000563it is changed to the new background character.
564\end{itemize}
565
566\end{methoddesc}
567
568\begin{methoddesc}{bkgdset}{ch\optional{, attr}}
569Sets the window's background. A window's background consists of a
570character and any combination of attributes. The attribute part of
571the background is combined (OR'ed) with all non-blank characters that
572are written into the window. Both the character and attribute parts
573of the background are combined with the blank characters. The
574background becomes a property of the character and moves with the
575character through any scrolling and insert/delete line/character
576operations.
Fred Drakea4070ce1999-06-21 21:13:09 +0000577\end{methoddesc}
578
Fred Drake0bccd731999-06-23 17:28:01 +0000579\begin{methoddesc}{border}{\optional{ls\optional{, rs\optional{, ts\optional{,
580 bs\optional{, tl\optional{, tr\optional{,
581 bl\optional{, br}}}}}}}}}
582Draw a border around the edges of the window. Each parameter specifies
583the character to use for a specific part of the border; see the table
584below for more details. The characters must be specified as integers;
585using one-character strings will cause \exception{TypeError} to be
586raised.
587
588\strong{Note:} A \code{0} value for any parameter will cause the
589default character to be used for that parameter. Keyword parameters
590can \emph{not} be used. The defaults are listed in this table:
591
592\begin{tableiii}{l|l|l}{var}{Parameter}{Description}{Default value}
593 \lineiii{ls}{Left side}{\constant{ACS_VLINE}}
594 \lineiii{rs}{Right side}{\constant{ACS_VLINE}}
595 \lineiii{ts}{Top}{\constant{ACS_HLINE}}
596 \lineiii{bs}{Bottom}{\constant{ACS_HLINE}}
597 \lineiii{tl}{Upper-left corner}{\constant{ACS_ULCORNER}}
598 \lineiii{tr}{Upper-right corner}{\constant{ACS_URCORNER}}
599 \lineiii{bl}{Bottom-left corner}{\constant{ACS_BLCORNER}}
600 \lineiii{br}{Bottom-right corner}{\constant{ACS_BRCORNER}}
601\end{tableiii}
Fred Drakea4070ce1999-06-21 21:13:09 +0000602\end{methoddesc}
603
Fred Drake0bccd731999-06-23 17:28:01 +0000604\begin{methoddesc}{box}{\optional{vertch, horch}}
605Similar to \method{border()}, but both \var{ls} and \var{rs} are
606\var{vertch} and both \var{ts} and {bs} are \var{horch}. The default
607corner characters are always used by this function.
Fred Drakea4070ce1999-06-21 21:13:09 +0000608\end{methoddesc}
609
Fred Drakea4070ce1999-06-21 21:13:09 +0000610\begin{methoddesc}{clear}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000611Like \method{erase()}, but also causes the whole window to be repainted
Fred Drakea4070ce1999-06-21 21:13:09 +0000612upon next call to \method{refresh()}.
613\end{methoddesc}
614
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000615\begin{methoddesc}{clearok}{yes}
616If \var{yes} is 1, the next call to \method{refresh()}
Eric S. Raymond68996602000-07-24 03:28:40 +0000617will clear the window completely.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000618\end{methoddesc}
619
Fred Drakea4070ce1999-06-21 21:13:09 +0000620\begin{methoddesc}{clrtobot}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000621Erase from cursor to the end of the window: all lines below the cursor
Fred Drakea4070ce1999-06-21 21:13:09 +0000622are deleted, and then the equivalent of \method{clrtoeol()} is performed.
623\end{methoddesc}
624
625\begin{methoddesc}{clrtoeol}{}
626Erase from cursor to the end of the line.
627\end{methoddesc}
628
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000629\begin{methoddesc}{cursyncup}{}
630Updates the current cursor position of all the ancestors of the window
631to reflect the current cursor position of the window.
Fred Drakea4070ce1999-06-21 21:13:09 +0000632\end{methoddesc}
633
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000634\begin{methoddesc}{delch}{\optional{x, y}}
635Delete any character at \code{(\var{y}, \var{x})}.
Fred Drakea4070ce1999-06-21 21:13:09 +0000636\end{methoddesc}
637
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000638\begin{methoddesc}{deleteln}{}
639Delete the line under the cursor. All following lines are moved up
640by 1 line.
641\end{methoddesc}
642
643\begin{methoddesc}{derwin}{\optional{nlines, ncols,} begin_y, begin_y}
644An abbreviation for ``derive window'', \method{derwin()} is the same
645as calling \method{subwin()}, except that \var{begin_y} and
646\var{begin_x} are relative to the origin of the window, rather than
647relative to the entire screen. Returns a window object for the
648derived window.
649\end{methoddesc}
650
651\begin{methoddesc}{echochar}{ch\optional{, attr}}
652Add character \var{ch} with attribute \var{attr}, and immediately
Eric S. Raymond68996602000-07-24 03:28:40 +0000653call \method{refresh} on the window.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000654\end{methoddesc}
655
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000656\begin{methoddesc}{enclose}{y, x}
657Tests whether the given pair of screen-relative character-cell
658coordinates are enclosed by the given window, returning true or
659false. It is useful for determining what subset of the screen
660windows enclose the location of a mouse event.
661\end{methoddesc}
662
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000663\begin{methoddesc}{erase}{}
664Clear the window.
665\end{methoddesc}
666
667\begin{methoddesc}{getbegyx}{}
668Return a tuple \code{(\var{y}, \var{x})} of co-ordinates of upper-left
669corner.
Fred Drakea4070ce1999-06-21 21:13:09 +0000670\end{methoddesc}
671
672\begin{methoddesc}{getch}{\optional{x, y}}
673Get a character. Note that the integer returned does \emph{not} have to
674be in \ASCII{} range: function keys, keypad keys and so on return numbers
675higher then 256. In no-delay mode, an exception is raised if there is
676no input.
677\end{methoddesc}
678
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000679\begin{methoddesc}{getkey}{\optional{x, y}}
680Get a character, returning a string instead of an integer, as
681\method{getch()} does. Function keys, keypad keys and so on return a
682multibyte string containing the key name. In no-delay mode, an
683exception is raised if there is no input.
684\end{methoddesc}
685
686\begin{methoddesc}{getmaxyx}{}
687Return a tuple \code{(\var{y}, \var{x})} of the height and width of
688the window.
689\end{methoddesc}
690
691\begin{methoddesc}{getparyx}{}
692Returns the beginning coordinates of this window relative to its
693parent window into two integer variables y and x. Returns
694\code{-1,-1} if this window has no parent.
695\end{methoddesc}
696
Fred Drakea4070ce1999-06-21 21:13:09 +0000697\begin{methoddesc}{getstr}{\optional{x, y}}
698Read a string from the user, with primitive line editing capacity.
699\end{methoddesc}
700
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000701\begin{methoddesc}{getyx}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000702Return a tuple \code{(\var{y}, \var{x})} of current cursor position
703relative to the window's upper-left corner.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000704\end{methoddesc}
705
706\begin{methoddesc}{hline}{\optional{y, x,} ch, n}
707Display a horizontal line starting at \code{(\var{y}, \var{x})} with
708length \var{n} consisting of the character \var{ch}.
709\end{methoddesc}
710
711\begin{methoddesc}{idcok}{flag}
712If \var{flag} is false, curses no longer considers using the hardware
713insert/delete character feature of the terminal; if \var{flag} is
714true, use of character insertion and deletion is enabled. When curses
715is first initialized, use of character insert/delete is enabled by
716default.
717\end{methoddesc}
718
719\begin{methoddesc}{idlok}{yes}
720If called with \var{yes} equal to 1, \module{curses} will try and use
721hardware line editing facilities. Otherwise, line insertion/deletion
722are disabled.
723\end{methoddesc}
724
725\begin{methoddesc}{immedok}{flag}
726If \var{flag} is true, any change in the window image
727automatically causes the window to be refreshed; you no longer
728have to call \method{refresh()} yourself. However, it may
729degrade performance considerably, due to repeated calls to
730wrefresh. This option is disabled by default.
731\end{methoddesc}
732
Fred Drakea4070ce1999-06-21 21:13:09 +0000733\begin{methoddesc}{inch}{\optional{x, y}}
734Return the character at the given position in the window. The bottom
7358 bits are the character proper, and upper bits are the attributes.
736\end{methoddesc}
737
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000738\begin{methoddesc}{insch}{\optional{y, x,} ch\optional{, attr}}
739Paint character \var{ch} at \code{(\var{y}, \var{x})} with attributes
740\var{attr}, moving the line from position \var{x} right by one
741character.
Fred Drakea4070ce1999-06-21 21:13:09 +0000742\end{methoddesc}
743
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000744\begin{methoddesc}{insdelln}{nlines}
745Inserts \var{nlines} lines into the specified window above the current
746line. The \var{nlines} bottom lines are lost. For negative
747\var{nlines}, delete \var{nlines} lines starting with the one under
748the cursor, and move the remaining lines up. The bottom \var{nlines}
749lines are cleared. The current cursor position remains the same.
750\end{methoddesc}
751
752\begin{methoddesc}{insertln}{}
753Insert a blank line under the cursor. All following lines are moved
754down by 1 line.
755\end{methoddesc}
756
757\begin{methoddesc}{insnstr}{\optional{y, x, } str, n \optional{, attr}}
758Insert a character string (as many characters as will fit on the line)
759before the character under the cursor, up to \var{n} characters.
760If \var{n} is zero or negative,
761the entire string is inserted.
762All characters to the right of
763the cursor are shifted right, with the the rightmost characters on the
764line being lost. The cursor position does not change (after moving to
765\var{y}, \var{x}, if specified).
766\end{methoddesc}
767
768\begin{methoddesc}{insstr}{\optional{y, x, } str \optional{, attr}}
769Insert a character string (as many characters as will fit on the line)
770before the character under the cursor. All characters to the right of
771the cursor are shifted right, with the the rightmost characters on the
772line being lost. The cursor position does not change (after moving to
773\var{y}, \var{x}, if specified).
774\end{methoddesc}
775
776\begin{methoddesc}{instr}{\optional{y, x} \optional{, n}}
777Returns a string of characters, extracted from the window starting at
778the current cursor position, or at \var{y}, \var{x} if specified.
779Attributes are stripped from the characters. If \var{n} is specified,
780\method{instr()} returns return a string at most \var{n} characters
781long (exclusive of the trailing NUL).
782\end{methoddesc}
783
784\begin{methoddesc}{is_linetouched}{\var{line}}
785Returns true if the specified line was modified since the last call to
786\method{refresh()}; otherwise returns false. Raises a
787\exception{curses.error} exception if \var{line} is not valid
788for the given window.
789\end{methoddesc}
790
791\begin{methoddesc}{is_wintouched}{}
792Returns true if the specified window was modified since the last call to
793\method{refresh()}; otherwise returns false.
794\end{methoddesc}
795
796\begin{methoddesc}{keypad}{yes}
797If \var{yes} is 1, escape sequences generated by some keys (keypad,
798function keys) will be interpreted by \module{curses}.
799If \var{yes} is 0, escape sequences will be left as is in the input
800stream.
Fred Drakea4070ce1999-06-21 21:13:09 +0000801\end{methoddesc}
802
803\begin{methoddesc}{leaveok}{yes}
Eric S. Raymond68996602000-07-24 03:28:40 +0000804If \var{yes} is 1, cursor is left where it is on update, instead of
805being at ``cursor position.'' This reduces cursor movement where
806possible. If possible the cursor will be made invisible.
Fred Drakea4070ce1999-06-21 21:13:09 +0000807
Eric S. Raymond68996602000-07-24 03:28:40 +0000808If \var{yes} is 0, cursor will always be at ``cursor position'' after
809an update.
Fred Drakea4070ce1999-06-21 21:13:09 +0000810\end{methoddesc}
811
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000812\begin{methoddesc}{move}{new_y, new_x}
813Move cursor to \code{(\var{new_y}, \var{new_x})}.
Fred Drakea4070ce1999-06-21 21:13:09 +0000814\end{methoddesc}
815
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000816\begin{methoddesc}{mvderwin}{y, x}
817Moves the window inside its parent window. The screen-relative
818parameters of the window are not changed. This routine is used to
819display different parts of the parent window at the same physical
820position on the screen.
821\end{methoddesc}
Fred Drakea4070ce1999-06-21 21:13:09 +0000822
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000823\begin{methoddesc}{mvwin}{new_y, new_x}
824Move the window so its upper-left corner is at \code{(\var{new_y}, \var{new_x})}.
Fred Drakea4070ce1999-06-21 21:13:09 +0000825\end{methoddesc}
826
827\begin{methoddesc}{nodelay}{yes}
828If \var{yes} is 1, \method{getch()} will be non-blocking.
829\end{methoddesc}
830
831\begin{methoddesc}{notimeout}{yes}
832If \var{yes} is 1, escape sequences will not be timed out.
833
834If \var{yes} is 0, after a few milliseconds, an escape sequence will
835not be interpreted, and will be left in the input stream as is.
836\end{methoddesc}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000837
838\begin{methoddesc}{noutrefresh}{}
Eric S. Raymond65983372000-08-09 21:49:31 +0000839Mark for refresh but wait. This function updates the data structure
840representing the desired state of the window, but does not force
841an update of the physical screen.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000842\end{methoddesc}
843
844\begin{methoddesc}{putwin}{file}
845Writes all data associated with the window into the provided file
846object. This information can be later retrieved using the
847\function{getwin()} function.
848
849\end{methoddesc}
850
851\begin{methoddesc}{redrawln}{beg, num}
852Indicates that the \var{num} screen lines, starting at line \var{beg},
853are corrupted and should be completely redrawn on the next
854\method{refresh()} call.
855\end{methoddesc}
856
857\begin{methoddesc}{redrawwin}{}
858Touches the entire window, causing it to be completely redrawn on the
859next \method{refresh()} call.
860\end{methoddesc}
861
862\begin{methoddesc}{refresh}{ \optional{pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol} }
863Update the display immediately (sync actual screen with previous
864drawing/deleting methods).
865
866The 6 optional arguments can only be specified when the window is a
867pad created with \function{newpad()}. The additional parameters are
868needed to indicate what part of the pad and screen are involved.
869\var{pminrow} and \var{pmincol} specify the upper left-hand corner of the
870rectangle to be displayed in the pad. \var{sminrow}, \var{smincol},
871\var{smaxrow}, and \var{smaxcol} specify the edges of the rectangle to be displayed on the screen. The lower right-hand corner of the
872rectangle to be displayed in the pad is calculated from the screen
873coordinates, since the rectangles must be the same size. Both
874rectangles must be entirely contained within their respective
875structures. Negative values of \var{pminrow}, \var{pmincol},
876\var{sminrow}, or \var{smincol} are treated as if they were zero.
877\end{methoddesc}
878
879\begin{methoddesc}{scroll}{\optional{lines\code{ = 1}}}
880Scroll the screen upward by \var{lines} lines.
881\end{methoddesc}
882
883\begin{methoddesc}{scrollok}{flag}
884Controls what happens when the cursor of a window is moved off the
Eric S. Raymond68996602000-07-24 03:28:40 +0000885edge of the window or scrolling region, either as a result of a
886newline action on the bottom line, or typing the last character
887of the last line. If \var{flag} is false, the cursor is left
888on the bottom line. If \var{flag} is true, the window is
889scrolled up one line. Note that in order to get the physical
890scrolling effect on the terminal, it is also necessary to call
891\method{idlok()}.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000892\end{methoddesc}
893
894\begin{methoddesc}{setscrreg}{top, bottom}
895Set the scrolling region from line \var{top} to line \var{bottom}. All
896scrolling actions will take place in this region.
897\end{methoddesc}
898
899\begin{methoddesc}{standend}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000900Turn off the standout attribute. On some terminals this has the
901side effect of turning off all attributes.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000902\end{methoddesc}
903
904\begin{methoddesc}{standout}{}
905Turn on attribute \var{A_STANDOUT}.
906\end{methoddesc}
907
908\begin{methoddesc}{subpad}{\optional{nlines, ncols,} begin_y, begin_y}
909Return a sub-window, whose upper-left corner is at
910\code{(\var{begin_y}, \var{begin_x})}, and whose width/height is
911\var{ncols}/\var{nlines}.
912\end{methoddesc}
913
914\begin{methoddesc}{subwin}{\optional{nlines, ncols,} begin_y, begin_y}
915Return a sub-window, whose upper-left corner is at
916\code{(\var{begin_y}, \var{begin_x})}, and whose width/height is
917\var{ncols}/\var{nlines}.
918
919By default, the sub-window will extend from the
920specified position to the lower right corner of the window.
921\end{methoddesc}
922
923\begin{methoddesc}{syncdown}{}
924Touches each location in the window that has been touched in any of
925its ancestor windows. This routine is called by \method{refresh()},
926so it should almost never be necessary to call it manually.
927\end{methoddesc}
928
929\begin{methoddesc}{syncok}{flag}
930If called with \var{flag} set to true, then \method{syncup()} is
931called automatically whenever there is a change in the window.
932\end{methoddesc}
933
934\begin{methoddesc}{syncup}{}
935Touches all locations in ancestors of the window that have been changed in
936the window.
937\end{methoddesc}
938
Andrew M. Kuchlingd24ff442000-06-21 01:42:51 +0000939\begin{methoddesc}{timeout}{delay}
Thomas Woutersf8316632000-07-16 19:01:10 +0000940Sets blocking or non-blocking read behavior for the window. If
Andrew M. Kuchlingd24ff442000-06-21 01:42:51 +0000941\var{delay} is negative, blocking read is used, which will wait
942indefinitely for input). If \var{delay} is zero, then non-blocking
943read is used, and -1 will be returned by \method{getch()} if no input
944is waiting. If \var{delay} is positive, then \method{getch()} will
945block for \var{delay} milliseconds, and return -1 if there is still no
946input at the end of that time.
947\end{methoddesc}
948
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000949\begin{methoddesc}{touchline}{start, count}
950Pretend \var{count} lines have been changed, starting with line
951\var{start}.
952\end{methoddesc}
953
954\begin{methoddesc}{touchwin}{}
955Pretend the whole window has been changed, for purposes of drawing
956optimizations.
957\end{methoddesc}
958
959\begin{methoddesc}{untouchwin}{}
960Marks all lines in the window as unchanged since the last call to
961\method{refresh()}.
962\end{methoddesc}
963
964\begin{methoddesc}{vline}{\optional{y, x,} ch, n}
965Display a vertical line starting at \code{(\var{y}, \var{x})} with
966length \var{n} consisting of the character \var{ch}.
967\end{methoddesc}
968
969\subsection{Constants}
970
971The \module{curses} module defines the following data members:
972
973\begin{datadesc}{version}
974A string representing the current version of the module.
975Also available as \constant{__version__}.
976\end{datadesc}
977
Fred Drakeec4b2af2000-08-09 14:34:48 +0000978Several constants are available to specify character cell attributes:
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000979
Fred Drakeec4b2af2000-08-09 14:34:48 +0000980\begin{tableii}{l|l}{code}{Attribute}{Meaning}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000981 \lineii{A_ALTCHARSET}{Alternate character set mode.}
982 \lineii{A_BLINK}{Blink mode.}
983 \lineii{A_BOLD}{Bold mode.}
984 \lineii{A_DIM}{Dim mode.}
985 \lineii{A_NORMAL}{Normal attribute.}
986 \lineii{A_STANDOUT}{Standout mode.}
987 \lineii{A_UNDERLINE}{Underline mode.}
988\end{tableii}
989
990Keys are referred to by integer constants with names starting with
Fred Drakeec4b2af2000-08-09 14:34:48 +0000991\samp{KEY_}. The exact keycaps available are system dependent.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000992
993% XXX this table is far too large!
994% XXX should this table be alphabetized?
995
Fred Drake1bf4e932000-09-21 16:04:08 +0000996\begin{longtableii}{l|l}{code}{Key constant}{Key}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000997 \lineii{KEY_MIN}{Minimum key value}
998 \lineii{KEY_BREAK}{ Break key (unreliable) }
999 \lineii{KEY_DOWN}{ Down-arrow }
1000 \lineii{KEY_UP}{ Up-arrow }
1001 \lineii{KEY_LEFT}{ Left-arrow }
1002 \lineii{KEY_RIGHT}{ Right-arrow }
1003 \lineii{KEY_HOME}{ Home key (upward+left arrow) }
1004 \lineii{KEY_BACKSPACE}{ Backspace (unreliable) }
1005 \lineii{KEY_F0}{ Function keys. Up to 64 function keys are supported. }
1006 \lineii{KEY_F\var{n}}{ Value of function key \var{n} }
1007 \lineii{KEY_DL}{ Delete line }
1008 \lineii{KEY_IL}{ Insert line }
1009 \lineii{KEY_DC}{ Delete character }
1010 \lineii{KEY_IC}{ Insert char or enter insert mode }
1011 \lineii{KEY_EIC}{ Exit insert char mode }
1012 \lineii{KEY_CLEAR}{ Clear screen }
1013 \lineii{KEY_EOS}{ Clear to end of screen }
1014 \lineii{KEY_EOL}{ Clear to end of line }
1015 \lineii{KEY_SF}{ Scroll 1 line forward }
1016 \lineii{KEY_SR}{ Scroll 1 line backward (reverse) }
1017 \lineii{KEY_NPAGE}{ Next page }
1018 \lineii{KEY_PPAGE}{ Previous page }
1019 \lineii{KEY_STAB}{ Set tab }
1020 \lineii{KEY_CTAB}{ Clear tab }
1021 \lineii{KEY_CATAB}{ Clear all tabs }
1022 \lineii{KEY_ENTER}{ Enter or send (unreliable) }
1023 \lineii{KEY_SRESET}{ Soft (partial) reset (unreliable) }
1024 \lineii{KEY_RESET}{ Reset or hard reset (unreliable) }
1025 \lineii{KEY_PRINT}{ Print }
1026 \lineii{KEY_LL}{ Home down or bottom (lower left) }
1027 \lineii{KEY_A1}{ Upper left of keypad }
1028 \lineii{KEY_A3}{ Upper right of keypad }
1029 \lineii{KEY_B2}{ Center of keypad }
1030 \lineii{KEY_C1}{ Lower left of keypad }
1031 \lineii{KEY_C3}{ Lower right of keypad }
1032 \lineii{KEY_BTAB}{ Back tab }
1033 \lineii{KEY_BEG}{ Beg (beginning) }
1034 \lineii{KEY_CANCEL}{ Cancel }
1035 \lineii{KEY_CLOSE}{ Close }
1036 \lineii{KEY_COMMAND}{ Cmd (command) }
1037 \lineii{KEY_COPY}{ Copy }
1038 \lineii{KEY_CREATE}{ Create }
1039 \lineii{KEY_END}{ End }
1040 \lineii{KEY_EXIT}{ Exit }
1041 \lineii{KEY_FIND}{ Find }
1042 \lineii{KEY_HELP}{ Help }
1043 \lineii{KEY_MARK}{ Mark }
1044 \lineii{KEY_MESSAGE}{ Message }
1045 \lineii{KEY_MOVE}{ Move }
1046 \lineii{KEY_NEXT}{ Next }
1047 \lineii{KEY_OPEN}{ Open }
1048 \lineii{KEY_OPTIONS}{ Options }
1049 \lineii{KEY_PREVIOUS}{ Prev (previous) }
1050 \lineii{KEY_REDO}{ Redo }
1051 \lineii{KEY_REFERENCE}{ Ref (reference) }
1052 \lineii{KEY_REFRESH}{ Refresh }
1053 \lineii{KEY_REPLACE}{ Replace }
1054 \lineii{KEY_RESTART}{ Restart }
1055 \lineii{KEY_RESUME}{ Resume }
1056 \lineii{KEY_SAVE}{ Save }
1057 \lineii{KEY_SBEG}{ Shifted Beg (beginning) }
1058 \lineii{KEY_SCANCEL}{ Shifted Cancel }
1059 \lineii{KEY_SCOMMAND}{ Shifted Command }
1060 \lineii{KEY_SCOPY}{ Shifted Copy }
1061 \lineii{KEY_SCREATE}{ Shifted Create }
1062 \lineii{KEY_SDC}{ Shifted Delete char }
1063 \lineii{KEY_SDL}{ Shifted Delete line }
1064 \lineii{KEY_SELECT}{ Select }
1065 \lineii{KEY_SEND}{ Shifted End }
1066 \lineii{KEY_SEOL}{ Shifted Clear line }
1067 \lineii{KEY_SEXIT}{ Shifted Dxit }
1068 \lineii{KEY_SFIND}{ Shifted Find }
1069 \lineii{KEY_SHELP}{ Shifted Help }
1070 \lineii{KEY_SHOME}{ Shifted Home }
1071 \lineii{KEY_SIC}{ Shifted Input }
1072 \lineii{KEY_SLEFT}{ Shifted Left arrow }
1073 \lineii{KEY_SMESSAGE}{ Shifted Message }
1074 \lineii{KEY_SMOVE}{ Shifted Move }
1075 \lineii{KEY_SNEXT}{ Shifted Next }
1076 \lineii{KEY_SOPTIONS}{ Shifted Options }
1077 \lineii{KEY_SPREVIOUS}{ Shifted Prev }
1078 \lineii{KEY_SPRINT}{ Shifted Print }
1079 \lineii{KEY_SREDO}{ Shifted Redo }
1080 \lineii{KEY_SREPLACE}{ Shifted Replace }
1081 \lineii{KEY_SRIGHT}{ Shifted Right arrow }
1082 \lineii{KEY_SRSUME}{ Shifted Resume }
1083 \lineii{KEY_SSAVE}{ Shifted Save }
1084 \lineii{KEY_SSUSPEND}{ Shifted Suspend }
1085 \lineii{KEY_SUNDO}{ Shifted Undo }
1086 \lineii{KEY_SUSPEND}{ Suspend }
1087 \lineii{KEY_UNDO}{ Undo }
1088 \lineii{KEY_MOUSE}{ Mouse event has occurred }
1089 \lineii{KEY_RESIZE}{ Terminal resize event }
1090 \lineii{KEY_MAX}{Maximum key value}
Fred Drake1bf4e932000-09-21 16:04:08 +00001091\end{longtableii}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001092
Fred Drakeec4b2af2000-08-09 14:34:48 +00001093On VT100s and their software emulations, such as X terminal emulators,
1094there are normally at least four function keys (\constant{KEY_F1},
1095\constant{KEY_F2}, \constant{KEY_F3}, \constant{KEY_F4}) available,
1096and the arrow keys mapped to \constant{KEY_UP}, \constant{KEY_DOWN},
1097\constant{KEY_LEFT} and \constant{KEY_RIGHT} in the obvious way. If
1098your machine has a PC keybboard, it is safe to expect arrow keys and
1099twelve function keys (older PC keyboards may have only ten function
1100keys); also, the following keypad mappings are standard:
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001101
Fred Drakeec4b2af2000-08-09 14:34:48 +00001102\begin{tableii}{l|l}{kbd}{Keycap}{Constant}
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001103 \lineii{Insert}{KEY_IC}
1104 \lineii{Delete}{KEY_DC}
1105 \lineii{Home}{KEY_HOME}
1106 \lineii{End}{KEY_END}
1107 \lineii{Page Up}{KEY_NPAGE}
1108 \lineii{Page Down}{KEY_PPAGE}
1109\end{tableii}
1110
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001111The following table lists characters from the alternate character set.
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001112These are inherited from the VT100 terminal, and will generally be
1113available on software emulations such as X terminals. When there
1114is no graphic available, curses falls back on a crude printable ASCII
1115approximation.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001116\strong{Note:} These are available only after \function{initscr()} has
1117been called.
1118
Fred Drake1bf4e932000-09-21 16:04:08 +00001119\begin{longtableii}{l|l}{code}{ACS code}{Meaning}
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001120 \lineii{ACS_BBSS}{alternate name for upper right corner}
Eric S. Raymond68996602000-07-24 03:28:40 +00001121 \lineii{ACS_BLOCK}{solid square block}
1122 \lineii{ACS_BOARD}{board of squares}
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001123 \lineii{ACS_BSBS}{alternate name for horizontal line}
1124 \lineii{ACS_BSSB}{alternate name for upper left corner}
1125 \lineii{ACS_BSSS}{alternate name for top tee}
Eric S. Raymond68996602000-07-24 03:28:40 +00001126 \lineii{ACS_BTEE}{bottom tee}
1127 \lineii{ACS_BULLET}{bullet}
1128 \lineii{ACS_CKBOARD}{checker board (stipple)}
1129 \lineii{ACS_DARROW}{arrow pointing down}
1130 \lineii{ACS_DEGREE}{degree symbol}
1131 \lineii{ACS_DIAMOND}{diamond}
1132 \lineii{ACS_GEQUAL}{greater-than-or-equal-to}
1133 \lineii{ACS_HLINE}{horizontal line}
1134 \lineii{ACS_LANTERN}{lantern symbol}
1135 \lineii{ACS_LARROW}{left arrow}
1136 \lineii{ACS_LEQUAL}{less-than-or-equal-to}
1137 \lineii{ACS_LLCORNER}{lower left-hand corner}
1138 \lineii{ACS_LRCORNER}{lower right-hand corner}
1139 \lineii{ACS_LTEE}{left tee}
1140 \lineii{ACS_NEQUAL}{not-equal sign}
1141 \lineii{ACS_PI}{letter pi}
1142 \lineii{ACS_PLMINUS}{plus-or-minus sign}
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001143 \lineii{ACS_PLUS}{big plus sign}
Eric S. Raymond68996602000-07-24 03:28:40 +00001144 \lineii{ACS_RARROW}{right arrow}
1145 \lineii{ACS_RTEE}{right tee}
1146 \lineii{ACS_S1}{scan line 1}
1147 \lineii{ACS_S3}{scan line 3}
1148 \lineii{ACS_S7}{scan line 7}
1149 \lineii{ACS_S9}{scan line 9}
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001150 \lineii{ACS_SBBS}{alternate name for lower right corner}
1151 \lineii{ACS_SBSB}{alternate name for vertical line}
1152 \lineii{ACS_SBSS}{alternate name for right tee}
1153 \lineii{ACS_SSBB}{alternate name for lower left corner}
1154 \lineii{ACS_SSBS}{alternate name for bottom tee}
1155 \lineii{ACS_SSSB}{alternate name for left tee}
1156 \lineii{ACS_SSSS}{alternate name for crossover or big plus}
Eric S. Raymond68996602000-07-24 03:28:40 +00001157 \lineii{ACS_STERLING}{pound sterling}
1158 \lineii{ACS_TTEE}{top tee}
1159 \lineii{ACS_UARROW}{up arrow}
1160 \lineii{ACS_ULCORNER}{upper left corner}
1161 \lineii{ACS_URCORNER}{upper right corner}
1162 \lineii{ACS_VLINE}{vertical line}
Fred Drake1bf4e932000-09-21 16:04:08 +00001163\end{longtableii}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001164
1165The following table lists the predefined colors:
1166
Fred Drakeec4b2af2000-08-09 14:34:48 +00001167\begin{tableii}{l|l}{code}{Constant}{Color}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001168 \lineii{COLOR_BLACK}{Black}
1169 \lineii{COLOR_BLUE}{Blue}
1170 \lineii{COLOR_CYAN}{Cyan (light greenish blue)}
1171 \lineii{COLOR_GREEN}{Green}
1172 \lineii{COLOR_MAGENTA}{Magenta (purplish red)}
1173 \lineii{COLOR_RED}{Red}
1174 \lineii{COLOR_WHITE}{White}
1175 \lineii{COLOR_YELLOW}{Yellow}
1176\end{tableii}
1177
Eric S. Raymond5a007692000-08-04 07:35:41 +00001178\section{\module{curses.textpad} ---
1179 Text input widget for curses programs}
1180
1181\declaremodule{standard}{curses.textpad}
1182\sectionauthor{Eric Raymond}{esr@thyrsus.com}
1183\moduleauthor{Eric Raymond}{esr@thyrsus.com}
1184\modulesynopsis{Emacs-like input editing in a curses window.}
1185\versionadded{1.6}
1186
1187The \module{curses.textpad} module provides a \class{Textbox} class
1188that handles elementary text editing in a curses window, supporting a
1189set of keybindings resembling those of Emacs (thus, also of Netscape
1190Navigator, BBedit 6.x, FrameMaker, and many other programs). The
1191module also provides a rectangle-drawing function useful for framing
1192text boxes or for other purposes.
1193
Fred Drakeec4b2af2000-08-09 14:34:48 +00001194The module \module{curses.textpad} defines the following function:
Eric S. Raymond5a007692000-08-04 07:35:41 +00001195
1196\begin{funcdesc}{rectangle}{win, uly, ulx, lry, lrx}
1197Draw a rectangle. The first argument must be a window object; the
1198remaining arguments are coordinates relative to that window. The
1199second and third arguments are the y and x coordinates of the upper
1200left hand corner of the rectangle To be drawn; the fourth and fifth
1201arguments are the y and x coordinates of the lower right hand corner.
1202The rectangle will be drawn using VT100/IBM PC forms characters on
1203terminals that make this possible (including xterm and most other
1204software terminal emulators). Otherwise it will be drawn with ASCII
1205dashes, vertical bars, and plus signs.
1206\end{funcdesc}
1207
Fred Drakeec4b2af2000-08-09 14:34:48 +00001208
Eric S. Raymond5a007692000-08-04 07:35:41 +00001209\subsection{Textbox objects \label{curses-textpad-objects}}
1210
1211You can instantiate a \class{Textbox} object as follows:
1212
Fred Drakeec4b2af2000-08-09 14:34:48 +00001213\begin{classdesc}{Textbox}{win}
1214Return a textbox widget object. The \var{win} argument should be a
1215curses \class{WindowObject} in which the textbox is to be contained.
1216The edit cursor of the textbox is initially located at the upper left
1217hand corner of the containin window, with coordinates \code{(0, 0)}.
1218The instance's \member{stripspaces} flag is initially on.
Eric S. Raymond5a007692000-08-04 07:35:41 +00001219\end{classdesc}
1220
Fred Drakeec4b2af2000-08-09 14:34:48 +00001221\class{Textbox} objects have the following methods:
Eric S. Raymond5a007692000-08-04 07:35:41 +00001222
Fred Drakeec4b2af2000-08-09 14:34:48 +00001223\begin{methoddesc}{edit}{\optional{validator}}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001224This is the entry point you will normally use. It accepts editing
Fred Drakeec4b2af2000-08-09 14:34:48 +00001225keystrokes until one of the termination keystrokes is entered. If
1226\var{validator} is supplied, it must be a function. It will be called
1227for each keystroke entered with the keystroke as a parameter; command
1228dispatch is done on the result. This method returns the window
1229contents as a string; whether blanks in the window are included is
1230affected by the \member{stripspaces} member.
Eric S. Raymond5a007692000-08-04 07:35:41 +00001231\end{methoddesc}
1232
1233\begin{methoddesc}{do_command}{ch}
1234Process a single command keystroke. Here are the supported special
1235keystrokes:
1236
Fred Drakeec4b2af2000-08-09 14:34:48 +00001237\begin{tableii}{l|l}{kbd}{Keystroke}{Action}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001238 \lineii{Ctrl-A}{Go to left edge of window.}
1239 \lineii{Ctrl-B}{Cursor left, wrapping to previous line if appropriate.}
1240 \lineii{Ctrl-D}{Delete character under cursor.}
1241 \lineii{Ctrl-E}{Go to right edge (stripspaces off) or end of line (stripspaces on).}
1242 \lineii{Ctrl-F}{Cursor right, wrapping to next line when appropriate.}
1243 \lineii{Ctrl-G}{Terminate, returning the window contents.}
1244 \lineii{Ctrl-H}{Delete character backward.}
1245 \lineii{Ctrl-J}{Terminate if the window is 1 line, otherwise insert newline.}
1246 \lineii{Ctrl-K}{If line is blank, delete it, otherwise clear to end of line.}
1247 \lineii{Ctrl-L}{Refresh screen.}
1248 \lineii{Ctrl-N}{Cursor down; move down one line.}
1249 \lineii{Ctrl-O}{Insert a blank line at cursor location.}
1250 \lineii{Ctrl-P}{Cursor up; move up one line.}
1251\end{tableii}
1252
1253Move operations do nothing if the cursor is at an edge where the
1254movement is not possible. The following synonyms are supported where
Fred Drakeec4b2af2000-08-09 14:34:48 +00001255possible:
1256
1257\begin{tableii}{l|l}{constant}{Constant}{Keystroke}
1258 \lineii{KEY_LEFT}{\kbd{Ctrl-B}}
1259 \lineii{KEY_RIGHT}{\kbd{Ctrl-F}}
1260 \lineii{KEY_UP}{\kbd{Ctrl-P}}
1261 \lineii{KEY_DOWN}{\kbd{Ctrl-N}}
1262 \lineii{KEY_BACKSPACE}{\kbd{Ctrl-h}}
1263\end{tableii}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001264
1265All other keystrokes are treated as a command to insert the given
1266character and move right (with line wrapping).
1267\end{methoddesc}
1268
1269\begin{methoddesc}{gather}{}
1270This method returns the window contents as a string; whether blanks in
1271the window are included is affected by the \member{stripspaces}
1272member.
1273\end{methoddesc}
1274
Fred Drakeec4b2af2000-08-09 14:34:48 +00001275\begin{memberdesc}{stripspaces}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001276This data member is a flag which controls the interpretation of blanks in
1277the window. When it is on, trailing blanks on each line are ignored;
1278any cursor motion that would land the cursor on a trailing blank goes
1279to the end of that line instead, and trailing blanks are stripped when
1280the window contents is gathered.
Fred Drakeec4b2af2000-08-09 14:34:48 +00001281\end{memberdesc}
1282
Eric S. Raymond5a007692000-08-04 07:35:41 +00001283
1284\section{\module{curses.wrapper} ---
Fred Drakeec4b2af2000-08-09 14:34:48 +00001285 Terminal handler for curses programs}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001286
1287\declaremodule{standard}{curses.wrapper}
1288\sectionauthor{Eric Raymond}{esr@thyrsus.com}
1289\moduleauthor{Eric Raymond}{esr@thyrsus.com}
Fred Drakeec4b2af2000-08-09 14:34:48 +00001290\modulesynopsis{Terminal configuration wrapper for curses programs.}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001291\versionadded{1.6}
1292
1293This module supplies one function, \function{wrapper()}, which runs
1294another function which should be the rest of your curses-using
1295application. If the application raises an exception,
1296\function{wrapper()} will restore the terminal to a sane state before
1297passing it further up the stack and generating a traceback.
1298
Fred Drakeec4b2af2000-08-09 14:34:48 +00001299\begin{funcdesc}{wrapper}{func, \moreargs}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001300Wrapper function that initializes curses and calls another function,
Fred Drakeec4b2af2000-08-09 14:34:48 +00001301\var{func}, restoring normal keyboard/screen behavior on error.
1302The callable object \var{func} is then passed the main window 'stdscr'
Eric S. Raymond5a007692000-08-04 07:35:41 +00001303as its first argument, followed by any other arguments passed to
1304\function{wrapper()}.
1305\end{funcdesc}
1306
Eric S. Raymond1ebd3f62000-08-09 21:11:07 +00001307Before calling the hook function, \function{wrapper()} turns on cbreak
1308mode, turns off echo, enables the terminal keypad, and initializes
1309colors if the terminal has color support. On exit (whether normally
1310or by exception) it restores cooked mode, turns on echo, and disables
1311the terminal keypad.
Eric S. Raymond5a007692000-08-04 07:35:41 +00001312