home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume1 / pcurses / part02 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  46.1 KB

  1. Subject:  Terminfo/Curses Part 2 of 11
  2.  
  3. : Run this shell script with "sh" not "csh"
  4. PATH=:/bin:/usr/bin:/usr/ucb
  5. export PATH
  6. if test ! -d =doc
  7. then
  8.     echo 'Making directory "=doc"'
  9.     mkdir =doc
  10. fi
  11. echo 'x - =doc/manual.tbl.ms'
  12. sed 's/^X//' <<'//go.sysin dd *' >=doc/manual.tbl.ms
  13. X.po +.5i
  14. X.TL
  15. The Curses Reference Manual
  16. X.AU
  17. Pavel Curtis
  18. X.NH
  19. Introduction
  20. X.LP
  21. Terminfo is a database describing many capabilities of over 150
  22. different terminals.  Curses is a subroutine package which
  23. presents a high level screen model to the programmer, while
  24. dealing with issues such as terminal differences and optimization of
  25. output to change one screenfull of text into another.
  26. X.LP
  27. Terminfo is based on Berkeley's termcap database, but contains a
  28. number of improvements and extensions.  Parameterized strings are
  29. introduced, making it possible to describe such capabilities as
  30. video attributes, and to handle far more unusual terminals than
  31. possible with termcap.
  32. X.LP
  33. Curses is also based on Berkeley's curses package, with many
  34. improvements.  The package makes use of the insert and delete
  35. line and character features of terminals so equipped, and
  36. determines how to optimally use these features with no help from the
  37. programmer.  It allows arbitrary combinations of video attributes
  38. to be displayed, even on terminals that leave ``magic cookies''
  39. on the screen to mark changes in attributes.
  40. X.NH
  41. An Overview of the Package
  42. X.NH 2
  43. Terminology
  44. X.PP
  45. In this document,
  46. the following terminology is kept to with reasonable consistency:
  47. X.IP \fIwindow\fP 10
  48. An internal representation
  49. containing an image of what a section of the terminal screen may look like
  50. at some point in time.
  51. This subsection can either encompass the entire terminal screen,
  52. or any smaller portion down to a single character within that screen.
  53. X.IP \fIterminal\fP 10
  54. Sometimes called \fIterminal screen\fP.
  55. The package's idea of what the terminal's screen currently looks like,
  56. i.e., what the user sees now.
  57. This is a special \fIscreen\fP:
  58. X.IP \fIscreen\fP 10
  59. This is a subset of windows which are as large as the terminal screen,
  60. i.e., they start at the upper left hand corner
  61. and encompass the lower right hand corner.
  62. One of these, \fIstdscr\fP,
  63. is automatically provided for the programmer.
  64. X.NH 2
  65. Compiling Programs using the Package
  66. X.PP
  67. In order to use the library,
  68. it is necessary to have certain types and variables defined.
  69. Therefore, the programmer must have a line:
  70. X.DS
  71. X.B "#include <ncurses.h>"
  72. X.DE
  73. at the top of the program source.
  74. The header file
  75. X.B <ncurses.h>
  76. needs to include
  77. X.B <sgtty.h> ,
  78. so the one should not do so oneself.\u*\d
  79. X.FS
  80. \u*\dThe screen package also uses the Standard I/O library,
  81. so \fB<ncurses.h>\fP includes \fB<stdio.h>\fP.
  82. It is redundant (but harmless) for the programmer to do it, too.
  83. X.FE
  84. Also,
  85. compilations should have the following form:
  86. X.DS
  87. \fBcc\fR [ \fIflags\fR ] file ... \fB\-lbcurses\fR
  88. X.DE
  89. X.NH 2
  90. Updating the Screen
  91. X.PP
  92. In order to update the screen optimally,
  93. it is necessary for the routines to know what the screen currently looks like
  94. and what the programmer wants it to look like next.
  95. XFor this purpose, a data type (structure) named \fIWINDOW\fP
  96. is defined which describes a window image to the routines,
  97. including its starting position on the screen
  98. (the (y, x) coordinates of the upper left hand corner)
  99. and its size.
  100. One of these (called \fIcurscr\fP, for \fIcurrent screen\fP)
  101. is a screen image of what the terminal currently looks like.
  102. Another screen (called \fIstdscr\fP, for \fIstandard screen\fP)
  103. is provided by default to make changes on.
  104. X.PP
  105. A window is a purely internal representation.
  106. It is used to build and store
  107. a potential image of a portion of the terminal.
  108. It doesn't bear any necessary relation
  109. to what is really on the terminal screen.
  110. It is more like an array of characters on which to make changes.
  111. X.PP
  112. When one has a window which describes
  113. what some part of the terminal screen should look like,
  114. the routine \fIrefresh()\fP (or \fIwrefresh()\fP if the window is not
  115. \fIstdscr\fP) is called.
  116. \fIRefresh()\fP in the area covered by the window,
  117. look like that window.
  118. Note, therefore, that changing something on a window
  119. \fIdoes not change the terminal\fP.
  120. Actual updates to the terminal screen are made only by calling
  121. \fIrefresh()\fP or \fIwrefresh()\fP.
  122. This allows the programmer to maintain several different ideas
  123. of what a portion of the terminal screen should look like.
  124. Also, changes can be made to windows in any order,
  125. without regard to motion efficiency.
  126. Then, at will, the programmer can effectively say
  127. ``make it look like this,''
  128. and let the package worry about the best way to do this.
  129. X.NH 2
  130. Naming Conventions
  131. X.PP
  132. As hinted above, the routines can use several windows,
  133. but two are automatically given:
  134. \fIcurscr\fP, which knows what the terminal looks like,
  135. and \fIstdscr\fP,
  136. which is what the programmer wants the terminal to look like next.
  137. The user should never really access \fIcurscr\fP directly.
  138. Changes should be made to the appropriate screen,
  139. and then the routine \fIrefresh()\fP (or \fIwrefresh()\fP)
  140. should be called.
  141. X.PP
  142. Many functions are set up to deal with \fIstdscr\fP as a default screen.
  143. XFor example, to add a character to \fIstdscr\fP,
  144. one calls \fIaddch()\fP with the desired character.
  145. If a different window is to be used, the routine \fIwaddch()\fP
  146. (for `w'indow-specific \fIaddch()\fP) is provided.\u*\d
  147. X.FS
  148. \u*\dActually, \fIaddch()\fP is really a ``#define'' macro with arguments,
  149. as are most of the ``functions'' which deal with \fIstdscr\fP
  150. as a default.
  151. X.FE
  152. This convention of prepending function names with a ``w''
  153. when they are to be applied to specific windows is consistent.
  154. The only routines which do \fInot\fP do this are those
  155. to which a window must always be specified.
  156. X.PP
  157. In order to move the current (y, x) coordinates from one point to another,
  158. the routines \fImove()\fP and \fIwmove()\fP are provided.
  159. However, it is often desirable to first move and then perform some I/O
  160. operation.
  161. In order to avoid clumsyness, most I/O routines can be preceded by the prefix
  162. ``mv'' and the desired (y, x) coordinates then can be added to the arguments
  163. to the function.
  164. XFor example, the calls
  165. X.DS
  166. move(y, x);
  167. addch(ch);
  168. X.DE
  169. can be replaced by
  170. X.DS
  171. mvaddch(y, x, ch);
  172. X.DE
  173. and
  174. X.DS
  175. wmove(win, y, x);
  176. waddch(win, ch);
  177. X.DE
  178. can be replaced by
  179. X.DS
  180. mvwaddch(win, y, x, ch);
  181. X.DE
  182. Note that the window description pointer (\fIwin\fP)
  183. comes before the added (y, x) coordinates.
  184. If such pointers are need, they are always the first parameters passed.
  185. X.NH 1
  186. Variables
  187. X.PP
  188. Many variables which are used to describe the terminal environment
  189. are available to the programmer. They are:
  190. X.TS
  191. expand;
  192. lw(6m) lw(8n) lw(50n).
  193. type    name    description
  194. _
  195. WINDOW *    curscr    T{
  196. X.fi
  197. current version of the screen (terminal screen).
  198. T}
  199. WINDOW *    stdscr    T{
  200. standard screen.  Most updates are usually done here.
  201. T}
  202. int    LINES    T{
  203. number of lines on the terminal
  204. T}
  205. int    COLS    T{
  206. number of columns on the terminal
  207. T}
  208. int    ERR    T{
  209. error flag returned by routines on a fail.
  210. T}
  211. int    OK    T{
  212. error flag returned by routines when things go right.
  213. T}
  214. X.TE
  215. X.LP
  216. There are also several ``#define'' constants and types
  217. which are of general usefulness:
  218. X.ta 11n
  219. X.DS L
  220. bool        boolean type, actually a ``char'' (e.g., \fIbool doneit;\fR\|)
  221. TRUE        boolean ``true'' flag (1).
  222. XFALSE        boolean ``false'' flag (0).
  223. X.DE
  224. X.NH 1
  225. Usage
  226. X.PP
  227. This is a description of how to actually use the screen package.
  228. In it, we assume all updating, reading, etc. is applied to
  229. \fIstdscr\fP.
  230. All instructions will work on any window,
  231. with changing the function name and parameters as mentioned above.
  232. X.NH 2
  233. Starting up
  234. X.PP
  235. In order to use the screen package,
  236. the routines must know about terminal characteristics, and the space for
  237. \fIcurscr\fP and \fIstdscr\fP must be allocated.
  238. These functions are performed by \fIinitscr()\fP.
  239. Since it must allocate space for the windows,
  240. it can overflow core when attempting to do so.
  241. On this rather rare occasion, \fIinitscr()\fP
  242. returns ERR.
  243. \fIinitscr()\fP must \fIalways\fP
  244. be called before any of the routines which affect windows are used.
  245. If it is not, the program will core dump as soon as either
  246. \fIcurscr\fP or \fIstdscr\fP are referenced.
  247. However, it is usually best to wait to call it
  248. until after you are sure you will need it,
  249. like after checking for startup errors.
  250. Terminal status changing routines like \fInl()\fP and \fIcbreak()\fP
  251. should be called after \fIinitscr()\fP.
  252. X.PP
  253. Now that the screen windows have been allocated,
  254. you can set them up for the run.
  255. If you want to, say, allow the window to scroll, use \fIscrollok()\fP.
  256. If you want the cursor to be left after the last change, use
  257. \fIleaveok()\fP.
  258. If this isn't done, \fIrefresh()\fP
  259. will move the cursor to the window's current (y, x) coordinates
  260. after updating it.
  261. New windows of your own can be created, too, by using the functions
  262. \fInewwin()\fP and \fIsubwin()\fP.
  263. \fIdelwin()\fP will allow you to get rid of old windows.
  264. X.NH 2
  265. Output
  266. X.PP
  267. Now that we have set things up, we will want to actually update the terminal.
  268. The basic functions used to change what will go on a window are \fIaddch()\fP
  269. and \fImove()\fP.
  270. \fIaddch()\fP adds a character at the current (y, x) coordinates,
  271. returning ERR if it would cause the window to illegally scroll,
  272. i.e., printing a character in the lower right-hand corner
  273. of a terminal which automatically scrolls if scrolling is not allowed.
  274. \fImove()\fP changes the current (y, x) coordinates to whatever you want
  275. them to be.
  276. It returns ERR if you try to move off the window.
  277. As mentioned above, you can combine the two into \fImvaddch()\fP
  278. to do both things at once.
  279. X.PP
  280. The other output functions, such as \fIaddstr()\fP
  281. and \fIprintw()\fP, all call \fIaddch()\fP to add characters to the window.
  282. X.PP
  283. After you have put on the window what you want there,
  284. when you want the portion of the terminal covered by the window
  285. to be made to look like it, you must call \fIrefresh()\fP.
  286. In order to optimize finding changes, \fIrefresh()\fP
  287. assumes that any part of the window not changed since the last
  288. \fIrefresh()\fP of that window has not been changed on the terminal, i.e.,
  289. that you have not refreshed a portion of the terminal
  290. with an overlapping window.
  291. If this is not the case, the routine \fItouchwin()\fP
  292. is provided to make it look like the entire window has been changed,
  293. thus making \fIrefresh()\fP check the whole subsection of the terminal for
  294. changes.
  295. X.PP
  296. If you call \fIwrefresh()\fP with \fIcurscr()\fP,
  297. it will make the screen look like \fIcurscr\fP thinks it looks like.
  298. This is useful for implementing a command
  299. which would redraw the screen in case it get messed up.
  300. X.NH 2
  301. Input
  302. X.PP
  303. Input is essentially a mirror image of output.
  304. The complementary function to \fIaddch()\fP is \fIgetch()\fP which,
  305. if echo is set, will call \fIaddch()\fP to echo the character.
  306. Since the screen package needs to know what is on the terminal at all times,
  307. if characters are to be echoed, the tty must be in raw or cbreak mode.
  308. If it is not, \fIgetch()\fP sets it to be cbreak, reads in the character,
  309. and then sets it back the way it was.
  310. X.NH 2
  311. Miscellaneous
  312. X.PP
  313. A plethora of other functions exist for maintaining and changing information
  314. about the windows.
  315. XFor the most part, the descriptions in section 5 should suffice.
  316. X.NH 2
  317. XFinishing Up
  318. X.PP
  319. In order to do certain optimizations, and, on some terminals,
  320. to work at all, some things must be done before the screen routines start up.
  321. In order to clean up after the routines, the routine \fIendwin()\fP
  322. is provided.
  323. It restores tty modes to what they were when \fIinitscr()\fP
  324. was first called, moves the cursor down to the lower-left corner, etc.
  325. Thus, anytime after the call to initscr, \fIendwin()\fP
  326. should be called before exiting.
  327. X.NH
  328. Descriptions of the Functions
  329. X.de Lp
  330. X.sp
  331. X.LP
  332. X..
  333. X.LP
  334. This section describes all the functions available to the
  335. programmer in the curses package.  For an alphabetical list, see the
  336. manual page \fIncurses\fP(3).
  337. X.NH 2
  338. Initialization
  339. X.LP
  340. These functions are called when initializing a program.
  341. X.Lp
  342. \fBinitscr\fP()
  343. X.br
  344. The first function called should always be \fBinitscr\fP.  This will
  345. determine the terminal type and initialize curses data
  346. structures.  \fBinitscr\fP also arranges that the first
  347. call to \fBrefresh\fP will clear the screen.
  348. X.Lp
  349. \fBendwin\fP()
  350. X.br
  351. A program should always call \fBendwin\fP before exiting.  This
  352. function will restore tty modes, move the cursor to the lower left
  353. corner of the screen, reset the terminal into the proper
  354. nonvisual mode.
  355. X.Lp
  356. \fBnewterm\fP(type, fp)
  357. X.br
  358. A program which outputs to more than one terminal should use
  359. \fBnewterm\fP instead of \fBinitscr\fP.  \fBnewterm\fP should be called once for
  360. each terminal.  It returns a variable of type \fBstruct\fP \fBscreen\fP \fB*\fP
  361. which should be saved as a reference to that terminal.  The
  362. arguments are the type of the terminal (a string) and a stdio FILE
  363. pointer for output to the terminal.  The FILE pointer
  364. should be open for both reading and writing, if input from the
  365. terminal is desired.
  366. The program should also call \fBendwin\fP for each terminal being used.
  367. X.Lp
  368. \fBset_term\fP(new)
  369. X.br
  370. This function is used to switch to a different terminal.  The
  371. screen reference for the new terminal is passed as the parameter.
  372. The previous terminal is returned by the function.  All other
  373. calls affect only the current terminal.
  374. X.Lp
  375. \fBlongname\fP()
  376. X.br
  377. This function returns a pointer to a static area containing a
  378. verbose description of the current terminal.  It is defined only
  379. after a call to \fBinitscr\fP or \fBnewterm\fP.
  380. X.NH 2
  381. Option Setting
  382. X.LP
  383. These functions set options within curses.  In each case, \fIwin\fP is
  384. the window affected, and \fIbf\fP is a boolean flag with value \fBTRUE\fP or
  385. \fBFALSE\fP indicating whether to enable or disable the option.  All
  386. options are initially \fBFALSE.\fP  It is not necessary to turn these
  387. options off before calling \fBendwin\fP.
  388. X.Lp
  389. \fBclearok\fP(win,bf)
  390. X.br
  391. If set, the next call to \fBwrefresh\fP with this window will clear the
  392. screen and redraw the entire screen.  If \fIwin\fP is \fBcurscr\fP, the next
  393. call to \fIwrefresh\fP with any window will cause the screen to be
  394. cleared.  This is useful when the contents of the screen are
  395. uncertain, or in some cases for a more pleasing visual effect.
  396. X.Lp
  397. \fBidlok\fP(win,bf)
  398. X.br
  399. If enabled, curses will consider using the hardware insert/delete
  400. line feature of terminals so equipped.  If disabled, curses will
  401. never use this feature.  The insert/delete character feature is
  402. always considered.  Enable this option only if your application
  403. needs insert/delete line, for example, for a screen editor.  It
  404. is disabled by default because insert/delete line is visually
  405. annoying when used in applications where it isn't really needed.
  406. X.Lp
  407. \fBkeypad\fP(win,bf)
  408. X.br
  409. This option enables the keypad of the users terminal.  If
  410. enabled, the user can press a function key (such as an arrow key)
  411. and \fBgetch\fP will return a single value representing the function
  412. key.  If disabled, curses will not treat function keys specially.
  413. If the keypad in the terminal can be turned on (made to transmit)
  414. and off (made to work locally), turning on this option will turn
  415. on the terminal keypad.
  416. X.Lp
  417. \fBleaveok\fP(win,bf)
  418. X.br
  419. Normally, the hardware cursor is left at the location of the
  420. window cursor being refreshed.  This option allows the cursor to be
  421. left wherever the update happens to leave it.  It is useful for
  422. applications where the cursor is not used, since it saves cursor
  423. motions.  If possible, the cursor is made invisible when this
  424. option is enabled.
  425. X.Lp
  426. \fBmeta\fP(win,bf)
  427. X.br
  428. If enabled, characters returned by \fBgetch\fP are transmitted with all
  429. 8 bits, instead of stripping the highest bit.  It is useful for
  430. extending the non-text command set in applications where the
  431. terminal has a meta shift key, such as EMACS.  \fINOTE\fP: This function
  432. is currently unsupported, due to lack of support in current
  433. teletype drivers for 8 bit input in non-raw mode.
  434. X.Lp
  435. \fBnodelay\fP(win,bf)
  436. X.br
  437. This option causes \fBgetch\fP to be a non-blocking call.  If no input
  438. is ready, \fBgetch\fP will return -1.
  439. If disabled, \fBgetch\fP will hang until a key is pressed.
  440. X.Lp
  441. \fBscrollok\fP(win,bf)
  442. X.br
  443. This option controls what happens when the cursor of a window is
  444. moved off the edge of the window, either from a newline on the
  445. bottom line, or typing the last character of the last line.  If
  446. disabled, the cursor is left on the bottom line.  If enabled,
  447. \fBwrefresh\fP is called on the window, and then the physical terminal
  448. and window are scrolled up one line.
  449. X.Lp
  450. \fBsetscrreg\fP(t,b)
  451. X.br
  452. \fBwsetscrreg\fP(win,t,b)
  453. X.br
  454. These functions allow the user to set a software scrolling region
  455. in a window \fIwin\fP or \fBstdscr\fP.
  456. \fIt\fP and \fIb\fP are the line numbers of the
  457. top and bottom margin of the scrolling region.  (Line 0 is the
  458. top line of the screen.) If this option and \fBscrollok\fP are enabled,
  459. an attempt to move off the bottom margin line will cause all
  460. lines in the scrolling region to scroll up one line.  Note that
  461. this has nothing to do with use of a physical scrolling region
  462. capability in the terminal, like that in the VT100.  Only the
  463. text of the window is scrolled.
  464. X.LP
  465. The scrolling region really acts as a sort of barrier, limiting the
  466. area of a window over which changes take place.  For this reason, an
  467. attempt to create a scrolling region in an area of the screen which
  468. does not contain the current (y, x) coordinates for that window is an
  469. error.
  470. Similarly, attempts to move the (y, x) coordinates out of the region will
  471. also fail with an ERR return.
  472. X.LP
  473. When a scrolling region is in place, all changes are limited to the region.
  474. XFor example, \fIerase()\fP will only erase the area inside the region;
  475. \fIinsertln()\fP will only shift lines down to the bottom of the region,
  476. etc.  It is anticipated that this method of controlling the area of change
  477. will prove quite handy in a number of applications.
  478. X.LP
  479. To disable the scrolling region, once defined, simply redefine it to be
  480. the whole window.  For example, to disable the scrolling region on
  481. \fIstdscr\fP, the following call would be used:
  482. X.DS
  483. \fBsetscrreg(0, LINES - 1)\fP
  484. X.DE
  485. XFor other windows, the height of the window should be used instead of
  486. (LINES - 1).
  487. X.NH 2
  488. Terminal Mode Setting
  489. X.LP
  490. These functions are used to set modes in the tty driver.  The
  491. initial mode usually depends on the setting when the program was
  492. called: the initial modes documented here represenet the normal
  493. situation.
  494. X.Lp
  495. \fBcbreak\fP()
  496. X.br
  497. \fBnocbreak\fP()
  498. X.br
  499. \fBcrmode\fP()
  500. X.br
  501. \fBnocrmode\fP()
  502. X.br
  503. These functions put the terminal into and out of \fBCBREAK\fP mode.
  504. In this mode, characters typed by the user are immediately
  505. available to the program.  When out of this mode, the teletype driver
  506. will buffer characters typed until newline is typed.  Interrupt
  507. and flow control characters are unaffected by this mode. 
  508. Initially the terminal is not in \fBCBREAK\fP mode.  Most interactive
  509. programs using curses will set this mode.
  510. X.LP
  511. The functions \fBcrmode\fP() and \fBnocrmode\fP() are the result of an
  512. accident in the first version of curses and are retained solely for
  513. upward compatibility.  \fBcrmode\fP() is the same as \fBcbreak\fP() and
  514. \fBnocrmode\fP() is the same as \fBnocbreak\fP().
  515. X.Lp
  516. \fBraw\fP()
  517. X.br
  518. \fBnoraw\fP()
  519. X.br
  520. These functions put the terminal into and out of \fBRAW\fP mode.
  521. \fBRAW\fP mode is just like \fBCBREAK\fP mode except that \fIno\fP
  522. special character processing is done (e.g. the interrupt character will
  523. be passed through to the program, uninterpreted, as will the kill
  524. character, etc.) and all 8 bits of the input character are retained;
  525. in \fBCBREAK\fP mode, the eighth bit is stripped off before it is
  526. given to the program.  Because of the lack of interpretation of
  527. special characters, it is not recommended that programs use this
  528. mode.
  529. X.Lp
  530. \fBecho\fP()
  531. X.br
  532. \fBnoecho\fP()
  533. X.br
  534. These functions control whether characters typed by the user are
  535. echoed as typed.  Initially, characters typed are echoed by the
  536. teletype driver.  Authors of most interactive programs prefer to
  537. do their own echoing in a controlled area of the screen, or not
  538. to echo at all, so they disable echoing.
  539. X.Lp
  540. \fBnl\fP()
  541. X.br
  542. \fBnonl\fP()
  543. X.br
  544. These functions control whether newline is translated into
  545. carriage return and linefeed on output, and whether return is
  546. translated into newline on input.  Initially, the translations do
  547. occur.  By disabling these translations, curses is able to make
  548. better use of the linefeed capability, resulting in faster cursor
  549. motion.
  550. X.Lp
  551. \fBresetty\fP()
  552. X.br
  553. \fBsavetty\fP()
  554. X.br
  555. These functions save and restore the state of the tty modes.
  556. \fBsavetty\fP saves the current state in a buffer, \fBresetty\fP restores the
  557. state to what it was at the last call to \fBsavetty\fP.
  558. X.NH 2
  559. Window Manipulation
  560. X.LP
  561. \fBnewwin\fP(num_lines, num_cols, begy, begx)
  562. X.br
  563. Create a new window with the given number of lines and columns.
  564. The upper left corner of the window is at line \fBbegy\fP column \fBbegx\fP.
  565. If either \fInum_lines\fP or \fInum_cols\fP is zero,
  566. they will be defaulted
  567. to \fBLINES\fP-\fIbegy\fP and \fBCOLS\fP-\fIbegx\fP.
  568. A new full-screen window is
  569. created by calling \fBnewwin\fP(0,0,0,0).
  570. X.Lp
  571. \fBsubwin\fP(orig, num_lines, num_cols, begy, begx)
  572. X.br
  573. Create a new window with the given number of lines and columns.
  574. The window is at position (\fIbegy\fP, \fIbegx\fP) on the screen.  (It is
  575. relative to the screen, not \fIorig\fP.) The window is made in the
  576. middle of the window \fIorig\fP, so that changes made to one window
  577. will affect both windows.  When using this function, often it
  578. will be necessary to call \fItouchwin\fP before calling \fIwrefresh\fP.
  579. X.Lp
  580. \fBdelwin\fP(win)
  581. X.br
  582. Deletes the named window, freeing up all memory associated with
  583. it.  In the case of sub-windows, they should be deleted before the main
  584. window.
  585. X.Lp
  586. \fBmvwin\fP(win, by, bx)
  587. X.br
  588. Move the window so that the upper left corner will be at position
  589. (\fIby\fP, \fIbx\fP).  If the move would cause the window to be off the
  590. screen, it is an error and the window is not moved.
  591. X.Lp
  592. \fBtouchwin\fP(win)
  593. X.br
  594. Throw away all optimization information about which parts of the
  595. window have been touched, by pretending the entire window has
  596. been drawn on.  This is sometimes necessary when using
  597. overlapping windows, since a change to one window will affect the other
  598. window, but the optimization records of the other window will not
  599. reflect the change.
  600. X.Lp
  601. \fBoverlay\fP(win1, win2)
  602. X.br
  603. \fBoverwrite\fP(win1, win2)
  604. X.br
  605. These functions overlay \fIwin1\fP on top of \fIwin2\fP, that is, all text in
  606. \fIwin1\fP is copied into \fIwin2\fP, after lining up the two windows'
  607. origins.
  608. The difference between the functions is that \fBoverlay\fP is
  609. nondestructive (blanks are not copied) while \fBoverwrite\fP is
  610. destructive.
  611. X.NH 2
  612. Causing Output to the Terminal
  613. X.LP
  614. \fBrefresh\fP()
  615. X.br
  616. \fBwrefresh\fP(win)
  617. X.br
  618. These functions must be called to actually get any output on the
  619. terminal, as other routines merely manipulate data structures.
  620. \fBwrefresh\fP copies the named window to the physical terminal screen,
  621. taking into account what is already there in order to do
  622. optimizations.
  623. \fBrefresh\fP is the same, using \fBstdscr\fP as a default screen.
  624. Unless \fBleaveok\fP has been enabled, the physical cursor of the
  625. terminal is left at the location of the window's cursor.
  626. X.Lp
  627. \fBdoupdate\fP()
  628. X.br
  629. \fBwnoutrefresh\fP(win)
  630. X.br
  631. These two functions allow multiple updates with more efficiency
  632. than \fBwrefresh.\fP  To use them, it is important to understand how
  633. curses works.  In addition to all the window structures, curses
  634. keeps two data structures representing the terminal screen: a
  635. \fIphysical\fP screen, describing what is actually on the screen, and a
  636. \fIvirtual\fP screen, describing what the programmer \fIwants\fP to have on
  637. the screen.  \fBwrefresh\fP works by first copying the named window to
  638. the virtual screen (\fBwnoutrefresh\fP), and then calling the routine
  639. to update the screen (\fBdoupdate\fP).  If the programmer wishes to
  640. output several windows at once, a series of calls to \fBwrefresh\fP
  641. will result in alternating calls to \fBwnoutrefresh\fP and \fBdoupdate\fP,
  642. causing several bursts of output to the screen.  By calling
  643. \fBwnoutrefresh\fP for each window, it is then possible to call
  644. \fBdoupdate\fP once, resulting in only one burst of output, with probably
  645. fewer total characters transmitted.
  646. X.NH 2
  647. Writing on Window Structures
  648. X.LP
  649. These routines are used to ``draw'' text on windows.  In all
  650. cases, a missing \fIwin\fP is taken to be \fBstdscr\fP.
  651. \fIy\fP and \fIx\fP are the row
  652. and column, respectively.  The upper left corner is always (0, 0) not (1, 1).
  653. The \fBmv\fP functions imply a call to \fBmove\fP before the call to the
  654. other function.
  655. X.NH 3
  656. Moving the Cursor
  657. X.LP
  658. \fBmove\fP(y, x)
  659. X.br
  660. \fBwmove\fP(win, y, x)
  661. X.br
  662. The cursor associated with the window is moved to the given
  663. location.  This does not move the physical cursor of the terminal
  664. until \fBrefresh\fP is called.
  665. X.NH 3
  666. Writing One Character
  667. X.LP
  668. \fBaddch\fP(ch)
  669. X.br
  670. \fBwaddch\fP(win, ch)
  671. X.br
  672. \fBmvaddch\fP(y, x, ch)
  673. X.br
  674. \fBmvwaddch\fP(win, y, x, ch)
  675. X.br
  676. The character \fIch\fP is put in the window at the current cursor
  677. position of the window.  If \fIch\fP is a tab, newline, or backspace, the
  678. cursor will be moved appropriately in the window.  If \fIch\fP is a
  679. different control character, it will be drawn in the ^X notation.
  680. The position of the window cursor is advanced.  At the right
  681. margin, an automatic newline is performed.  At the bottom of the
  682. scrolling region, if \fBscrollok\fP is enabled, the scrolling region
  683. will be scrolled up one line.
  684. X.NH 3
  685. Writing a String
  686. X.LP
  687. \fBaddstr\fP(str)
  688. X.br
  689. \fBwaddstr\fP(win,str)
  690. X.br
  691. \fBmvaddstr\fP(y,x,str)
  692. X.br
  693. \fBmvwaddstr\fP(win,y,x,str)
  694. X.br
  695. These functions write all the characters of the null terminated
  696. character string \fIstr\fP on the given window.  They are identical to
  697. a series of calls to \fBaddch\fP.
  698. X.NH 3
  699. Clearing Areas of the Screen
  700. X.LP
  701. \fBerase\fP()
  702. X.br
  703. \fBwerase\fP(win)
  704. X.br
  705. These functions copy blanks to every position in the window.
  706. X.Lp
  707. \fBclear\fP()
  708. X.br
  709. \fBwclear\fP(win)
  710. X.br
  711. These functions are like \fBerase\fP and \fBwerase\fP but they also call
  712. \fBclearok\fP, arranging that the screen will be cleared on the next
  713. \fBrefresh\fP.
  714. X.Lp
  715. \fBclrtobot\fP()
  716. X.br
  717. \fBwclrtobot\fP(win)
  718. X.br
  719. All lines below the cursor in this window are erased.  Also, the
  720. current line to the right of the cursor is erased.
  721. X.Lp
  722. \fBclrtoeol\fP()
  723. X.br
  724. \fBwclrtoeol\fP(win)
  725. X.br
  726. The current line to the right of the cursor is erased.
  727. X.NH 3
  728. Inserting and Deleting Text
  729. X.LP
  730. \fBdelch\fP()
  731. X.br
  732. \fBwdelch\fP(win)
  733. X.br
  734. \fBmvdelch\fP(y,x)
  735. X.br
  736. \fBmvwdelch\fP(win,y,x)
  737. X.br
  738. The character under the cursor in the window is deleted.  All
  739. characters to the right on the same line are moved to the left
  740. one position.  This does not imply use of the hardware delete
  741. character feature.
  742. X.Lp
  743. \fBdeleteln\fP()
  744. X.br
  745. \fBwdeleteln\fP(win)
  746. X.br
  747. The line under the cursor in the window is deleted.  All lines
  748. below the current line are moved up one line.  The bottom line of
  749. the window is cleared.  This does not imply use of the hardware
  750. delete line feature.
  751. X.Lp
  752. \fBinsch\fP(c)
  753. X.br
  754. \fBwinsch\fP(win, c)
  755. X.br
  756. \fBmvinsch\fP(y,x,c)
  757. X.br
  758. \fBmvwinsch\fP(win,y,x,c)
  759. X.br
  760. The character \fIc\fP is inserted before the character under the
  761. cursor.  All characters to the right are moved one space to the
  762. right, possibly losing the rightmost character on the line.  This
  763. does not imply use of the hardware insert character feature.
  764. X.Lp
  765. \fBinsertln\fP()
  766. X.br
  767. \fBwinsertln\fP(win)
  768. X.br
  769. A blank line is inserted above the current line.  The bottom line
  770. is lost.  This does not imply use of the hardware insert line
  771. feature.
  772. X.NH 3
  773. XFormatted Output
  774. X.LP
  775. \fBprintw\fP(fmt, args)
  776. X.br
  777. \fBwprintw\fP(win, fmt, args)
  778. X.br
  779. \fBmvprintw\fP(y, x, fmt, args)
  780. X.br
  781. \fBmvwprintw\fP(win, y, x, fmt, args)
  782. X.br
  783. These functions correspond to \fIprintf\fP.  The characters which would
  784. be output by \fIprintf\fP are instead output using \fIwaddch\fP on the given
  785. window.
  786. X.NH 3
  787. Miscelaneous
  788. X.LP
  789. \fBbox\fP(win, vert, hor)
  790. X.br
  791. A box is drawn around the edge of the window.  \fIvert\fP and \fIhor\fP are
  792. the characters the box is to be drawn with.
  793. X.Lp
  794. \fBscroll\fP(win)
  795. X.br
  796. The window is scrolled up one line.  This involves moving the
  797. lines in the window data structure.
  798. X.NH 2
  799. Querying the Contents of a Window
  800. X.LP
  801. \fBgetyx\fP(win,y,x)
  802. X.br
  803. The cursor position of the window is placed in the two integer
  804. variables \fIy\fP and \fIx\fP.  Since this is a macro, no & is necessary.
  805. X.Lp
  806. \fBinch\fP()
  807. X.br
  808. \fBwinch\fP(win)
  809. X.br
  810. \fBmvinch\fP(y,x)
  811. X.br
  812. \fBmvwinch\fP(win,y,x)
  813. X.br
  814. The character at the current position in the named window is
  815. returned.
  816. X.NH 2
  817. Input from the Terminal
  818. X.LP
  819. \fBgetch\fP()
  820. X.br
  821. \fBwgetch\fP(win)
  822. X.br
  823. \fBmvgetch\fP(y,x)
  824. X.br
  825. \fBmvwgetch\fP(win,y,x)
  826. X.br
  827. A character is read from the terminal associated with the window.
  828. In nodelay mode, if there is no input waiting, the value -1 is
  829. returned.  In delay mode, the program will hang until a character is typed.
  830. X.Lp
  831. If \fIkeypad\fP mode is enabled, and a function key is pressed, the
  832. code for that function key will be returned instead of the raw
  833. characters.  Possible function keys are defined with integers
  834. beginning with 0401, whose names begin with KEY_, defined in
  835. <ncurses.h>.  If a character is received that could be the
  836. beginning of a function key (such as escape), curses will set a one
  837. second timer.  If the remainder of the sequence does not come in
  838. within one second, the character will be passed through,
  839. otherwise the function key value will be returned.  For this reason,
  840. on many terminals, there will be a one second delay after a user
  841. presses the escape key.  (Use by a programmer of the escape key
  842. for a single character function is discouraged.)
  843. X.Lp
  844. \fBgetstr\fP(str)
  845. X.br
  846. \fBwgetstr\fP(win,str)
  847. X.br
  848. \fBmvgetstr\fP(y,x,str)
  849. X.br
  850. \fBmvwgetstr\fP(win,y,x,str)
  851. X.br
  852. A series of calls to \fIgetch\fP is made, until a newline is received.
  853. The resulting value is placed in the area pointed at by the
  854. character pointer \fIstr\fP.  The users erase and kill characters are
  855. interpreted, and the string is echoed.
  856. X.Lp
  857. \fBscanw\fP(fmt, args)
  858. X.br
  859. \fBwscanw\fP(win, fmt, args)
  860. X.br
  861. \fBmvscanw\fP(y, x, fmt, args)
  862. X.br
  863. \fBmvwscanw\fP(win, y, x, fmt, args)
  864. X.br
  865. This function corresponds to \fIscanf\fP.  \fIwgetstr\fP is called on the
  866. window, and the resulting line is used as input for the scan.
  867. X.NH 2
  868. Video Attributes
  869. X.LP
  870. \fBattroff\fP(at)
  871. X.br
  872. \fBwattroff\fP(win, attrs)
  873. X.br
  874. \fBattron\fP(at)
  875. X.br
  876. \fBwattron\fP(win, attrs)
  877. X.br
  878. \fBattrset\fP(at)
  879. X.br
  880. \fBwattrset\fP(win, attrs)
  881. X.br
  882. \fBstandout\fP()
  883. X.br
  884. \fBstandend\fP()
  885. X.br
  886. \fBwstandout\fP(win)
  887. X.br
  888. \fBwstandend\fP(win)
  889. X.br
  890. These functions set the \fIcurrent\fP \fIattributes\fP of the named window.
  891. These attributes can be any combination of \fBA_STANDOUT\fP, \fBA_REVERSE\fP,
  892. \fBA_BOLD\fP, \fBA_DIM\fP, \fBA_BLINK\fP, \fBA_BLANK\fP, \fBA_UNDERLINE\fP,
  893. \fBA_PROTECT\fP, and \fBA_ALTCHARSET\fP.
  894. These constants are defined in <ncurses.h> and can
  895. be combined with the C | (or) operator.
  896. X.LP
  897. The current attributes of a window are applied to all characters
  898. that are written into the window.  Attributes are a
  899. property of the character, and move with the character through
  900. any scrolling and insert/delete line/character operations.  To
  901. the extent possible on the particular terminal, they will be
  902. displayed as the graphic rendition of characters put on the
  903. screen.
  904. X.LP
  905. \fIattrset\fP(at) sets the current attributes of the given window to
  906. \fIat\fP.  \fIattroff\fP(at) turns off the named attributes without affecting
  907. any other attributes.  \fIattron\fP(at) turns on the named attributes
  908. without affecting any others.  \fIstandout\fP is the same as
  909. \fIattrset\fP(A_STANDOUT) \fIstandend\fP is the same as \fIattrset\fP(0),
  910. that is, it turns off all attributes.
  911. X.NH 2
  912. Bells and Flashing Lights
  913. X.LP
  914. \fBbeep\fP()
  915. X.br
  916. \fBflash\fP()
  917. X.br
  918. These functions are used to signal the programmer.  \fIbeep\fP will
  919. sound the audible alarm on the terminal, if possible, and if not,
  920. will flash the screen (visible bell), if that is possible.  \fIflash\fP
  921. will flash the screen, and if that is not possible, will sound
  922. the audible signal.  If neither signal is possible, nothing will
  923. happen.  Nearly all terminals have an audible signal (bell or
  924. beep) but only some can flash the screen.
  925. X.NH 2
  926. Portability Functions
  927. X.LP
  928. These functions do not have anything to do with terminal
  929. dependent character output, but tend to be needed by programs that use
  930. curses.  Unfortunately, their implemention varies from one
  931. version of UNIX\u*\d to another.  They have been included here to
  932. enhance the portability of programs using curses.
  933. X.FS
  934. \u*\d UNIX is a trademark of Bell Laboratories.
  935. X.FE
  936. X.Lp
  937. \fBbaudrate\fP()
  938. X.br
  939. \fIbaudrate\fP returns the output speed of the terminal.  The number
  940. returned is the integer baud rate, for example, 9600, rather than
  941. a table index such as \fBB9600\fP.
  942. X.Lp
  943. \fBerasechar\fP()
  944. X.br
  945. The erase character chosen by the user is returned.  This is the
  946. character typed by the user to erase the character just typed.
  947. X.Lp
  948. \fBkillchar\fP()
  949. X.br
  950. The line kill character chosen by the user is returned.  This is
  951. the character typed by the user to forget the entire line being
  952. typed.
  953. X.Lp
  954. \fBflushinp\fP()
  955. X.br
  956. \fIflushinp\fP throws away any typeahead that has been typed by the
  957. user and has not yet been read by the program.
  958. X.NH 2
  959. Debugging
  960. X.LP
  961. These functions are useful when debugging a program with curses.
  962. X.Lp
  963. \fBunctrl\fP(ch)
  964. X.br
  965. This macro expands to a character string which is a printable
  966. representation of the character \fIch\fP.  The program must include the
  967. file <unctrl.h>.  Control characters are displayed in the ^x
  968. notation.  Printing characters are displayed as is.
  969. X.Lp
  970. \fBtraceoff\fP()
  971. X.br
  972. \fBtraceon\fP()
  973. X.br
  974. It is possible to compile a debugging version of curses with
  975. tracing turned on, and with the -g option for sdb.  This library
  976. may be available on your system as -ldcurses.  When using this
  977. version, the file ``trace'' will be created each time the program
  978. is run, containing verbose information showing each step done by
  979. curses.  This output is useful for finding bugs in curses, and
  980. may be useful for finding bugs in user programs.  Since the
  981. output is so verbose, with any bug that cannot be easily and quickly
  982. reproduced, it may be necessary to turn the debugging output off
  983. in some parts of the program.  These functions can be used to
  984. turn tracing off and back on.  When \fIinitscr\fP is first called,
  985. tracing is automatically turned on.
  986. X.NH 2
  987. Lower Level Functions
  988. X.LP
  989. These functions are provided for programs not needing the screen
  990. optimization capabilities of curses.  Programs are discouraged
  991. from working at this level, since they must handle various
  992. glitches in certain terminals.  However, a program can be smaller
  993. if it only brings in the low level routines.
  994. X.NH 3
  995. Cursor Motion
  996. X.Lp
  997. \fBgettmode\fP()
  998. X.br
  999. \fBsetterm\fP(type)
  1000. X.br
  1001. These two initialization routines are provided for upward
  1002. compatibility with the old curses.  \fIgettmode\fP does nothing.
  1003. \fIsetterm\fP
  1004. results in a call to \fIsetupterm\fP with appropriate arguments.
  1005. X.Lp
  1006. \fBmvcur\fP(oldrow, oldcol, newrow, newcol)
  1007. X.br
  1008. This routine optimally moves the cursor from (oldrow, oldcol) to
  1009. (newrow, newcol).  The user program is expected to keep track of
  1010. the current cursor position.  Note that unless a full screen
  1011. image is kept, curses will have to make pessimistic assumptions,
  1012. sometimes resulting in less than optimal cursor motion.  For
  1013. example, moving the cursor a few spaces to the right can be done
  1014. by transmitting the characters being moved over, but if curses
  1015. does not have access to the screen image, it doesn't know what
  1016. these characters are.
  1017. X.LP
  1018. If either of oldcol or oldrow are negative, \fImvcur()\fP will refrain
  1019. from using any relative motions.  This is handy for occasions when
  1020. a program is unsure as to the current cursor location.
  1021. X.NH 3
  1022. Terminfo Level
  1023. X.LP
  1024. These routines are called by low level
  1025. programs that need access to specific capabilities of terminfo.
  1026. A program working at this level should include both <ncurses.h>
  1027. and <term.h>.  After a call to \fIsetupterm\fP, the
  1028. capabilities will be available with macro names defined in
  1029. <term.h>.  See \fBterminfo\fP(5) for a detailed description of the
  1030. capabilies.  If the program only needs to handle one terminal,
  1031. the definition \fB-DSINGLE\fP can be passed to the C compiler,
  1032. resulting in static references to capabilities instead of dynamic
  1033. references.  This can result in smaller code, but prevents use of
  1034. more than one terminal at a time.  Very few programs use more
  1035. than one terminal, so almost all programs can use this flag.
  1036. X.Lp
  1037. \fBsetupterm\fP(term, filenum, errret)
  1038. X.br
  1039. This routine is called to initialize a terminal.  \fIterm\fP is the
  1040. character string representing the name of the terminal being
  1041. used.  \fIfilenum\fP is the UNIX file descriptor of the terminal being
  1042. used for output.  \fIerrret\fP is a pointer to an integer, in which a
  1043. success or failure indication is returned.  The values returned
  1044. can be 1 (all is well), 0 (no such terminal), or -1 (some problem
  1045. locating the terminfo database).
  1046. X.LP
  1047. The value of \fIterm\fP can be given as 0, which will cause the value
  1048. of TERM in the environment to be used.  The \fIerrret\fP pointer can
  1049. also be given as 0, meaning no error code is wanted.  If \fIerrret\fP
  1050. is defaulted, and something goes wrong, \fIsetupterm\fP will print an
  1051. appropriate error message and exit, rather than returning.  Thus,
  1052. a simple program can call \fIsetupterm\fP(0, 1, 0) and not worry about
  1053. initialization errors.
  1054. X.LP
  1055. \fIsetupterm\fP will check the tty driver mode bits, and change any
  1056. that might prevent the correct operation of other low level
  1057. routines.  Currently, the mode that expands tabs into spaces is
  1058. disabled, because the tab character is sometimes used for different
  1059. functions by different terminals.  (Some terminals use it to move
  1060. right one space.  Others use it to address the cursor to row or
  1061. column 9.) If the system is expanding tabs, \fIsetupterm\fP will remove
  1062. the definition of the \fBtab\fP and \fBbacktab\fP functions, assuming that
  1063. since the user is not using hardware tabs, they may not be
  1064. properly set in the terminal.
  1065. X.LP
  1066. After the call to \fIsetupterm\fP, the global variable \fIcur_term\fP is set
  1067. to point to the current structure of terminal capabilities.  By
  1068. calling \fIsetupterm\fP for each terminal, and saving and restoring
  1069. \fIcur_term\fP, it is possible for a program to use two or more
  1070. terminals at once.  \fISetupterm\fP also stores the names section of the
  1071. terminal description in the global character array \fIttytype[]\fP.
  1072. Subsequent calls to \fIsetupterm\fP will overwrite this array, so you'll
  1073. have to save it yourself if need be.
  1074. X.LP
  1075. The mode that turns newlines into CRLF on output is not disabled.
  1076. Programs that use \fBcud1\fP or \fBind\fP should avoid these capabilities if
  1077. their value is linefeed unless they disable this mode.  \fIsetupterm\fP
  1078. calls \fIfixterm\fP after any changes it makes.
  1079. X.Lp
  1080. \fBfixterm\fP()
  1081. X.br
  1082. \fBresetterm\fP()
  1083. X.br
  1084. \fBsaveterm\fP()
  1085. X.br
  1086. These routines can be used to change the tty modes between the
  1087. two states: \fInormal\fP (the mode they were in before the program was
  1088. started) and \fIprogram\fP (the mode needed by the program).  \fIfixterm\fP
  1089. puts the terminal into program mode, and \fIresetterm\fP puts the
  1090. terminal into normal mode.  These functions are useful for shell
  1091. escapes and control-Z suspensions.  In addition, all programs
  1092. must call \fIresetterm\fP before they exit.
  1093. X.LP
  1094. The routine \fBsaveterm\fP saves the current state of the tty modes
  1095. so that the next time \fBfixterm\fP is called, the same modes will be
  1096. used.  This is useful for programs which use some of the functions
  1097. described in section 2.3 to tailor the modes.
  1098. X.LP
  1099. Normal mode is stored in \fIcur_term\fP->\fIOttyb\fP, and program mode is in
  1100. \fIcur_term\fP->\fINttyb\fP.  These structures are both of type SGTTYB (which
  1101. varies depending on the system).  Currently the only possible type
  1102. is \fBstruct\fP \fBsgttyb\fP.
  1103. X.Lp
  1104. \fBvidattr\fP(newmode)
  1105. X.br
  1106. \fBvidputs\fP(newmode, outc)
  1107. X.br
  1108. \fInewmode\fP is any combination of attributes, defined in <ncurses.h>.
  1109. The proper string to put the terminal in the given video mode is
  1110. output. The routine \fBvidattr\fP() sends the output characters to
  1111. \fBputchar\fP; \fBvidputs\fP sends them to the given routine \fIoutc\fP,
  1112. one character at a time.  That routine should therefore expect one
  1113. \fBchar\fP parameter.
  1114. The previous mode is remembered by this routine.
  1115. X.Lp
  1116. \fBtparm\fP(instring, p1, p2, p3, p4, p5, p6, p7, p8, p9)
  1117. X.br
  1118. \fItparm\fP is used to instantiate a parameterized string.  The
  1119. character string returned is suitable for \fItputs\fP.  Up to 9
  1120. parameters can be passed, in addition to the parameterized string.
  1121. X.Lp
  1122. \fBtputs\fP(cp, affcnt, outc)
  1123. X.br
  1124. A string capability, possibly containing padding information, is
  1125. processed.  Enough padding characters to delay for the specified
  1126. time replace the padding specification, and the resulting string
  1127. is passed, one character at a time, to the routine \fIoutc\fP, which
  1128. should expect one character parameter.  (This routine often just
  1129. calls \fIputchar\fP.) \fIcp\fP is the capability string.  \fIaffcnt\fP is the
  1130. number of units affected by the capability, which varies with the
  1131. particular capability.  (For example, the \fIaffcnt\fP for \fIinsert_line\fP
  1132. is the number of lines below the inserted line on the screen,
  1133. that is, the number of lines that will have to be moved by the
  1134. terminal.) \fIaffcnt\fP is used by the padding information of some
  1135. terminals as a multiplication factor.  If the capability does not
  1136. have a factor, the value 1 should be passed.
  1137. X.Lp
  1138. \fBputp\fP(str)
  1139. X.br
  1140. This is a convenient function to output a capability with no
  1141. \fIaffcnt\fP.
  1142. The string is output to \fIputchar\fP with an \fIaffcnt\fP of 1.
  1143. It can be used in simple applications that do not need to process
  1144. the output of \fItputs\fP.
  1145. //go.sysin dd *
  1146. echo 'x - =doc/ncurses.3'
  1147. sed 's/^X//' <<'//go.sysin dd *' >=doc/ncurses.3
  1148. X.TH NCURSES 3
  1149. X.UC 4
  1150. X.SH NAME
  1151. ncurses \- terminal-independent screen management package
  1152. X.SH SYNOPSIS
  1153. #include <ncurses.h>
  1154. X.sp
  1155. X.B cc
  1156. [ flags ] files
  1157. X.B \-lncurses
  1158. [ libraries ]
  1159. X.SH DESCRIPTION
  1160. These routines give the user a method
  1161. of updating screens with reasonable optimization and terminal independence.
  1162. They keep an image of the current screen,
  1163. and the user sets up an image of a new one.
  1164. Then the
  1165. X.I refresh()
  1166. call tells the routines to make the current screen look
  1167. like the new one.
  1168. In order to initialize the routines,
  1169. the routine
  1170. X.I initscr()
  1171. must be called before any of the other routines
  1172. that deal with windows and screens
  1173. are used.
  1174. The routine
  1175. X.I endwin()
  1176. should be called before exiting.
  1177. X.SH SEE ALSO
  1178. X.I "The Curses Reference Manual",
  1179. Curtis
  1180. X.br
  1181. terminfo(5)
  1182. X.SH AUTHOR
  1183. Pavel Curtis
  1184. X.SH FUNCTIONS
  1185. X.nf
  1186. X.ds w \fIwin\fR
  1187. X.ds s \fIstdscr\fR
  1188. X.ta 3i
  1189. addch(ch)    add a character to \*s
  1190. addstr(str)    add a string to \*s
  1191. attroff(at)    turn off video attributes on \*s
  1192. attron(at)    turn on video attributes on \*s
  1193. attrset(at)    set video attributes on \*s
  1194. baudrate()    return baudrate of current terminal
  1195. beep()    sound audible bell
  1196. box(win,vert,hor)    draw a box around a window
  1197. cbreak()    set cbreak mode
  1198. crmode()    set cbreak mode
  1199. clear()    clear \*s
  1200. clearok(scr,boolf)    set clear flag for \fIscr\fR
  1201. clrtobot()    clear to bottom on \*s
  1202. clrtoeol()    clear to end of line on \*s
  1203. delch()    delete a character
  1204. deleteln()    delete a line
  1205. delwin(win)    delete \*w
  1206. doupdate()    update the physical screen
  1207. echo()    set echo mode
  1208. endwin()    end window modes
  1209. erase()    erase \*s
  1210. erasechar()    return erase character of current terminal
  1211. fixterm()    set terminal into program mode
  1212. flash()    execute visible bell
  1213. flushinp()    flush outstanding input on current terminal
  1214. getch()    get a char through \*s
  1215. getcap(name)    get terminal capability \fIname\fR
  1216. getstr(str)    get a string through \*s
  1217. gettmode()    no-op
  1218. getyx(win,y,x)    get (y,x) coordinates
  1219. idlok(win,flag)    enable insert/delete lines operations
  1220. inch()    get char at current (y,x) coordinates
  1221. initscr()    initialize screens
  1222. insch(c)    insert a char
  1223. insertln()    insert a line
  1224. keypad(win,flag)    enable keypad-sequence mapping
  1225. killchar()    return kill character of current terminal
  1226. leaveok(win,boolf)    set leave flag for \*w
  1227. longname(termbuf,name)    get long name from \fItermbuf\fR
  1228. meta(win,flag)    enable use of the `meta' key
  1229. move(y,x)    move to (y,x) on \*s
  1230. mvcur(lasty,lastx,newy,newx)    actually move cursor
  1231. newterm(type,fp)    initialise a new terminal
  1232. newwin(lines,cols,begin_y,begin_x)\     create a new window
  1233. nl()    set newline mapping
  1234. nocbreak()    unset cbreak mode
  1235. nocrmode()    unset cbreak mode
  1236. nodelay(win,flag)    make getch() non-blocking
  1237. noecho()    unset echo mode
  1238. nonl()    unset newline mapping
  1239. noraw()    unset raw mode
  1240. overlay(win1,win2)    overlay win1 on win2
  1241. overwrite(win1,win2)    overwrite win1 on top of win2
  1242. printw(fmt,arg1,arg2,...)    printf on \*s
  1243. putp(string)    tputs() with affcnt=1 and outc=putchar
  1244. raw()    set raw mode
  1245. refresh()    make current screen look like \*s
  1246. resetterm()    set terminal into normal mode
  1247. resetty()    reset tty flags to stored value
  1248. savetty()    store current tty flags
  1249. saveterm()    save current state of tty
  1250. scanw(fmt,arg1,arg2,...)    scanf through \*s
  1251. scroll(win)    scroll \*w one line
  1252. scrollok(win,boolf)    set scroll flag
  1253. setscrreg(top,bottom)    set up scrolling region on \*s
  1254. setterm(name)    set term variables for name
  1255. set_term(new)    change current terminal
  1256. setupterm(term,fd,errret)    initialise terminal capabilities
  1257. standend()    end standout mode
  1258. standout()    start standout mode
  1259. subwin(win,lines,cols,begin_y,begin_x)\     create a subwindow
  1260. touchwin(win)    \*(lqchange\*(rq all of \*w
  1261. tparm(string,p1..p9)    instantiate a parameterised string
  1262. tputs(string,affcnt,outc)    process a capability string
  1263. traceoff()    turn off debugging output
  1264. traceon()    turn on debugging output
  1265. unctrl(ch)    printable version of \fIch\fR
  1266. vidattr(newmode)    set terminal's video attributes
  1267. vidputs(newmode,outc)    set video attributes into a function
  1268. waddch(win,ch)    add char to \*w
  1269. waddstr(win,str)    add string to \*w
  1270. wattroff(win,at)    turn off video attributes on \*w
  1271. wattron(win,at)    turn on video attributes on \*w
  1272. wattrset(win,at)    set video attributes on \*w
  1273. wclear(win)    clear \*w
  1274. wclrtobot(win)    clear to bottom of \*w
  1275. wclrtoeol(win)    clear to end of line on \*w
  1276. wdelch(win,c)    delete char from \*w
  1277. wdeleteln(win)    delete line from \*w
  1278. werase(win)    erase \*w
  1279. wgetch(win)    get a char through \*w
  1280. wgetstr(win,str)    get a string through \*w
  1281. winch(win)    get char at current (y,x) in \*w
  1282. winsch(win,c)    insert char into \*w
  1283. winsertln(win)    insert line into \*w
  1284. wmove(win,y,x)    set current (y,x) co-ordinates on \*w
  1285. wnoutrefresh(win)    copy \*w to virtual screen
  1286. wprintw(win,fmt,arg1,arg2,...)\     printf on \*w
  1287. wrefresh(win)    make screen look like \*w
  1288. wscanw(win,fmt,arg1,arg2,...)\     scanf through \*w
  1289. wsetscrreg(win,top,bottom)    set up scrolling region on \*w
  1290. wstandend(win)    end standout mode on \*w
  1291. wstandout(win)    start standout mode on \*w
  1292. //go.sysin dd *
  1293. exit
  1294.