]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_threads.3x
ncurses 5.7 - patch 20091107
[ncurses.git] / man / curs_threads.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 2008 Free Software Foundation, Inc.                        *
3 .\"                                                                          *
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:                 *
11 .\"                                                                          *
12 .\" The above copyright notice and this permission notice shall be included  *
13 .\" in all copies or substantial portions of the Software.                   *
14 .\"                                                                          *
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.                               *
22 .\"                                                                          *
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       *
26 .\" authorization.                                                           *
27 .\"***************************************************************************
28 .\"
29 .\" $Id: curs_threads.3x,v 1.12 2008/04/12 18:22:51 tom Exp $
30 .TH curs_threads 3X ""
31 .na
32 .hy 0
33 .SH NAME
34 \fBuse_screen\fR,
35 \fBuse_window\fR - \fBcurses\fR thread support
36 .ad
37 .hy
38 .SH SYNOPSIS
39 \fB#include <curses.h>\fR
40 .sp
41 \fBtypedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *);\fR
42 \fBtypedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *);\fR
43 .br
44 \fBint set_escdelay(int size);\fR
45 .br
46 \fBint set_tabsize(int size);\fR
47 .br
48 \fBint use_screen(SCREEN *scr, NCURSES_WINDOW_CB func, void *data);\fR
49 .br
50 \fBint use_window(WINDOW *win, NCURSES_SCREEN_CB func, void *data);\fR
51 .br
52 .SH DESCRIPTION
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.
57 .PP
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.
62 .PP
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,
66 e.g.,
67 COLORS,
68 COLOR_PAIRS,
69 COLS,
70 ESCDELAY,
71 LINES,
72 TABSIZE
73 curscr,
74 newscr and
75 ttytype.
76 Those variables are maintained as read-only values, stored in the \fBSCREEN\fP
77 structure.
78 .PP
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
84 applications.
85 The functions described here address these special situations.
86 .PP
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.
91 .PP
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 .\" ***************************************************************************
98 .SS USAGE
99 All of the ncurses library functions assume that the locale is not
100 altered during operation.
101 In addition,
102 they use data which is maintained within a hierarchy of scopes.
103 .RS
104 .TP 3
105 -
106 global data, e.g., used in the low-level terminfo or termcap interfaces.
107 .TP 3
108 -
109 terminal data, e.g., associated with a call to \fIset_curterm\fP.
110 The terminal data are initialized when screens are created.
111 .TP 3
112 -
113 screen data, e.g., associated with a call to \fInewterm\fP or \fIinitscr\fP.
114 .TP 3
115 -
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.
119 .IP
120 Most curses applications operate on one or more windows within a single screen.
121 .TP 3
122 -
123 reentrant, i.e., it uses only the data passed as parameters.
124 .RE
125 .PP
126 This table lists the scope of data used for each symbol in the
127 ncurses library when it is configured to support threading:
128 .TS
129 center tab(/);
130 l l
131 l l .
132 Symbol/Scope
133 =
134 BC/global
135 COLORS/screen (readonly)
136 COLOR_PAIR/reentrant
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
142 PC/global
143 SP/global
144 TABSIZE/screen (readonly)
145 UP/global
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)
165 baudrate/screen
166 beep/screen
167 bkgd/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)
176 box/window (stdscr)
177 box_set/window (stdscr)
178 can_change_color/terminal
179 cbreak/screen
180 chgat/window (stdscr)
181 clear/window (stdscr)
182 clearok/window
183 clrtobot/window (stdscr)
184 clrtoeol/window (stdscr)
185 color_content/screen
186 color_set/window (stdscr)
187 copywin/window locks(source, target)
188 cur_term/terminal
189 curs_set/screen
190 curscr/screen (readonly)
191 curses_version/global (readonly)
192 def_prog_mode/terminal
193 def_shell_mode/terminal
194 define_key/screen
195 del_curterm/screen
196 delay_output/screen
197 delch/window (stdscr)
198 deleteln/window (stdscr)
199 delscreen/global locks(screenlist, screen)
200 delwin/global locks(windowlist)
201 derwin/screen
202 doupdate/screen
203 dupwin/screen locks(window)
204 echo/screen
205 echo_wchar/window (stdscr)
206 echochar/window (stdscr)
207 endwin/screen
208 erase/window (stdscr)
209 erasechar/window (stdscr)
210 erasewchar/window (stdscr)
211 filter/global
212 flash/terminal
213 flushinp/screen
214 get_wch/screen (input-operation)
215 get_wstr/screen (input-operation)
216 getattrs/window
217 getbegx/window
218 getbegy/window
219 getbkgd/window
220 getbkgrnd/window
221 getcchar/reentrant
222 getch/screen (input-operation)
223 getcurx/window
224 getcury/window
225 getmaxx/window
226 getmaxy/window
227 getmouse/screen (input-operation)
228 getn_wstr/screen (input-operation)
229 getnstr/screen (input-operation)
230 getparx/window
231 getpary/window
232 getstr/screen (input-operation)
233 getwin/screen (input-operation)
234 halfdelay/screen
235 has_colors/terminal
236 has_ic/terminal
237 has_il/terminal
238 has_key/screen
239 hline/window (stdscr)
240 hline_set/window (stdscr)
241 idcok/window
242 idlok/window
243 immedok/window
244 in_wch/window (stdscr)
245 in_wchnstr/window (stdscr)
246 in_wchstr/window (stdscr)
247 inch/window (stdscr)
248 inchnstr/window (stdscr)
249 inchstr/window (stdscr)
250 init_color/screen
251 init_pair/screen
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)
264 intrflush/terminal
265 inwstr/window (stdscr)
266 is_cleared/window
267 is_idcok/window
268 is_idlok/window
269 is_immedok/window
270 is_keypad/window
271 is_leaveok/window
272 is_linetouched/window
273 is_nodelay/window
274 is_notimeout/window
275 is_scrollok/window
276 is_syncok/window
277 is_term_resized/terminal
278 is_wintouched/window
279 isendwin/screen
280 key_defined/screen
281 key_name/global (static data)
282 keybound/screen
283 keyname/global (static data)
284 keyok/screen
285 keypad/window
286 killchar/terminal
287 killwchar/terminal
288 leaveok/window
289 longname/screen
290 mcprint/terminal
291 meta/screen
292 mouse_trafo/window (stdscr)
293 mouseinterval/screen
294 mousemask/screen
295 move/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)
307 mvcur/screen
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)
335 mvscanw/screen
336 mvvline/window (stdscr)
337 mvvline_set/window (stdscr)
338 mvwadd_wch/window
339 mvwadd_wchnstr/window
340 mvwadd_wchstr/window
341 mvwaddch/window
342 mvwaddchnstr/window
343 mvwaddchstr/window
344 mvwaddnstr/window
345 mvwaddnwstr/window
346 mvwaddstr/window
347 mvwaddwstr/window
348 mvwchgat/window
349 mvwdelch/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)
356 mvwhline/window
357 mvwhline_set/window
358 mvwin/window
359 mvwin_wch/window
360 mvwin_wchnstr/window
361 mvwin_wchstr/window
362 mvwinch/window
363 mvwinchnstr/window
364 mvwinchstr/window
365 mvwinnstr/window
366 mvwinnwstr/window
367 mvwins_nwstr/window
368 mvwins_wch/window
369 mvwins_wstr/window
370 mvwinsch/window
371 mvwinsnstr/window
372 mvwinsstr/window
373 mvwinstr/window
374 mvwinwstr/window
375 mvwprintw/window
376 mvwscanw/screen
377 mvwvline/window
378 mvwvline_set/window
379 napms/reentrant
380 newpad/global locks(windowlist)
381 newscr/screen (readonly)
382 newterm/global locks(screenlist)
383 newwin/global locks(windowlist)
384 nl/screen
385 nocbreak/screen
386 nodelay/window
387 noecho/screen
388 nofilter/global
389 nonl/screen
390 noqiflush/terminal
391 noraw/screen
392 notimeout/window
393 numcodes/global (readonly)
394 numfnames/global (readonly)
395 numnames/global (readonly)
396 ospeed/global
397 overlay/window locks(source, target)
398 overwrite/window locks(source, target)
399 pair_content/screen
400 pecho_wchar/screen
401 pechochar/screen
402 pnoutrefresh/screen
403 prefresh/screen
404 printw/window
405 putp/global
406 putwin/window
407 qiflush/terminal
408 raw/screen
409 redrawwin/window
410 refresh/screen
411 reset_prog_mode/screen
412 reset_shell_mode/screen
413 resetty/terminal
414 resize_term/screen locks(windowlist)
415 resizeterm/screen
416 restartterm/screen
417 ripoffline/global (static data)
418 savetty/terminal
419 scanw/screen
420 scr_dump/screen
421 scr_init/screen
422 scr_restore/screen
423 scr_set/screen
424 scrl/window (stdscr)
425 scroll/window
426 scrollok/window
427 set_curterm/screen
428 set_escdelay/screen
429 set_tabsize/screen
430 set_term/global locks(screenlist, screen)
431 setcchar/reentrant
432 setscrreg/window (stdscr)
433 setupterm/global
434 slk_attr/screen
435 slk_attr_off/screen
436 slk_attr_on/screen
437 slk_attr_set/screen
438 slk_attroff/screen
439 slk_attron/screen
440 slk_attrset/screen
441 slk_clear/screen
442 slk_color/screen
443 slk_init/screen
444 slk_label/screen
445 slk_noutrefresh/screen
446 slk_refresh/screen
447 slk_restore/screen
448 slk_set/screen
449 slk_touch/screen
450 slk_wset/screen
451 standend/window
452 standout/window
453 start_color/screen
454 stdscr/screen (readonly)
455 strcodes/global (readonly)
456 strfnames/global (readonly)
457 strnames/global (readonly)
458 subpad/window
459 subwin/window
460 syncok/window
461 term_attrs/screen
462 termattrs/screen
463 termname/terminal
464 tgetent/global
465 tgetflag/global
466 tgetnum/global
467 tgetstr/global
468 tgoto/global
469 tigetflag/terminal
470 tigetnum/terminal
471 tigetstr/terminal
472 timeout/window (stdscr)
473 touchline/window
474 touchwin/window
475 tparm/global (static data)
476 tputs/screen
477 trace/global (static data)
478 ttytype/screen (readonly)
479 typeahead/screen
480 unctrl/screen
481 unget_wch/screen (input-operation)
482 ungetch/screen (input-operation)
483 ungetmouse/screen (input-operation)
484 untouchwin/window
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)
491 vid_attr/screen
492 vid_puts/screen
493 vidattr/screen
494 vidputs/screen
495 vline/window (stdscr)
496 vline_set/window (stdscr)
497 vw_printw/window
498 vw_scanw/screen
499 vwprintw/window
500 vwscanw/screen
501 wadd_wch/window
502 wadd_wchnstr/window
503 wadd_wchstr/window
504 waddch/window
505 waddchnstr/window
506 waddchstr/window
507 waddnstr/window
508 waddnwstr/window
509 waddstr/window
510 waddwstr/window
511 wattr_get/window
512 wattr_off/window
513 wattr_on/window
514 wattr_set/window
515 wattroff/window
516 wattron/window
517 wattrset/window
518 wbkgd/window
519 wbkgdset/window
520 wbkgrnd/window
521 wbkgrndset/window
522 wborder/window
523 wborder_set/window
524 wchgat/window
525 wclear/window
526 wclrtobot/window
527 wclrtoeol/window
528 wcolor_set/window
529 wcursyncup/screen (affects window plus parents)
530 wdelch/window
531 wdeleteln/window
532 wecho_wchar/window
533 wechochar/window
534 wenclose/window
535 werase/window
536 wget_wch/screen (input-operation)
537 wget_wstr/screen (input-operation)
538 wgetbkgrnd/window
539 wgetch/screen (input-operation)
540 wgetn_wstr/screen (input-operation)
541 wgetnstr/screen (input-operation)
542 wgetparent/window
543 wgetscrreg/window
544 wgetstr/screen (input-operation)
545 whline/window
546 whline_set/window
547 win_wch/window
548 win_wchnstr/window
549 win_wchstr/window
550 winch/window
551 winchnstr/window
552 winchstr/window
553 winnstr/window
554 winnwstr/window
555 wins_nwstr/window
556 wins_wch/window
557 wins_wstr/window
558 winsch/window
559 winsdelln/window
560 winsertln/window
561 winsnstr/window
562 winsstr/window
563 winstr/window
564 winwstr/window
565 wmouse_trafo/window
566 wmove/window
567 wnoutrefresh/screen
568 wprintw/window
569 wredrawln/window
570 wrefresh/screen
571 wresize/window locks(windowlist)
572 wscanw/screen
573 wscrl/window
574 wsetscrreg/window
575 wstandend/window
576 wstandout/window
577 wsyncdown/screen (affects window plus parents)
578 wsyncup/screen (affects window plus parents)
579 wtimeout/window
580 wtouchln/window
581 wunctrl/global (static data)
582 wvline/window
583 wvline_set/window
584 .TE
585 .\" ***************************************************************************
586 .SH RETURN VALUE
587 These functions all return TRUE or FALSE, except as noted.
588 .SH NOTES
589 Both a macro and a function are provided for each name.
590 .SH PORTABILITY
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.
595 .SH SEE ALSO
596 \fBcurses\fR(3X),
597 \fBcurs_opaque\fR(3X)
598 .\"#
599 .\"# The following sets edit modes for GNU EMACS
600 .\"# Local Variables:
601 .\"# mode:nroff
602 .\"# fill-column:79
603 .\"# End: