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