blob: eacc8e190b38408055017c7d7a8e2d27675fa31e [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.}
Eric S. Raymond5a007692000-08-04 07:35:41 +00008\versionadded{1.6}
Fred Drakea4070ce1999-06-21 21:13:09 +00009
Fred Draked79c33a2000-09-25 14:14:30 +000010The \module{curses} module provides an interface to the curses
Fred Drakea4070ce1999-06-21 21:13:09 +000011library, the de-facto standard for portable advanced terminal
12handling.
13
14While curses is most widely used in the \UNIX{} environment, versions
Eric S. Raymond68996602000-07-24 03:28:40 +000015are available for DOS, OS/2, and possibly other systems as well. This
16extension module is designed to match the API of ncurses, an
17open-source curses library hosted on Linux and the BSD variants of
Fred Draked79c33a2000-09-25 14:14:30 +000018\UNIX.
Fred Drakea4070ce1999-06-21 21:13:09 +000019
20\begin{seealso}
Fred Drake5c529d32000-06-28 22:11:40 +000021 \seemodule{curses.ascii}{Utilities for working with \ASCII{}
22 characters, regardless of your locale
23 settings.}
Eric S. Raymond5a007692000-08-04 07:35:41 +000024 \seemodule{curses.textpad}{Editable text widget for curses supporting
Fred Drakeec4b2af2000-08-09 14:34:48 +000025 \program{Emacs}-like bindings.}
26 \seemodule{curses.wrapper}{Convenience function to ensure proper
27 terminal setup and resetting on
28 application entry and exit.}
Fred Draked79c33a2000-09-25 14:14:30 +000029 \seetitle[http://www.python.org/doc/howto/curses/curses.html]{Curses
30 Programming with Python}{Tutorial material on using curses
31 with Python, by Andrew Kuchling, is available on the
32 Python Web site.}
Fred Drakea4070ce1999-06-21 21:13:09 +000033\end{seealso}
34
35
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000036\subsection{Functions \label{curses-functions}}
Fred Drakea4070ce1999-06-21 21:13:09 +000037
38The module \module{curses} defines the following exception:
Fred Drakeec4b2af2000-08-09 14:34:48 +000039
Fred Drakea4070ce1999-06-21 21:13:09 +000040\begin{excdesc}{error}
Fred Drakeec4b2af2000-08-09 14:34:48 +000041Exception raised when a curses library function returns an error.
Fred Drakea4070ce1999-06-21 21:13:09 +000042\end{excdesc}
43
Fred Drake0bccd731999-06-23 17:28:01 +000044\strong{Note:} Whenever \var{x} or \var{y} arguments to a function
45or a method are optional, they default to the current cursor location.
46Whenever \var{attr} is optional, it defaults to \constant{A_NORMAL}.
47
Fred Drakea4070ce1999-06-21 21:13:09 +000048The module \module{curses} defines the following functions:
49
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000050\begin{funcdesc}{baudrate}{}
Eric S. Raymond68996602000-07-24 03:28:40 +000051Returns the output speed of the terminal in bits per second. On
52software terminal emulators it will have a fixed high value.
53Included for historical reasons; in former times, it was used to
54write output loops for time delays and occasionally to change
55interfaces depending on the line speed.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000056\end{funcdesc}
57
58\begin{funcdesc}{beep}{}
Eric S. Raymond68996602000-07-24 03:28:40 +000059Emit a short attention sound.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000060\end{funcdesc}
61
62\begin{funcdesc}{can_change_color}{}
63Returns true or false, depending on whether the programmer can change
64the colors displayed by the terminal.
65\end{funcdesc}
66
67\begin{funcdesc}{cbreak}{}
Eric S. Raymond68996602000-07-24 03:28:40 +000068Enter cbreak mode. In cbreak mode (sometimes called ``rare'' mode)
69normal tty line buffering is turned off and characters are available
70to be read one by one. However, unlike raw mode, special characters
71(interrupt, quit, suspend, and flow control) retain their effects on
72the tty driver and calling program. Calling first \function{raw()}
73then \function{cbreak()} leaves the terminal in cbreak mode.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000074\end{funcdesc}
75
76\begin{funcdesc}{color_content}{color_number}
77Returns the intensity of the red, green, and blue (RGB) components in
78the color \var{color_number}, which must be between 0 and COLORS. A
793-tuple is returned, containing the R,G,B values for the given color,
80which will be between 0 (no component) and 1000 (maximum amount of
81component).
82\end{funcdesc}
83
84\begin{funcdesc}{color_pair}{color_number}
85Returns the attribute value for displaying text in the specified
86color. This attribute value can be combined with
87\constant{A_STANDOUT}, \constant{A_REVERSE}, and the other
88\constant{A_*} attributes. \function{pair_number()} is the counterpart to this function.
89\end{funcdesc}
90
91\begin{funcdesc}{curs_set}{visibility}
92Sets the cursor state. \var{visibility} can be set to 0, 1, or 2, for
93invisible, normal, or very visible. If the terminal supports the
94visibility requested, the previous cursor state is returned;
Eric S. Raymond68996602000-07-24 03:28:40 +000095otherwise, an exception is raised. On many terminals, the ``visible''
96mode is an underline cursor and the ``very visible'' mode is a block cursor.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +000097\end{funcdesc}
98
99\begin{funcdesc}{def_prog_mode}{}
100Saves the current terminal mode as the ``program'' mode, the mode when
101the running program is using curses. (Its counterpart is the
102``shell'' mode, for when the program is not in curses.) Subsequent calls
103to \function{reset_prog_mode()} will restore this mode.
104\end{funcdesc}
105
106\begin{funcdesc}{def_shell_mode}{}
107Saves the current terminal mode as the ``shell'' mode, the mode when
108the running program is not using curses. (Its counterpart is the
109``program'' mode, when the program is using curses capabilities.)
110Subsequent calls
111to \function{reset_shell_mode()} will restore this mode.
112\end{funcdesc}
113
114\begin{funcdesc}{delay_output}{ms}
115Inserts an \var{ms} millisecond pause in output.
116\end{funcdesc}
117
118\begin{funcdesc}{doupdate}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000119Update the physical screen. The curses library keeps two data
120structures, one representing the current physical screen contents
121and a virtual screen representing the desired next state. The
122\function{doupdate()} ground updates the physical screen to match the
123virtual screen.
124
125The virtual screen may be updated by a \method{noutrefresh()} call
126after write operations such as \method{addstr()} have been performed
127on a window. The normal \method{refresh()} call is simply
128\method{noutrefresh()} followed by \function{doupdate()}; if you have
129to update multiple windows, you can speed performance and perhaps
130reduce screen flicker by issuing \method{noutrefresh()} calls on
131all windows, followed by a single \function{doupdate()}.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000132\end{funcdesc}
133
134\begin{funcdesc}{echo}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000135Enter echo mode. In echo mode, each character input is echoed to the
136screen as it is entered.
Fred Drakea4070ce1999-06-21 21:13:09 +0000137\end{funcdesc}
138
139\begin{funcdesc}{endwin}{}
140De-initialize the library, and return terminal to normal status.
141\end{funcdesc}
142
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000143\begin{funcdesc}{erasechar}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000144Returns the user's current erase character. Under Unix operating
145systems this is a property of the controlling tty of the curses
146program, and is not set by the curses library itself.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000147\end{funcdesc}
148
149\begin{funcdesc}{filter}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000150The \function{filter()} routine, if used, must be called before
151\function{initscr()} is called. The effect is that, during those
152calls, LINES is set to 1; the capabilities clear, cup, cud, cud1,
153cuu1, cuu, vpa are disabled; and the home string is set to the value of cr.
154The effect is that the cursor is confined to the current line, and so
155are screen updates. This may be used for enabling cgaracter-at-a-time
156line editing without touching the rest of the screen.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000157\end{funcdesc}
158
159\begin{funcdesc}{flash}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000160Flash the screen. That is, change it to reverse-video and then change
161it back in a short interval. Some people prefer such as `visible bell'
162to the audible attention signal produced by \function{beep()}.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000163\end{funcdesc}
164
165\begin{funcdesc}{flushinp}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000166Flush all input buffers. This throws away any typeahead that has
167been typed by the user and has not yet been processed by the program.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000168\end{funcdesc}
169
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000170\begin{funcdesc}{getmouse}{}
171After \method{getch()} returns \constant{KEY_MOUSE} to signal a mouse
172event, this method should be call to retrieve the queued mouse event,
173represented as a 5-tuple
174\code{(\var{id}, \var{x}, \var{y}, \var{z}, \var{bstate})}.
175\var{id} is an ID value used to distinguish multiple devices,
176and \var{x}, \var{y}, \var{z} are the event's coordinates. (\var{z}
177is currently unused.). \var{bstate} is an integer value whose bits
178will be set to indicate the type of event, and will be the bitwise OR
179of one or more of the following constants, where \var{n} is the button
180number from 1 to 4:
181\constant{BUTTON\var{n}_PRESSED},
182\constant{BUTTON\var{n}_RELEASED},
183\constant{BUTTON\var{n}_CLICKED},
184\constant{BUTTON\var{n}_DOUBLE_CLICKED},
185\constant{BUTTON\var{n}_TRIPLE_CLICKED},
186\constant{BUTTON_SHIFT},
187\constant{BUTTON_CTRL},
188\constant{BUTTON_ALT}.
189\end{funcdesc}
190
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000191\begin{funcdesc}{getsyx}{}
192Returns the current coordinates of the virtual screen cursor in y and
193x. If leaveok is currently true, then -1,-1 is returned.
194\end{funcdesc}
195
196\begin{funcdesc}{getwin}{file}
197Reads window related data stored in the file by an earlier
198\function{putwin()} call. The routine then creates and initializes a
199new window using that data, returning the new window object.
200\end{funcdesc}
201
202\begin{funcdesc}{has_colors}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000203Returns true if the terminal can display colors; otherwise, it
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000204returns false.
205\end{funcdesc}
206
207\begin{funcdesc}{has_ic}{}
208Returns true if the terminal has insert- and delete- character
Eric S. Raymond68996602000-07-24 03:28:40 +0000209capabilities. This function is included for historical reasons only,
210as all modern software terminal emulators have such capabilities.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000211\end{funcdesc}
212
213\begin{funcdesc}{has_il}{}
214Returns true if the terminal has insert- and
215delete-line capabilities, or can simulate them using
Eric S. Raymond68996602000-07-24 03:28:40 +0000216scrolling regions. This function is included for historical reasons only,
217as all modern software terminal emulators have such capabilities.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000218\end{funcdesc}
219
220\begin{funcdesc}{has_key}{ch}
221Takes a key value \var{ch}, and returns true if the current terminal
222type recognizes a key with that value.
223\end{funcdesc}
224
225\begin{funcdesc}{halfdelay}{tenths}
226Used for half-delay mode, which is similar to cbreak mode in that
227characters typed by the user are immediately available to the program.
228However, after blocking for \var{tenths} tenths of seconds, an
229exception is raised if nothing has been typed. The value of
Eric S. Raymond68996602000-07-24 03:28:40 +0000230\var{tenths} must be a number between 1 and 255. Use \function{nocbreak()} to
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000231leave half-delay mode.
232\end{funcdesc}
233
234\begin{funcdesc}{init_color}{color_number, r, g, b}
235Changes the definition of a color, taking the number of the color to
236be changed followed by three RGB values (for the amounts of red,
237green, and blue components). The value of \var{color_number} must be
238between 0 and COLORS. Each of \var{r}, \var{g}, \var{b}, must be a
239value between 0 and 1000. When \function{init_color()} is used, all
240occurrences of that color on the screen immediately change to the new
Eric S. Raymond68996602000-07-24 03:28:40 +0000241definition. This function is a no-op on most terminals; it is active
242only if \function{can_change_color()} returns 1.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000243\end{funcdesc}
244
245\begin{funcdesc}{init_pair}{pair_number, fg, bg}
246Changes the definition of a color-pair. It takes three arguments: the
247number of the color-pair to be changed, the foreground color number,
248and the background color number. The value of \var{pair_number} must
249be between 1 and COLOR_PAIRS-1 (the 0 color pair is wired to white on
250black and cannot be changed). The value of \var{fg} and \var{bg}
251arguments must be between 0 and COLORS. If the color-pair was
252previously initialized, the screen is refreshed and all occurrences of
253that color-pair are changed to the new definition.
254\end{funcdesc}
255
256\begin{funcdesc}{initscr}{}
257Initialize the library. Returns a \class{WindowObject} which represents
258the whole screen.
259\end{funcdesc}
260
Fred Drakea4070ce1999-06-21 21:13:09 +0000261\begin{funcdesc}{isendwin}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000262Returns true if \function{endwin()} has been called (that is, the
263curses library has been deinitialized).
Fred Drakea4070ce1999-06-21 21:13:09 +0000264\end{funcdesc}
265
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000266\begin{funcdesc}{keyname}{k}
Eric S. Raymond68996602000-07-24 03:28:40 +0000267Return the name of the key numbered \var{k}. The name of a key
268generating printable ASCII character is the key's character. The name
269of a control-key combination is a two-character string consisting of a
270caret followed by the corresponding printable ASCII character. The
271name of an alt-key combination (128-255) is a string consisting of the
272prefix `M-' followed by the name of the corresponding ASCII character.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000273\end{funcdesc}
274
275\begin{funcdesc}{killchar}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000276Returns the user's current line kill character. Under Unix operating
277systems this is a property of the controlling tty of the curses
278program, and is not set by the curses library itself.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000279\end{funcdesc}
280
281\begin{funcdesc}{longname}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000282Returns a string containing the terminfo long name field describing the current
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000283terminal. The maximum length of a verbose description is 128
284characters. It is defined only after the call to
285\function{initscr()}.
286\end{funcdesc}
287
288\begin{funcdesc}{meta}{yes}
Eric S. Raymond68996602000-07-24 03:28:40 +0000289If \var{yes} is 1, allow 8-bit characters to be input. If \var{yes} is 0,
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000290allow only 7-bit chars.
291\end{funcdesc}
292
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000293\begin{funcdesc}{mouseinterval}{interval}
Thomas Woutersf8316632000-07-16 19:01:10 +0000294Sets the maximum time in milliseconds that can elapse between press and
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000295release events in order for them to be recognized as a click, and
296returns the previous interval value. The default value is 200 msec,
297or one fifth of a second.
298\end{funcdesc}
299
300\begin{funcdesc}{mousemask}{mousemask}
301Sets the mouse events to be reported, and returns a tuple
302\code{(\var{availmask}, \var{oldmask})}.
303\var{availmask} indicates which of the
304specified mouse events can be reported; on complete failure it returns
3050. \var{oldmask} is the previous value of the given window's mouse
306event mask. If this function is never called, no mouse events are
307ever reported.
308\end{funcdesc}
309
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000310\begin{funcdesc}{newpad}{nlines, ncols}
311Creates and returns a pointer to a new pad data structure with the
312given number of lines and columns. A pad is returned as a
313window object.
314
Eric S. Raymond68996602000-07-24 03:28:40 +0000315A pad is like a window, except that it is not restricted by the screen
316size, and is not necessarily associated with a particular part of the
317screen. Pads can be used when a large window is needed, and only a
318part of the window will be on the screen at one time. Automatic
319refreshes of pads (e.g., from scrolling or echoing of input) do not
320occur. The \method{refresh()} and \method{noutrefresh()} methods of a
321pad require 6 arguments to specify the part of the pad to be
322displayed and the location on the screen to be used for the display.
323The arguments are pminrow, pmincol, sminrow, smincol, smaxrow,
324smaxcol; the p arguments refer to the upper left corner of the the pad
325region to be displayed and the s arguments define a clipping box on
326the screen within which the pad region is to be displayed.
Fred Drakea4070ce1999-06-21 21:13:09 +0000327\end{funcdesc}
328
329\begin{funcdesc}{newwin}{\optional{nlines, ncols,} begin_y, begin_x}
330Return a new window, whose left-upper corner is at
331\code{(\var{begin_y}, \var{begin_x})}, and whose height/width is
Fred Drake0bccd731999-06-23 17:28:01 +0000332\var{nlines}/\var{ncols}.
333
334By default, the window will extend from the
Fred Drakea4070ce1999-06-21 21:13:09 +0000335specified position to the lower right corner of the screen.
336\end{funcdesc}
337
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000338\begin{funcdesc}{nl}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000339Enter newline mode. This mode translates the return key into newline
340on input, and translates newline into return and line-feed on output.
341Newline mode is initially on.
Fred Drakea4070ce1999-06-21 21:13:09 +0000342\end{funcdesc}
343
344\begin{funcdesc}{nocbreak}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000345Leave cbreak mode. Return to normal ``cooked'' mode with line buffering.
Fred Drakea4070ce1999-06-21 21:13:09 +0000346\end{funcdesc}
347
Fred Drakea4070ce1999-06-21 21:13:09 +0000348\begin{funcdesc}{noecho}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000349Leave echo mode. Echoing of input characters is turned off,
Fred Drakea4070ce1999-06-21 21:13:09 +0000350\end{funcdesc}
351
Fred Drakea4070ce1999-06-21 21:13:09 +0000352\begin{funcdesc}{nonl}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000353Leave newline mode. Disable translation of return into newline on
354input, and disable low-level translation of newline into
355newline/return on output (but this does not change the behavior of
Fred Drakee1b304d2000-07-24 19:35:52 +0000356\code{addch('\e n')}, which always does the equivalent of return and
357line feed on the virtual screen). With translation off, curses can
358sometimes speed up vertical motion a little; also, it will be able to
359detect the return key on input.
Fred Drakea4070ce1999-06-21 21:13:09 +0000360\end{funcdesc}
361
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000362\begin{funcdesc}{noqiflush}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000363When the noqiflush routine is used, normal flush of input and
364output queues associated with the INTR, QUIT and SUSP
365characters will not be done. You may want to call
366\function{noqiflush()} in a signal handler if you want output
367to continue as though the interrupt had not occurred, after the
368handler exits.
Fred Drakea4070ce1999-06-21 21:13:09 +0000369\end{funcdesc}
370
371\begin{funcdesc}{noraw}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000372Leave raw mode. Return to normal ``cooked'' mode with line buffering.
Fred Drakea4070ce1999-06-21 21:13:09 +0000373\end{funcdesc}
374
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000375\begin{funcdesc}{pair_content}{pair_number}
376Returns a tuple \var{(fg,bg)} containing the colors for the requested
377color pair. The value of \var{pair_number} must be between 0 and
378COLOR_PAIRS-1.
Fred Drakea4070ce1999-06-21 21:13:09 +0000379\end{funcdesc}
380
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000381\begin{funcdesc}{pair_number}{attr}
382Returns the number of the color-pair set by the attribute value \var{attr}.
383\function{color_pair()} is the counterpart to this function.
Fred Drakea4070ce1999-06-21 21:13:09 +0000384\end{funcdesc}
385
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000386\begin{funcdesc}{putp}{string}
Eric S. Raymond68996602000-07-24 03:28:40 +0000387Equivalent to \code{tputs(str, 1, putchar)}; emits the value of a
388specified terminfo capability for the current terminal. Note that the
389output of putp always goes to standard output.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000390\end{funcdesc}
391
392\begin{funcdesc}{qiflush}{ \optional{flag} }
393If \var{flag} is false, the effect is the same as calling
394\function{noqiflush()}. If \var{flag} is true, or no argument is
395provided, the queues will be flushed when these control characters are
396read.
397\end{funcdesc}
398
399\begin{funcdesc}{raw}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000400Enter raw mode. In raw mode, normal line buffering and
401processing of interrupt, quit, suspend, and flow control keys are
402turned off; characters are presented to curses input functions one
403by one.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000404\end{funcdesc}
405
406\begin{funcdesc}{reset_prog_mode}{}
407Restores the terminal to ``program'' mode, as previously saved
408by \function{def_prog_mode()}.
409\end{funcdesc}
410
411\begin{funcdesc}{reset_shell_mode}{}
412Restores the terminal to ``shell'' mode, as previously saved
413by \function{def_shell_mode()}.
414\end{funcdesc}
415
416\begin{funcdesc}{setsyx}{y, x}
417Sets the virtual screen cursor to \var{y}, \var{x}.
418If \var{y} and \var{x} are both -1, then leaveok is set.
419\end{funcdesc}
420
421\begin{funcdesc}{start_color}{}
422Must be called if the programmer wants to use colors, and before any
423other color manipulation routine is called. It is good
424practice to call this routine right after \function{initscr()}.
425
426\function{start_color()} initializes eight basic colors (black, red,
427green, yellow, blue, magenta, cyan, and white), and two global
428variables in the \module{curses} module, COLORS and COLOR_PAIRS,
429containing the maximum number of colors and color-pairs the terminal
430can support. It also restores the colors on the terminal to the
431values they had when the terminal was just turned on.
432\end{funcdesc}
433
434\begin{funcdesc}{termattrs}{}
435Returns a logical OR of all video attributes supported by the
436terminal. This information is useful when a curses program needs
437complete control over the appearance of the screen.
438\end{funcdesc}
439
440\begin{funcdesc}{termname}{}
441Returns the value of the environment variable TERM, truncated to 14
442characters.
443\end{funcdesc}
444
Andrew M. Kuchling1962fb52000-07-26 02:59:13 +0000445\begin{funcdesc}{tigetflag}{capname}
446Returns the value of the Boolean capability corresponding to the
447terminfo capability name \var{capname}. The value -1 is returned if
448\var{capname} is not a Boolean capability, or 0 if it is canceled or
449absent from the terminal description.
450\end{funcdesc}
451
452\begin{funcdesc}{tigetnum}{capname}
453Returns the value of the numeric capability corresponding to the
454terminfo capability name \var{capname}. The value -2 is returned if
455\var{capname} is not a numeric capability, or -1 if it is canceled or absent
456from the terminal description.
457\end{funcdesc}
458
459\begin{funcdesc}{tigetstr}{capname}
460Returns the value of the string capability corresponding to the
461terminfo capability name \var{capname}. \code{None} is returned if
462\var{capname} is not a string capability, or is canceled or absent
463from the terminal description.
464\end{funcdesc}
465
Andrew M. Kuchlingd24ff442000-06-21 01:42:51 +0000466\begin{funcdesc}{typeahead}{fd}
467Specifies that the file descriptor \var{fd} be used for typeahead
468checking. If \var{fd} is -1, then no typeahead checking is done.
469
470The curses library does ``line-breakout optimization'' by looking for
471typeahead periodically while updating the screen. If input is found,
472and it is coming from a tty, the current update is postponed until
473refresh or doupdate is called again, allowing faster response to
474commands typed in advance. This function allows specifying a different
475file descriptor for typeahead checking.
476\end{funcdesc}
477
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000478\begin{funcdesc}{unctrl}{ch}
479Returns a string which is a printable representation of the character
480\var{ch}. Control characters are displayed as a caret followed by the
481character, for example as \verb|^C|. Printing characters are left as they
482are.
483\end{funcdesc}
484
485\begin{funcdesc}{ungetch}{ch}
486Push \var{ch} so the next \method{getch()} will return it.
487\strong{Note:} only one \var{ch} can be pushed before \method{getch()}
488is called.
489\end{funcdesc}
490
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000491\begin{funcdesc}{ungetmouse}{id, x, y, z, bstate}
492Push a \constant{KEY_MOUSE} event onto the input queue, associating
493the given state data with it.
494\end{funcdesc}
495
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000496\begin{funcdesc}{use_env}{flag}
497If used, this function should be called before \function{initscr} or
498newterm are called. When \var{flag} is false, the values of
499lines and columns specified in the terminfo database will be
500used, even if environment variables LINES and COLUMNS (used by
501default) are set, or if curses is running in a window (in which
502case default behavior would be to use the window size if LINES
503and COLUMNS are not set).
504\end{funcdesc}
Fred Drakea4070ce1999-06-21 21:13:09 +0000505
506\subsection{Window Objects \label{curses-window-objects}}
507
508Window objects, as returned by \function{initscr()} and
509\function{newwin()} above, have the
510following methods:
511
Fred Drakea4070ce1999-06-21 21:13:09 +0000512\begin{methoddesc}{addch}{\optional{y, x,} ch\optional{, attr}}
513\strong{Note:} A \emph{character} means a C character (i.e., an
514\ASCII{} code), rather then a Python character (a string of length 1).
515(This note is true whenever the documentation mentions a character.)
Eric S. Raymond68996602000-07-24 03:28:40 +0000516The builtin \function{ord()} is handy for conveying strings to codes.
Fred Drakea4070ce1999-06-21 21:13:09 +0000517
518Paint character \var{ch} at \code{(\var{y}, \var{x})} with attributes
519\var{attr}, overwriting any character previously painter at that
520location. By default, the character position and attributes are the
521current settings for the window object.
522\end{methoddesc}
523
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000524\begin{methoddesc}{addnstr}{\optional{y, x,} str, n\optional{, attr}}
525Paint at most \var{n} characters of the
526string \var{str} at \code{(\var{y}, \var{x})} with attributes
Fred Drake0bccd731999-06-23 17:28:01 +0000527\var{attr}, overwriting anything previously on the display.
Fred Drakea4070ce1999-06-21 21:13:09 +0000528\end{methoddesc}
529
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000530\begin{methoddesc}{addstr}{\optional{y, x,} str\optional{, attr}}
531Paint the string \var{str} at \code{(\var{y}, \var{x})} with attributes
532\var{attr}, overwriting anything previously on the display.
Fred Drakea4070ce1999-06-21 21:13:09 +0000533\end{methoddesc}
534
535\begin{methoddesc}{attroff}{attr}
Eric S. Raymond68996602000-07-24 03:28:40 +0000536Remove attribute \var{attr} from the ``background'' set applied to all
537writes to the current window.
Fred Drakea4070ce1999-06-21 21:13:09 +0000538\end{methoddesc}
539
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000540\begin{methoddesc}{attron}{attr}
Eric S. Raymond68996602000-07-24 03:28:40 +0000541Add attribute \var{attr} from the ``background'' set applied to all
542writes to the current window.
Fred Drakea4070ce1999-06-21 21:13:09 +0000543\end{methoddesc}
544
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000545\begin{methoddesc}{attrset}{attr}
Eric S. Raymond68996602000-07-24 03:28:40 +0000546Set the ``background'' set of attributes to \var{attr}. This set is
547initially 0 (no attributes).
Fred Drakea4070ce1999-06-21 21:13:09 +0000548\end{methoddesc}
549
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000550\begin{methoddesc}{bkgd}{ch\optional{, attr}}
551Sets the background property of the window to the character \var{ch},
552with attributes \var{attr}. The change is then applied to every
553character position in that window:
554\begin{itemize}
Eric S. Raymondb924bd42000-07-27 21:10:02 +0000555\item
556The attribute of every character in the window is
557changed to the new background attribute.
558\item
559Wherever the former background character appears,
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000560it is changed to the new background character.
561\end{itemize}
562
563\end{methoddesc}
564
565\begin{methoddesc}{bkgdset}{ch\optional{, attr}}
566Sets the window's background. A window's background consists of a
567character and any combination of attributes. The attribute part of
568the background is combined (OR'ed) with all non-blank characters that
569are written into the window. Both the character and attribute parts
570of the background are combined with the blank characters. The
571background becomes a property of the character and moves with the
572character through any scrolling and insert/delete line/character
573operations.
Fred Drakea4070ce1999-06-21 21:13:09 +0000574\end{methoddesc}
575
Fred Drake0bccd731999-06-23 17:28:01 +0000576\begin{methoddesc}{border}{\optional{ls\optional{, rs\optional{, ts\optional{,
577 bs\optional{, tl\optional{, tr\optional{,
578 bl\optional{, br}}}}}}}}}
579Draw a border around the edges of the window. Each parameter specifies
580the character to use for a specific part of the border; see the table
581below for more details. The characters must be specified as integers;
582using one-character strings will cause \exception{TypeError} to be
583raised.
584
585\strong{Note:} A \code{0} value for any parameter will cause the
586default character to be used for that parameter. Keyword parameters
587can \emph{not} be used. The defaults are listed in this table:
588
589\begin{tableiii}{l|l|l}{var}{Parameter}{Description}{Default value}
590 \lineiii{ls}{Left side}{\constant{ACS_VLINE}}
591 \lineiii{rs}{Right side}{\constant{ACS_VLINE}}
592 \lineiii{ts}{Top}{\constant{ACS_HLINE}}
593 \lineiii{bs}{Bottom}{\constant{ACS_HLINE}}
594 \lineiii{tl}{Upper-left corner}{\constant{ACS_ULCORNER}}
595 \lineiii{tr}{Upper-right corner}{\constant{ACS_URCORNER}}
596 \lineiii{bl}{Bottom-left corner}{\constant{ACS_BLCORNER}}
597 \lineiii{br}{Bottom-right corner}{\constant{ACS_BRCORNER}}
598\end{tableiii}
Fred Drakea4070ce1999-06-21 21:13:09 +0000599\end{methoddesc}
600
Fred Drake0bccd731999-06-23 17:28:01 +0000601\begin{methoddesc}{box}{\optional{vertch, horch}}
602Similar to \method{border()}, but both \var{ls} and \var{rs} are
603\var{vertch} and both \var{ts} and {bs} are \var{horch}. The default
604corner characters are always used by this function.
Fred Drakea4070ce1999-06-21 21:13:09 +0000605\end{methoddesc}
606
Fred Drakea4070ce1999-06-21 21:13:09 +0000607\begin{methoddesc}{clear}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000608Like \method{erase()}, but also causes the whole window to be repainted
Fred Drakea4070ce1999-06-21 21:13:09 +0000609upon next call to \method{refresh()}.
610\end{methoddesc}
611
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000612\begin{methoddesc}{clearok}{yes}
613If \var{yes} is 1, the next call to \method{refresh()}
Eric S. Raymond68996602000-07-24 03:28:40 +0000614will clear the window completely.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000615\end{methoddesc}
616
Fred Drakea4070ce1999-06-21 21:13:09 +0000617\begin{methoddesc}{clrtobot}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000618Erase from cursor to the end of the window: all lines below the cursor
Fred Drakea4070ce1999-06-21 21:13:09 +0000619are deleted, and then the equivalent of \method{clrtoeol()} is performed.
620\end{methoddesc}
621
622\begin{methoddesc}{clrtoeol}{}
623Erase from cursor to the end of the line.
624\end{methoddesc}
625
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000626\begin{methoddesc}{cursyncup}{}
627Updates the current cursor position of all the ancestors of the window
628to reflect the current cursor position of the window.
Fred Drakea4070ce1999-06-21 21:13:09 +0000629\end{methoddesc}
630
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000631\begin{methoddesc}{delch}{\optional{x, y}}
632Delete any character at \code{(\var{y}, \var{x})}.
Fred Drakea4070ce1999-06-21 21:13:09 +0000633\end{methoddesc}
634
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000635\begin{methoddesc}{deleteln}{}
636Delete the line under the cursor. All following lines are moved up
637by 1 line.
638\end{methoddesc}
639
640\begin{methoddesc}{derwin}{\optional{nlines, ncols,} begin_y, begin_y}
641An abbreviation for ``derive window'', \method{derwin()} is the same
642as calling \method{subwin()}, except that \var{begin_y} and
643\var{begin_x} are relative to the origin of the window, rather than
644relative to the entire screen. Returns a window object for the
645derived window.
646\end{methoddesc}
647
648\begin{methoddesc}{echochar}{ch\optional{, attr}}
649Add character \var{ch} with attribute \var{attr}, and immediately
Eric S. Raymond68996602000-07-24 03:28:40 +0000650call \method{refresh} on the window.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000651\end{methoddesc}
652
Andrew M. Kuchlingefc43d42000-06-30 01:05:39 +0000653\begin{methoddesc}{enclose}{y, x}
654Tests whether the given pair of screen-relative character-cell
655coordinates are enclosed by the given window, returning true or
656false. It is useful for determining what subset of the screen
657windows enclose the location of a mouse event.
658\end{methoddesc}
659
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000660\begin{methoddesc}{erase}{}
661Clear the window.
662\end{methoddesc}
663
664\begin{methoddesc}{getbegyx}{}
665Return a tuple \code{(\var{y}, \var{x})} of co-ordinates of upper-left
666corner.
Fred Drakea4070ce1999-06-21 21:13:09 +0000667\end{methoddesc}
668
669\begin{methoddesc}{getch}{\optional{x, y}}
670Get a character. Note that the integer returned does \emph{not} have to
671be in \ASCII{} range: function keys, keypad keys and so on return numbers
672higher then 256. In no-delay mode, an exception is raised if there is
673no input.
674\end{methoddesc}
675
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000676\begin{methoddesc}{getkey}{\optional{x, y}}
677Get a character, returning a string instead of an integer, as
678\method{getch()} does. Function keys, keypad keys and so on return a
679multibyte string containing the key name. In no-delay mode, an
680exception is raised if there is no input.
681\end{methoddesc}
682
683\begin{methoddesc}{getmaxyx}{}
684Return a tuple \code{(\var{y}, \var{x})} of the height and width of
685the window.
686\end{methoddesc}
687
688\begin{methoddesc}{getparyx}{}
689Returns the beginning coordinates of this window relative to its
690parent window into two integer variables y and x. Returns
691\code{-1,-1} if this window has no parent.
692\end{methoddesc}
693
Fred Drakea4070ce1999-06-21 21:13:09 +0000694\begin{methoddesc}{getstr}{\optional{x, y}}
695Read a string from the user, with primitive line editing capacity.
696\end{methoddesc}
697
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000698\begin{methoddesc}{getyx}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000699Return a tuple \code{(\var{y}, \var{x})} of current cursor position
700relative to the window's upper-left corner.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000701\end{methoddesc}
702
703\begin{methoddesc}{hline}{\optional{y, x,} ch, n}
704Display a horizontal line starting at \code{(\var{y}, \var{x})} with
705length \var{n} consisting of the character \var{ch}.
706\end{methoddesc}
707
708\begin{methoddesc}{idcok}{flag}
709If \var{flag} is false, curses no longer considers using the hardware
710insert/delete character feature of the terminal; if \var{flag} is
711true, use of character insertion and deletion is enabled. When curses
712is first initialized, use of character insert/delete is enabled by
713default.
714\end{methoddesc}
715
716\begin{methoddesc}{idlok}{yes}
717If called with \var{yes} equal to 1, \module{curses} will try and use
718hardware line editing facilities. Otherwise, line insertion/deletion
719are disabled.
720\end{methoddesc}
721
722\begin{methoddesc}{immedok}{flag}
723If \var{flag} is true, any change in the window image
724automatically causes the window to be refreshed; you no longer
725have to call \method{refresh()} yourself. However, it may
726degrade performance considerably, due to repeated calls to
727wrefresh. This option is disabled by default.
728\end{methoddesc}
729
Fred Drakea4070ce1999-06-21 21:13:09 +0000730\begin{methoddesc}{inch}{\optional{x, y}}
731Return the character at the given position in the window. The bottom
7328 bits are the character proper, and upper bits are the attributes.
733\end{methoddesc}
734
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000735\begin{methoddesc}{insch}{\optional{y, x,} ch\optional{, attr}}
736Paint character \var{ch} at \code{(\var{y}, \var{x})} with attributes
737\var{attr}, moving the line from position \var{x} right by one
738character.
Fred Drakea4070ce1999-06-21 21:13:09 +0000739\end{methoddesc}
740
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000741\begin{methoddesc}{insdelln}{nlines}
742Inserts \var{nlines} lines into the specified window above the current
743line. The \var{nlines} bottom lines are lost. For negative
744\var{nlines}, delete \var{nlines} lines starting with the one under
745the cursor, and move the remaining lines up. The bottom \var{nlines}
746lines are cleared. The current cursor position remains the same.
747\end{methoddesc}
748
749\begin{methoddesc}{insertln}{}
750Insert a blank line under the cursor. All following lines are moved
751down by 1 line.
752\end{methoddesc}
753
754\begin{methoddesc}{insnstr}{\optional{y, x, } str, n \optional{, attr}}
755Insert a character string (as many characters as will fit on the line)
756before the character under the cursor, up to \var{n} characters.
757If \var{n} is zero or negative,
758the entire string is inserted.
759All characters to the right of
760the cursor are shifted right, with the the rightmost characters on the
761line being lost. The cursor position does not change (after moving to
762\var{y}, \var{x}, if specified).
763\end{methoddesc}
764
765\begin{methoddesc}{insstr}{\optional{y, x, } str \optional{, attr}}
766Insert a character string (as many characters as will fit on the line)
767before the character under the cursor. All characters to the right of
768the cursor are shifted right, with the the rightmost characters on the
769line being lost. The cursor position does not change (after moving to
770\var{y}, \var{x}, if specified).
771\end{methoddesc}
772
773\begin{methoddesc}{instr}{\optional{y, x} \optional{, n}}
774Returns a string of characters, extracted from the window starting at
775the current cursor position, or at \var{y}, \var{x} if specified.
776Attributes are stripped from the characters. If \var{n} is specified,
777\method{instr()} returns return a string at most \var{n} characters
778long (exclusive of the trailing NUL).
779\end{methoddesc}
780
781\begin{methoddesc}{is_linetouched}{\var{line}}
782Returns true if the specified line was modified since the last call to
783\method{refresh()}; otherwise returns false. Raises a
784\exception{curses.error} exception if \var{line} is not valid
785for the given window.
786\end{methoddesc}
787
788\begin{methoddesc}{is_wintouched}{}
789Returns true if the specified window was modified since the last call to
790\method{refresh()}; otherwise returns false.
791\end{methoddesc}
792
793\begin{methoddesc}{keypad}{yes}
794If \var{yes} is 1, escape sequences generated by some keys (keypad,
795function keys) will be interpreted by \module{curses}.
796If \var{yes} is 0, escape sequences will be left as is in the input
797stream.
Fred Drakea4070ce1999-06-21 21:13:09 +0000798\end{methoddesc}
799
800\begin{methoddesc}{leaveok}{yes}
Eric S. Raymond68996602000-07-24 03:28:40 +0000801If \var{yes} is 1, cursor is left where it is on update, instead of
802being at ``cursor position.'' This reduces cursor movement where
803possible. If possible the cursor will be made invisible.
Fred Drakea4070ce1999-06-21 21:13:09 +0000804
Eric S. Raymond68996602000-07-24 03:28:40 +0000805If \var{yes} is 0, cursor will always be at ``cursor position'' after
806an update.
Fred Drakea4070ce1999-06-21 21:13:09 +0000807\end{methoddesc}
808
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000809\begin{methoddesc}{move}{new_y, new_x}
810Move cursor to \code{(\var{new_y}, \var{new_x})}.
Fred Drakea4070ce1999-06-21 21:13:09 +0000811\end{methoddesc}
812
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000813\begin{methoddesc}{mvderwin}{y, x}
814Moves the window inside its parent window. The screen-relative
815parameters of the window are not changed. This routine is used to
816display different parts of the parent window at the same physical
817position on the screen.
818\end{methoddesc}
Fred Drakea4070ce1999-06-21 21:13:09 +0000819
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000820\begin{methoddesc}{mvwin}{new_y, new_x}
821Move the window so its upper-left corner is at \code{(\var{new_y}, \var{new_x})}.
Fred Drakea4070ce1999-06-21 21:13:09 +0000822\end{methoddesc}
823
824\begin{methoddesc}{nodelay}{yes}
825If \var{yes} is 1, \method{getch()} will be non-blocking.
826\end{methoddesc}
827
828\begin{methoddesc}{notimeout}{yes}
829If \var{yes} is 1, escape sequences will not be timed out.
830
831If \var{yes} is 0, after a few milliseconds, an escape sequence will
832not be interpreted, and will be left in the input stream as is.
833\end{methoddesc}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000834
835\begin{methoddesc}{noutrefresh}{}
Eric S. Raymond65983372000-08-09 21:49:31 +0000836Mark for refresh but wait. This function updates the data structure
837representing the desired state of the window, but does not force
838an update of the physical screen.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000839\end{methoddesc}
840
841\begin{methoddesc}{putwin}{file}
842Writes all data associated with the window into the provided file
843object. This information can be later retrieved using the
844\function{getwin()} function.
845
846\end{methoddesc}
847
848\begin{methoddesc}{redrawln}{beg, num}
849Indicates that the \var{num} screen lines, starting at line \var{beg},
850are corrupted and should be completely redrawn on the next
851\method{refresh()} call.
852\end{methoddesc}
853
854\begin{methoddesc}{redrawwin}{}
855Touches the entire window, causing it to be completely redrawn on the
856next \method{refresh()} call.
857\end{methoddesc}
858
859\begin{methoddesc}{refresh}{ \optional{pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol} }
860Update the display immediately (sync actual screen with previous
861drawing/deleting methods).
862
863The 6 optional arguments can only be specified when the window is a
864pad created with \function{newpad()}. The additional parameters are
865needed to indicate what part of the pad and screen are involved.
866\var{pminrow} and \var{pmincol} specify the upper left-hand corner of the
867rectangle to be displayed in the pad. \var{sminrow}, \var{smincol},
868\var{smaxrow}, and \var{smaxcol} specify the edges of the rectangle to be displayed on the screen. The lower right-hand corner of the
869rectangle to be displayed in the pad is calculated from the screen
870coordinates, since the rectangles must be the same size. Both
871rectangles must be entirely contained within their respective
872structures. Negative values of \var{pminrow}, \var{pmincol},
873\var{sminrow}, or \var{smincol} are treated as if they were zero.
874\end{methoddesc}
875
876\begin{methoddesc}{scroll}{\optional{lines\code{ = 1}}}
877Scroll the screen upward by \var{lines} lines.
878\end{methoddesc}
879
880\begin{methoddesc}{scrollok}{flag}
881Controls what happens when the cursor of a window is moved off the
Eric S. Raymond68996602000-07-24 03:28:40 +0000882edge of the window or scrolling region, either as a result of a
883newline action on the bottom line, or typing the last character
884of the last line. If \var{flag} is false, the cursor is left
885on the bottom line. If \var{flag} is true, the window is
886scrolled up one line. Note that in order to get the physical
887scrolling effect on the terminal, it is also necessary to call
888\method{idlok()}.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000889\end{methoddesc}
890
891\begin{methoddesc}{setscrreg}{top, bottom}
892Set the scrolling region from line \var{top} to line \var{bottom}. All
893scrolling actions will take place in this region.
894\end{methoddesc}
895
896\begin{methoddesc}{standend}{}
Eric S. Raymond68996602000-07-24 03:28:40 +0000897Turn off the standout attribute. On some terminals this has the
898side effect of turning off all attributes.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000899\end{methoddesc}
900
901\begin{methoddesc}{standout}{}
902Turn on attribute \var{A_STANDOUT}.
903\end{methoddesc}
904
905\begin{methoddesc}{subpad}{\optional{nlines, ncols,} begin_y, begin_y}
906Return a sub-window, whose upper-left corner is at
907\code{(\var{begin_y}, \var{begin_x})}, and whose width/height is
908\var{ncols}/\var{nlines}.
909\end{methoddesc}
910
911\begin{methoddesc}{subwin}{\optional{nlines, ncols,} begin_y, begin_y}
912Return a sub-window, whose upper-left corner is at
913\code{(\var{begin_y}, \var{begin_x})}, and whose width/height is
914\var{ncols}/\var{nlines}.
915
916By default, the sub-window will extend from the
917specified position to the lower right corner of the window.
918\end{methoddesc}
919
920\begin{methoddesc}{syncdown}{}
921Touches each location in the window that has been touched in any of
922its ancestor windows. This routine is called by \method{refresh()},
923so it should almost never be necessary to call it manually.
924\end{methoddesc}
925
926\begin{methoddesc}{syncok}{flag}
927If called with \var{flag} set to true, then \method{syncup()} is
928called automatically whenever there is a change in the window.
929\end{methoddesc}
930
931\begin{methoddesc}{syncup}{}
932Touches all locations in ancestors of the window that have been changed in
933the window.
934\end{methoddesc}
935
Andrew M. Kuchlingd24ff442000-06-21 01:42:51 +0000936\begin{methoddesc}{timeout}{delay}
Thomas Woutersf8316632000-07-16 19:01:10 +0000937Sets blocking or non-blocking read behavior for the window. If
Andrew M. Kuchlingd24ff442000-06-21 01:42:51 +0000938\var{delay} is negative, blocking read is used, which will wait
939indefinitely for input). If \var{delay} is zero, then non-blocking
940read is used, and -1 will be returned by \method{getch()} if no input
941is waiting. If \var{delay} is positive, then \method{getch()} will
942block for \var{delay} milliseconds, and return -1 if there is still no
943input at the end of that time.
944\end{methoddesc}
945
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000946\begin{methoddesc}{touchline}{start, count}
947Pretend \var{count} lines have been changed, starting with line
948\var{start}.
949\end{methoddesc}
950
951\begin{methoddesc}{touchwin}{}
952Pretend the whole window has been changed, for purposes of drawing
953optimizations.
954\end{methoddesc}
955
956\begin{methoddesc}{untouchwin}{}
957Marks all lines in the window as unchanged since the last call to
958\method{refresh()}.
959\end{methoddesc}
960
961\begin{methoddesc}{vline}{\optional{y, x,} ch, n}
962Display a vertical line starting at \code{(\var{y}, \var{x})} with
963length \var{n} consisting of the character \var{ch}.
964\end{methoddesc}
965
966\subsection{Constants}
967
968The \module{curses} module defines the following data members:
969
970\begin{datadesc}{version}
971A string representing the current version of the module.
972Also available as \constant{__version__}.
973\end{datadesc}
974
Fred Drakeec4b2af2000-08-09 14:34:48 +0000975Several constants are available to specify character cell attributes:
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000976
Fred Drakeec4b2af2000-08-09 14:34:48 +0000977\begin{tableii}{l|l}{code}{Attribute}{Meaning}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000978 \lineii{A_ALTCHARSET}{Alternate character set mode.}
979 \lineii{A_BLINK}{Blink mode.}
980 \lineii{A_BOLD}{Bold mode.}
981 \lineii{A_DIM}{Dim mode.}
982 \lineii{A_NORMAL}{Normal attribute.}
983 \lineii{A_STANDOUT}{Standout mode.}
984 \lineii{A_UNDERLINE}{Underline mode.}
985\end{tableii}
986
987Keys are referred to by integer constants with names starting with
Fred Drakeec4b2af2000-08-09 14:34:48 +0000988\samp{KEY_}. The exact keycaps available are system dependent.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000989
990% XXX this table is far too large!
991% XXX should this table be alphabetized?
992
Fred Drake1bf4e932000-09-21 16:04:08 +0000993\begin{longtableii}{l|l}{code}{Key constant}{Key}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +0000994 \lineii{KEY_MIN}{Minimum key value}
995 \lineii{KEY_BREAK}{ Break key (unreliable) }
996 \lineii{KEY_DOWN}{ Down-arrow }
997 \lineii{KEY_UP}{ Up-arrow }
998 \lineii{KEY_LEFT}{ Left-arrow }
999 \lineii{KEY_RIGHT}{ Right-arrow }
1000 \lineii{KEY_HOME}{ Home key (upward+left arrow) }
1001 \lineii{KEY_BACKSPACE}{ Backspace (unreliable) }
1002 \lineii{KEY_F0}{ Function keys. Up to 64 function keys are supported. }
1003 \lineii{KEY_F\var{n}}{ Value of function key \var{n} }
1004 \lineii{KEY_DL}{ Delete line }
1005 \lineii{KEY_IL}{ Insert line }
1006 \lineii{KEY_DC}{ Delete character }
1007 \lineii{KEY_IC}{ Insert char or enter insert mode }
1008 \lineii{KEY_EIC}{ Exit insert char mode }
1009 \lineii{KEY_CLEAR}{ Clear screen }
1010 \lineii{KEY_EOS}{ Clear to end of screen }
1011 \lineii{KEY_EOL}{ Clear to end of line }
1012 \lineii{KEY_SF}{ Scroll 1 line forward }
1013 \lineii{KEY_SR}{ Scroll 1 line backward (reverse) }
1014 \lineii{KEY_NPAGE}{ Next page }
1015 \lineii{KEY_PPAGE}{ Previous page }
1016 \lineii{KEY_STAB}{ Set tab }
1017 \lineii{KEY_CTAB}{ Clear tab }
1018 \lineii{KEY_CATAB}{ Clear all tabs }
1019 \lineii{KEY_ENTER}{ Enter or send (unreliable) }
1020 \lineii{KEY_SRESET}{ Soft (partial) reset (unreliable) }
1021 \lineii{KEY_RESET}{ Reset or hard reset (unreliable) }
1022 \lineii{KEY_PRINT}{ Print }
1023 \lineii{KEY_LL}{ Home down or bottom (lower left) }
1024 \lineii{KEY_A1}{ Upper left of keypad }
1025 \lineii{KEY_A3}{ Upper right of keypad }
1026 \lineii{KEY_B2}{ Center of keypad }
1027 \lineii{KEY_C1}{ Lower left of keypad }
1028 \lineii{KEY_C3}{ Lower right of keypad }
1029 \lineii{KEY_BTAB}{ Back tab }
1030 \lineii{KEY_BEG}{ Beg (beginning) }
1031 \lineii{KEY_CANCEL}{ Cancel }
1032 \lineii{KEY_CLOSE}{ Close }
1033 \lineii{KEY_COMMAND}{ Cmd (command) }
1034 \lineii{KEY_COPY}{ Copy }
1035 \lineii{KEY_CREATE}{ Create }
1036 \lineii{KEY_END}{ End }
1037 \lineii{KEY_EXIT}{ Exit }
1038 \lineii{KEY_FIND}{ Find }
1039 \lineii{KEY_HELP}{ Help }
1040 \lineii{KEY_MARK}{ Mark }
1041 \lineii{KEY_MESSAGE}{ Message }
1042 \lineii{KEY_MOVE}{ Move }
1043 \lineii{KEY_NEXT}{ Next }
1044 \lineii{KEY_OPEN}{ Open }
1045 \lineii{KEY_OPTIONS}{ Options }
1046 \lineii{KEY_PREVIOUS}{ Prev (previous) }
1047 \lineii{KEY_REDO}{ Redo }
1048 \lineii{KEY_REFERENCE}{ Ref (reference) }
1049 \lineii{KEY_REFRESH}{ Refresh }
1050 \lineii{KEY_REPLACE}{ Replace }
1051 \lineii{KEY_RESTART}{ Restart }
1052 \lineii{KEY_RESUME}{ Resume }
1053 \lineii{KEY_SAVE}{ Save }
1054 \lineii{KEY_SBEG}{ Shifted Beg (beginning) }
1055 \lineii{KEY_SCANCEL}{ Shifted Cancel }
1056 \lineii{KEY_SCOMMAND}{ Shifted Command }
1057 \lineii{KEY_SCOPY}{ Shifted Copy }
1058 \lineii{KEY_SCREATE}{ Shifted Create }
1059 \lineii{KEY_SDC}{ Shifted Delete char }
1060 \lineii{KEY_SDL}{ Shifted Delete line }
1061 \lineii{KEY_SELECT}{ Select }
1062 \lineii{KEY_SEND}{ Shifted End }
1063 \lineii{KEY_SEOL}{ Shifted Clear line }
1064 \lineii{KEY_SEXIT}{ Shifted Dxit }
1065 \lineii{KEY_SFIND}{ Shifted Find }
1066 \lineii{KEY_SHELP}{ Shifted Help }
1067 \lineii{KEY_SHOME}{ Shifted Home }
1068 \lineii{KEY_SIC}{ Shifted Input }
1069 \lineii{KEY_SLEFT}{ Shifted Left arrow }
1070 \lineii{KEY_SMESSAGE}{ Shifted Message }
1071 \lineii{KEY_SMOVE}{ Shifted Move }
1072 \lineii{KEY_SNEXT}{ Shifted Next }
1073 \lineii{KEY_SOPTIONS}{ Shifted Options }
1074 \lineii{KEY_SPREVIOUS}{ Shifted Prev }
1075 \lineii{KEY_SPRINT}{ Shifted Print }
1076 \lineii{KEY_SREDO}{ Shifted Redo }
1077 \lineii{KEY_SREPLACE}{ Shifted Replace }
1078 \lineii{KEY_SRIGHT}{ Shifted Right arrow }
1079 \lineii{KEY_SRSUME}{ Shifted Resume }
1080 \lineii{KEY_SSAVE}{ Shifted Save }
1081 \lineii{KEY_SSUSPEND}{ Shifted Suspend }
1082 \lineii{KEY_SUNDO}{ Shifted Undo }
1083 \lineii{KEY_SUSPEND}{ Suspend }
1084 \lineii{KEY_UNDO}{ Undo }
1085 \lineii{KEY_MOUSE}{ Mouse event has occurred }
1086 \lineii{KEY_RESIZE}{ Terminal resize event }
1087 \lineii{KEY_MAX}{Maximum key value}
Fred Drake1bf4e932000-09-21 16:04:08 +00001088\end{longtableii}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001089
Fred Drakeec4b2af2000-08-09 14:34:48 +00001090On VT100s and their software emulations, such as X terminal emulators,
1091there are normally at least four function keys (\constant{KEY_F1},
1092\constant{KEY_F2}, \constant{KEY_F3}, \constant{KEY_F4}) available,
1093and the arrow keys mapped to \constant{KEY_UP}, \constant{KEY_DOWN},
1094\constant{KEY_LEFT} and \constant{KEY_RIGHT} in the obvious way. If
1095your machine has a PC keybboard, it is safe to expect arrow keys and
1096twelve function keys (older PC keyboards may have only ten function
1097keys); also, the following keypad mappings are standard:
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001098
Fred Drakeec4b2af2000-08-09 14:34:48 +00001099\begin{tableii}{l|l}{kbd}{Keycap}{Constant}
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001100 \lineii{Insert}{KEY_IC}
1101 \lineii{Delete}{KEY_DC}
1102 \lineii{Home}{KEY_HOME}
1103 \lineii{End}{KEY_END}
1104 \lineii{Page Up}{KEY_NPAGE}
1105 \lineii{Page Down}{KEY_PPAGE}
1106\end{tableii}
1107
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001108The following table lists characters from the alternate character set.
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001109These are inherited from the VT100 terminal, and will generally be
1110available on software emulations such as X terminals. When there
1111is no graphic available, curses falls back on a crude printable ASCII
1112approximation.
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001113\strong{Note:} These are available only after \function{initscr()} has
1114been called.
1115
Fred Drake1bf4e932000-09-21 16:04:08 +00001116\begin{longtableii}{l|l}{code}{ACS code}{Meaning}
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001117 \lineii{ACS_BBSS}{alternate name for upper right corner}
Eric S. Raymond68996602000-07-24 03:28:40 +00001118 \lineii{ACS_BLOCK}{solid square block}
1119 \lineii{ACS_BOARD}{board of squares}
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001120 \lineii{ACS_BSBS}{alternate name for horizontal line}
1121 \lineii{ACS_BSSB}{alternate name for upper left corner}
1122 \lineii{ACS_BSSS}{alternate name for top tee}
Eric S. Raymond68996602000-07-24 03:28:40 +00001123 \lineii{ACS_BTEE}{bottom tee}
1124 \lineii{ACS_BULLET}{bullet}
1125 \lineii{ACS_CKBOARD}{checker board (stipple)}
1126 \lineii{ACS_DARROW}{arrow pointing down}
1127 \lineii{ACS_DEGREE}{degree symbol}
1128 \lineii{ACS_DIAMOND}{diamond}
1129 \lineii{ACS_GEQUAL}{greater-than-or-equal-to}
1130 \lineii{ACS_HLINE}{horizontal line}
1131 \lineii{ACS_LANTERN}{lantern symbol}
1132 \lineii{ACS_LARROW}{left arrow}
1133 \lineii{ACS_LEQUAL}{less-than-or-equal-to}
1134 \lineii{ACS_LLCORNER}{lower left-hand corner}
1135 \lineii{ACS_LRCORNER}{lower right-hand corner}
1136 \lineii{ACS_LTEE}{left tee}
1137 \lineii{ACS_NEQUAL}{not-equal sign}
1138 \lineii{ACS_PI}{letter pi}
1139 \lineii{ACS_PLMINUS}{plus-or-minus sign}
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001140 \lineii{ACS_PLUS}{big plus sign}
Eric S. Raymond68996602000-07-24 03:28:40 +00001141 \lineii{ACS_RARROW}{right arrow}
1142 \lineii{ACS_RTEE}{right tee}
1143 \lineii{ACS_S1}{scan line 1}
1144 \lineii{ACS_S3}{scan line 3}
1145 \lineii{ACS_S7}{scan line 7}
1146 \lineii{ACS_S9}{scan line 9}
Eric S. Raymondb924bd42000-07-27 21:10:02 +00001147 \lineii{ACS_SBBS}{alternate name for lower right corner}
1148 \lineii{ACS_SBSB}{alternate name for vertical line}
1149 \lineii{ACS_SBSS}{alternate name for right tee}
1150 \lineii{ACS_SSBB}{alternate name for lower left corner}
1151 \lineii{ACS_SSBS}{alternate name for bottom tee}
1152 \lineii{ACS_SSSB}{alternate name for left tee}
1153 \lineii{ACS_SSSS}{alternate name for crossover or big plus}
Eric S. Raymond68996602000-07-24 03:28:40 +00001154 \lineii{ACS_STERLING}{pound sterling}
1155 \lineii{ACS_TTEE}{top tee}
1156 \lineii{ACS_UARROW}{up arrow}
1157 \lineii{ACS_ULCORNER}{upper left corner}
1158 \lineii{ACS_URCORNER}{upper right corner}
1159 \lineii{ACS_VLINE}{vertical line}
Fred Drake1bf4e932000-09-21 16:04:08 +00001160\end{longtableii}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001161
1162The following table lists the predefined colors:
1163
Fred Drakeec4b2af2000-08-09 14:34:48 +00001164\begin{tableii}{l|l}{code}{Constant}{Color}
Andrew M. Kuchlingf1dc5fa2000-05-23 16:46:04 +00001165 \lineii{COLOR_BLACK}{Black}
1166 \lineii{COLOR_BLUE}{Blue}
1167 \lineii{COLOR_CYAN}{Cyan (light greenish blue)}
1168 \lineii{COLOR_GREEN}{Green}
1169 \lineii{COLOR_MAGENTA}{Magenta (purplish red)}
1170 \lineii{COLOR_RED}{Red}
1171 \lineii{COLOR_WHITE}{White}
1172 \lineii{COLOR_YELLOW}{Yellow}
1173\end{tableii}
1174
Eric S. Raymond5a007692000-08-04 07:35:41 +00001175\section{\module{curses.textpad} ---
1176 Text input widget for curses programs}
1177
1178\declaremodule{standard}{curses.textpad}
1179\sectionauthor{Eric Raymond}{esr@thyrsus.com}
1180\moduleauthor{Eric Raymond}{esr@thyrsus.com}
1181\modulesynopsis{Emacs-like input editing in a curses window.}
1182\versionadded{1.6}
1183
1184The \module{curses.textpad} module provides a \class{Textbox} class
1185that handles elementary text editing in a curses window, supporting a
1186set of keybindings resembling those of Emacs (thus, also of Netscape
1187Navigator, BBedit 6.x, FrameMaker, and many other programs). The
1188module also provides a rectangle-drawing function useful for framing
1189text boxes or for other purposes.
1190
Fred Drakeec4b2af2000-08-09 14:34:48 +00001191The module \module{curses.textpad} defines the following function:
Eric S. Raymond5a007692000-08-04 07:35:41 +00001192
1193\begin{funcdesc}{rectangle}{win, uly, ulx, lry, lrx}
1194Draw a rectangle. The first argument must be a window object; the
1195remaining arguments are coordinates relative to that window. The
1196second and third arguments are the y and x coordinates of the upper
1197left hand corner of the rectangle To be drawn; the fourth and fifth
1198arguments are the y and x coordinates of the lower right hand corner.
1199The rectangle will be drawn using VT100/IBM PC forms characters on
1200terminals that make this possible (including xterm and most other
1201software terminal emulators). Otherwise it will be drawn with ASCII
1202dashes, vertical bars, and plus signs.
1203\end{funcdesc}
1204
Fred Drakeec4b2af2000-08-09 14:34:48 +00001205
Eric S. Raymond5a007692000-08-04 07:35:41 +00001206\subsection{Textbox objects \label{curses-textpad-objects}}
1207
1208You can instantiate a \class{Textbox} object as follows:
1209
Fred Drakeec4b2af2000-08-09 14:34:48 +00001210\begin{classdesc}{Textbox}{win}
1211Return a textbox widget object. The \var{win} argument should be a
1212curses \class{WindowObject} in which the textbox is to be contained.
1213The edit cursor of the textbox is initially located at the upper left
1214hand corner of the containin window, with coordinates \code{(0, 0)}.
1215The instance's \member{stripspaces} flag is initially on.
Eric S. Raymond5a007692000-08-04 07:35:41 +00001216\end{classdesc}
1217
Fred Drakeec4b2af2000-08-09 14:34:48 +00001218\class{Textbox} objects have the following methods:
Eric S. Raymond5a007692000-08-04 07:35:41 +00001219
Fred Drakeec4b2af2000-08-09 14:34:48 +00001220\begin{methoddesc}{edit}{\optional{validator}}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001221This is the entry point you will normally use. It accepts editing
Fred Drakeec4b2af2000-08-09 14:34:48 +00001222keystrokes until one of the termination keystrokes is entered. If
1223\var{validator} is supplied, it must be a function. It will be called
1224for each keystroke entered with the keystroke as a parameter; command
1225dispatch is done on the result. This method returns the window
1226contents as a string; whether blanks in the window are included is
1227affected by the \member{stripspaces} member.
Eric S. Raymond5a007692000-08-04 07:35:41 +00001228\end{methoddesc}
1229
1230\begin{methoddesc}{do_command}{ch}
1231Process a single command keystroke. Here are the supported special
1232keystrokes:
1233
Fred Drakeec4b2af2000-08-09 14:34:48 +00001234\begin{tableii}{l|l}{kbd}{Keystroke}{Action}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001235 \lineii{Ctrl-A}{Go to left edge of window.}
1236 \lineii{Ctrl-B}{Cursor left, wrapping to previous line if appropriate.}
1237 \lineii{Ctrl-D}{Delete character under cursor.}
1238 \lineii{Ctrl-E}{Go to right edge (stripspaces off) or end of line (stripspaces on).}
1239 \lineii{Ctrl-F}{Cursor right, wrapping to next line when appropriate.}
1240 \lineii{Ctrl-G}{Terminate, returning the window contents.}
1241 \lineii{Ctrl-H}{Delete character backward.}
1242 \lineii{Ctrl-J}{Terminate if the window is 1 line, otherwise insert newline.}
1243 \lineii{Ctrl-K}{If line is blank, delete it, otherwise clear to end of line.}
1244 \lineii{Ctrl-L}{Refresh screen.}
1245 \lineii{Ctrl-N}{Cursor down; move down one line.}
1246 \lineii{Ctrl-O}{Insert a blank line at cursor location.}
1247 \lineii{Ctrl-P}{Cursor up; move up one line.}
1248\end{tableii}
1249
1250Move operations do nothing if the cursor is at an edge where the
1251movement is not possible. The following synonyms are supported where
Fred Drakeec4b2af2000-08-09 14:34:48 +00001252possible:
1253
1254\begin{tableii}{l|l}{constant}{Constant}{Keystroke}
1255 \lineii{KEY_LEFT}{\kbd{Ctrl-B}}
1256 \lineii{KEY_RIGHT}{\kbd{Ctrl-F}}
1257 \lineii{KEY_UP}{\kbd{Ctrl-P}}
1258 \lineii{KEY_DOWN}{\kbd{Ctrl-N}}
1259 \lineii{KEY_BACKSPACE}{\kbd{Ctrl-h}}
1260\end{tableii}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001261
1262All other keystrokes are treated as a command to insert the given
1263character and move right (with line wrapping).
1264\end{methoddesc}
1265
1266\begin{methoddesc}{gather}{}
1267This method returns the window contents as a string; whether blanks in
1268the window are included is affected by the \member{stripspaces}
1269member.
1270\end{methoddesc}
1271
Fred Drakeec4b2af2000-08-09 14:34:48 +00001272\begin{memberdesc}{stripspaces}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001273This data member is a flag which controls the interpretation of blanks in
1274the window. When it is on, trailing blanks on each line are ignored;
1275any cursor motion that would land the cursor on a trailing blank goes
1276to the end of that line instead, and trailing blanks are stripped when
1277the window contents is gathered.
Fred Drakeec4b2af2000-08-09 14:34:48 +00001278\end{memberdesc}
1279
Eric S. Raymond5a007692000-08-04 07:35:41 +00001280
1281\section{\module{curses.wrapper} ---
Fred Drakeec4b2af2000-08-09 14:34:48 +00001282 Terminal handler for curses programs}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001283
1284\declaremodule{standard}{curses.wrapper}
1285\sectionauthor{Eric Raymond}{esr@thyrsus.com}
1286\moduleauthor{Eric Raymond}{esr@thyrsus.com}
Fred Drakeec4b2af2000-08-09 14:34:48 +00001287\modulesynopsis{Terminal configuration wrapper for curses programs.}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001288\versionadded{1.6}
1289
1290This module supplies one function, \function{wrapper()}, which runs
1291another function which should be the rest of your curses-using
1292application. If the application raises an exception,
1293\function{wrapper()} will restore the terminal to a sane state before
1294passing it further up the stack and generating a traceback.
1295
Fred Drakeec4b2af2000-08-09 14:34:48 +00001296\begin{funcdesc}{wrapper}{func, \moreargs}
Eric S. Raymond5a007692000-08-04 07:35:41 +00001297Wrapper function that initializes curses and calls another function,
Fred Drakeec4b2af2000-08-09 14:34:48 +00001298\var{func}, restoring normal keyboard/screen behavior on error.
1299The callable object \var{func} is then passed the main window 'stdscr'
Eric S. Raymond5a007692000-08-04 07:35:41 +00001300as its first argument, followed by any other arguments passed to
1301\function{wrapper()}.
1302\end{funcdesc}
1303
Eric S. Raymond1ebd3f62000-08-09 21:11:07 +00001304Before calling the hook function, \function{wrapper()} turns on cbreak
1305mode, turns off echo, enables the terminal keypad, and initializes
1306colors if the terminal has color support. On exit (whether normally
1307or by exception) it restores cooked mode, turns on echo, and disables
1308the terminal keypad.
Eric S. Raymond5a007692000-08-04 07:35:41 +00001309