1 .\"***************************************************************************
2 .\" Copyright (c) 2008 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.12 2008/04/12 18:22:51 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
42 \fBtypedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *);\fR
44 \fBint set_escdelay(int size);\fR
46 \fBint set_tabsize(int size);\fR
48 \fBint use_screen(SCREEN *scr, NCURSES_SCREEN_CB func, void *data);\fR
50 \fBint use_window(WINDOW *win, NCURSES_WINDOW_CB func, void *data);\fR
53 This implementation can be configured to provide rudimentary support
54 for multi-threaded applications.
55 This makes a different set of libraries, e.g., \fIlibncursest\fP since
56 the binary interfaces are different.
58 Rather than modify the interfaces to pass a thread specifier to
59 each function, it adds a few functions which can be used in any
60 configuration which hide the mutex's needed to prevent concurrent
61 use of the global variables when configured for threading.
63 In addition to forcing access to members of the \fBWINDOW\fP structure
64 to be via functions (see \fBcurs_opaque\fP(3x)),
65 it makes functions of the common global variables,
76 Those variables are maintained as read-only values, stored in the \fBSCREEN\fP
79 Even this is not enough to make a thread-safe application using curses.
80 A multi-threaded application would be expected to have threads updating
81 separate windows (within the same device),
82 or updating on separate screens (on different devices).
83 Also, a few of the global variables are considered writable by some
85 The functions described here address these special situations.
87 The ESCDELAY and TABSIZE global variables are modified by some applications.
88 To modify them in any configuration,
89 use the \fBset_escdelay\fP or \fBset_tabsize\fP functions.
90 Other global variables are not modifiable.
92 The \fBuse_window\fP and \fBuse_screen\fP functions provide coarse
93 granularity mutexes for their respective \fBWINDOW\fP and \fBSCREEN\fP
94 parameters, and call a user-supplied function,
95 passing it a \fIdata\fP parameter,
96 and returning the value from the user-supplied function to the application.
97 .\" ***************************************************************************
99 All of the ncurses library functions assume that the locale is not
100 altered during operation.
102 they use data which is maintained within a hierarchy of scopes.
106 global data, e.g., used in the low-level terminfo or termcap interfaces.
109 terminal data, e.g., associated with a call to \fIset_curterm\fP.
110 The terminal data are initialized when screens are created.
113 screen data, e.g., associated with a call to \fInewterm\fP or \fIinitscr\fP.
116 window data, e.g., associated with a call to \fInewwin\fP or \fIsubwin\fP.
117 Windows are associated with screens.
118 Pads are not necessarily associated with a particular screen.
120 Most curses applications operate on one or more windows within a single screen.
123 reentrant, i.e., it uses only the data passed as parameters.
126 This table lists the scope of data used for each symbol in the
127 ncurses library when it is configured to support threading:
135 COLORS/screen (readonly)
137 COLOR_PAIRS/screen (readonly)
138 COLS/screen (readonly)
139 ESCDELAY/screen (readonly, see \fIset_escdelay\fP)
140 LINES/screen (readonly)
141 PAIR_NUMBER/reentrant
144 TABSIZE/screen (readonly)
146 acs_map/screen (readonly)
147 add_wch/window (stdscr)
148 add_wchnstr/window (stdscr)
149 add_wchstr/window (stdscr)
150 addch/window (stdscr)
151 addchnstr/window (stdscr)
152 addchstr/window (stdscr)
153 addnstr/window (stdscr)
154 addnwstr/window (stdscr)
155 addstr/window (stdscr)
156 addwstr/window (stdscr)
157 assume_default_colors/screen
158 attr_get/window (stdscr)
159 attr_off/window (stdscr)
160 attr_on/window (stdscr)
161 attr_set/window (stdscr)
162 attroff/window (stdscr)
163 attron/window (stdscr)
164 attrset/window (stdscr)
168 bkgdset/window (stdscr)
169 bkgrnd/window (stdscr)
170 bkgrndset/window (stdscr)
171 boolcodes/global (readonly)
172 boolfnames/global (readonly)
173 boolnames/global (readonly)
174 border/window (stdscr)
175 border_set/window (stdscr)
177 box_set/window (stdscr)
178 can_change_color/terminal
180 chgat/window (stdscr)
181 clear/window (stdscr)
183 clrtobot/window (stdscr)
184 clrtoeol/window (stdscr)
186 color_set/window (stdscr)
187 copywin/window locks(source, target)
190 curscr/screen (readonly)
191 curses_version/global (readonly)
192 def_prog_mode/terminal
193 def_shell_mode/terminal
197 delch/window (stdscr)
198 deleteln/window (stdscr)
199 delscreen/global locks(screenlist, screen)
200 delwin/global locks(windowlist)
203 dupwin/screen locks(window)
205 echo_wchar/window (stdscr)
206 echochar/window (stdscr)
208 erase/window (stdscr)
209 erasechar/window (stdscr)
210 erasewchar/window (stdscr)
214 get_wch/screen (input-operation)
215 get_wstr/screen (input-operation)
222 getch/screen (input-operation)
227 getmouse/screen (input-operation)
228 getn_wstr/screen (input-operation)
229 getnstr/screen (input-operation)
232 getstr/screen (input-operation)
233 getwin/screen (input-operation)
239 hline/window (stdscr)
240 hline_set/window (stdscr)
244 in_wch/window (stdscr)
245 in_wchnstr/window (stdscr)
246 in_wchstr/window (stdscr)
248 inchnstr/window (stdscr)
249 inchstr/window (stdscr)
252 initscr/global locks(screenlist)
253 innstr/window (stdscr)
254 innwstr/window (stdscr)
255 ins_nwstr/window (stdscr)
256 ins_wch/window (stdscr)
257 ins_wstr/window (stdscr)
258 insch/window (stdscr)
259 insdelln/window (stdscr)
260 insertln/window (stdscr)
261 insnstr/window (stdscr)
262 insstr/window (stdscr)
263 instr/window (stdscr)
265 inwstr/window (stdscr)
272 is_linetouched/window
277 is_term_resized/terminal
281 key_name/global (static data)
283 keyname/global (static data)
292 mouse_trafo/window (stdscr)
296 mvadd_wch/window (stdscr)
297 mvadd_wchnstr/window (stdscr)
298 mvadd_wchstr/window (stdscr)
299 mvaddch/window (stdscr)
300 mvaddchnstr/window (stdscr)
301 mvaddchstr/window (stdscr)
302 mvaddnstr/window (stdscr)
303 mvaddnwstr/window (stdscr)
304 mvaddstr/window (stdscr)
305 mvaddwstr/window (stdscr)
306 mvchgat/window (stdscr)
308 mvdelch/window (stdscr)
309 mvderwin/window (stdscr)
310 mvget_wch/screen (input-operation)
311 mvget_wstr/screen (input-operation)
312 mvgetch/screen (input-operation)
313 mvgetn_wstr/screen (input-operation)
314 mvgetnstr/screen (input-operation)
315 mvgetstr/screen (input-operation)
316 mvhline/window (stdscr)
317 mvhline_set/window (stdscr)
318 mvin_wch/window (stdscr)
319 mvin_wchnstr/window (stdscr)
320 mvin_wchstr/window (stdscr)
321 mvinch/window (stdscr)
322 mvinchnstr/window (stdscr)
323 mvinchstr/window (stdscr)
324 mvinnstr/window (stdscr)
325 mvinnwstr/window (stdscr)
326 mvins_nwstr/window (stdscr)
327 mvins_wch/window (stdscr)
328 mvins_wstr/window (stdscr)
329 mvinsch/window (stdscr)
330 mvinsnstr/window (stdscr)
331 mvinsstr/window (stdscr)
332 mvinstr/window (stdscr)
333 mvinwstr/window (stdscr)
334 mvprintw/window (stdscr)
336 mvvline/window (stdscr)
337 mvvline_set/window (stdscr)
339 mvwadd_wchnstr/window
350 mvwget_wch/screen (input-operation)
351 mvwget_wstr/screen (input-operation)
352 mvwgetch/screen (input-operation)
353 mvwgetn_wstr/screen (input-operation)
354 mvwgetnstr/screen (input-operation)
355 mvwgetstr/screen (input-operation)
380 newpad/global locks(windowlist)
381 newscr/screen (readonly)
382 newterm/global locks(screenlist)
383 newwin/global locks(windowlist)
393 numcodes/global (readonly)
394 numfnames/global (readonly)
395 numnames/global (readonly)
397 overlay/window locks(source, target)
398 overwrite/window locks(source, target)
411 reset_prog_mode/screen
412 reset_shell_mode/screen
414 resize_term/screen locks(windowlist)
417 ripoffline/global (static data)
430 set_term/global locks(screenlist, screen)
432 setscrreg/window (stdscr)
445 slk_noutrefresh/screen
454 stdscr/screen (readonly)
455 strcodes/global (readonly)
456 strfnames/global (readonly)
457 strnames/global (readonly)
472 timeout/window (stdscr)
475 tparm/global (static data)
477 trace/global (static data)
478 ttytype/screen (readonly)
481 unget_wch/screen (input-operation)
482 ungetch/screen (input-operation)
483 ungetmouse/screen (input-operation)
485 use_default_colors/screen
486 use_env/global (static data)
487 use_extended_names/global (static data)
488 use_legacy_coding/screen
489 use_screen/global locks(screenlist, screen)
490 use_window/global locks(windowlist, window)
495 vline/window (stdscr)
496 vline_set/window (stdscr)
529 wcursyncup/screen (affects window plus parents)
536 wget_wch/screen (input-operation)
537 wget_wstr/screen (input-operation)
539 wgetch/screen (input-operation)
540 wgetn_wstr/screen (input-operation)
541 wgetnstr/screen (input-operation)
544 wgetstr/screen (input-operation)
571 wresize/window locks(windowlist)
577 wsyncdown/screen (affects window plus parents)
578 wsyncup/screen (affects window plus parents)
581 wunctrl/global (static data)
585 .\" ***************************************************************************
587 These functions all return TRUE or FALSE, except as noted.
589 Both a macro and a function are provided for each name.
591 These routines are specific to ncurses.
592 They were not supported on Version 7, BSD or System V implementations.
593 It is recommended that any code depending on ncurses extensions
594 be conditioned using NCURSES_VERSION.
597 \fBcurs_opaque\fR(3X)
599 .\"# The following sets edit modes for GNU EMACS
600 .\"# Local Variables: