home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume2 / window / part4 / curses.h.new < prev    next >
Encoding:
Text File  |  1986-11-30  |  4.7 KB  |  154 lines

  1. /* @(#)curses.h    1.14 (Berkeley) 7/4/83 */
  2. /* Dec 83 Corrections made at University of California, San Francisco */
  3. # ifndef WINDOW
  4.  
  5. # include    <stdio.h>
  6.  
  7. # include    <sgtty.h>
  8. # include    <sys/ioctl.h>
  9.  
  10. # define    bool    char
  11. # define    reg    register
  12.  
  13. # define    TRUE    (1)
  14. # define    FALSE    (0)
  15. # define    ERR    (0)
  16. # define    OK    (1)
  17.  
  18. # define    _ENDLINE    001
  19. # define    _FULLWIN    002
  20. # define    _SCROLLWIN    004
  21. # define    _FLUSH        010
  22. # define    _STANDOUT    0200
  23. # define    _NOCHANGE    -1
  24.  
  25. # define    _puts(s)    tputs(s, 0, _putchar)
  26.  
  27. typedef    struct sgttyb    SGTTY;
  28.  
  29. /*
  30.  * Capabilities from termcap
  31.  */
  32.  
  33. extern bool     AM, BS, CA, DA, DB, EO, GT, HZ, IN, MI, MS, NC, OS, UL,
  34.         XN;
  35. extern char     *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *DC, *DL, *DM,
  36.         *DO, *ED, *EI, *HO, *IC, *IM, *IP, *LL, *MA, *ND, *NL,
  37.         *SE, *SF, *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US,
  38.         *VB, *VE, *VS, PC;
  39.  
  40. /*
  41.  * From the tty modes...
  42.  */
  43.  
  44. extern bool    NONL, UPPERCASE, normtty, _pfast;
  45.  
  46. struct _win_st {
  47.     short        _cury, _curx;
  48.     short        _maxy, _maxx;
  49.     short        _begy, _begx;
  50.     short        _flags;
  51.     bool        _clear;
  52.     bool        _leave;
  53.     bool        _scroll;
  54.     char        **_y;
  55.     short        *_firstch;
  56.     short        *_lastch;
  57.     struct _win_st    *_nextp, *_orig;
  58. };
  59.  
  60. # define    WINDOW    struct _win_st
  61.  
  62. extern bool    My_term, _echoit, _rawmode, _endwin;
  63.  
  64. extern char    *Def_term, ttytype[];
  65.  
  66. extern int    LINES, COLS, _tty_ch, _res_flg;
  67.  
  68. extern SGTTY    _tty;
  69.  
  70. extern WINDOW    *stdscr, *curscr;
  71.  
  72. /*
  73.  *    Define VOID to stop lint from generating "null effect"
  74.  * comments.
  75.  */
  76. # ifdef lint
  77. int    __void__;
  78. # define    VOID(x)    (__void__ = (int) (x))
  79. # else
  80. # define    VOID(x)    (x)
  81. # endif
  82.  
  83. /*
  84.  * psuedo functions for standard screen
  85.  */
  86. # define    addch(ch)    VOID(waddch(stdscr, ch))
  87. # define    getch()        VOID(wgetch(stdscr))
  88. # define    addstr(str)    VOID(waddstr(stdscr, str))
  89. # define    getstr(str)    VOID(wgetstr(stdscr, str))
  90. # define    move(y, x)    VOID(wmove(stdscr, y, x))
  91. # define    clear()        VOID(wclear(stdscr))
  92. # define    erase()        VOID(werase(stdscr))
  93. # define    clrtobot()    VOID(wclrtobot(stdscr))
  94. # define    clrtoeol()    VOID(wclrtoeol(stdscr))
  95. # define    insertln()    VOID(winsertln(stdscr))
  96. # define    deleteln()    VOID(wdeleteln(stdscr))
  97. # define    refresh()    VOID(wrefresh(stdscr))
  98. # define    inch()        VOID(winch(stdscr))
  99. # define    insch(c)    VOID(winsch(stdscr,c))
  100. # define    delch()        VOID(wdelch(stdscr))
  101. # define    standout()    VOID(wstandout(stdscr))
  102. # define    standend()    VOID(wstandend(stdscr))
  103.  
  104. /*
  105.  * mv functions
  106.  */
  107. #define    mvwaddch(win,y,x,ch)    VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch))
  108. #define    mvwgetch(win,y,x)    VOID(wmove(win,y,x)==ERR?ERR:wgetch(win))
  109. #define    mvwaddstr(win,y,x,str)    VOID(wmove(win,y,x)==ERR?ERR:waddstr(win,str))
  110. #define mvwgetstr(win,y,x,str)  VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
  111. #define    mvwinch(win,y,x)    VOID(wmove(win,y,x) == ERR ? ERR : winch(win))
  112. #define    mvwdelch(win,y,x)    VOID(wmove(win,y,x) == ERR ? ERR : wdelch(win))
  113. #define    mvwinsch(win,y,x,c)    VOID(wmove(win,y,x) == ERR ? ERR:winsch(win,c))
  114. #define    mvaddch(y,x,ch)        mvwaddch(stdscr,y,x,ch)
  115. #define    mvgetch(y,x)        mvwgetch(stdscr,y,x)
  116. #define    mvaddstr(y,x,str)    mvwaddstr(stdscr,y,x,str)
  117. #define mvgetstr(y,x,str)       mvwgetstr(stdscr,y,x,str)
  118. #define    mvinch(y,x)        mvwinch(stdscr,y,x)
  119. #define    mvdelch(y,x)        mvwdelch(stdscr,y,x)
  120. #define    mvinsch(y,x,c)        mvwinsch(stdscr,y,x,c)
  121.  
  122. /*
  123.  * psuedo functions
  124.  */
  125.  
  126. #define    clearok(win,bf)     (win->_clear = bf)
  127. #define    leaveok(win,bf)     (win->_leave = bf)
  128. #define    scrollok(win,bf) (win->_scroll = bf)
  129. #define flushok(win,bf)     (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH))
  130. #define    getyx(win,y,x)     y = win->_cury, x = win->_curx
  131. #define    winch(win)     (win->_y[win->_cury][win->_curx] & 0177)
  132.  
  133. #define raw()     (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, ioctl(_tty_ch,TIOCSETN,(char *)&_tty))
  134. #define noraw()     (_tty.sg_flags&=~RAW,_rawmode=FALSE,_pfast=!(_tty.sg_flags&CRMOD),ioctl(_tty_ch,TIOCSETN,(char *)&_tty))
  135. #define crmode() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, ioctl(_tty_ch,TIOCSETN,(char *)&_tty))
  136. #define nocrmode() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE,ioctl(_tty_ch,TIOCSETN,(char *)&_tty))
  137. #define echo()     (_tty.sg_flags |= ECHO, _echoit = TRUE, ioctl(_tty_ch,TIOCSETN,(char *)&_tty))
  138. #define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, ioctl(_tty_ch,TIOCSETN,(char *)&_tty))
  139. /* nl(), nonl() fixed by Mike Lilley and Mike Laman */
  140. #define nl()     (_tty.sg_flags |= CRMOD,_pfast = _tty.sg_flags&RAW,NONL=FALSE,ioctl(_tty_ch,TIOCSETN,(char *)&_tty))
  141. #define nonl()     (_tty.sg_flags &= ~CRMOD, _pfast = TRUE,NONL=TRUE, ioctl(_tty_ch,TIOCSETN,(char *)&_tty))
  142. #define    savetty() ((void)gtty(_tty_ch,&_tty), _res_flg = _tty.sg_flags)
  143. #define    resetty() (_tty.sg_flags = _res_flg, ioctl(_tty_ch,TIOCSETN,(char *)&_tty))
  144.  
  145. WINDOW    *initscr(), *newwin(), *subwin();
  146. char    *longname(), *getcap();
  147.  
  148. /*
  149.  * Used to be in unctrl.h.
  150.  */
  151. #define    unctrl(c)    _unctrl[(c) & 0177]
  152. extern char *_unctrl[];
  153. # endif
  154.