blob: 17dabdb7b40a560971884e8bc1c45c7c6301d498 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301.\"***************************************************************************
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
53This implementation can be configured to provide rudimentary support
54for multi-threaded applications.
55This makes a different set of libraries, e.g., \fIlibncursest\fP since
56the binary interfaces are different.
57.PP
58Rather than modify the interfaces to pass a thread specifier to
59each function, it adds a few functions which can be used in any
60configuration which hide the mutex's needed to prevent concurrent
61use of the global variables when configured for threading.
62.PP
63In addition to forcing access to members of the \fBWINDOW\fP structure
64to be via functions (see \fBcurs_opaque\fP(3x)),
65it makes functions of the common global variables,
66e.g.,
67COLORS,
68COLOR_PAIRS,
69COLS,
70ESCDELAY,
71LINES,
72TABSIZE
73curscr,
74newscr and
75ttytype.
76Those variables are maintained as read-only values, stored in the \fBSCREEN\fP
77structure.
78.PP
79Even this is not enough to make a thread-safe application using curses.
80A multi-threaded application would be expected to have threads updating
81separate windows (within the same device),
82or updating on separate screens (on different devices).
83Also, a few of the global variables are considered writable by some
84applications.
85The functions described here address these special situations.
86.PP
87The ESCDELAY and TABSIZE global variables are modified by some applications.
88To modify them in any configuration,
89use the \fBset_escdelay\fP or \fBset_tabsize\fP functions.
90Other global variables are not modifiable.
91.PP
92The \fBuse_window\fP and \fBuse_screen\fP functions provide coarse
93granularity mutexes for their respective \fBWINDOW\fP and \fBSCREEN\fP
94parameters, and call a user-supplied function,
95passing it a \fIdata\fP parameter,
96and returning the value from the user-supplied function to the application.
97.\" ***************************************************************************
98.SS USAGE
99All of the ncurses library functions assume that the locale is not
100altered during operation.
101In addition,
102they use data which is maintained within a hierarchy of scopes.
103.RS
104.TP 3
105-
106global data, e.g., used in the low-level terminfo or termcap interfaces.
107.TP 3
108-
109terminal data, e.g., associated with a call to \fIset_curterm\fP.
110The terminal data are initialized when screens are created.
111.TP 3
112-
113screen data, e.g., associated with a call to \fInewterm\fP or \fIinitscr\fP.
114.TP 3
115-
116window data, e.g., associated with a call to \fInewwin\fP or \fIsubwin\fP.
117Windows are associated with screens.
118Pads are not necessarily associated with a particular screen.
119.IP
120Most curses applications operate on one or more windows within a single screen.
121.TP 3
122-
123reentrant, i.e., it uses only the data passed as parameters.
124.RE
125.PP
126This table lists the scope of data used for each symbol in the
127ncurses library when it is configured to support threading:
128.TS
129center tab(/);
130l l
131l l .
132Symbol/Scope
133=
134BC/global
135COLORS/screen (readonly)
136COLOR_PAIR/reentrant
137COLOR_PAIRS/screen (readonly)
138COLS/screen (readonly)
139ESCDELAY/screen (readonly, see \fIset_escdelay\fP)
140LINES/screen (readonly)
141PAIR_NUMBER/reentrant
142PC/global
143SP/global
144TABSIZE/screen (readonly)
145UP/global
146acs_map/screen (readonly)
147add_wch/window (stdscr)
148add_wchnstr/window (stdscr)
149add_wchstr/window (stdscr)
150addch/window (stdscr)
151addchnstr/window (stdscr)
152addchstr/window (stdscr)
153addnstr/window (stdscr)
154addnwstr/window (stdscr)
155addstr/window (stdscr)
156addwstr/window (stdscr)
157assume_default_colors/screen
158attr_get/window (stdscr)
159attr_off/window (stdscr)
160attr_on/window (stdscr)
161attr_set/window (stdscr)
162attroff/window (stdscr)
163attron/window (stdscr)
164attrset/window (stdscr)
165baudrate/screen
166beep/screen
167bkgd/window (stdscr)
168bkgdset/window (stdscr)
169bkgrnd/window (stdscr)
170bkgrndset/window (stdscr)
171boolcodes/global (readonly)
172boolfnames/global (readonly)
173boolnames/global (readonly)
174border/window (stdscr)
175border_set/window (stdscr)
176box/window (stdscr)
177box_set/window (stdscr)
178can_change_color/terminal
179cbreak/screen
180chgat/window (stdscr)
181clear/window (stdscr)
182clearok/window
183clrtobot/window (stdscr)
184clrtoeol/window (stdscr)
185color_content/screen
186color_set/window (stdscr)
187copywin/window locks(source, target)
188cur_term/terminal
189curs_set/screen
190curscr/screen (readonly)
191curses_version/global (readonly)
192def_prog_mode/terminal
193def_shell_mode/terminal
194define_key/screen
195del_curterm/screen
196delay_output/screen
197delch/window (stdscr)
198deleteln/window (stdscr)
199delscreen/global locks(screenlist, screen)
200delwin/global locks(windowlist)
201derwin/screen
202doupdate/screen
203dupwin/screen locks(window)
204echo/screen
205echo_wchar/window (stdscr)
206echochar/window (stdscr)
207endwin/screen
208erase/window (stdscr)
209erasechar/window (stdscr)
210erasewchar/window (stdscr)
211filter/global
212flash/terminal
213flushinp/screen
214get_wch/screen (input-operation)
215get_wstr/screen (input-operation)
216getattrs/window
217getbegx/window
218getbegy/window
219getbkgd/window
220getbkgrnd/window
221getcchar/reentrant
222getch/screen (input-operation)
223getcurx/window
224getcury/window
225getmaxx/window
226getmaxy/window
227getmouse/screen (input-operation)
228getn_wstr/screen (input-operation)
229getnstr/screen (input-operation)
230getparx/window
231getpary/window
232getstr/screen (input-operation)
233getwin/screen (input-operation)
234halfdelay/screen
235has_colors/terminal
236has_ic/terminal
237has_il/terminal
238has_key/screen
239hline/window (stdscr)
240hline_set/window (stdscr)
241idcok/window
242idlok/window
243immedok/window
244in_wch/window (stdscr)
245in_wchnstr/window (stdscr)
246in_wchstr/window (stdscr)
247inch/window (stdscr)
248inchnstr/window (stdscr)
249inchstr/window (stdscr)
250init_color/screen
251init_pair/screen
252initscr/global locks(screenlist)
253innstr/window (stdscr)
254innwstr/window (stdscr)
255ins_nwstr/window (stdscr)
256ins_wch/window (stdscr)
257ins_wstr/window (stdscr)
258insch/window (stdscr)
259insdelln/window (stdscr)
260insertln/window (stdscr)
261insnstr/window (stdscr)
262insstr/window (stdscr)
263instr/window (stdscr)
264intrflush/terminal
265inwstr/window (stdscr)
266is_cleared/window
267is_idcok/window
268is_idlok/window
269is_immedok/window
270is_keypad/window
271is_leaveok/window
272is_linetouched/window
273is_nodelay/window
274is_notimeout/window
275is_scrollok/window
276is_syncok/window
277is_term_resized/terminal
278is_wintouched/window
279isendwin/screen
280key_defined/screen
281key_name/global (static data)
282keybound/screen
283keyname/global (static data)
284keyok/screen
285keypad/window
286killchar/terminal
287killwchar/terminal
288leaveok/window
289longname/screen
290mcprint/terminal
291meta/screen
292mouse_trafo/window (stdscr)
293mouseinterval/screen
294mousemask/screen
295move/window (stdscr)
296mvadd_wch/window (stdscr)
297mvadd_wchnstr/window (stdscr)
298mvadd_wchstr/window (stdscr)
299mvaddch/window (stdscr)
300mvaddchnstr/window (stdscr)
301mvaddchstr/window (stdscr)
302mvaddnstr/window (stdscr)
303mvaddnwstr/window (stdscr)
304mvaddstr/window (stdscr)
305mvaddwstr/window (stdscr)
306mvchgat/window (stdscr)
307mvcur/screen
308mvdelch/window (stdscr)
309mvderwin/window (stdscr)
310mvget_wch/screen (input-operation)
311mvget_wstr/screen (input-operation)
312mvgetch/screen (input-operation)
313mvgetn_wstr/screen (input-operation)
314mvgetnstr/screen (input-operation)
315mvgetstr/screen (input-operation)
316mvhline/window (stdscr)
317mvhline_set/window (stdscr)
318mvin_wch/window (stdscr)
319mvin_wchnstr/window (stdscr)
320mvin_wchstr/window (stdscr)
321mvinch/window (stdscr)
322mvinchnstr/window (stdscr)
323mvinchstr/window (stdscr)
324mvinnstr/window (stdscr)
325mvinnwstr/window (stdscr)
326mvins_nwstr/window (stdscr)
327mvins_wch/window (stdscr)
328mvins_wstr/window (stdscr)
329mvinsch/window (stdscr)
330mvinsnstr/window (stdscr)
331mvinsstr/window (stdscr)
332mvinstr/window (stdscr)
333mvinwstr/window (stdscr)
334mvprintw/window (stdscr)
335mvscanw/screen
336mvvline/window (stdscr)
337mvvline_set/window (stdscr)
338mvwadd_wch/window
339mvwadd_wchnstr/window
340mvwadd_wchstr/window
341mvwaddch/window
342mvwaddchnstr/window
343mvwaddchstr/window
344mvwaddnstr/window
345mvwaddnwstr/window
346mvwaddstr/window
347mvwaddwstr/window
348mvwchgat/window
349mvwdelch/window
350mvwget_wch/screen (input-operation)
351mvwget_wstr/screen (input-operation)
352mvwgetch/screen (input-operation)
353mvwgetn_wstr/screen (input-operation)
354mvwgetnstr/screen (input-operation)
355mvwgetstr/screen (input-operation)
356mvwhline/window
357mvwhline_set/window
358mvwin/window
359mvwin_wch/window
360mvwin_wchnstr/window
361mvwin_wchstr/window
362mvwinch/window
363mvwinchnstr/window
364mvwinchstr/window
365mvwinnstr/window
366mvwinnwstr/window
367mvwins_nwstr/window
368mvwins_wch/window
369mvwins_wstr/window
370mvwinsch/window
371mvwinsnstr/window
372mvwinsstr/window
373mvwinstr/window
374mvwinwstr/window
375mvwprintw/window
376mvwscanw/screen
377mvwvline/window
378mvwvline_set/window
379napms/reentrant
380newpad/global locks(windowlist)
381newscr/screen (readonly)
382newterm/global locks(screenlist)
383newwin/global locks(windowlist)
384nl/screen
385nocbreak/screen
386nodelay/window
387noecho/screen
388nofilter/global
389nonl/screen
390noqiflush/terminal
391noraw/screen
392notimeout/window
393numcodes/global (readonly)
394numfnames/global (readonly)
395numnames/global (readonly)
396ospeed/global
397overlay/window locks(source, target)
398overwrite/window locks(source, target)
399pair_content/screen
400pecho_wchar/screen
401pechochar/screen
402pnoutrefresh/screen
403prefresh/screen
404printw/window
405putp/global
406putwin/window
407qiflush/terminal
408raw/screen
409redrawwin/window
410refresh/screen
411reset_prog_mode/screen
412reset_shell_mode/screen
413resetty/terminal
414resize_term/screen locks(windowlist)
415resizeterm/screen
416restartterm/screen
417ripoffline/global (static data)
418savetty/terminal
419scanw/screen
420scr_dump/screen
421scr_init/screen
422scr_restore/screen
423scr_set/screen
424scrl/window (stdscr)
425scroll/window
426scrollok/window
427set_curterm/screen
428set_escdelay/screen
429set_tabsize/screen
430set_term/global locks(screenlist, screen)
431setcchar/reentrant
432setscrreg/window (stdscr)
433setupterm/global
434slk_attr/screen
435slk_attr_off/screen
436slk_attr_on/screen
437slk_attr_set/screen
438slk_attroff/screen
439slk_attron/screen
440slk_attrset/screen
441slk_clear/screen
442slk_color/screen
443slk_init/screen
444slk_label/screen
445slk_noutrefresh/screen
446slk_refresh/screen
447slk_restore/screen
448slk_set/screen
449slk_touch/screen
450slk_wset/screen
451standend/window
452standout/window
453start_color/screen
454stdscr/screen (readonly)
455strcodes/global (readonly)
456strfnames/global (readonly)
457strnames/global (readonly)
458subpad/window
459subwin/window
460syncok/window
461term_attrs/screen
462termattrs/screen
463termname/terminal
464tgetent/global
465tgetflag/global
466tgetnum/global
467tgetstr/global
468tgoto/global
469tigetflag/terminal
470tigetnum/terminal
471tigetstr/terminal
472timeout/window (stdscr)
473touchline/window
474touchwin/window
475tparm/global (static data)
476tputs/screen
477trace/global (static data)
478ttytype/screen (readonly)
479typeahead/screen
480unctrl/screen
481unget_wch/screen (input-operation)
482ungetch/screen (input-operation)
483ungetmouse/screen (input-operation)
484untouchwin/window
485use_default_colors/screen
486use_env/global (static data)
487use_extended_names/global (static data)
488use_legacy_coding/screen
489use_screen/global locks(screenlist, screen)
490use_window/global locks(windowlist, window)
491vid_attr/screen
492vid_puts/screen
493vidattr/screen
494vidputs/screen
495vline/window (stdscr)
496vline_set/window (stdscr)
497vw_printw/window
498vw_scanw/screen
499vwprintw/window
500vwscanw/screen
501wadd_wch/window
502wadd_wchnstr/window
503wadd_wchstr/window
504waddch/window
505waddchnstr/window
506waddchstr/window
507waddnstr/window
508waddnwstr/window
509waddstr/window
510waddwstr/window
511wattr_get/window
512wattr_off/window
513wattr_on/window
514wattr_set/window
515wattroff/window
516wattron/window
517wattrset/window
518wbkgd/window
519wbkgdset/window
520wbkgrnd/window
521wbkgrndset/window
522wborder/window
523wborder_set/window
524wchgat/window
525wclear/window
526wclrtobot/window
527wclrtoeol/window
528wcolor_set/window
529wcursyncup/screen (affects window plus parents)
530wdelch/window
531wdeleteln/window
532wecho_wchar/window
533wechochar/window
534wenclose/window
535werase/window
536wget_wch/screen (input-operation)
537wget_wstr/screen (input-operation)
538wgetbkgrnd/window
539wgetch/screen (input-operation)
540wgetn_wstr/screen (input-operation)
541wgetnstr/screen (input-operation)
542wgetparent/window
543wgetscrreg/window
544wgetstr/screen (input-operation)
545whline/window
546whline_set/window
547win_wch/window
548win_wchnstr/window
549win_wchstr/window
550winch/window
551winchnstr/window
552winchstr/window
553winnstr/window
554winnwstr/window
555wins_nwstr/window
556wins_wch/window
557wins_wstr/window
558winsch/window
559winsdelln/window
560winsertln/window
561winsnstr/window
562winsstr/window
563winstr/window
564winwstr/window
565wmouse_trafo/window
566wmove/window
567wnoutrefresh/screen
568wprintw/window
569wredrawln/window
570wrefresh/screen
571wresize/window locks(windowlist)
572wscanw/screen
573wscrl/window
574wsetscrreg/window
575wstandend/window
576wstandout/window
577wsyncdown/screen (affects window plus parents)
578wsyncup/screen (affects window plus parents)
579wtimeout/window
580wtouchln/window
581wunctrl/global (static data)
582wvline/window
583wvline_set/window
584.TE
585.\" ***************************************************************************
586.SH RETURN VALUE
587These functions all return TRUE or FALSE, except as noted.
588.SH NOTES
589Both a macro and a function are provided for each name.
590.SH PORTABILITY
591These routines are specific to ncurses.
592They were not supported on Version 7, BSD or System V implementations.
593It is recommended that any code depending on ncurses extensions
594be 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: