home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / EFFO / pd3.lzh / SBPROLOG2.2 / SIM / BUILTIN / pseudo_curses.h < prev    next >
Text File  |  1991-08-10  |  5KB  |  171 lines

  1. /************************************************************************
  2. *                                    *
  3. *    The SB-Prolog System                        *
  4. *    Copyright SUNY at Stony Brook, 1986                *
  5. *                                    *
  6. ************************************************************************/
  7.  
  8. /*-----------------------------------------------------------------
  9. SB-Prolog 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 SB-Prolog General Public
  14. License for full details.
  15.  
  16. Everyone is granted permission to copy, modify and redistribute
  17. SB-Prolog, but only under the conditions described in the
  18. SB-Prolog General Public License.   A copy of this license is
  19. supposed to have been given to you along with SB-Prolog 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. /* This is a part of the file /INCLUDE/CURSES.H.  Because of naming
  26.    conflicts, only part of curses could actually be included in the
  27.    compilation of the DBPROLOG system                            */
  28.  
  29. # ifndef WINDOW
  30.  
  31. # include    <stdio.h>
  32.  
  33. # include    <sgtty.h>
  34.  
  35. # define    bool    char
  36.  
  37.  
  38. # define    TRUE    (1)
  39. # define    FALSE    (0)
  40. # define    ERR    (0)
  41. # define    OK    (1)
  42.  
  43. # define    _ENDLINE    001
  44. # define    _FULLWIN    002
  45. # define    _SCROLLWIN    004
  46. # define    _FLUSH        010
  47. # define    _STANDOUT    0200
  48. # define    _NOCHANGE    -1
  49.  
  50. # define    _puts(s)    tputs(s, 0, _putchar);
  51.  
  52. typedef    struct sgttyb    SGTTY;
  53.  
  54. /*
  55.  * Capabilities from termcap
  56.  */
  57.  
  58. /*
  59.  * From the tty modes...
  60.  */
  61.  
  62. extern bool    NONL, UPPERCASE, normtty, _pfast;
  63.  
  64. struct _win_st {
  65.     short        _cury, _curx;
  66.     short        _maxy, _maxx;
  67.     short        _begy, _begx;
  68.     short        _flags;
  69.     bool        _clear;
  70.     bool        _leave;
  71.     bool        _scroll;
  72.     char        **_y;
  73.     short        *_firstch;
  74.     short        *_lastch;
  75.     struct _win_st    *_nextp, *_orig;
  76. };
  77.  
  78. # define    WINDOW    struct _win_st
  79.  
  80. extern bool    My_term, _echoit, _rawmode, _endwin;
  81.  
  82. extern char    *Def_term, ttytype[];
  83.  
  84. extern int    LINES, COLS, _tty_ch, _res_flg;
  85.  
  86. extern SGTTY    _tty;
  87.  
  88. extern WINDOW    *stdscr, *curscr;
  89.  
  90. /*
  91.  *    Define VOID to stop lint from generating "null effect"
  92.  * comments.
  93.  */
  94. # ifdef lint
  95. int    __void__;
  96. # define    VOID(x)    (__void__ = (int) (x))
  97. # else
  98. # define    VOID(x)    (x)
  99. # endif
  100.  
  101. /*
  102.  * psuedo functions for standard screen
  103.  */
  104. # define    addch(ch)    VOID(waddch(stdscr, ch))
  105. # define    getch()        VOID(wgetch(stdscr))
  106. # define    addstr(str)    VOID(waddstr(stdscr, str))
  107. # define    getstr(str)    VOID(wgetstr(stdscr, str))
  108. # define    move(y, x)    VOID(wmove(stdscr, y, x))
  109. # define    clear()        VOID(wclear(stdscr))
  110. # define    erase()        VOID(werase(stdscr))
  111. # define    clrtobot()    VOID(wclrtobot(stdscr))
  112. # define    clrtoeol()    VOID(wclrtoeol(stdscr))
  113. # define    insertln()    VOID(winsertln(stdscr))
  114. # define    deleteln()    VOID(wdeleteln(stdscr))
  115. # define    refresh()    VOID(wrefresh(stdscr))
  116. # define    inch()        VOID(winch(stdscr))
  117. # define    insch(c)    VOID(winsch(stdscr,c))
  118. # define    delch()        VOID(wdelch(stdscr))
  119. # define    standout()    VOID(wstandout(stdscr))
  120. # define    standend()    VOID(wstandend(stdscr))
  121.  
  122. /*
  123.  * mv functions
  124.  */
  125. #define    mvwaddch(win,y,x,ch)    VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch))
  126. #define    mvwgetch(win,y,x)    VOID(wmove(win,y,x)==ERR?ERR:wgetch(win))
  127. #define    mvwaddstr(win,y,x,str)    VOID(wmove(win,y,x)==ERR?ERR:waddstr(win,str))
  128. #define mvwgetstr(win,y,x,str)  VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
  129. #define    mvwinch(win,y,x)    VOID(wmove(win,y,x) == ERR ? ERR : winch(win))
  130. #define    mvwdelch(win,y,x)    VOID(wmove(win,y,x) == ERR ? ERR : wdelch(win))
  131. #define    mvwinsch(win,y,x,c)    VOID(wmove(win,y,x) == ERR ? ERR:winsch(win,c))
  132. #define    mvaddch(y,x,ch)        mvwaddch(stdscr,y,x,ch)
  133. #define    mvgetch(y,x)        mvwgetch(stdscr,y,x)
  134. #define    mvaddstr(y,x,str)    mvwaddstr(stdscr,y,x,str)
  135. #define mvgetstr(y,x,str)       mvwgetstr(stdscr,y,x,str)
  136. #define    mvinch(y,x)        mvwinch(stdscr,y,x)
  137. #define    mvdelch(y,x)        mvwdelch(stdscr,y,x)
  138. #define    mvinsch(y,x,c)        mvwinsch(stdscr,y,x,c)
  139.  
  140. /*
  141.  * psuedo functions
  142.  */
  143.  
  144. #define    clearok(win,bf)     (win->_clear = bf)
  145. #define    leaveok(win,bf)     (win->_leave = bf)
  146. #define    scrollok(win,bf) (win->_scroll = bf)
  147. #define flushok(win,bf)     (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH))
  148. #define    getyx(win,y,x)     y = win->_cury, x = win->_curx
  149. #define    winch(win)     (win->_y[win->_cury][win->_curx] & 0177)
  150.  
  151. #define raw()     (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, stty(_tty_ch,&_tty))
  152. #define noraw()     (_tty.sg_flags&=~RAW,_rawmode=FALSE,_pfast=!(_tty.sg_flags&CRMOD),stty(_tty_ch,&_tty))
  153. #define crmode() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, stty(_tty_ch,&_tty))
  154. #define nocrmode() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE,stty(_tty_ch,&_tty))
  155. #define echo()     (_tty.sg_flags |= ECHO, _echoit = TRUE, stty(_tty_ch, &_tty))
  156. #define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, stty(_tty_ch, &_tty))
  157. #define nl()     (_tty.sg_flags |= CRMOD,_pfast = _rawmode,stty(_tty_ch, &_tty))
  158. #define nonl()     (_tty.sg_flags &= ~CRMOD, _pfast = TRUE, stty(_tty_ch, &_tty))
  159. #define    savetty() (gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags)
  160. #define    resetty() (_tty.sg_flags = _res_flg, stty(_tty_ch, &_tty))
  161.  
  162. WINDOW    *initscr(), *newwin(), *subwin();
  163. char    *longname(), *getcap();
  164.  
  165. /*
  166.  * Used to be in unctrl.h.
  167.  */
  168. #define    unctrl(c)    _unctrl[(c) & 0177]
  169. extern char *_unctrl[];
  170. # endif
  171.