1 .\"***************************************************************************
2 .\" Copyright (c) 2008-2014,2015 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.23 2015/12/05 18:47:04 tom Exp $
30 .TH curs_threads 3X ""
37 \fBcurs_threads\fR \- \fBcurses\fR thread support
41 \fB#include <curses.h>\fR
43 \fBtypedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *);\fR
45 \fBtypedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *);\fR
47 \fBint get_escdelay(void);\fR
49 \fBint set_escdelay(int size);\fR
51 \fBint set_tabsize(int size);\fR
53 \fBint use_screen(SCREEN *scr, NCURSES_SCREEN_CB func, void *data);\fR
55 \fBint use_window(WINDOW *win, NCURSES_WINDOW_CB func, void *data);\fR
58 This implementation can be configured to provide rudimentary support
59 for multi-threaded applications.
60 This makes a different set of libraries, e.g., \fIlibncursest\fP since
61 the binary interfaces are different.
63 Rather than modify the interfaces to pass a thread specifier to
64 each function, it adds a few functions which can be used in any
65 configuration which hide the mutex's needed to prevent concurrent
66 use of the global variables when configured for threading.
68 In addition to forcing access to members of the \fBWINDOW\fP structure
69 to be via functions (see \fBcurs_opaque\fP(3X)),
70 it makes functions of the common global variables,
81 Those variables are maintained as read-only values, stored in the \fBSCREEN\fP
84 Even this is not enough to make a thread-safe application using curses.
85 A multi-threaded application would be expected to have threads updating
86 separate windows (within the same device),
87 or updating on separate screens (on different devices).
88 Also, a few of the global variables are considered writable by some
90 The functions described here address these special situations.
92 The ESCDELAY and TABSIZE global variables are modified by some applications.
93 To modify them in any configuration,
94 use the \fBset_escdelay\fP or \fBset_tabsize\fP functions.
95 Other global variables are not modifiable.
97 The \fBget_escdelay\fP function returns the value for ESCDELAY.
99 The \fBuse_window\fP and \fBuse_screen\fP functions provide coarse
100 granularity mutexes for their respective \fBWINDOW\fP and \fBSCREEN\fP
101 parameters, and call a user-supplied function,
102 passing it a \fIdata\fP parameter,
103 and returning the value from the user-supplied function to the application.
104 .\" ***************************************************************************
106 All of the ncurses library functions assume that the locale is not
107 altered during operation.
109 they use data which is maintained within a hierarchy of scopes.
112 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.
117 screen data, e.g., associated with a call to \fInewterm\fP or \fIinitscr\fP.
119 window data, e.g., associated with a call to \fInewwin\fP or \fIsubwin\fP.
120 Windows are associated with screens.
121 Pads are not necessarily associated with a particular screen.
123 Most curses applications operate on one or more windows within a single screen.
125 reentrant, i.e., it uses only the data passed as parameters.
128 This table lists the scope of data used for each symbol in the
129 ncurses library when it is configured to support threading:
137 COLORS/screen (readonly)
139 COLOR_PAIRS/screen (readonly)
140 COLS/screen (readonly)
141 ESCDELAY/screen (readonly, see \fIset_escdelay\fP)
142 LINES/screen (readonly)
143 PAIR_NUMBER/reentrant
146 TABSIZE/screen (readonly)
148 acs_map/screen (readonly)
149 add_wch/window (stdscr)
150 add_wchnstr/window (stdscr)
151 add_wchstr/window (stdscr)
152 addch/window (stdscr)
153 addchnstr/window (stdscr)
154 addchstr/window (stdscr)
155 addnstr/window (stdscr)
156 addnwstr/window (stdscr)
157 addstr/window (stdscr)
158 addwstr/window (stdscr)
159 assume_default_colors/screen
160 attr_get/window (stdscr)
161 attr_off/window (stdscr)
162 attr_on/window (stdscr)
163 attr_set/window (stdscr)
164 attroff/window (stdscr)
165 attron/window (stdscr)
166 attrset/window (stdscr)
170 bkgdset/window (stdscr)
171 bkgrnd/window (stdscr)
172 bkgrndset/window (stdscr)
173 boolcodes/global (readonly)
174 boolfnames/global (readonly)
175 boolnames/global (readonly)
176 border/window (stdscr)
177 border_set/window (stdscr)
179 box_set/window (stdscr)
180 can_change_color/terminal
182 chgat/window (stdscr)
183 clear/window (stdscr)
185 clrtobot/window (stdscr)
186 clrtoeol/window (stdscr)
188 color_set/window (stdscr)
189 copywin/window locks(source, target)
192 curscr/screen (readonly)
193 curses_version/global (readonly)
194 def_prog_mode/terminal
195 def_shell_mode/terminal
199 delch/window (stdscr)
200 deleteln/window (stdscr)
201 delscreen/global locks(screenlist, screen)
202 delwin/global locks(windowlist)
205 dupwin/screen locks(window)
207 echo_wchar/window (stdscr)
208 echochar/window (stdscr)
210 erase/window (stdscr)
211 erasechar/window (stdscr)
212 erasewchar/window (stdscr)
216 get_wch/screen (input-operation)
217 get_wstr/screen (input-operation)
224 getch/screen (input-operation)
229 getmouse/screen (input-operation)
230 getn_wstr/screen (input-operation)
231 getnstr/screen (input-operation)
234 getstr/screen (input-operation)
235 getwin/screen (input-operation)
241 hline/window (stdscr)
242 hline_set/window (stdscr)
246 in_wch/window (stdscr)
247 in_wchnstr/window (stdscr)
248 in_wchstr/window (stdscr)
250 inchnstr/window (stdscr)
251 inchstr/window (stdscr)
254 initscr/global locks(screenlist)
255 innstr/window (stdscr)
256 innwstr/window (stdscr)
257 ins_nwstr/window (stdscr)
258 ins_wch/window (stdscr)
259 ins_wstr/window (stdscr)
260 insch/window (stdscr)
261 insdelln/window (stdscr)
262 insertln/window (stdscr)
263 insnstr/window (stdscr)
264 insstr/window (stdscr)
265 instr/window (stdscr)
267 inwstr/window (stdscr)
274 is_linetouched/window
279 is_term_resized/terminal
283 key_name/global (static data)
285 keyname/global (static data)
294 mouse_trafo/window (stdscr)
298 mvadd_wch/window (stdscr)
299 mvadd_wchnstr/window (stdscr)
300 mvadd_wchstr/window (stdscr)
301 mvaddch/window (stdscr)
302 mvaddchnstr/window (stdscr)
303 mvaddchstr/window (stdscr)
304 mvaddnstr/window (stdscr)
305 mvaddnwstr/window (stdscr)
306 mvaddstr/window (stdscr)
307 mvaddwstr/window (stdscr)
308 mvchgat/window (stdscr)
310 mvdelch/window (stdscr)
311 mvderwin/window (stdscr)
312 mvget_wch/screen (input-operation)
313 mvget_wstr/screen (input-operation)
314 mvgetch/screen (input-operation)
315 mvgetn_wstr/screen (input-operation)
316 mvgetnstr/screen (input-operation)
317 mvgetstr/screen (input-operation)
318 mvhline/window (stdscr)
319 mvhline_set/window (stdscr)
320 mvin_wch/window (stdscr)
321 mvin_wchnstr/window (stdscr)
322 mvin_wchstr/window (stdscr)
323 mvinch/window (stdscr)
324 mvinchnstr/window (stdscr)
325 mvinchstr/window (stdscr)
326 mvinnstr/window (stdscr)
327 mvinnwstr/window (stdscr)
328 mvins_nwstr/window (stdscr)
329 mvins_wch/window (stdscr)
330 mvins_wstr/window (stdscr)
331 mvinsch/window (stdscr)
332 mvinsnstr/window (stdscr)
333 mvinsstr/window (stdscr)
334 mvinstr/window (stdscr)
335 mvinwstr/window (stdscr)
336 mvprintw/window (stdscr)
338 mvvline/window (stdscr)
339 mvvline_set/window (stdscr)
341 mvwadd_wchnstr/window
352 mvwget_wch/screen (input-operation)
353 mvwget_wstr/screen (input-operation)
354 mvwgetch/screen (input-operation)
355 mvwgetn_wstr/screen (input-operation)
356 mvwgetnstr/screen (input-operation)
357 mvwgetstr/screen (input-operation)
382 newpad/global locks(windowlist)
383 newscr/screen (readonly)
384 newterm/global locks(screenlist)
385 newwin/global locks(windowlist)
395 numcodes/global (readonly)
396 numfnames/global (readonly)
397 numnames/global (readonly)
399 overlay/window locks(source, target)
400 overwrite/window locks(source, target)
413 reset_prog_mode/screen
414 reset_shell_mode/screen
416 resize_term/screen locks(windowlist)
419 ripoffline/global (static data)
432 set_term/global locks(screenlist, screen)
434 setscrreg/window (stdscr)
447 slk_noutrefresh/screen
456 stdscr/screen (readonly)
457 strcodes/global (readonly)
458 strfnames/global (readonly)
459 strnames/global (readonly)
474 timeout/window (stdscr)
477 tparm/global (static data)
479 trace/global (static data)
480 ttytype/screen (readonly)
483 unget_wch/screen (input-operation)
484 ungetch/screen (input-operation)
485 ungetmouse/screen (input-operation)
487 use_default_colors/screen
488 use_env/global (static data)
489 use_extended_names/global (static data)
490 use_legacy_coding/screen
491 use_screen/global locks(screenlist, screen)
492 use_window/global locks(windowlist, window)
497 vline/window (stdscr)
498 vline_set/window (stdscr)
531 wcursyncup/screen (affects window plus parents)
538 wget_wch/screen (input-operation)
539 wget_wstr/screen (input-operation)
541 wgetch/screen (input-operation)
543 wgetn_wstr/screen (input-operation)
544 wgetnstr/screen (input-operation)
547 wgetstr/screen (input-operation)
574 wresize/window locks(windowlist)
580 wsyncdown/screen (affects window plus parents)
581 wsyncup/screen (affects window plus parents)
584 wunctrl/global (static data)
588 .\" ***************************************************************************
590 These functions all return \fBTRUE\fP or \fBFALSE\fP, except as noted.
592 Both a macro and a function are provided for each name.
594 These routines are specific to ncurses.
595 They were not supported on Version 7, BSD or System V implementations.
596 It is recommended that any code depending on ncurses extensions
597 be conditioned using NCURSES_VERSION.
600 \fBcurs_opaque\fR(3X),
601 \fBcurs_variables\fR(3X).