1 .\"***************************************************************************
2 .\" Copyright (c) 2008,2010 Free Software Foundation, Inc. *
4 .\" Permission is hereby granted, free of charge, to any person obtaining a *
5 .\" copy of this software and associated documentation files (the *
6 .\" "Software"), to deal in the Software without restriction, including *
7 .\" without limitation the rights to use, copy, modify, merge, publish, *
8 .\" distribute, distribute with modifications, sublicense, and/or sell *
9 .\" copies of the Software, and to permit persons to whom the Software is *
10 .\" furnished to do so, subject to the following conditions: *
12 .\" The above copyright notice and this permission notice shall be included *
13 .\" in all copies or substantial portions of the Software. *
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 .\" Except as contained in this notice, the name(s) of the above copyright *
24 .\" holders shall not be used in advertising or otherwise to promote the *
25 .\" sale, use or other dealings in this Software without prior written *
27 .\"***************************************************************************
29 .\" $Id: curs_threads.3x,v 1.15 2010/09/11 22:17:11 tom Exp $
30 .TH curs_threads 3X ""
35 \fBuse_window\fR \- \fBcurses\fR thread support
39 \fB#include <curses.h>\fR
41 \fBtypedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *);\fR
43 \fBtypedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *);\fR
45 \fBint get_escdelay(void);\fR
47 \fBint set_escdelay(int size);\fR
49 \fBint set_tabsize(int size);\fR
51 \fBint use_screen(SCREEN *scr, NCURSES_WINDOW_CB func, void *data);\fR
53 \fBint use_window(WINDOW *win, NCURSES_SCREEN_CB func, void *data);\fR
56 This implementation can be configured to provide rudimentary support
57 for multi-threaded applications.
58 This makes a different set of libraries, e.g., \fIlibncursest\fP since
59 the binary interfaces are different.
61 Rather than modify the interfaces to pass a thread specifier to
62 each function, it adds a few functions which can be used in any
63 configuration which hide the mutex's needed to prevent concurrent
64 use of the global variables when configured for threading.
66 In addition to forcing access to members of the \fBWINDOW\fP structure
67 to be via functions (see \fBcurs_opaque\fP(3x)),
68 it makes functions of the common global variables,
79 Those variables are maintained as read-only values, stored in the \fBSCREEN\fP
82 Even this is not enough to make a thread-safe application using curses.
83 A multi-threaded application would be expected to have threads updating
84 separate windows (within the same device),
85 or updating on separate screens (on different devices).
86 Also, a few of the global variables are considered writable by some
88 The functions described here address these special situations.
90 The ESCDELAY and TABSIZE global variables are modified by some applications.
91 To modify them in any configuration,
92 use the \fBset_escdelay\fP or \fBset_tabsize\fP functions.
93 Other global variables are not modifiable.
95 The \fBget_escdelay\fP function returns the value for ESCDELAY.
97 The \fBuse_window\fP and \fBuse_screen\fP functions provide coarse
98 granularity mutexes for their respective \fBWINDOW\fP and \fBSCREEN\fP
99 parameters, and call a user-supplied function,
100 passing it a \fIdata\fP parameter,
101 and returning the value from the user-supplied function to the application.
102 .\" ***************************************************************************
104 All of the ncurses library functions assume that the locale is not
105 altered during operation.
107 they use data which is maintained within a hierarchy of scopes.
111 global data, e.g., used in the low-level terminfo or termcap interfaces.
114 terminal data, e.g., associated with a call to \fIset_curterm\fP.
115 The terminal data are initialized when screens are created.
118 screen data, e.g., associated with a call to \fInewterm\fP or \fIinitscr\fP.
121 window data, e.g., associated with a call to \fInewwin\fP or \fIsubwin\fP.
122 Windows are associated with screens.
123 Pads are not necessarily associated with a particular screen.
125 Most curses applications operate on one or more windows within a single screen.
128 reentrant, i.e., it uses only the data passed as parameters.
131 This table lists the scope of data used for each symbol in the
132 ncurses library when it is configured to support threading:
140 COLORS/screen (readonly)
142 COLOR_PAIRS/screen (readonly)
143 COLS/screen (readonly)
144 ESCDELAY/screen (readonly, see \fIset_escdelay\fP)
145 LINES/screen (readonly)
146 PAIR_NUMBER/reentrant
149 TABSIZE/screen (readonly)
151 acs_map/screen (readonly)
152 add_wch/window (stdscr)
153 add_wchnstr/window (stdscr)
154 add_wchstr/window (stdscr)
155 addch/window (stdscr)
156 addchnstr/window (stdscr)
157 addchstr/window (stdscr)
158 addnstr/window (stdscr)
159 addnwstr/window (stdscr)
160 addstr/window (stdscr)
161 addwstr/window (stdscr)
162 assume_default_colors/screen
163 attr_get/window (stdscr)
164 attr_off/window (stdscr)
165 attr_on/window (stdscr)
166 attr_set/window (stdscr)
167 attroff/window (stdscr)
168 attron/window (stdscr)
169 attrset/window (stdscr)
173 bkgdset/window (stdscr)
174 bkgrnd/window (stdscr)
175 bkgrndset/window (stdscr)
176 boolcodes/global (readonly)
177 boolfnames/global (readonly)
178 boolnames/global (readonly)
179 border/window (stdscr)
180 border_set/window (stdscr)
182 box_set/window (stdscr)
183 can_change_color/terminal
185 chgat/window (stdscr)
186 clear/window (stdscr)
188 clrtobot/window (stdscr)
189 clrtoeol/window (stdscr)
191 color_set/window (stdscr)
192 copywin/window locks(source, target)
195 curscr/screen (readonly)
196 curses_version/global (readonly)
197 def_prog_mode/terminal
198 def_shell_mode/terminal
202 delch/window (stdscr)
203 deleteln/window (stdscr)
204 delscreen/global locks(screenlist, screen)
205 delwin/global locks(windowlist)
208 dupwin/screen locks(window)
210 echo_wchar/window (stdscr)
211 echochar/window (stdscr)
213 erase/window (stdscr)
214 erasechar/window (stdscr)
215 erasewchar/window (stdscr)
219 get_wch/screen (input-operation)
220 get_wstr/screen (input-operation)
227 getch/screen (input-operation)
232 getmouse/screen (input-operation)
233 getn_wstr/screen (input-operation)
234 getnstr/screen (input-operation)
237 getstr/screen (input-operation)
238 getwin/screen (input-operation)
244 hline/window (stdscr)
245 hline_set/window (stdscr)
249 in_wch/window (stdscr)
250 in_wchnstr/window (stdscr)
251 in_wchstr/window (stdscr)
253 inchnstr/window (stdscr)
254 inchstr/window (stdscr)
257 initscr/global locks(screenlist)
258 innstr/window (stdscr)
259 innwstr/window (stdscr)
260 ins_nwstr/window (stdscr)
261 ins_wch/window (stdscr)
262 ins_wstr/window (stdscr)
263 insch/window (stdscr)
264 insdelln/window (stdscr)
265 insertln/window (stdscr)
266 insnstr/window (stdscr)
267 insstr/window (stdscr)
268 instr/window (stdscr)
270 inwstr/window (stdscr)
277 is_linetouched/window
282 is_term_resized/terminal
286 key_name/global (static data)
288 keyname/global (static data)
297 mouse_trafo/window (stdscr)
301 mvadd_wch/window (stdscr)
302 mvadd_wchnstr/window (stdscr)
303 mvadd_wchstr/window (stdscr)
304 mvaddch/window (stdscr)
305 mvaddchnstr/window (stdscr)
306 mvaddchstr/window (stdscr)
307 mvaddnstr/window (stdscr)
308 mvaddnwstr/window (stdscr)
309 mvaddstr/window (stdscr)
310 mvaddwstr/window (stdscr)
311 mvchgat/window (stdscr)
313 mvdelch/window (stdscr)
314 mvderwin/window (stdscr)
315 mvget_wch/screen (input-operation)
316 mvget_wstr/screen (input-operation)
317 mvgetch/screen (input-operation)
318 mvgetn_wstr/screen (input-operation)
319 mvgetnstr/screen (input-operation)
320 mvgetstr/screen (input-operation)
321 mvhline/window (stdscr)
322 mvhline_set/window (stdscr)
323 mvin_wch/window (stdscr)
324 mvin_wchnstr/window (stdscr)
325 mvin_wchstr/window (stdscr)
326 mvinch/window (stdscr)
327 mvinchnstr/window (stdscr)
328 mvinchstr/window (stdscr)
329 mvinnstr/window (stdscr)
330 mvinnwstr/window (stdscr)
331 mvins_nwstr/window (stdscr)
332 mvins_wch/window (stdscr)
333 mvins_wstr/window (stdscr)
334 mvinsch/window (stdscr)
335 mvinsnstr/window (stdscr)
336 mvinsstr/window (stdscr)
337 mvinstr/window (stdscr)
338 mvinwstr/window (stdscr)
339 mvprintw/window (stdscr)
341 mvvline/window (stdscr)
342 mvvline_set/window (stdscr)
344 mvwadd_wchnstr/window
355 mvwget_wch/screen (input-operation)
356 mvwget_wstr/screen (input-operation)
357 mvwgetch/screen (input-operation)
358 mvwgetn_wstr/screen (input-operation)
359 mvwgetnstr/screen (input-operation)
360 mvwgetstr/screen (input-operation)
385 newpad/global locks(windowlist)
386 newscr/screen (readonly)
387 newterm/global locks(screenlist)
388 newwin/global locks(windowlist)
398 numcodes/global (readonly)
399 numfnames/global (readonly)
400 numnames/global (readonly)
402 overlay/window locks(source, target)
403 overwrite/window locks(source, target)
416 reset_prog_mode/screen
417 reset_shell_mode/screen
419 resize_term/screen locks(windowlist)
422 ripoffline/global (static data)
435 set_term/global locks(screenlist, screen)
437 setscrreg/window (stdscr)
450 slk_noutrefresh/screen
459 stdscr/screen (readonly)
460 strcodes/global (readonly)
461 strfnames/global (readonly)
462 strnames/global (readonly)
477 timeout/window (stdscr)
480 tparm/global (static data)
482 trace/global (static data)
483 ttytype/screen (readonly)
486 unget_wch/screen (input-operation)
487 ungetch/screen (input-operation)
488 ungetmouse/screen (input-operation)
490 use_default_colors/screen
491 use_env/global (static data)
492 use_extended_names/global (static data)
493 use_legacy_coding/screen
494 use_screen/global locks(screenlist, screen)
495 use_window/global locks(windowlist, window)
500 vline/window (stdscr)
501 vline_set/window (stdscr)
534 wcursyncup/screen (affects window plus parents)
541 wget_wch/screen (input-operation)
542 wget_wstr/screen (input-operation)
544 wgetch/screen (input-operation)
545 wgetn_wstr/screen (input-operation)
546 wgetnstr/screen (input-operation)
549 wgetstr/screen (input-operation)
576 wresize/window locks(windowlist)
582 wsyncdown/screen (affects window plus parents)
583 wsyncup/screen (affects window plus parents)
586 wunctrl/global (static data)
590 .\" ***************************************************************************
592 These functions all return TRUE or FALSE, except as noted.
594 Both a macro and a function are provided for each name.
596 These routines are specific to ncurses.
597 They were not supported on Version 7, BSD or System V implementations.
598 It is recommended that any code depending on ncurses extensions
599 be conditioned using NCURSES_VERSION.
602 \fBcurs_opaque\fR(3X)
604 .\"# The following sets edit modes for GNU EMACS
605 .\"# Local Variables: