#ifndef H_ED_VT100_20030226212701
#define H_ED_VT100_20030226212701

/* ---------------------------------------------------------------------
   Fred P. for J2K Library
   LGPL Licensed.
   http://j2k.sourceforge.net/
   Initially 'ANSI-PRINT'

   Project      : CLIB
   Function     : VT-100 screen functions
   Module       : VT100
   File         : VT100.H
   Created      : 26-02-2003
   Modified     : 09-09-2005
   --------------------------------------------------------------------- */

/* ---------------------------------------------------------------------
   Log

   1.3 - 09-09-2005 fflush (stdout) added)
   1.2 - 16-12-2004 'vt100 prefix added to avoid confusion.
   1.1 - 21-09-2004 Types trimming
   1.0 - 26-02-2003 Initial version

   --------------------------------------------------------------------- */
#ifdef __cplusplus
extern "C"
{
#endif

#include "ed/inc/types.h"

/*!
   * #include <vt100.h>
   *
   * using namespace ANSI_PRINT;
   *
   * int main()
   * {
   *  cls( 1 );
   *  locate( 10, 10 );
   *  qbColor( 15, 1 );
   *  printf("Yeah!\n");
   *
   *  qbColor( 14, 2 );
   *  center( 12, "C'est bien centre !\n" );
   *
   *  for( int j = 0; j < 8; j++ )
   *  {
   *    for( int i = 0; i < 16; i++ )
   *    {
   *      locate(  2+i, (short)(9.5*j) );
   *      qbColor(   i, j  );
   *      printf( "%s",  colorNameTable[ i ] );
   *    }
   *  }
   *  center( 24, "" );
   *
   *  return 0;
   * }
 */

/* macros ============================================================== */
#define vt100_ATTR(att, col) (((att) << 3) | (col))

#define vt100_ATT(attr) ((attr) >> 3)
#define vt100_COL(attr) ((attr) & 0x7)

/* constants =========================================================== */

   typedef enum
   {
      vt100_Text40x25BW = 0x0000,  /* Color card */

      vt100_Text40x25C = 0x0001,
      vt100_Text40 = 0x0001,    /* Old Big Text Mode 40x25 */

      vt100_Text80x25BW = 0x0002,

      vt100_Text80x25C = 0x0003,  /* Classic Text Mode 80x25 */
      vt100_Text80 = 0x0003,

      vt100_Graph320x200x4C = 0x0004,
      vt100_Graph320x200x4BW = 0x0005,

      vt100_Graph640x200x4C = 0x0006,

      vt100_GraphMonoCard = 0x0007,

      vt100_Graph160x200x16jr = 0x0008,  /* PC Junior and higher */
      vt100_Graph320x200x16jr = 0x0009,
      vt100_Graph640x200x4jr = 0x000A,

      vt100_Graph320x200x16 = 0x000D,  /* EGA and higher */
      vt100_Graph640x200x16 = 0x000E,
      vt100_Graph640x350BW = 0x000F,
      vt100_Graph640x350x16 = 0x0010,

      vt100_Graph640x480x2 = 0x0011,  /* MCGA and higher */

      vt100_Graph640x480x16 = 0x0012,  /* Classic VGA 16 color */
      vt100_VGA16 = 0x0012,

      vt100_Graph320x200x256 = 0x0013,  /* Classic VGA 256 color (MCGA+) */
      vt100_VGA256 = 0x0013,

      vt100_dummy
   }
   vt100_VideoMode_e;

   typedef enum
   {
      vt100_NoAttribute = 0,    /* Aucun attribut */
      vt100_Bold = 1,           /* Gras */
      vt100_Underline = 4,      /* Souligne (moniteurs monochromes uniquement) */
      vt100_Flashing = 5,       /* Clignotant */
      vt100_InverseVideo = 7,   /* Video inverse */
      vt100_HiddenText = 8      /* Cache */
   }
   vt100_TextAttr_e;

   typedef enum
   {
      vt100_Black = 0,
      vt100_Blue = 1,
      vt100_Green = 2,
      vt100_Cyan = 3,
      vt100_Red = 4,
      vt100_Purple = 5,
      vt100_Yellow = 6,
      vt100_White = 7
   }
   vt100_Color_e;

/* types =============================================================== */
/* structures ========================================================== */
/* internal public functions =========================================== */
/* public variables ==================================================== */

   extern const char *colorNameTable[];

/* entry points ======================================================== */

   char const *vt100_sid (void);
   char const *vt100_sver (void);

   /*!
    * Place the cursor at location defined by row \p r and column \p c.
    */
   void vt100_locate (uint r, uint c);
   void vt100_gotoXY (uint row, uint col);
   void vt100_goUp (uint y);
   void vt100_goDown (uint y);
   void vt100_goRight (uint x);
   void vt100_goLeft (uint y);
   void vt100_saveCursor (void);
   void vt100_loadCursor (void);
   void vt100_eraseLine (void);

   void vt100_center (uint row, const char *text);
   void vt100_color (vt100_Color_e fg, vt100_Color_e bg, vt100_TextAttr_e txtAttr);
   void vt100_qbColor (uint fg, vt100_Color_e bg);
   void vt100_cls (vt100_Color_e bg);
   void vt100_screen (vt100_VideoMode_e mode);
   void vt100_screenNoLine (vt100_VideoMode_e mode);

#ifdef __cplusplus
}
#endif

#endif                          /* H_ED_VT100_20030226212701 */
/* GUARD (c) ED 2000-2002 Dec 15 2002 Ver. 1.4 */
