curs_threads.3x.html 27 KB

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