home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 315_01 / ansi.h < prev    next >
Text File  |  1990-05-16  |  2KB  |  58 lines

  1.  
  2. /* ansi.h defines some of the ANSI.SYS driver commands.  ANSI.SYS must    */
  3. /* be installed on your computer for these routines to work.  To use,     */
  4. /* simply add #include "ansi.h" or #include <ansi.h> in your preprocessor */
  5. /* directives.  The header file is self-documenting.  Written by T. Clune */
  6.  
  7. #ifndef ANSI_H
  8. #define ANSI_H
  9.  
  10.     /* to move the cursor to x,y -- where 1<=x<=80 and 1<=y<=25 */
  11. #define POSITION(x, y)  printf("\033[%d;%dH",y,x)
  12.  
  13.     /* to move the cursor UP y lines -- where 0<y<=24 */
  14. #define UP_SHIFT(y)           printf("\033[%dA",y)
  15.  
  16.     /* to move the cursor DOWN y lines -- where 0<y<=24 */
  17. #define DOWN_SHIFT(y)         printf("\033[%dB",y)
  18.  
  19.     /* to move the  cursor RIGHT x columns -- where 0<x<=79 */
  20. #define RIGHT_SHIFT(x)        printf("\033[%dC",x)
  21.  
  22.     /* to move the cursor LEFT x columns -- where 0<x<=79 */
  23. #define LEFT_SHIFT(x)         printf("\033[%dD",x)
  24.  
  25.     /* to save the current cursor position (internal to ansi.sys) */
  26. #define SAVE_POSITION   printf("\033[s")
  27.  
  28.     /* to restore cursor to SAVE_POSITION position */
  29. #define RESTORE_POSITION        printf("\033[u")
  30.  
  31.     /* to clear screen */
  32. #define CLS             printf("\033[2J")
  33.  
  34.     /* to erase a line from the cursor position to the end of line */
  35. #define LINE_CLEAR      printf("\033[K")
  36.  
  37.     /* to change screen attributes as follows: x=0, restore to normal */
  38.     /* x=1, high intensity; x=4, underscore (monochrome screen only) */
  39.     /* x=5, blinking chars; x=7, reverse video; x=8, invisible display */
  40. #define CHAR_ATTRIBUTE(x)       printf("\033[%dm",x)
  41.  
  42. #define NORMAL 0
  43. #define HIGH_INTENSITY 1
  44. #define UNDERSCORE 4
  45. #define BLINKING 5
  46. #define REVERSE_VIDEO 7
  47. #define INVISIBLE 8
  48.  
  49.  
  50.     /* tab to an absolute position on the screen */
  51. #define TAB(x)  LEFT_SHIFT(79); RIGHT_SHIFT(x)
  52.  
  53.        /* vtab tabs vertically to an absolute row */
  54. #define VTAB(y) UP_SHIFT(24); DOWN_SHIFT(y)
  55.  
  56. #endif
  57.  
  58.