home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / program / d / elvis / Source / h / curses next >
Encoding:
Text File  |  1990-03-18  |  4.9 KB  |  112 lines

  1. /* curses.h */
  2.  
  3. /* This is the header file for a small, fast, fake curses package */
  4.  
  5. /* termcap stuff */
  6. extern char     *tgoto();
  7.  
  8. /* faddch() is a function.  a pointer to it is passed to tputs() */
  9. extern int      faddch();
  10.  
  11. /* data types */
  12. #define ushort  unsigned short
  13. #define WINDOW  char
  14.  
  15. /* CONSTANTS & SYMBOLS */
  16. #define TRUE            1
  17. #define FALSE           0
  18. #define A_NORMAL        0
  19. #define A_STANDOUT      1
  20. #define A_BOLD          2
  21. #define A_UNDERLINE     3
  22. #define A_ALTCHARSET    4
  23. #define KBSIZ           6144
  24.  
  25. /* extern variables, defined in curses.c */
  26. extern short    ospeed;         /* tty speed, eg B2400 */
  27. extern WINDOW   *stdscr;        /* pointer into kbuf[] */
  28. extern WINDOW   kbuf[KBSIZ];    /* a very large output buffer */
  29. extern int      LINES;          /* :li#: number of rows */
  30. extern int      COLS;           /* :co#: number of columns */
  31. extern int      AM;             /* :am:  boolean: auto margins? */
  32. extern int      PT;             /* :pt:  boolean: physical tabs? */
  33. extern char     *VB;            /* :vb=: visible bell */
  34. extern char     *UP;            /* :up=: move cursor up */
  35. extern char     *SC;            /* :sc=: save cursor posn & char attributes */
  36. extern char     *RC;            /* :rc=: restore cursor posn & char attr */
  37. extern char     *SO;            /* :so=: standout start */
  38. extern char     *SE;            /* :se=: standout end */
  39. extern char     *US;            /* :us=: underline start */
  40. extern char     *UE;            /* :ue=: underline end */
  41. extern char     *VB_s;          /* :VB=: bold start */
  42. extern char     *VB_e;          /* :Vb=: bold end */
  43. extern char     *AS;            /* :as=: alternate (italic) start */
  44. extern char     *AE;            /* :ae=: alternate (italic) end */
  45. extern char     *CM;            /* :cm=: cursor movement */
  46. extern char     *CE;            /* :ce=: clear to end of line */
  47. extern char     *CL;            /* :cl=: home cursor & clear screen */
  48. extern char     *CD;            /* :cd=: clear to end of screen */
  49. extern char     *AL;            /* :al=: add a line */
  50. extern char     *DL;            /* :dl=: delete a line */
  51. extern char     *SR;            /* :sr=: scroll reverse */
  52. extern char     *KU;            /* :ku=: sequence sent by up key */
  53. extern char     *KD;            /* :kd=: sequence sent by down key */
  54. extern char     *KL;            /* :kl=: sequence sent by left key */
  55. extern char     *KR;            /* :kr=: sequence sent by right key */
  56. extern char     *IM;            /* :im=: insert mode start */
  57. extern char     *IC;            /* :ic=: insert following char */
  58. extern char     *EI;            /* :ei=: insert mode end */
  59. extern char     *DC;            /* :dc=: delete a character */
  60. extern char     *aend;          /* end an attribute -- either UE or VB_e */
  61. extern char     ERASEKEY;       /* taken from the ioctl structure */
  62.  
  63. #define _addCR          (stdscr[-1] == '\n' ? qaddch('\r') : 0)
  64. #define qaddch(ch)      (*stdscr++ = (ch))
  65. #define addch(ch)       if (qaddch(ch) == '\n') qaddch('\r'); else
  66. #ifdef CRUNCH
  67. extern void attrset();
  68. extern void insch();
  69. extern void qaddstr();
  70. #else
  71. # define attrset(a)     {tputs(aend, 1, faddch); if ((a) == A_BOLD)\
  72.                                 {tputs(VB_s, 1, faddch); aend = VB_e;}\
  73.                          else if ((a) == A_UNDERLINE)\
  74.                                 {tputs(US, 1, faddch); aend = UE;}\
  75.                          else if ((a) == A_ALTCHARSET)\
  76.                                 {tputs(AS, 1, faddch); aend = AE;}\
  77.                          else aend = "";}
  78. # define insch(ch)      {if (IM) tputs(IM, 1, faddch);\
  79.                          tputs(IC, 1, faddch);\
  80.                          qaddch(ch);\
  81.                          if (EI) tputs(EI, 1, faddch);\
  82.                         }
  83. # define qaddstr(str)   {register char *s_, *d_;\
  84.                          for (s_=(str), d_=stdscr; *d_++ = *s_++; ){}\
  85.                          stdscr = d_ - 1;\
  86.                         }
  87. #endif
  88. #define addstr(str)     {qaddstr(str); _addCR;}
  89. #define move(y,x)       tputs(tgoto(CM, x, y), 1, faddch);
  90. #define wprintw         for (*stdscr = 1; *stdscr; stdscr += strlen(stdscr), _addCR, *stdscr = 0)\
  91.                                 sprintf
  92. #define mvaddch(y,x,ch) {move(y,x); addch(ch);}
  93. #define refresh()       wrefresh(stdscr)
  94. #define wrefresh(w)     if ((w) != kbuf) {write(1, kbuf, (int)((w) - kbuf)); (w) = kbuf;}else;
  95. #define wqrefresh(w)    if ((w) - kbuf > 2000)  {write(1, kbuf, (int)((w) - kbuf)); (w) = kbuf;}else;
  96. #define standout()      tputs(SO, 1, faddch)
  97. #define standend()      tputs(SE, 1, faddch)
  98. #define clear()         tputs(CL, 1, faddch)
  99. #define clrtoeol()      tputs(CE, 1, faddch)
  100. #define clrtobot()      tputs(CD, 1, faddch)
  101. #define insertln()      tputs(AL, LINES, faddch)
  102. #define deleteln()      tputs(DL, LINES, faddch)
  103. #define delch()         tputs(DC, COLS, faddch)
  104. #define scrollok(w,b)
  105. #define raw()
  106. #define echo()
  107. #define cbreak()
  108. #define noraw()
  109. #define noecho()
  110. #define nocbreak()
  111.  
  112.