home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / GNU_1OF3.ZIP / HEADERS.ZIP / g++-include / curses.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-06  |  7.2 KB  |  289 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2.  
  3. /* 
  4. Copyright (C) 1989, 1992 Free Software Foundation
  5.     written by Eric Newton (newton@rocky.oswego.edu)
  6.  
  7. This file is part of the GNU C++ Library.  This library is free
  8. software; you can redistribute it and/or modify it under the terms of
  9. the GNU Library General Public License as published by the Free
  10. Software Foundation; either version 2 of the License, or (at your
  11. option) any later version.  This library is distributed in the hope
  12. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  13. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  14. PURPOSE.  See the GNU Library General Public License for more details.
  15. You should have received a copy of the GNU Library General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. /*
  21.  * Edited for compatablity with C++, 2/28/89 <ecn>
  22.  * This file has all the /usr/include/curses.h info (with proper prototypes)
  23.  * used for the CursesWindow classes.  You may need to change this to be
  24.  * compatable with your curses implementation.
  25.  *
  26.  */
  27.  
  28. #ifndef _curses_h
  29. #ifdef __GNUG__
  30. #pragma interface
  31. #endif
  32. #define _curses_h
  33.  
  34. # include   <stddef.h>
  35. # include   <std.h>
  36. # include   <stdio.h> 
  37. extern "C" {
  38. #ifndef VMS
  39. # include   <sgtty.h>
  40. #endif
  41.  
  42. // protection against possibility that these are macros:
  43.  
  44. #ifndef stty
  45. extern int stty(int, struct sgttyb*); 
  46. #endif
  47.  
  48. #ifndef gtty
  49. extern int gtty(int, struct sgttyb*); 
  50. #endif
  51.  
  52. int       tputs(const char *, int, auto int (*)());
  53. int       tgetent(const char*, const char*);
  54. int       tgetnum(const char*);
  55. int       tgetflag(const char*);
  56. char*     tgetstr(const char *, char **);
  57. char*     tgoto(const char*, int, int);
  58.  
  59. }
  60.  
  61. typedef char cbool; // curses explicitly declares bools as chars
  62.  
  63. #if defined(hpux)
  64. #define ERR -1
  65. #define OK 0
  66. #else
  67. #define ERR 0
  68. #define OK 1
  69. #endif
  70.  
  71. /*
  72.  *  BSD'ish.  Warning!!
  73.  *
  74.  */
  75. # define    _ENDLINE    001
  76. # define    _FULLWIN    002
  77. # define    _SCROLLWIN  004
  78. # define    _FLUSH      010
  79. # define    _FULLLINE   020
  80. # define    _IDLINE     040
  81. # define    _STANDOUT   0200
  82. # define    _NOCHANGE   -1
  83.  
  84. # define    _puts(s)    tputs(s, 0, _putchar)
  85.  
  86. /*
  87.  * Capabilities from termcap
  88.  */
  89.  
  90. extern cbool     AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL,
  91.         XB, XN, XT, XS, XX;
  92. extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
  93.         *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
  94.         *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
  95.         *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
  96.         *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
  97.         *VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM,
  98.         *LEFT_PARM, *RIGHT_PARM;
  99.  
  100. extern char PC;
  101.  
  102. extern cbool    GT, NONL, UPPERCASE, normtty, _pfast;
  103.  
  104. struct _win_st {
  105. #ifdef VMS
  106.     int        _cury, _curx;
  107.     int        _maxy, _maxx;
  108.     int        _begy, _begx;
  109. #else
  110.     short       _cury, _curx;
  111.     short       _maxy, _maxx;
  112.     short       _begy, _begx;
  113. #endif
  114.     short       _flags;
  115. #ifndef VMS
  116.     short       _ch_off;
  117. #endif
  118.     cbool       _clear;
  119.     cbool       _leave;
  120.     cbool       _scroll;
  121. #ifdef VMS
  122.     cbool    _wrap;
  123. #endif
  124.     char        **_y;
  125.     short       *_firstch;
  126.     short       *_lastch;
  127.     struct _win_st  *_nextp, *_orig;
  128. #ifdef VMS
  129.     struct _win_st  *_parent , *_child;
  130.     int        _id;
  131. #endif
  132. };
  133.  
  134. #define WINDOW  struct _win_st
  135.  
  136. extern cbool My_term;
  137. extern cbool _echoit;
  138. extern cbool _rawmode;
  139. extern cbool _endwin;
  140.  
  141. extern char *Def_term;
  142. extern char  ttytype[];
  143.  
  144. extern int  LINES;
  145. extern int  COLS; 
  146. extern int  _tty_ch;
  147. extern int  _res_flg;
  148.  
  149.  
  150. typedef struct sgttyb SGTTY;
  151.  
  152. extern SGTTY _tty;
  153.  
  154. /*
  155.  * standard curses functions.
  156.  *
  157.  */
  158.  
  159. extern "C"
  160. {
  161. extern WINDOW * stdscr;
  162. extern WINDOW * curscr;
  163. WINDOW * newwin(int lines, int cols, int sy, int sx);
  164. WINDOW * subwin(WINDOW *w, int lines, int cols, int sy, int sx);
  165. WINDOW * initscr();
  166. int      box (WINDOW*, char, char);
  167. int      delwin(WINDOW*);
  168. int      mvcur(int, int, int, int);
  169. int      overlay(WINDOW*, WINDOW*);
  170. int      overwrite(WINDOW*, WINDOW*);
  171. int      scroll(WINDOW*);
  172. int      touchwin(WINDOW*);
  173. int      waddch(WINDOW*, char);
  174. int      waddstr(WINDOW*, const char*);
  175. int      wclear(WINDOW*);
  176. int      wclrtobot(WINDOW*);
  177. int      wclrtoeol(WINDOW*);
  178. int      wdelch(WINDOW*);
  179. int      wdeleteln(WINDOW*);
  180. int      werase(WINDOW*);
  181. int      wgetch(WINDOW*);
  182. int      wgetstr(WINDOW*, char*);
  183. int      winsch(WINDOW*, char);
  184. int      winsertln(WINDOW*);
  185. int      wmove(WINDOW*, int, int);
  186. int      wrefresh(WINDOW*);
  187. int      wstandend(WINDOW*);
  188. int      wstandout(WINDOW*);
  189. int      wprintw(WINDOW*, const char * fmt, ...);
  190. int      mvwprintw(WINDOW*, int y, int x, const char * fmt, ...);
  191. int      wscanw(WINDOW*, const char *, ...);
  192. int      mvwscanw(int, int, WINDOW*, const char*, ...);
  193. int      endwin();
  194. }
  195.  
  196. /* Pseudo functions */
  197. /* 
  198.  * these are inlines rather than defines here so as to allow overloaded
  199.  * versions in the CursesWindow class
  200.  */
  201.  
  202. inline int clearok(WINDOW* win, cbool bf)  { return(win->_clear = bf); }
  203. inline int leaveok(WINDOW* win, cbool bf)  { return(win->_leave = bf); }
  204. inline int scrollok(WINDOW* win, cbool bf) { return(win->_scroll = bf); }
  205. inline int flushok(WINDOW* win, cbool bf)  
  206. { return(bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH)); }
  207. inline void getyx(WINDOW* win, int& y, int& x)   
  208. { y = win->_cury; x = win->_curx; }
  209. inline int winch(WINDOW* win)   
  210. {return  win->_y[win->_cury][win->_curx] & 0177; }
  211.  
  212. #if defined(USG) || defined(VMS)
  213. extern "C" {
  214. int raw();
  215. int noraw();
  216. int cbreak();
  217. int nocbreak();
  218. }
  219.  
  220. #else
  221.  
  222. inline int raw()    
  223. { return _tty.sg_flags|=RAW, _pfast=_rawmode=1, stty(_tty_ch,&_tty); }
  224. inline int noraw()  
  225. { return _tty.sg_flags&=~RAW,_rawmode=0,_pfast=!(_tty.sg_flags&CRMOD),stty(_tty_ch,&_tty); }
  226. inline int cbreak() 
  227. { return _tty.sg_flags |= CBREAK, _rawmode = 1, stty(_tty_ch,&_tty); }
  228. inline int nocbreak() 
  229. { return _tty.sg_flags &= ~CBREAK,_rawmode=0,stty(_tty_ch,&_tty); }
  230.  
  231. #endif /* USG */
  232.  
  233.  
  234. #if defined(USG) || defined(VMS)
  235.  
  236. extern "C" {
  237. int _setecho(int);
  238. int _setnonl(int);
  239. }
  240.  
  241. inline int echo()   { return _setecho(1); }
  242. inline int noecho() { return _setecho(0); }
  243. inline int nl()     { return _setnonl(0); }
  244. inline int nonl()   { return _setnonl(1); }
  245.  
  246. extern "C" {
  247. int savetty();
  248. int resetty();
  249. int erasechar();
  250. int killchar();
  251. int baudrate();
  252. }
  253.  
  254. #else /* not USG */
  255.  
  256. inline int echo()   
  257. { return _tty.sg_flags |= ECHO, _echoit = 1, stty(_tty_ch, &_tty); }
  258. inline int noecho() 
  259. { return _tty.sg_flags &= ~ECHO, _echoit = 0, stty(_tty_ch, &_tty); }
  260. inline int nl()     
  261. { return _tty.sg_flags |= CRMOD,_pfast = _rawmode,stty(_tty_ch, &_tty); }
  262. inline int nonl()   
  263. { return _tty.sg_flags &= ~CRMOD, _pfast = 1, stty(_tty_ch, &_tty); }
  264. inline int savetty() 
  265. { return (void) gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags; }
  266. inline int resetty() 
  267. { return _tty.sg_flags = _res_flg, stty(_tty_ch, &_tty); }
  268. inline int erasechar() 
  269. { return _tty.sg_erase; }
  270. inline int killchar()  
  271. { return _tty.sg_kill; }
  272. inline int baudrate()  
  273. { return _tty.sg_ospeed; }
  274.  
  275. #endif /* USG */
  276.  
  277. extern "C" {
  278. char *longname(char *, char *);
  279. char *getcap(char *);
  280. extern char *_unctrl[];
  281. }
  282.  
  283. inline int crmode() { return  cbreak(); }
  284. inline int nocrmode() { return  nocbreak(); }
  285. inline char * unctrl(int c) {  return _unctrl[(c) & 0177]; }
  286.  
  287. #endif
  288.  
  289.