home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / djgpp / include / curses.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-03  |  8.1 KB  |  343 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. #ifdef __GNUG__
  35. #pragma once
  36. #pragma interface
  37. #endif
  38. #define _curses_h
  39.  
  40. # include   <stddef.h>
  41. # include   <std.h>
  42. # include   <stdio.h> 
  43. extern "C" {
  44. #ifndef VMS
  45. # include   <sgtty.h>
  46. #endif
  47.  
  48. // protection against possibility that these are macros:
  49.  
  50. #ifndef stty
  51. extern int stty(int, struct sgttyb*); 
  52. #endif
  53.  
  54. #ifndef gtty
  55. extern int gtty(int, struct sgttyb*); 
  56. #endif
  57.  
  58. }
  59.  
  60. typedef char cbool; // curses explicitly declares bools as chars
  61.  
  62. #if defined(hpux)
  63. enum CursesStatus { ERR = -1, OK = 0 };        // curses lib uses define's
  64. #else
  65. enum CursesStatus { ERR = 0, OK = 1 };        // curses lib uses define's
  66. #endif
  67.  
  68. /*
  69.  *  BSD'ish.  Warning!!
  70.  *
  71.  */
  72. # define    _ENDLINE    001
  73. # define    _FULLWIN    002
  74. # define    _SCROLLWIN  004
  75. # define    _FLUSH      010
  76. # define    _FULLLINE   020
  77. # define    _IDLINE     040
  78. # define    _STANDOUT   0200
  79. # define    _NOCHANGE   -1
  80.  
  81. # define    _puts(s)    tputs(s, 0, _putchar)
  82.  
  83. /*
  84.  * Capabilities from termcap
  85.  */
  86.  
  87. extern cbool     AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL,
  88.         XB, XN, XT, XS, XX;
  89. extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
  90.         *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
  91.         *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
  92.         *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
  93.         *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
  94.         *VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM,
  95.         *LEFT_PARM, *RIGHT_PARM;
  96.  
  97. extern char PC;
  98.  
  99. extern cbool    GT, NONL, UPPERCASE, normtty, _pfast;
  100.  
  101. struct _win_st {
  102. #ifdef VMS
  103.     int        _cury, _curx;
  104.     int        _maxy, _maxx;
  105.     int        _begy, _begx;
  106. #else
  107.     short       _cury, _curx;
  108.     short       _maxy, _maxx;
  109.     short       _begy, _begx;
  110. #endif
  111.     short       _flags;
  112. #ifndef VMS
  113.     short       _ch_off;
  114. #endif
  115.     cbool       _clear;
  116.     cbool       _leave;
  117.     cbool       _scroll;
  118. #ifdef VMS
  119.     cbool    _wrap;
  120. #endif
  121.     char        **_y;
  122.     short       *_firstch;
  123.     short       *_lastch;
  124.     struct _win_st  *_nextp, *_orig;
  125. #ifdef VMS
  126.     struct _win_st  *_parent , *_child;
  127.     int        _id;
  128. #endif
  129. };
  130.  
  131. #define WINDOW  struct _win_st
  132.  
  133. extern cbool My_term;
  134. extern cbool _echoit;
  135. extern cbool _rawmode;
  136. extern cbool _endwin;
  137.  
  138. extern char *Def_term;
  139. extern char  ttytype[];
  140.  
  141. extern int  LINES;
  142. extern int  COLS; 
  143. extern int  _tty_ch;
  144. extern int  _res_flg;
  145.  
  146.  
  147. typedef struct sgttyb SGTTY;
  148.  
  149. extern SGTTY _tty;
  150.  
  151. /*
  152.  * standard curses functions.
  153.  *
  154.  */
  155.  
  156. extern "C"
  157. {
  158. extern WINDOW * stdscr;
  159. extern WINDOW * curscr;
  160. WINDOW * newwin(int lines, int cols, int sy, int sx);
  161. WINDOW * subwin(WINDOW *w, int lines, int cols, int sy, int sx);
  162. WINDOW * initscr();
  163. int      box (WINDOW*, char, char);
  164. int      delwin(WINDOW*);
  165. int      mvcur(int, int, int, int);
  166. int      overlay(WINDOW*, WINDOW*);
  167. int      overwrite(WINDOW*, WINDOW*);
  168. int      scroll(WINDOW*);
  169. int      touchwin(WINDOW*);
  170. int      waddch(WINDOW*, char);
  171. int      waddstr(WINDOW*, const char*);
  172. int      wclear(WINDOW*);
  173. int      wclrtobot(WINDOW*);
  174. int      wclrtoeol(WINDOW*);
  175. int      wdelch(WINDOW*);
  176. int      wdeleteln(WINDOW*);
  177. int      werase(WINDOW*);
  178. int      wgetch(WINDOW*);
  179. int      wgetstr(WINDOW*, char*);
  180. int      winsch(WINDOW*, char);
  181. int      winsertln(WINDOW*);
  182. int      wmove(WINDOW*, int, int);
  183. int      wrefresh(WINDOW*);
  184. int      wstandend(WINDOW*);
  185. int      wstandout(WINDOW*);
  186. int      wprintw(WINDOW*, const char * fmt, ...);
  187. int      mvwprintw(WINDOW*, int y, int x, const char * fmt, ...);
  188. int      wscanw(WINDOW*, const char *, ...);
  189. int      mvwscanw(int, int, WINDOW*, const char*, ...);
  190. int      endwin();
  191. }
  192.  
  193. /* Pseudo functions */
  194. /* 
  195.  * these are inlines rather than defines here so as to allow overloaded
  196.  * versions in the CursesWindow class
  197.  */
  198.  
  199. int clearok(WINDOW* win, cbool bf);
  200. int leaveok(WINDOW* win, cbool bf);
  201. int scrollok(WINDOW* win, cbool bf);
  202. int flushok(WINDOW* win, cbool bf);
  203. void getyx(WINDOW* win, int& y, int& x);
  204. int winch(WINDOW* win);
  205.  
  206. #if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
  207.  
  208. inline int clearok(WINDOW* win, cbool bf)  { return(win->_clear = bf); }
  209. inline int leaveok(WINDOW* win, cbool bf)  { return(win->_leave = bf); }
  210. inline int scrollok(WINDOW* win, cbool bf) { return(win->_scroll = bf); }
  211. inline int flushok(WINDOW* win, cbool bf)  
  212. { return(bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH)); }
  213. inline void getyx(WINDOW* win, int& y, int& x)   
  214. { y = win->_cury; x = win->_curx; }
  215. inline int winch(WINDOW* win)   
  216. {return  win->_y[win->_cury][win->_curx] & 0177; }
  217.  
  218. #endif /* __OPTIMIZE__ */
  219.  
  220. #if defined(USG) || defined(VMS)
  221. extern "C" {
  222. int raw();
  223. int noraw();
  224. int cbreak();
  225. int nocbreak();
  226. }
  227.  
  228. #else
  229.  
  230. int raw();
  231. int noraw();
  232. int cbreak();
  233. int nocbreak();
  234.  
  235. #if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
  236.  
  237. inline int raw()    
  238. { return _tty.sg_flags|=RAW, _pfast=_rawmode=1, stty(_tty_ch,&_tty); }
  239. inline int noraw()  
  240. { return _tty.sg_flags&=~RAW,_rawmode=0,_pfast=!(_tty.sg_flags&CRMOD),stty(_tty_ch,&_tty); }
  241. inline int cbreak() 
  242. { return _tty.sg_flags |= CBREAK, _rawmode = 1, stty(_tty_ch,&_tty); }
  243. inline int nocbreak() 
  244. { return _tty.sg_flags &= ~CBREAK,_rawmode=0,stty(_tty_ch,&_tty); }
  245.  
  246. #endif /* __ OPTIMIZE __ */
  247.  
  248. #endif /* USG */
  249.  
  250.  
  251. int crmode();
  252. int nocrmode();
  253.  
  254. #if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
  255.  
  256. inline int crmode() { return  cbreak(); }
  257. inline int nocrmode() { return  nocbreak(); }
  258.  
  259. #endif /* __ OPTIMIZE __ */
  260.  
  261. #if defined(USG) || defined(VMS)
  262.  
  263. extern "C" {
  264. int _setecho(int);
  265. int _setnonl(int);
  266. }
  267.  
  268. int echo();
  269. int noecho();
  270. int nl();
  271. int nonl();
  272.  
  273. #if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
  274.  
  275. inline int echo()   { return _setecho(1); }
  276. inline int noecho() { return _setecho(0); }
  277. inline int nl()     { return _setnonl(0); }
  278. inline int nonl()   { return _setnonl(1); }
  279.  
  280. #endif /* __ OPTIMIZE __ */
  281.  
  282. extern "C" {
  283. int savetty();
  284. int resetty();
  285. int erasechar();
  286. int killchar();
  287. int baudrate();
  288. }
  289.  
  290. #else /* not USG */
  291.  
  292. int echo();
  293. int noecho();
  294. int nl();
  295. int nonl();
  296. int savetty();
  297. inline int resetty();
  298. int erasechar();
  299. int killchar();
  300. int baudrate();
  301.  
  302. #if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
  303.  
  304. inline int echo()   
  305. { return _tty.sg_flags |= ECHO, _echoit = 1, stty(_tty_ch, &_tty); }
  306. inline int noecho() 
  307. { return _tty.sg_flags &= ~ECHO, _echoit = 0, stty(_tty_ch, &_tty); }
  308. inline int nl()     
  309. { return _tty.sg_flags |= CRMOD,_pfast = _rawmode,stty(_tty_ch, &_tty); }
  310. inline int nonl()   
  311. { return _tty.sg_flags &= ~CRMOD, _pfast = 1, stty(_tty_ch, &_tty); }
  312. inline int savetty() 
  313. { return (void) gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags; }
  314. inline int resetty() 
  315. { return _tty.sg_flags = _res_flg, stty(_tty_ch, &_tty); }
  316. inline int erasechar() 
  317. { return _tty.sg_erase; }
  318. inline int killchar()  
  319. { return _tty.sg_kill; }
  320. inline int baudrate()  
  321. { return _tty.sg_ospeed; }
  322.  
  323. #endif /* __ OPTIMIZE __ */
  324.  
  325. #endif /* USG */
  326.  
  327. extern "C" {
  328. char *longname(char *, char *);
  329. char *getcap(char *);
  330. extern char *_unctrl[];
  331. }
  332.  
  333.  
  334. char * unctrl(int c);
  335.  
  336. #if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
  337.  
  338. inline char * unctrl(int c) {  return _unctrl[(c) & 0177]; }
  339.  
  340. #endif /* __ OPTIMIZE __ */
  341.  
  342. #endif
  343.