home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / crssrc12 / intro.3 < prev    next >
Text File  |  1993-07-29  |  5KB  |  205 lines

  1. .\" Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
  2. .\" University of California.  Permission is granted to freely
  3. .\" distribute curses and its documentation provided that this
  4. .\" notice is left intact.
  5. .\"
  6. .\"    @(#)intro.3    6.1 (Berkeley) 4/23/86
  7. .\"
  8. .sh 1 Usage
  9. .pp
  10. This is a description of how to actually use the screen package.
  11. In it, we assume all updating, reading, etc.
  12. is applied to
  13. .Vn stdscr .
  14. All instructions will work on any window,
  15. with changing the function name and parameters as mentioned above.
  16. .sh 2 "Starting up"
  17. .pp
  18. In order to use the screen package,
  19. the routines must know about terminal characteristics,
  20. and the space for
  21. .Vn curscr
  22. and
  23. .Vn stdscr
  24. must be allocated.
  25. These functions are performed by
  26. .Fn initscr .
  27. Since it must allocate space for the windows,
  28. it can overflow core when attempting to do so.
  29. On this rather rare occasion,
  30. .Fn initscr
  31. returns ERR.
  32. .Fn initscr
  33. must
  34. .bi always
  35. be called before any of the routines which affect windows are used.
  36. If it is not,
  37. the program will core dump as soon as either
  38. .Vn curscr
  39. or
  40. .Vn stdscr
  41. are referenced.
  42. However, it is usually best to wait to call it
  43. until after you are sure you will need it,
  44. like after checking for startup errors.
  45. Terminal status changing routines
  46. like
  47. .Fn nl
  48. and
  49. .Fn cbreak
  50. should be called after
  51. .Fn initscr .
  52. .pp
  53. Now that the screen windows have been allocated,
  54. you can set them up for the run.
  55. If you want to, say, allow the window to scroll,
  56. use
  57. .Fn scrollok .
  58. If you want the cursor to be left after the last change, use
  59. .Fn leaveok .
  60. If this isn't done,
  61. .Fn refresh
  62. will move the cursor to the window's current \*y after updating it.
  63. New windows of your own can be created, too, by using the functions
  64. .Fn newwin
  65. and
  66. .Fn subwin .
  67. .Fn delwin
  68. will allow you to get rid of old windows.
  69. If you wish to change the official size of the terminal by hand,
  70. just set the variables
  71. .Vn LINES
  72. and
  73. .Vn COLS
  74. to be what you want,
  75. and then call
  76. .Fn initscr .
  77. This is best done before,
  78. but can be done either before or after,
  79. the first call to
  80. .Fn initscr ,
  81. as it will always delete any existing
  82. .Vn stdscr
  83. and/or
  84. .Vn curscr
  85. before creating new ones.
  86. .pp
  87. .sh 2 "The Nitty-Gritty"
  88. .sh 3 Output
  89. .pp
  90. Now that we have set things up,
  91. we will want to actually update the terminal.
  92. The basic functions
  93. used to change what will go on a window are
  94. .Fn addch
  95. and
  96. .Fn move .
  97. .Fn addch
  98. adds a character at the current \*y,
  99. returning ERR if it would cause the window to illegally scroll,
  100. .i i.e. ,
  101. printing a character in the lower right-hand corner
  102. of a terminal which automatically scrolls
  103. if scrolling is not allowed.
  104. .Fn move
  105. changes the current \*y to whatever you want them to be.
  106. It returns ERR if you try to move off the window when scrolling is not allowed.
  107. As mentioned above, you can combine the two into
  108. .Fn mvaddch
  109. to do both things in one fell swoop.
  110. .pp
  111. The other output functions,
  112. such as
  113. .Fn addstr
  114. and
  115. .Fn printw ,
  116. all call
  117. .Fn addch
  118. to add characters to the window.
  119. .pp
  120. After you have put on the window what you want there,
  121. when you want the portion of the terminal covered by the window
  122. to be made to look like it,
  123. you must call
  124. .Fn refresh .
  125. In order to optimize finding changes,
  126. .Fn refresh
  127. assumes that any part of the window not changed
  128. since the last
  129. .Fn refresh
  130. of that window has not been changed on the terminal,
  131. .i i.e. ,
  132. that you have not refreshed a portion of the terminal
  133. with an overlapping window.
  134. If this is not the case,
  135. the routines
  136. .Fn touchwin ,
  137. .Fn touchline ,
  138. and
  139. .Fn touchoverlap
  140. are provided to make it look like a desired part of window has been changed,
  141. thus forcing
  142. .Fn refresh
  143. check that whole subsection of the terminal for changes.
  144. .pp
  145. If you call
  146. .Fn wrefresh
  147. with
  148. .Vn curscr ,
  149. it will make the screen look like
  150. .Vn curscr
  151. thinks it looks like.
  152. This is useful for implementing a command
  153. which would redraw the screen in case it get messed up.
  154. .sh 3 Input
  155. .pp
  156. Input is essentially a mirror image of output.
  157. The complementary function to
  158. .Fn addch
  159. is
  160. .Fn getch
  161. which,
  162. if echo is set,
  163. will call
  164. .Fn addch
  165. to echo the character.
  166. Since the screen package needs to know what is on the terminal at all times,
  167. if characters are to be echoed,
  168. the tty must be in raw or cbreak mode.
  169. If it is not,
  170. .Fn getch
  171. sets it to be cbreak,
  172. and then reads in the character.
  173. .sh 3 Miscellaneous
  174. .pp
  175. All sorts of fun functions exists for maintaining and changing information
  176. about the windows.
  177. For the most part,
  178. the descriptions in section 5.4. should suffice.
  179. .sh 2 "Finishing up"
  180. .pp
  181. In order to do certain optimizations,
  182. and,
  183. on some terminals,
  184. to work at all,
  185. some things must be done
  186. before the screen routines start up.
  187. These functions are performed in
  188. .Fn getttmode
  189. and
  190. .Fn setterm ,
  191. which are called by
  192. .Fn initscr .
  193. In order to clean up after the routines,
  194. the routine
  195. .Fn endwin
  196. is provided.
  197. It restores tty modes to what they were
  198. when
  199. .Fn initscr
  200. was first called.
  201. Thus,
  202. anytime after the call to initscr,
  203. .Fn endwin
  204. should be called before exiting.
  205.