home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / program / curses / curses.doc < prev    next >
Text File  |  1987-08-23  |  33KB  |  851 lines

  1.            The CURSES screen updating and cursor movement package.
  2.  
  3.           A collection of C-functions for Atari ST-series computers
  4.  
  5.                                Version 1.0
  6.  
  7.  
  8.                              R. van 't Veen 
  9.  
  10.  
  11.  
  12.  
  13.     This document describes a set of C-functions which allow the user
  14. easier design of full-screen applications. This package is intended for
  15. programs that perform graphics-like operations on terminal screens.
  16. It is largely compatible with the UN*X curses(3x) package. This document
  17. provides pointers to its use, a little detail about its inner workings and it
  18. stresses differences between the UN*X-implementation and the Atari-ST series
  19. implementation.
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.    Introduction.
  27.    
  28.    This package was born out of my desire to make more programs available for
  29. UN*X also available on my Atari. A side-effect of this is that it provides
  30. easier screen updating than by means of sending escape codes. The package is
  31. also quite fast, timing of a sample application yielded a rate of about
  32. 90 kilobaud per second.
  33.  
  34.    Terminology.
  35.    
  36.    Throughout this document  the following words will be used frequently :
  37.  
  38. WINDOW       An internal representation of what a section of the terminal
  39.        screen may eventually look like. A window is a rectangular
  40.              array, which may be as big as the terminal screen or even as 
  41.              small as a single character.
  42.  
  43. TERMINAL     Or terminal screen, the packages idea of what the Atari's VT52
  44.      emulation looks like. If everything is allright this is what you
  45.              see. The terminal screen is a special screen.
  46.  
  47. SCREEN       A screen is an element of the set of windows that are as large as 
  48.        the terminal screen. One screen, called stdscr, is already
  49.              provided for.
  50.  
  51.    Using the package.
  52.    
  53.    To use the package, include the file "curses.h" in your source. This gives
  54. you the types and definitions necessary to be able to use it. After compilation
  55. one should link with the file containing the compiled curses-source, as well as
  56. with the object-file or library giving you access to the system calls,
  57. gemdos, bios and xbios. You also should link in a file giving you access
  58. to the malloc() and free() calls. ( Note : this is not the GEMDOS Malloc/Mfree
  59. pair, but a malloc() and free(), which should be contained in any decent
  60. standard C-function library. GEMDOS Malloc/Mfree are very buggy indeed.)
  61. There is a difference with UN*X here : the UN*X-curses includes stdio.h
  62. and sgtty.h, whereas Atari-curses includes portab.h and stdio.h. This should
  63. give you the definitions for BYTE, WORD and LONG. 
  64.  Some compilers supply default startup files that don't supply enough heap space
  65. to run curses in, you should adapt these startup files to your liking.
  66.  
  67.    Installing the package.
  68.    
  69.    Compile the file "curses.c" with your favorite C-compiler, to create an
  70. object-file or library, whatever you prefer. Curses.c includes "portab.h"
  71. for BYTE, WORD, LONG, and NULL definitions, osbind.h for system-call macros
  72. and curses.h for its own definitions. Remember curses.h also includes stdio.h.
  73. The code should be portable between various brands of compilers. Forget about
  74. warnings like : warning : pointer substraction yields a long result. 
  75. Not all compilers adhere to Kernighan and Ritchie standards in this respect.
  76. The meaning of each of the constants is given in the table below. In another
  77. table the used system call macro's are given.
  78.  
  79. +---------------+----------------------------------------------------+
  80. | constant name | meaning                                            |
  81. +===============+====================================================+
  82. | BYTE          | a type with at least 8 bits in it, usually a char  |
  83. | WORD          | a type with at least 16 bits in it                 |
  84. | LONG          | a type with at least 32 bits, used for pointers    |
  85. | NULL          | a value assigned to pointers pointing nowhere      |
  86. +---------------+----------------------------------------------------+
  87.  
  88. +---------------+-----------------------------------------------------+
  89. | macro name    | meaning                                             |
  90. +===============+=====================================================+
  91. | Pterm         | gemdos $4c, terminate process and return to caller  |
  92. | Cconis        | gemdos $0b, console character available ?           |
  93. | Crawcin       | gemdos $07, get a raw character from console        |
  94. | Cnecin        | gemdos $08, get a not-so raw character from console |
  95. | Bconout       | bios $03, output a character to a device            |
  96. | Bconstat      | bios $01, get input device status                   |
  97. | Bconin        | bios $02, input a character from a device           |
  98. | Supexec       | xbios $26, execute function in supervisor mode      |
  99. +---------------+-----------------------------------------------------+
  100.  
  101.    Screen updating.
  102.    
  103.    The package defines a data type called WINDOW, which represents what a
  104. section of the terminal may eventually look like. It can be used as a
  105. scratch-pad onto which you can make changes. Only after calling
  106. the function refresh() or wrefresh() an attempt will be made by the package
  107. to make things on the screen look like the things you specified in the
  108. window. Information contained in the window include not only its contents,
  109. but also its size, its starting point and various other information. Two
  110. standard window are defined after initialization of the package, namely
  111. curscr, which constitutes the package's idea of what the screen looks like,
  112. and stdscr, which is a default window to make changes on. It is advised not
  113. to address curscr directly, but first to make changes on another window and
  114. then to call refresh() or wrefresh() to make curscr look like the other
  115. window. Making a change on curscr results in immediate execution of the
  116. change, this greatly reduces any chances of optimization and therefore results
  117. in a sizeable loss of speed ( unless you know what you're doing, of course ).
  118.  
  119.    Naming conventions.
  120.    
  121.    All output and input functions can be used with any window. These functions
  122. have two variants, one to act on the default screen stdscr, and another to
  123. act on any window. An example is the function addch(), which adds a character
  124. to stdscr. The variant, which adds a character to a window w is called
  125. waddch() and takes w as an argument. This convention is used throughout the
  126. package. The routines which do not adhere to this convention always take a 
  127. window as an argument.
  128.    Apart from the w-convention some functions also take a mv- prefix.
  129. Ordinarily one moves the current coordinates of a window by calling
  130. the move or wmove function. Preceding an I/O function by mv first moves
  131. the current coordinates and then performs the I/O function. In this way
  132. one can write the sequence :
  133.  
  134. move(y,x) ;
  135. addch('Q') ;
  136.  
  137. as :
  138.  
  139. mvaddch(y,x,'Q') ;
  140.  
  141. and the sequence :
  142.  
  143. wmove(win,y,x) ;
  144. waddch(win,'W') ;
  145.  
  146. may be replaced by :
  147.  
  148. mvwaddch(win,y,x,'W') ;
  149.  
  150. You may have noticed the following other conventions :
  151. 1. If a window must be specified as a parameter, it is always the first
  152.    parameter.
  153. 2. Coordinates are specified as (y,x) pairs, where y is in the up/down
  154.    direction, and x in the letf/right direction, the coordinate (0,0) is
  155.    in the upper-left corner of the window.
  156.  
  157.  
  158.    Programming with curses.
  159.    
  160.    The following sections deal with programming with the library.
  161. First of all curses should be initialized first. This is done by a call to
  162. initscr(). On return curses will have initialized the screen to a state known
  163. by curses, and have initialized curscr and stdscr, whereas prior to the
  164. initscr() call, any reference to curscr or stdscr will result in bombs.
  165. After calling initscr() you should perform any terminal status changing
  166. routines like crmode() or nonl(), although these may be performed anytime
  167. when curses is active. After that you can set up the screen status using
  168. functions like leaveok() and scrollok() or allocate new windows with newwin()
  169. or subwin(), delete them with delwin(). 
  170.    Calling initscr() again will either result in a redraw of the screen or
  171. another initialization step when the variables LINES or COLS have changed.
  172. This enables you to set the screen size by hand, because normally
  173. the variables LINES and COLS contain the true size of the terminal. Calling
  174. initscr ni such a way again, results in the deletion and regeneration of
  175. curscr and stdscr.
  176.    The basic functions that allow you to change the contents of a window
  177. are addch() and move(). Addch() adds a character to a window and move() moves
  178. the current coordinates. Other output functions exist to let you do some
  179. more elaborate things, like addstr() to add an entire string, insertln() to
  180. insert a line etc.. When you have composed the contents of the window to your
  181. liking you can call refresh() to make the portion of the terminal screen
  182. overlapped by the window look like the window. When updating one must keep
  183. in mind that refresh assumes that parts of the window not changed since the
  184. last update of the window are also not changed on the terminal. Use the
  185. touchwin() function to let curses think the entire window has changed when
  186. using overlapping windows.
  187.    Calling wrefresh() with curscr as an argument results in a complete redraw
  188. of the terminal screen. Because curses has to know what the contents of the
  189. physical screen is at all times, you should not do any other screen output,
  190. than by curses alone. Or if you really have to, do a redraw afterwards. If
  191. you don't, you're bound to end up with some very confused screens.
  192.    Input is done by the getch() function, which inputs a character from the
  193. keyboard and echoes it through addch() if echo is set. When using curses
  194. you may notice that, while performing output and other functions, the cursor
  195. is switched off, when curses waits for input however the cursor is switched
  196. on. Input can be done in either one of three modes : cooked, cbreak and raw.
  197. These input modes are primarily introduced to maintain UN*X-compatability, but
  198. they do not work the same, so when porting UN*X-programs special care should
  199. be taken with any input routines. Moreover, you should not perform any input
  200. through the stdio library, as they will surely echo something on the screen.
  201. UN*X-curses can handle this because it explicitly sets the echo of the terminal
  202. off, whereas Atari-curses only simulates this behaviour. So : any input only
  203. through curses.
  204.    Cooked mode is supposed to be a line-oriented input interface. Using UN*X
  205. and curses, cooked input can only be performed, when echo is not set, if it
  206. is set cooked mode input turns to cbreak mode for the duration of the
  207. input call. Using Atari and curses, the same restrictions apply, with the
  208. exception that the following characters have special meanings :
  209.  
  210. +---------------+-------+------------------------------------------+
  211. | character     | ASCII | action                                   |
  212. +===============+=======+==========================================+
  213. | control-C     |   $03 | do a Pterm(-1), i.e. exit immediately    |
  214. | control-H/BS  |   $08 | do a backspace, not beyond the beginning |
  215. |               |       | of the input-field.                      |
  216. | control-U     |   $13 | kill the entire input field              |
  217. +---------------+-------+------------------------------------------+
  218.  
  219.    Cbreak mode is supposed to be a single character oriented interface, with
  220. which one can receive any character and have no special meaning attached to it.
  221. The only exceptions are job-control characters like control-C ( interrupt ),
  222. delete ( kill the process ), control-Z ( suspend the process ) etc. On Atari
  223. this is translated in the following : all characters are received and only
  224. control-C has special meaning, which is : terminate the process.
  225.    Raw mode is also a single character interface and has no special processing
  226. whatsoever. The same holds for Atari.
  227.    Apart from the above-mentioned functions one should also note that
  228. getch() does not return a character, but a 32-bit value. For UN*X getch()
  229. returns an int, with ( apart from errors ) only the lower 7 or 8 bits set.
  230. On Atari the same holds true for cooked mode, in cbreak mode the ASCII value
  231. is returned in bits 0 to 7 and the scancode of the key in bits 16 to 23, raw
  232. mode adds the keyboard shift state in bits 24 to 30. When entering a string
  233. through getstr() or wgetstr() only the character portion of the long values
  234. are retained.
  235.    Cleaning up is performed by the endwin() function. It releases the storage
  236. acquired for curscr and stdscr, switches the terminal to its normal state
  237. and puts the cursor in a reasonably comfortable place, i.e. at the bottom
  238. of the screen. Note that any windows acquired through newwin() and subwin()
  239. still exist. They should be released from storage prior to calling endwin().  
  240.  
  241.  
  242.    Constants, types and variables defined by curses.h.
  243.    
  244.    The include file curses.h makes several constants, types and variables
  245. available to the programmer. In this section something will be told about
  246. their function and use.
  247.    The most important thing defined in curses.h is the data type WINDOW. This
  248. datatype is used by curses to maintain data for all windows. It has the
  249. following definition :
  250.  
  251. #define      WINDOW         struct _win_st
  252.  
  253. struct _win_st {
  254.     WORD   _cury, _curx ;
  255.     WORD   _maxy, _maxx ;
  256.     WORD   _begy, _begx ;
  257.     WORD   _flags ;
  258.     bool   _clear ;
  259.     bool   _leave ;
  260.     bool   _scroll ;
  261.     WORD   **_y ;
  262.     WORD   *_firstch ;
  263.     WORD   *_lastch ;
  264.     } ;
  265.  
  266. The internals of this structure are not normally to be accessed by the user.
  267. This structure differs in three aspects from the UN*X-curses WINDOW structure.
  268. First of all the _y field is char in UN*X-curses, WORD in Atari-curses. This
  269. had been done to ensure that all characters in the Atari character set, 
  270. including all diacritical marks, can be displayed, whereas UN*X-curses will
  271. only display characters $20-$7f, or standard ASCII characters. As a matter
  272. of act the Atari will display codes $00-$ff, with the exception of tabs,
  273. linefeeds and carriage returns. These have a special meaning.
  274.  Each character can be in standout mode, if so desired. The other changes are
  275. in the _firstch, _lastch fields. This reflects the updating algorithms used.
  276.    The fields have the following meaning : _cury and _curx are the current
  277. coordinates of the window, relative to the window's home, _begy and _begx. This
  278. beginning is relative to the terminals home position (0,0). _maxy and _maxx are
  279. the maximum values allowed for _cury and _curx. _flags is a bit-pattern
  280. of several flags describing the structure of the window. _flags can have 
  281. several values OR'ed into it. _SUBWIN means that the window is a subwindow,
  282. which indicates to delwin() that the character space cannot be freed. The 
  283. _FULLWIN flag indicates that the window is a screen. _STANDOUT means that any
  284. added character is in standout-mode. UN*X-curses also defines the _ENDLINE
  285. and _SCROLLWIN flags, they are defined in curses.h for compatability purposes,
  286. but Atari-curses does nothing with these values. The _clear field in the
  287. WINDOW structure is set when the next refresh on the window should generate
  288. a clear screen sequence. Setting the clear flag for curscr will always
  289. generate a clear screen sequence on any refresh. The _leave field is TRUE
  290. if the windows current coordinates are to be set after the last character
  291. changed on the terminal after a refresh. The _scroll field is TRUE, if
  292. scrolling is allowed. The _y field is a pointer to an array of pointers to
  293. arrays of character values. These values are the actual contents of a window.
  294. The lower 8 bits of a character value contain the real character value, the
  295. upper 8 bits are used by curses internally. The _firstch and _lastch fields
  296. are used by the updating algorithms of curses. Unless you know what you are
  297. doing you are not supposed to tamper with any of these values, curses supplies
  298. a full set of functions to set any values which you want to be set.
  299.    After initializing curses you can be sure the following variables have been
  300. set and initialized to their proper values. Some variables may even be set
  301. prior to initializing curses. This is marked by a & in the table.
  302.  
  303. +----------------+------------+-----------------------------------------------+
  304. | variable name  | type       | description                                   |
  305. +================+============+===============================================+
  306. | curscr         | WINDOW *   | curses idea of what the terminal screen looks |
  307. |                |            | like.                                         |
  308. | stdscr         | WINDOW *   | Default screen for updates.                   |
  309. | Def_term       | char *     | Default terminal type. UN*X-compatability.    |
  310. | My_term      & | bool       | UN*X-compatability, does nothing.             |
  311. | ttytype        | char *     | Full name of the terminal                     |
  312. | LINES        & | int        | Number of ines curses thinks the terminal has |
  313. |                |            | normally 25, but may be changed, see text     |
  314. | COLS         & | int        | Number of columns curses thinks the terminal  |
  315. |                |            | has, may be changed, see text.                |
  316. | ERR            | int        | If this is set, curses had an internal error  |
  317. | OK             | int        | If this is set, everything is gone right      |
  318. +----------------+------------+-----------------------------------------------+
  319.  
  320.    Also the following constants and macros are defined in curses.h :
  321.  
  322. +----------------+------------------------------------------------------------+
  323. | name           | description                                                |
  324. +================+============================================================+
  325. | reg            | storage class register, i.e. register int i => reg int i   |
  326. | bool           | boolean type, values can be TRUE or FALSE                  |
  327. | TRUE           | boolean 'true' flag.                                       |
  328. | FALSE          | boolean 'false' flag.                                      |
  329. +----------------+------------------------------------------------------------+
  330.  
  331.    Another difference between Atari-curses and UN*X-curses is that UN*X-curses
  332. reads in a lot of variables described in /etc/termcap, no such thing exists
  333. for Atari, and is not needed anyway. However these variables are available
  334. to the programmer in UN*X-curses, but not in Atari-curses. These include
  335. things like strings, which when output to the terminal cause some action to be
  336. taken, like the string VB, for a visible bell, or DM, enter delete mode. Care
  337. should be taken with UN*X-programs that perform such actions.
  338.  
  339.  
  340.    Description of individual functions.
  341.    
  342.    The following is a description of all the individual routines, a lot of them
  343. are defined as macros, notably those that take stdscr as the window and
  344. functions that can be preceded by "mv". If such is the case, it is stated by
  345. a '!' a little further on the line.
  346.  
  347.    Output functions.
  348.    
  349.  
  350. addch(c)                  !
  351. char c ;
  352.  
  353. mvaddch(y,x,c)            !
  354. int y,x ;
  355. char c ;
  356.  
  357. mvwaddch(win,y,x,c)       !
  358. WINDOW *win ;
  359. int y,x ;
  360. char c ;
  361.  
  362. waddch(win,c)
  363. WINDOW *win ;
  364. char c ;
  365.  
  366.    Add the character c at the current coordinates of the window w. The
  367. following characters cause special processing : a newline ('\n') causes
  368. the line to be cleared to the end, and the current coordinates to be changed to
  369. the beginning of the next line if newline mapping is on, or to the next line
  370. at the same column if newline mapping isn't on. A return ('\r') will move the
  371. cursor to the beginning of the line on the window. Tabs ('\t') will be
  372. expanded into spaces into the normal tabstop positions of every eight
  373. characters.
  374.    
  375. addstr(s)                 !
  376. char *s ;
  377.  
  378. mvaddstr(y,x,s)           !
  379. int y,x ;
  380. char *s ;
  381.  
  382. mvwaddstr(win,y,x,s)      !
  383. WINDOW *win ;
  384. int y,x ;
  385. char *s ;
  386.  
  387. waddstr(win,s)
  388. WINDOW *win ;
  389. char *s ;
  390.  
  391.    Add the string s to the window at the current coordinates. Addstr() calls
  392. addch repeatedly to add the characters.
  393.  
  394. box(win,vert,hor)
  395. WINDOW *win ;
  396. char vert, hor ;
  397.  
  398. mvbox(win,y,x,vert,hor)   !
  399. WINDOW *win ;
  400. int y, x ;
  401. char vert, hor ;
  402.  
  403.    Draws a box around the window using vert as the vertical drawing character
  404. and hort as the horizontal drawing character.
  405.  
  406. clear()                   !
  407.  
  408. wclear(win)               
  409. WINDOW *win ;
  410.  
  411.    Reset the window to blanks. If win is a screen this will cause a clear
  412. screen sequence to be sent on the next refresh. The current coordinates
  413. are also moved to the home-position (0, 0).
  414.  
  415. clearok(scr, boolf)       !
  416. WINDOW *scr ;
  417. bool boolf
  418.  
  419.    Sets the clear-flag for the screen scr to boolf. If boolf is TRUE this
  420. will generate a clear screen sequence on the next refresh. If it is FALSE
  421. refresh may be stopped from generating a clear screen sequence.
  422.  
  423. clrtobot()                !
  424.  
  425. wclrtobot(win)
  426. WINDOW *win ;
  427.  
  428.    Clear the window from the current coordinates to the bottom. The current
  429. coordinates aren't changed.
  430.  
  431. clrtoeol()                !
  432.  
  433. wclrtoeol(win)
  434. WINDOW *win ;
  435.  
  436.    Clear the window from the current coordinates to the end of the line. This
  437. doesn't change the current coordinates.
  438.  
  439. delch()                   !
  440.  
  441. mvdelch(y,x)              !
  442. int y, x ;
  443.  
  444. mvwdelch(win,y,x)         !
  445. WINDOW *win ;
  446. int y, x ;
  447.  
  448. wdelch(win)
  449. WINDOW *win ;
  450.  
  451.    Delete the character at the current coordinates. Characters on the same
  452. line after the deleted character shift to the left and the last character
  453. becomes blank.
  454.  
  455. deleteln()                !
  456.  
  457. mvdeleteln(y,x)           !
  458. int y, x ;
  459.  
  460. mvwdeleteln(win,y,x)      !
  461. WINDOW *win ;
  462. int y,x ;
  463.  
  464. wdeleteln(win)
  465. WINDOW *win ;
  466.  
  467.    Delete the current line, move every line under it one line up and make the
  468. bottom line blank. This doesn't change the current coordinates.
  469.  
  470. erase()                   !
  471.  
  472. werase(win)
  473. WINDOW *win ;
  474.  
  475.    Sets the entire window to blanks without setting the clear flag. See
  476. clear(). The difference is that erase doesn't cause a clear screen sequence
  477. to be generated.
  478.  
  479. insch(c)                  !
  480. char c ;
  481.  
  482. mvinsch(y,x,c)            !
  483. int y, x ;
  484. char c ;
  485.  
  486. mvwinsch(win,y,x,c)       !
  487. WINDOW *win ;
  488. int y, x ;
  489. char c ;
  490.  
  491.    Insert the character c at the current coordinates. each character after
  492. the current character shifts one place to the right and the rightmost character
  493. falls off.
  494.  
  495. insertln()                !
  496.  
  497. mvinsertln(y,x)           !
  498. int y, x ;
  499.  
  500. mvwinsertln(win,y,x)      !
  501. WINDOW *win ;
  502. int y, x ;
  503.  
  504.    Insert a line above the current line. Every line below will scroll down, and
  505. the bottom line will disappear. The inserted line will be blank. The current
  506. coordinates aren't chnaged by this function.
  507.  
  508. move(y,x)                 !
  509. int y, x ;
  510.  
  511. wmove(win,y,x)
  512. WINDOW *win ;
  513. int y, x ;
  514.  
  515.    Change the current coordinates of window win to (y, x). Whenever one of the
  516. other output or input functions are preceded by "mv", this function is
  517. executed first.
  518.  
  519. overlay(win1,win2)
  520. WINDOW *win1, *win2 ;
  521.  
  522.    The contents of win1 are placed on win2 at their respective starting
  523. coordinates. Those contents of win1, which would not fit in win2, are
  524. discarded. Blanks on win1 leave the contents of win2 untouched.
  525.  
  526. overwrite(win1, win2)
  527. WINDOW *win1, *win2 ;
  528.  
  529.    The contents of win1 are placed on win2 at their respective starting
  530. coordinates. Those contents of win1, which would not fit in win2, are
  531. discarded.
  532.  
  533. refresh()                 !
  534.  
  535. wrefresh(win)
  536. WINDOW *win ;
  537.  
  538.    Update the terminal screen with the contents of the window. Only those parts
  539. covered by the window will be updated. If the window is a screen and its
  540. clear flag has been set, then a clear screen sequence will be generated.
  541.  
  542. mvstandend(y,x)           !
  543. int y, x ;
  544.  
  545. mvwstandend(win,y,x)      !
  546. WINDOW *win ;
  547. int y, x ;
  548.  
  549. standend()                !
  550.  
  551. wstandend(win)
  552. WINDOW *win ;
  553.  
  554.    Stop putting characters onto win in standout mode.
  555.  
  556. mvstandout(y,x)           !
  557. int y, x ;
  558.  
  559. mvwstandout(win,y,x)      !
  560. WINDOW *win ;
  561. int y, x ;
  562.  
  563. standout()                !
  564.  
  565. wstandout(win)
  566. WINDOW *win ;
  567.  
  568.    Start putting characters onto win in standout mode, i.e. display inverted
  569. characters.
  570.  
  571.  
  572.    Input functions.
  573.    
  574.  
  575. crmode()
  576.  
  577.    Set the terminal in cbreak mode.
  578.  
  579. nocrmode()
  580.  
  581.    Reset the terminal from cbreak mode into cooked mode.
  582.  
  583. echo()
  584.  
  585.    Let the terminal echo characters on input.
  586.  
  587. noecho()
  588.  
  589.    Do not allow the terminal to echo characters on input.
  590.  
  591. getch()                   !
  592.  
  593. mvgetch(y,x)              !
  594. int y,x ;
  595.  
  596. mvwgetch(win,y,x)         !
  597. WINDOW *win ;
  598. int y, x ;
  599.  
  600. wgetch(win)
  601. WINDOW *win ;
  602.  
  603.    Get a character from the terminal and echo it on the window if echo is set.
  604. See the section on programming with curses for more details about input modes.
  605. Remember getch() returns a 32-bit value, and not a char.
  606.  
  607. getstr(s)                 !
  608. char *s ;
  609.  
  610. mvgetstr(y,x,s)           !
  611. int y,x ;
  612. char *s ;
  613.  
  614. mvwgetstr(win,y,x,s)      !
  615. WINDOW *win ;
  616. int y, x ;
  617. char *s ;
  618.  
  619. wgetstr(win,s)
  620. WINDOW *win ;
  621. char *s ;
  622.  
  623.    Get a string through the window win and put it in the string s, which is
  624. assumed to be large enough to hold the data. To get the input it calls 
  625. getch() repeatedly. The end of the input is designated by any of the
  626. following characters, a carriage return, a linefeed, a EOF or control-D, and
  627. any character, which results in a '\0'. This character is stripped of the
  628. string and replaced by a null character to indicate the end of the string.
  629.  
  630. raw()
  631.  
  632.    Set the terminal in raw input mode.
  633.  
  634. noraw()
  635.  
  636.    Set the terminal from raw into cooked input mode.
  637.  
  638.  
  639.    Miscellaneous functions.
  640.    
  641.  
  642. delwin(win)
  643. WINDOW *win ;
  644.  
  645.    Deletes the window. All resources ( i.e. storage ) held by the window is
  646. freed for future use. As subwindows share their character space with another
  647. window their character space is not freed. To delete a window with
  648. subwindows, you should first delete the subwindows and then the root window,
  649. as any access to a subwindow after deletion of its parent window is a sure
  650. route to disaster.
  651.  
  652. endwin()
  653.  
  654.    Clean up after curses. You should call this prior to termination of
  655. your program.
  656.  
  657. getyx(win,y,x)            !
  658. WINDOW *win ;
  659. int y,x ;
  660.  
  661.    This macro puts the window current coordinates into the variables y and x.
  662. Note that you do not supply the address of the variables, as it is a macro.
  663.  
  664. inch()                    !
  665.  
  666. mvinch(y,x)               !
  667. int y,x ;
  668.  
  669. mvwinch(w,y,x)            !
  670. WINDOW *w ;
  671. int y, x ;
  672.  
  673. winch(win)                !
  674. WINDOW *win ;
  675.  
  676.    This macro returns the value of the character at the current coordinates
  677. of the window. This does not change the contents of the window. The functions
  678. mvinch() and mvwinch() are not supported by standard UN*X-curses, although
  679. they probably are by most UN*X-implementations.
  680.  
  681. initscr()
  682.  
  683.    Initialize curses. You should call this before any of the other calls.
  684.  
  685. leaveok(win,flag)
  686. WINDOW *win ;
  687. bool   flag ;
  688.  
  689.    Sets the _leave field of the window win to the value flag. If flag is
  690. TRUE then after an update on the terminal, the window's current
  691. coordinates will be set to the coordinates immediately after the last updated
  692. character. If flag is FALSE, then the cursor will be moved to the windows
  693. current coordinates. This flag is FALSE by default.
  694.  
  695. longname(termbuf,name)
  696. char *termbuf, *name ;
  697.  
  698.    Introduced for UN*X-compatability, it returns the contents of ttytype
  699. in name, regardless of the contents of termbuf. This is not really consistent
  700. with UN*X-curses.
  701.  
  702. mvwin(win,y,x)
  703. WINDOW *win ;
  704. int y, x ;
  705.  
  706.    Move the home position of the window win, from its current coordinates to
  707. the coordinates specified in y and x. You cannot move a window off the
  708. terminal screen, not even by a character.
  709.  
  710. WINDOW *newwin(l,c,by,bx)
  711. int l, c, by, bx ;
  712.  
  713.    Create a new window with l lines and c columns starting at position (by,bx).
  714. If either l or c is zero, then the dimension will be set to ( LINES - by ),
  715. ( LINES - bx ). To get a screen, one would say newwin(0,0,0,0).
  716.  
  717. nl()
  718.  
  719.    Set curses to newline mapping. This has consequences for adding the
  720. character '\n'. See addch() for these consequences.
  721.  
  722. nonl()
  723.  
  724.    Set curses to do no newline mapping. This is the default. In UN*X-curses
  725. you get the fastest updates when you have no newline mapping, Atari-curses
  726. doesn't care about it.
  727.  
  728. scrollok(win,flag)
  729.  
  730.    Set the _scroll field of the window win to flag. If flag is FALSE, the
  731. terminal is not allowed to scroll, which is also the default.
  732.  
  733. touchwin(win)
  734. WINDOW *win ;
  735.  
  736.    Force curses to believe that the entire window has changed on the next
  737. refresh. This is useful for overlapping windows.
  738.  
  739. WINDOW *subwin(win,l,c,by,bx)
  740.  
  741.    Create a new window with a shared character space,as opposed to newwin(),
  742. which allocates a new character space. See newwin() for more details about
  743. the l, c, by and bx parameters. The new window will share the character space
  744. with the window win. The subwindow must be smaller or the same size as
  745. the parent window. Changes on either window are reflected on the other window.
  746. Moving subwindows with mvwin() will create some pretty weird results, because
  747. the mapping of the subwindow to the parent window will tend to get displaced.
  748. For instance, if I have a one character subwindow of a screen at coordinates
  749. (2,3) and if I move the subwindow to say (4,5), then if I change the character
  750. on the subwindow at (4,5), the parent window will have changed at (2,3).
  751. I don't know whether this is UN*X-compatible, so take care here.
  752.  
  753.  
  754.    Detail functions.
  755.    
  756.  
  757.    These routines are at the core of UN*X-curses, and can be used on a
  758. standalone basis. Atari-curses has a very limited implemntation of this, so
  759. if a program uses these, you'd better rewrite the whole thing. Most likely,
  760. the results of using these won't be the same on either of the two 
  761. implementations.
  762.  
  763. mvcur(lasty,lastx,newy,newx)
  764. int lasty, lastx, newy, newx ;
  765.  
  766.    Move the terminals cursor from (lasty,lastx) to (newy,newx). Don't use it
  767. when you use any of the screen routines.
  768.  
  769. scroll(win)
  770. WINDOW *win ;
  771.  
  772.    Scroll the window upward one line. You don't normally want to do this.
  773.  
  774.  
  775.    Functions not supported by Atari-curses.
  776.    
  777.  
  778.    Several functions are not supported by Atari-curses, but are by UN*X-curses.
  779. The names of these functions are given, as well as a reason for not
  780. implementing them.
  781.  
  782. mvprintw(), mvwprintw(), printw() and wprintw()
  783.  
  784.    Performs a printf() on a window. I didn't want to implement this for two
  785. reasons :
  786. 1. This introduces compiler dependant code.
  787. 2. A large overhead in coding is required. ( I'm very lazy. )
  788. This omission can easily be gotten around with by inline replacement with :
  789.                  sprintf(a_string, format, ... ) ;
  790.                  addstr(a_string) ;
  791.  
  792. mvscanw(), mvwscanw(), scanw() and wscanw()
  793.  
  794.   Performs a scanf() on a window. The same reasons apply here as the reasons
  795. for printw(). Replace it inline with :
  796.                  getstr(a_string) ;
  797.                  sscanf(a_string, format, ... ) ;
  798.  
  799. uncntrl()
  800.  
  801.   Returns a string which is a representation of a character, nice debugging
  802. feature for UN*X-curses, but pretty meaningless for Atari-curses as
  803. Atari-curses can show any character.
  804.  
  805. gettmode()
  806.  
  807.    A function called by UN*X-initscr(), it gets tty stats, which is
  808. UN*X-dependant anyway.
  809.  
  810. savetty() and resetty()
  811.  
  812.    Save and reset tty characteristics, used by UN*X-curses to initialize and
  813. clean up respectively. Not necessary on Atari.
  814.  
  815. setterm(name)
  816.  
  817.    Set terminal characteristics to those of the terminal with name name.
  818. Pretty useless on Atari.
  819.  
  820. tstp()
  821.  
  822.    Function which is used in UN*X-curses to save the current state when a 
  823. process is put to sleep and to restore it when it is restarted. This is the 
  824. normal catch for the signal SIGTSTP, which Atari users won't be able to receive
  825. anyway.
  826.  
  827.  
  828.    Caveats and bugs.
  829.    
  830.  
  831.    There are differences between Atari-curses and UN*X-curses, especially in
  832. the area of input and the more detailed workings of curses. I will
  833. probably not change the workings of any input routines, because if I did
  834. application programs wouldn't have any control over say function keys, cursor
  835. keys, etc. Such keys really make a difference in user friendly programs, so
  836. I'd better let a programmer have access to them. The more detailed workings
  837. of curses are best left out too, as they concern themselves with multiple types
  838. of terminals, where the Atari-curses is only fitted to a single 
  839. terminaltype, i.e. the Atari's VT52 emulation mode. Another problem
  840. is possibly the low-resolution mode of the Atari, I don't have access to
  841. a color monitor, so I wasn't able to test it in either medium or low-res.
  842. Medium probably works fine, but low-res ?. So, if you don't do anything too
  843. fancy, you should be allright. One more thing : when you write portable
  844. programs, keep in mind that the Atari-curses is a lot faster than any
  845. implementation, which sends data over a terminal line. Comparing speeds
  846. will put any program on the Atari seemingly on a 50+ kilobaud line.
  847. Also beware of funny characters, i.e. portable programs require character
  848. ranges between $20 and $7F, Atari-curses can and will handle a lot more. This
  849. warning should especially be heeded by say Germans and French, diacritical
  850. marks may screw things up real bad.
  851.