home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / BBS / NSDEDIT2.ZIP / EDTKT06B.ZIP / EDIT_GLB.H < prev    next >
C/C++ Source or Header  |  1994-09-08  |  6KB  |  190 lines

  1. /***********************************************************************
  2. *                                                                      *
  3. *  Definition file for EDIT.HPP                                        *
  4. *                                                                      *
  5. *  Purpose : Defines global functions                                  *
  6. *                                                                      *
  7. *  Author  : Peter Bloemendaal                                         *
  8. *            Brainbox systems +31-70-3523661                           *
  9. *  eMail   : internet -> bloemendaal@rullf2.LeidenUniv.nl              *
  10. *            fidonet  -> 2:281/908                                     *
  11. *                                                                      *
  12. *----------------------------------------------------------------------*
  13. *                                                                      *
  14. *                                                                      *
  15. * $Log: edit_glb.v $
  16.  * Revision 1.7  1994/09/08  08:03:51  BRAINBOX
  17.  * 1. Bounce checked by I_A
  18.  *                                                   *
  19. * Revision 1.6  1994/08/24  19:27:23  BRAINBOX                         *
  20. * 1. Bug in ansi colors fixed. Now always reset colors                 *
  21. *                                                                      *
  22. * Revision 1.5  1994/08/20  13:32:32  BRAINBOX                         *
  23. * 1. fastFilelength implemented                                        *
  24. *                                                                      *
  25. * Revision 1.4  1994/08/12  13:37:51  BRAINBOX                         *
  26. * 1. Added NONE definitions                                            *
  27. *                                                                      *
  28. * Revision 1.3  1994/08/11  22:33:26  BRAINBOX                         *
  29. * 1. Ansi color                                                        *
  30. * 2. Ansi gotoxy                                                       *
  31. *                                                                      *
  32. * Revision 1.2  1994/08/10  20:22:48  BRAINBOX                         *
  33. * 1. Added definition for several colors. Exactly the same as in TC,   *
  34. *    but functionaly different from pb_sdk.h                           *
  35. *                                                                      *
  36. * Revision 1.1  1994/08/08  14:53:05  BRAINBOX                         *
  37. * Initial revision                                                     *
  38. *                                                                      *
  39. *                                                                      *
  40. *                                                                      *
  41. ************************************************************************
  42. */
  43.  
  44. #ifndef _EDIT_GLB_H
  45. #define _EDIT_GLB_H
  46.  
  47.  
  48.  
  49. // Ammount memory for reserve
  50. #define _BLOCK    1024
  51. // Mean characters / line, savest number is 1 !!
  52. #define _BLKPRT   10
  53. // Reserve
  54. #define _RESERVE  4096
  55.  
  56. #ifndef _PB_SDK_H
  57.    typedef unsigned char  bool;
  58.    #define TRUE      1
  59.    #define FALSE     0
  60.    #include <dos.h>
  61. #endif
  62.  
  63. #if 1
  64. #define MAXINT    32767
  65. #else
  66. #define MAXINT    0x6789
  67. #endif
  68.  
  69.  
  70. #define STRTCOLS_START        256 /* array starts with this size */
  71. #define STRTCOLS_INCREMENT      32    /* and is increment using this */
  72.  
  73.  
  74.  
  75. #define C_BLACK          0
  76. #define C_BLUE           1
  77. #define C_GREEN          2
  78. #define C_CYAN           3
  79. #define C_RED            4
  80. #define C_MAGENTA        5
  81. #define C_BROWN          6
  82. #define C_LIGHTGRAY      7
  83. #define C_DARKGRAY       8
  84. #define C_LIGHTBLUE      9
  85. #define C_LIGHTGREEN    10
  86. #define C_LIGHTCYAN     11
  87. #define C_LIGHTRED      12
  88. #define C_LIGHTMAGENTA  13
  89. #define C_YELLOW        14
  90. #define C_WHITE         15
  91.  
  92.  
  93. // Lowest line on the screen. Used for ASCII control
  94. #define _LOWEST_LINE    80
  95.  
  96. int max(int value1, int value2)
  97. {
  98.    return ( (value1 > value2) ? value1 : value2);
  99. }
  100.  
  101. int min(int value1, int value2)
  102. {
  103.      return ( (value1 < value2) ? value1: value2) ;
  104. }
  105.  
  106.  
  107. void ColorAnsi(int color,char *code)
  108. {
  109.      unsigned char forcol, backcol;
  110. #if 0
  111.      unsigned char blink ;
  112. #endif
  113. #if 0
  114.      char    blinkst[3] ; // I_A: was '2' before but ";5" below is 3 wide(!)
  115. #else
  116.      char *blinkst; // I_A: much better!
  117. #endif
  118. #if 0
  119.      unsigned int conversion[8]  ;
  120.  
  121.      // Stupid way to fill an array due to pex making for proboard.
  122.      conversion[0]=0 ;
  123.      conversion[1]=4 ;
  124.      conversion[2]=2 ;
  125.      conversion[3]=6 ;
  126.      conversion[4]=1 ;
  127.      conversion[5]=5 ;
  128.      conversion[6]=3 ;
  129.      conversion[7]=7 ;
  130. #else
  131.     static unsigned int conversion[8] =
  132.      {
  133.      0, 4, 2, 6, 1, 5, 3, 7
  134.      };
  135. #endif
  136.  
  137.  
  138.      forcol  = color & 15 ;
  139.      backcol = (color >> 4) & 7 ;
  140. #if 0
  141.      blink   = color & 128 ;
  142. #endif
  143.  
  144. #if 0
  145.      if (blink)
  146.             strcpy(blinkst,";5")  ;
  147.      else
  148.             strcpy(blinkst,"") ; ; // I_A: why the second ';' ????????
  149. #else
  150.      blinkst = "";
  151.      if (color & 128)
  152.             blinkst = ";5";
  153. #endif
  154.  
  155. #if 1
  156.    if (forcol > 7)
  157. {
  158.       sprintf(code,"\x1b[0;%i;%i;1%sm",conversion[forcol - 8] + 30, conversion[backcol] + 40, blinkst) ;
  159. }
  160.    else
  161.       sprintf(code,"\x1b[0;%i;%i;2%sm",conversion[forcol] + 30, conversion[backcol] + 40, blinkst) ;
  162. #else
  163.       strcpy(code, "\x1b[0;34;47;2m");
  164. #endif
  165. }
  166.  
  167.  
  168. void GotoAnsi(int x, int y, char *code)
  169. {
  170.    sprintf(code,"\x1b[%i;%iH",y,x) ;
  171. }
  172.  
  173.  
  174. long fastFilelength(char *fileName)
  175. {
  176.  
  177.    struct find_t ffblk;
  178.    int done;
  179.  
  180.    done = _dos_findfirst(fileName,_A_NORMAL,&ffblk);
  181.    if (done)
  182.       return 0L ;
  183.    else
  184.       return ffblk.size ;
  185.  
  186. }
  187.  
  188. #endif
  189.  
  190.