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