home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / g__lib / curses.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-23  |  6.1 KB  |  206 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2.  
  3. /* 
  4. Copyright (C) 1989 Free Software Foundation
  5.     written by Eric Newton (newton@rocky.oswego.edu)
  6.  
  7. This file is part of GNU CC.
  8.  
  9. GNU CC is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY.  No author or distributor
  11. accepts responsibility to anyone for the consequences of using it
  12. or for whether it serves any particular purpose or works at all,
  13. unless he says so in writing.  Refer to the GNU CC General Public
  14. License for full details.
  15.  
  16. Everyone is granted permission to copy, modify and redistribute
  17. GNU CC, but only under the conditions described in the
  18. GNU CC General Public License.   A copy of this license is
  19. supposed to have been given to you along with GNU CC so you
  20. can know your rights and responsibilities.  It should be in a
  21. file named COPYING.  Among other things, the copyright notice
  22. and this notice must be preserved on all copies.  
  23. */
  24.  
  25. /*
  26.  * Edited for compatablity with C++, 2/28/89 <ecn>
  27.  * This file has all the /usr/include/curses.h info (with proper prototypes)
  28.  * used for the CursesWindow classes.  You may need to change this to be
  29.  * compatable with your curses implementation.
  30.  *
  31.  */
  32.  
  33. #ifndef _curses_h
  34. #pragma once
  35. #define _curses_h
  36.  
  37. # include   <stddef.h>
  38. # include   <std.h>
  39. # include   <stdio.h> 
  40. extern "C" {
  41. # include   <sgtty.h>
  42. }
  43.  
  44. typedef char cbool; // curses explicitly declares bools as chars
  45.  
  46. enum CursesStatus { ERR = 0, OK = 1 }; // curses lib uses define's
  47.  
  48. /*
  49.  *  BSD'ish.  Warning!!
  50.  *
  51.  */
  52. # define    _ENDLINE    001
  53. # define    _FULLWIN    002
  54. # define    _SCROLLWIN  004
  55. # define    _FLUSH      010
  56. # define    _FULLLINE   020
  57. # define    _IDLINE     040
  58. # define    _STANDOUT   0200
  59. # define    _NOCHANGE   -1
  60.  
  61. # define    _puts(s)    tputs(s, 0, _putchar)
  62.  
  63. /*
  64.  * Capabilities from termcap
  65.  */
  66.  
  67. extern cbool     AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL,
  68.         XB, XN, XT, XS, XX;
  69. extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
  70.         *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
  71.         *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
  72.         *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
  73.         *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
  74.         *VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM,
  75.         *LEFT_PARM, *RIGHT_PARM;
  76.  
  77. extern char PC;
  78.  
  79. extern cbool    GT, NONL, UPPERCASE, normtty, _pfast;
  80.  
  81. struct _win_st {
  82.     short       _cury, _curx;
  83.     short       _maxy, _maxx;
  84.     short       _begy, _begx;
  85.     short       _flags;
  86.     short       _ch_off;
  87.     cbool       _clear;
  88.     cbool       _leave;
  89.     cbool       _scroll;
  90.     char        **_y;
  91.     short       *_firstch;
  92.     short       *_lastch;
  93.     struct _win_st  *_nextp, *_orig;
  94. };
  95.  
  96. #define WINDOW  struct _win_st
  97.  
  98. extern cbool My_term;
  99. extern cbool _echoit;
  100. extern cbool _rawmode;
  101. extern cbool _endwin;
  102.  
  103. extern char *Def_term;
  104. extern char  ttytype[];
  105.  
  106. extern int  LINES;
  107. extern int  COLS; 
  108. extern int  _tty_ch;
  109. extern int  _res_flg;
  110.  
  111.  
  112. typedef struct sgttyb SGTTY;
  113.  
  114. extern SGTTY _tty;
  115.  
  116. /*
  117.  * standard curses functions.
  118.  *
  119.  */
  120.  
  121. extern "C"
  122. {
  123. WINDOW * stdscr;
  124. WINDOW * curscr;
  125. WINDOW * newwin(int lines, int cols, int sy, int sx);
  126. WINDOW * subwin(WINDOW *w, int lines, int cols, int sy, int sx);
  127. WINDOW * initscr();
  128. int      box (WINDOW*, char, char);
  129. int      delwin(WINDOW*);
  130. int      mvcur(int, int, int, int);
  131. int      overlay(WINDOW*, WINDOW*);
  132. int      overwrite(WINDOW*, WINDOW*);
  133. int      scroll(WINDOW*);
  134. int      touchline(WINDOW*, int, int, int);
  135. int      touchoverlap(WINDOW*, WINDOW*);
  136. int      touchwin(WINDOW*);
  137. int      waddch(WINDOW*, char);
  138. int      waddstr(WINDOW*, const char*);
  139. int      wclear(WINDOW*);
  140. int      wclrtobot(WINDOW*);
  141. int      wclrtoeol(WINDOW*);
  142. int      wdelch(WINDOW*);
  143. int      wdeleteln(WINDOW*);
  144. int      werase(WINDOW*);
  145. int      wgetch(WINDOW*);
  146. int      wgetstr(WINDOW*, char*);
  147. int      winch(WINDOW*);
  148. int      winsch(WINDOW*, char);
  149. int      winsertln(WINDOW*);
  150. int      wmove(WINDOW*, int, int);
  151. int      wrefresh(WINDOW*);
  152. int      wstandend(WINDOW*);
  153. int      wstandout(WINDOW*);
  154. int      wprintw(WINDOW*, const char * fmt, ...);
  155. int      mvwprintw(WINDOW*, int y, int x, const char * fmt, ...);
  156. int      wscanw(WINDOW*, const char *, ...);
  157. int      mvwscanw(int, int, WINDOW*, const char*, ...);
  158. int      endwin();
  159. }
  160.  
  161. /* Pseudo functions */
  162. /* 
  163.  * these are inlines rather than defines here so as to allow overloaded
  164.  * versions in the CursesWindow class
  165.  */
  166.  
  167. inline int clearok(WINDOW* win, cbool bf)  { return(win->_clear = bf); }
  168. inline int leaveok(WINDOW* win, cbool bf)  { return(win->_leave = bf); }
  169. inline int scrollok(WINDOW* win, cbool bf) { return(win->_scroll = bf); }
  170. inline int flushok(WINDOW* win, cbool bf)  
  171. { return(bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH)); }
  172. inline void getyx(WINDOW* win, int& y, int& x)   
  173. { y = win->_cury; x = win->_curx; }
  174. inline int winch(WINDOW* win)   { win->_y[win->_cury][win->_curx] & 0177; }
  175.  
  176. /*
  177.  * these are left as define's
  178.  */
  179.  
  180. #define raw()    (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, stty(_tty_ch,&_tty))
  181. #define noraw()  (_tty.sg_flags&=~RAW,_rawmode=FALSE,_pfast=!(_tty.sg_flags&CRMOD),stty(_tty_ch,&_tty))
  182. #define cbreak() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, stty(_tty_ch,&_tty))
  183. #define nocbreak() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE,stty(_tty_ch,&_tty))
  184. #define crmode() cbreak()   /* backwards compatability */
  185. #define nocrmode() nocbreak()   /* backwards compatability */
  186. #define echo()   (_tty.sg_flags |= ECHO, _echoit = TRUE, stty(_tty_ch, &_tty))
  187. #define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, stty(_tty_ch, &_tty))
  188. #define nl()     (_tty.sg_flags |= CRMOD,_pfast = _rawmode,stty(_tty_ch, &_tty))
  189. #define nonl()   (_tty.sg_flags &= ~CRMOD, _pfast = TRUE, stty(_tty_ch, &_tty))
  190. #define savetty() ((void) gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags)
  191. #define resetty() (_tty.sg_flags = _res_flg, stty(_tty_ch, &_tty))
  192.  
  193. #define erasechar() (_tty.sg_erase)
  194. #define killchar()  (_tty.sg_kill)
  195. #define baudrate()  (_tty.sg_ospeed)
  196.  
  197. extern "C" {
  198. char *longname(char *, char *);
  199. char *getcap(char *);
  200. char *_unctrl[];
  201. }
  202.  
  203. inline char * unctrl(int c) {  return _unctrl[(c) & 0177]; }
  204.  
  205. #endif
  206.