home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 8 / amigaformatcd08.iso / screenplay / utilities / scott / source / source.lha / ansi.c < prev    next >
C/C++ Source or Header  |  1996-09-22  |  2KB  |  89 lines

  1. /*
  2.  *  ANSI commands (some AMIGA specific) for Scott-Free, Write to CON:
  3.  *
  4.  *  ===================================================================
  5.  *
  6.  *  Version History AMIGA:
  7.  *  Ver ,     Date,         Author, Comment
  8.  *  -------------------------------------------------------------------
  9.  *  1.0 , 28/07/96, Andreas Aumayr, First public release
  10.  *  1.1 , 01/09/96, Andreas Aumayr, some more codes
  11.  *  ___________________________________________________________________
  12.  */
  13.  
  14.  
  15. #include <dos/stdio.h>
  16. #include <libraries/dos.h>
  17.  
  18. #define ESC          "\x1b"
  19. #define CSI          ESC "["
  20. #define CLREOL       CSI "K""\0"
  21. #define CLRSCR       "\x0c""\0"
  22. #define CLRSYS       ESC "c""\0"
  23. #define CURSOR_ON    CSI " p""\0"
  24. #define CURSOR_OFF   CSI "0 p""\0"
  25. #define CURSOR_LEFT  CSI "D""\0"
  26. #define CURSOR_RIGHT CSI "C""\0"
  27. #define DEF_TXTCOL   CSI "39;49m""\0"
  28. #define DEL_CHAR     CSI "P"
  29. #define INS_CHAR     CSI "@"
  30. #define AUTO_WRAP    CSI "?7""\0"
  31. #define AUTO_SCRL    CSI ">1""\0"
  32.  
  33. #define GREY        0
  34. #define BLACK       1
  35. #define WHITE       2
  36. #define BLUE        3
  37.  
  38. char str_buf[1024];
  39.  
  40. struct FileHandle *CON_handle,*act_hdl=NULL,*env_hdl=NULL;
  41.  
  42. void WriteCON(char *string)
  43. {
  44.     Write(CON_handle,string,strlen(string));
  45. }
  46.  
  47. void cursor(BOOL action)
  48. {
  49.     if (action) WriteCON(CURSOR_ON);
  50.     else WriteCON(CURSOR_OFF);
  51. }
  52.  
  53. void clrsys(void)
  54. {
  55.     WriteCON(CLRSYS);
  56.     //WriteCON(AUTO_WRAP);
  57.     //WriteCON(AUTO_SCRL);
  58. }
  59.  
  60. void clrscr(void)
  61. {
  62.     WriteCON(CLRSCR);
  63. }
  64.  
  65. void clreol(void)
  66. {
  67.     WriteCON(CLREOL);
  68.  
  69. }
  70.  
  71. void textcolor(int fg, int bg)
  72. {
  73.     sprintf(str_buf,CSI"0;%d;%dm\0",fg+30,bg+40);
  74.     WriteCON(str_buf);
  75. }
  76.  
  77. void background(int color)
  78. {
  79.     sprintf(str_buf,CSI">%dm\0",color);
  80.     WriteCON(str_buf);
  81. }
  82.  
  83. void gotoxy(int x, int y)
  84. {
  85.     sprintf(str_buf,CSI"%d;%dH\0",y,x);
  86.     WriteCON(str_buf);
  87. }
  88.  
  89.