home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / LIB / unix.zoo / curses.h < prev    next >
Text File  |  2009-11-06  |  11KB  |  296 lines

  1. /*********************************************************************
  2. *                         COPYRIGHT NOTICE                           * 
  3. ********************************************************************** 
  4. *        This software is copyright (C) 1982 by Pavel Curtis         * 
  5. *                                                                    * 
  6. *        Permission is granted to reproduce and distribute           * 
  7. *        this file by any means so long as no fee is charged         * 
  8. *        above a nominal handling fee and so long as this            * 
  9. *        notice is always included in the copies.                    * 
  10. *                                                                    * 
  11. *        Other rights are reserved except as explicitly granted      * 
  12. *        by written permission of the author.                        * 
  13. *                Pavel Curtis                                        * 
  14. *                Computer Science Dept.                              * 
  15. *                405 Upson Hall                                      * 
  16. *                Cornell University                                  * 
  17. *                Ithaca, NY 14853                                    * 
  18. *                                                                    * 
  19. *                Ph- (607) 256-4934                                  * 
  20. *                                                                    * 
  21. *                Pavel.Cornell@Udel-Relay   (ARPAnet)                * 
  22. *                decvax!cornell!pavel       (UUCPnet)                * 
  23. *********************************************************************/ 
  24.  
  25. /*
  26.  *      curses.h - Main header file for the curses package 
  27.  * 
  28.  *  $Header:   RCS/curses.v  Revision 2.1  82/10/25  14:46:08  pavel  Exp$ 
  29.  * 
  30.  *  $Log:    RCS/curses.v $
  31. Revision 2.1  82/10/25  14:46:08  pavel
  32. Added Copyright Notice 
  33.  
  34. Revision 2.0  82/10/24  15:17:22  pavel
  35. Beta-one Test Release  
  36.  
  37. Revision 1.4  82/08/23  22:30:13  pavel
  38. The REAL Alpha-one Release Version 
  39.  
  40. Revision 1.3  82/08/20  16:52:46  pavel
  41. Fixed <terminfo.h> bug
  42.  
  43. Revision 1.2  82/08/19  19:10:13  pavel
  44. Alpha Test Release One 
  45.  
  46. Revision 1.1  82/08/12  18:38:57  pavel
  47. Initial revision
  48.  
  49.  * 
  50.  */
  51.  
  52. #include <stdio.h>
  53.  
  54. # ifndef OSK
  55. #include <termio.h>
  56. # endif
  57.  
  58. #ifndef WINDOW 
  59.  
  60. #include <UNIX/terminfo.h>  
  61.  
  62.  
  63. #define bool    char
  64.  
  65.  
  66. #ifndef MINICURSES
  67.     typedef unsigned short  chtype;
  68. #else
  69.     typedef unsigned char   chtype;
  70. #endif  MINICURSES
  71.  
  72.  
  73. #ifndef TRUE
  74. #  define TRUE    (1)
  75. #  define FALSE   (0)
  76. #endif
  77.  
  78. #define ERR     (0)
  79. #define OK      (1)
  80.  
  81. #define _SUBWIN         01
  82. #define _ENDLINE        02
  83. #define _FULLWIN        04
  84. #define _SCROLLWIN      010
  85.  
  86. #define _NOCHANGE       -1
  87.  
  88. struct _win_st {
  89.     short   _cury, _curx;
  90.     short   _maxy, _maxx;
  91.     short   _begy, _begx;
  92.     short   _flags;
  93.     chtype  _attrs;
  94.     bool    _clear;
  95.     bool    _leave;
  96.     bool    _scroll;
  97.     bool    _idlok;
  98.     bool    _use_keypad;    /* 0=no, 1=yes, 2=yes/timeout */
  99.     bool    _use_meta;      /* T=use the meta key */
  100.     bool    _nodelay;       /* T=don't wait for tty input */
  101.     chtype  **_line;
  102.     short   *_firstchar;    /* First changed character in the line */
  103.     short   *_lastchar;     /* Last changed character in the line */
  104.     short   *_numchngd;     /* Number of changes made in the line */
  105.     short    _regtop;    /* Top and bottom of scrolling region */
  106.     short    _regbottom;
  107. };
  108.  
  109. #define WINDOW  struct _win_st
  110.  
  111. extern WINDOW   *stdscr, *curscr;
  112.  
  113. extern int    LINES, COLS;
  114.  
  115. WINDOW  *initscr(), *newwin(), *subwin();
  116. char    *longname();
  117. struct  screen  *newterm(), *set_term();
  118.  
  119.  
  120. /*
  121.  * psuedo functions
  122.  */
  123.  
  124. #define getyx(win,y,x)   (y = (win)->_cury, x = (win)->_curx)
  125.  
  126. #define inch()              winch(stdscr)
  127. #define standout()          wstandout(stdscr)
  128. #define standend()          wstandend(stdscr)
  129. #define attron(at)          wattron(stdscr,at)
  130. #define attroff(at)         wattroff(stdscr,at)
  131. #define attrset(at)         wattrset(stdscr,at)
  132.  
  133. #define winch(win)           ((win)->_line[(win)->_cury][(win)->_curx])
  134. #define wstandout(win)          (wattrset(win,A_STANDOUT))
  135. #define wstandend(win)          (wattrset(win,A_NORMAL))
  136. #define wattron(win,at)         ((win)->_attrs |= (at))
  137. #define wattroff(win,at)        ((win)->_attrs &= ~(at))
  138. #define wattrset(win,at)        ((win)->_attrs = (at))
  139.  
  140.  
  141. #ifndef MINICURSES
  142.     /*
  143.      * psuedo functions for standard screen
  144.      */
  145. #  define addch(ch)       waddch(stdscr, ch)
  146. #  define getch()         wgetch(stdscr)
  147. #  define addstr(str)     waddstr(stdscr, str)
  148. #  define getstr(str)     wgetstr(stdscr, str)
  149. #  define move(y, x)      wmove(stdscr, y, x)
  150. #  define clear()         wclear(stdscr)
  151. #  define erase()         werase(stdscr)
  152. #  define clrtobot()      wclrtobot(stdscr)
  153. #  define clrtoeol()      wclrtoeol(stdscr)
  154. #  define insertln()      winsertln(stdscr)
  155. #  define deleteln()      wdeleteln(stdscr)
  156. #  define refresh()       wrefresh(stdscr)
  157. #  define insch(c)        winsch(stdscr,c)
  158. #  define delch()         wdelch(stdscr)
  159. #  define setscrreg(t,b)  wsetscrreg(stdscr,t,b)
  160.  
  161.         /*
  162.          * mv functions
  163.          */
  164. /*
  165. #  define mvwaddch(win,y,x,ch)    (wmove(win,y,x) == ERR ? ERR : waddch(win,ch))
  166. #  define mvwgetch(win,y,x)       (wmove(win,y,x) == ERR ? ERR : wgetch(win))  
  167. #  define mvwaddstr(win,y,x,str)  (wmove(win,y,x) == ERR ? ERR : waddstr(win,str))
  168. #  define mvwgetstr(win,y,x,str)  (wmove(win,y,x) == ERR ? ERR : wgetstr(win,str)) 
  169. #  define mvwinch(win,y,x)        (wmove(win,y,x) == ERR ? ERR : winch(win))
  170. #  define mvwdelch(win,y,x)       (wmove(win,y,x) == ERR ? ERR : wdelch(win))  
  171. #  define mvwinsch(win,y,x,c)     (wmove(win,y,x) == ERR ? ERR : winsch(win,c))
  172. */
  173. #  define mvaddch(y,x,ch)         mvwaddch(stdscr,y,x,ch)
  174. #  define mvgetch(y,x)            mvwgetch(stdscr,y,x)
  175. #  define mvaddstr(y,x,str)       mvwaddstr(stdscr,y,x,str)
  176. #  define mvgetstr(y,x,str)       mvwgetstr(stdscr,y,x,str)
  177. #  define mvinch(y,x)             mvwinch(stdscr,y,x)
  178. #  define mvdelch(y,x)            mvwdelch(stdscr,y,x)
  179. #  define mvinsch(y,x,c)          mvwinsch(stdscr,y,x,c)
  180.  
  181. #else MINICURSES
  182.  
  183. #  define addch              m_addch
  184. #  define addstr                  m_addstr
  185. #  define erase                   m_erase
  186. #  define clear                   m_clear
  187. #  define refresh                 m_refresh
  188. #  define initscr                 m_initscr
  189. #  define newterm                 m_newterm
  190. #  define mvaddch(y,x,ch)         (move(y,x) == ERR ? ERR : addch(ch))
  191. #  define mvaddstr(y,x,str)       (move(y,x) == ERR ? ERR : addstr(str))
  192.  
  193. /*
  194.  * These functions don't exist in minicurses, so we define them
  195.  * to nonexistent functions to help the user catch the error.
  196.  */
  197. #  define box             no_box
  198. #  define clrtobot        no_clrtobot
  199. #  define clrtoeol        no_clrtoeol
  200. #  define delch           no_delch
  201. #  define deleteln        no_deleteln
  202. #  define delwin          no_delwin
  203. #  define getch           no_getch
  204. #  define getstr          no_getstr
  205. #  define insch           no_insch
  206. #  define insertln        no_insertln
  207. #  define longname        no_longname
  208. #  define mvprintw        no_mvprintw
  209. #  define mvscanw         no_mvscanw
  210. #  define mvwin           no_mvwin
  211. #  define mvwprintw       no_mvwprintw
  212. #  define mvwscanw        no_mvwscanw
  213. #  define newwin          no_newwin
  214. #  define overlay         no_overlay
  215. #  define overwrite       no_overwrite
  216. #  define printw          no_printw
  217. #  define putp            no_putp
  218. #  define scanw           no_scanw
  219. #  define scroll          no_scroll
  220. #  define setscrreg       no_setscrreg
  221. #  define subwin          no_subwin
  222. #  define touchwin        no_touchwin
  223. #  define tstp            no_tstp
  224. #  define vidattr         no_vidattr
  225. #  define waddch          no_waddch
  226. #  define waddstr         no_waddstr
  227. #  define wclear          no_wclear
  228. #  define wclrtobot       no_wclrtobot
  229. #  define wclrtoeol       no_wclrtoeol
  230. #  define wdelch          no_wdelch
  231. #  define wdeleteln       no_wdeleteln
  232. #  define werase          no_werase
  233. #  define wgetch          no_wgetch
  234. #  define wgetstr         no_wgetstr
  235. #  define winsch          no_winsch
  236. #  define winsertln       no_winsertln
  237. #  define wmove           no_wmove
  238. #  define wprintw         no_wprintw
  239. #  define wrefresh        no_wrefresh
  240. #  define wscanw          no_wscanw
  241. #  define wsetscrreg      no_wsetscrreg
  242.  
  243. /* mv functions that aren't valid */
  244. #  define mvdelch         no_mvwdelch 
  245. #  define mvgetch         no_mvwgetch 
  246. #  define mvgetstr        no_mvwgetstr
  247. #  define mvinch          no_mvwinch
  248. #  define mvinsch         no_mvwinsch
  249. #  define mvwaddch        no_mvwaddch
  250. #  define mvwaddstr       no_mvaddstr
  251. #  define mvwdelch        no_mvwdelch
  252. #  define mvwgetch        no_mvwgetch
  253. #  define mvwgetstr       no_mvwgetstr
  254. #  define mvwinch         no_mvwinch
  255. #  define mvwinsch        no_mvwinsch
  256.  
  257. #endif MINICURSES
  258.  
  259.  
  260. #ifndef MINICURSES
  261. /* Funny "characters" enabled for various special function keys for input */
  262. #define KEY_BREAK       0401            /* break key (unreliable) */
  263. #define KEY_DOWN        0402            /* The four arrow keys ... */
  264. #define KEY_UP          0403
  265. #define KEY_LEFT        0404
  266. #define KEY_RIGHT       0405            /* ... */
  267. #define KEY_HOME        0406            /* Home key (upward+left arrow) */
  268. #define KEY_BACKSPACE   0407            /* backspace (unreliable) */
  269. #define KEY_F0          0410            /* Function keys.  Space for 64 */
  270. #define KEY_F(n)        (KEY_F0+(n))    /* keys is reserved. */
  271. #define KEY_DL          0510            /* Delete line */
  272. #define KEY_IL          0511            /* Insert line */
  273. #define KEY_DC          0512            /* Delete character */
  274. #define KEY_IC          0513            /* Insert char or enter insert mode */ 
  275. #define KEY_EIC         0514            /* Exit insert char mode */
  276. #define KEY_CLEAR       0515            /* Clear screen */
  277. #define KEY_EOS         0516            /* Clear to end of screen */
  278. #define KEY_EOL         0517            /* Clear to end of line */
  279. #define KEY_SF          0520            /* Scroll 1 line forward */
  280. #define KEY_SR          0521            /* Scroll 1 line backwards (reverse) */
  281. #define KEY_NPAGE       0522            /* Next page */
  282. #define KEY_PPAGE       0523            /* Previous page */
  283. #define KEY_STAB        0524            /* Set tab */
  284. #define KEY_CTAB        0525            /* Clear tab */
  285. #define KEY_CATAB       0526            /* Clear all tabs */
  286. #define KEY_ENTER       0527            /* Enter or send (unreliable) */
  287. #define KEY_SRESET      0530            /* soft (partial) reset (unreliable) */
  288. #define KEY_RESET       0531            /* reset or hard reset (unreliable) */ 
  289. #define KEY_PRINT       0532            /* print or copy */
  290. #define KEY_LL          0533            /* home down or bottom (lower left) */ 
  291.  
  292. #endif MINICURSES
  293.  
  294. #endif WINDOW
  295.  
  296.