
/*****************************************************************************/

/*  PNL3.H  Include file

    PANEL:  Type 3          : Language Linkage 
            Source Language : C

    Modification History (Push-Down List):  

            01.01.86        : Distribution Source PANEL V6.20
            13.04.85        : Added argument checking

******************************************************************************/

                                /* prevent multiple inclusion */
#ifndef PNL3

/*  Note the correspondence for the attribute and mask bits between external
    data representation and that used by C.  PANEL saves such 16-bit fields with
    bits numbered 0 to 15 from left to right.  (Because Pascal sets are stored
    that way !).  This means that in C, when running on 8086 or PDP11 each
    byte of the field has its bit numbers reversed, and for a processor with
    low byte stored in higher memory the whole field has bit numbers reversed.
    The PANEL C interface started life on the 8086, so this byte orientation
    is defined as 'normal'.  If BYTESWAP is defined, two-byte integers are
    stored with the least significant byte at the higher-numbered address.
    
    PANEL     0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
    C 8086    7   6   5   4   3   2   1   0  15  14  13  12  11  10   9   8
    C SWAP   15  14  13  12  11  10   9   8   7   6   5   4   3   2   1   0  */ 

/*  Function to make bit-mask for use in testing whether X is in entry mask */

#ifdef BYTESWAP
#define inmask(x) ( 1 << (15 - x) )
#else
#define inmask(x) ( 1 << ( (x < 8) ? (7 - x) : (23 - x) ) ) 
#endif

/*  Define values for field entry attributes, for masking field SA */

#ifdef BYTESWAP
#define upper 0x8000
#define echo  0x4000
#define crreq 0x2000
#define wipe  0x1000
#define rj    0x800
#define num   0x400
#define dlr   0x200
#define usr   0x100
#define init  0x80
#define input 0x40
#define key   0x20
#define mask  0x10
#define bord  0x4
#define xtend 0x2
#define abbr  0x1
#else
#define upper 0x80
#define echo  0x40
#define crreq 0x20
#define wipe  0x10
#define rj    0x8
#define num   0x4
#define dlr   0x2
#define usr   0x1
#define init  0x8000
#define input 0x4000
#define key   0x2000
#define mask  0x1000
#define bord  0x400
#define xtend 0x200
#define abbr  0x100
#endif

typedef struct
      { uint  xbits;            /* xtend attributes 0..15  */
        char  *xattr[16]; }     /* pointer array to attribute strings */
      panxa;                    /* extended attribute control block */

typedef struct 
      { uchar sx,sy,sl,sh;      /* coordinates and size of field */
        uchar sf;               /* fill character */
        uchar so;               /* overlay level */
        uint  sa;               /* entry attribute bits */
        uint  sm;               /* entry mask */
        uchar hightype;         /* highlight type */
        uchar highmodi;         /* highlight modifier */
        uchar datawidth;        /* width of each line of data */
        uchar dataheight;       /* no of lines in data area */
        uchar *datablock;       /* offset of data area */
        uchar charvaln;         /* character validation routine number */
        uchar linevaln;         /* line validation routine number */
        panxa *xa;              /* extended attributes */
        uchar fi,fj;            /* cursor position in field    +++  */
        uchar di,dj;            /* pos of field home in data   +++  */
        uchar fname[8]; }       /* field name                  +++  */ 
      panfcb;                   /* +++ items not in abbreviated fcb */

extern panfcb PACRF;            /* current field control block */

typedef struct 
      { uchar asx,asy,asl,ash;  /* coordinates and size of field */
        uchar asf;              /* fill character */
        uchar aso;              /* overlay level */
        uint  asa;              /* entry attribute bits */
        uint  aasm;             /* entry mask */
        uchar ahightype;        /* highlight type */
        uchar ahighmodi;        /* highlight modifier */
        uchar adatawidth;       /* width of each line of data */
        uchar adataheight;      /* no of lines in data area */
        uchar *adatablock;      /* offset of data area */
        uchar acharvaln;        /* character validation routine number */
        uchar alinevaln;        /* line validation routine number */
        panxa *axa; }           /* extended attributes */
      panafcb;

typedef struct                  /* Environment Control Block */
      { uchar   termid[10];     /* global termid */
        uint    maxcol;         /* integer value of maxc */
        uint    maxrow;         /* integer value of maxr */
        uint    paiden;         /* version of PANLOW */
        uchar   padsp[32]; }    /* displayable characters */
      panecb;
  
extern panecb PAECB;            /* current environment control block */
                            
extern uchar PAOLDH;            /* place old type in here for HL change */
extern int   PAOVTH;            /* overlay threshhold for fdisp function */
extern int   PASSEC;            /* screen save element count: nz if enabled */

#define fdispu  1       /* display field */
#define fdisp   2       /* display field with highlighting */
#define fdispa  3       /* display field with highlighting & alternate border */
#define fbordd  4       /* display default border on displayed field */
#define fborda  5       /* display alternate border on displayed field */
#define funsh   6       /* redisplay saved screen from under overlay */
#define flose   7       /* forget and free saved screen under overlay */
#define freadu 11       /* read field */
#define freadh 12       /* read field with highlighting (documented as fread) */
#define freads 13       /* read field from special start point */
#define fhigh1 21       /* set highlighting on for field */
#define fhigh2 22       /* complete highlighting for field */
#define fhighc 23       /* change highlighting of displayed field */
#define ferase 24       /* erase field from screen */
#define fsetm  30       /* set up mask for field */
#define ffilm  31       /* insert fill chars under mask control */
#define ffill  32       /* set field to fill characters */
#define funfil 33       /* set fill characters to blank */
#define fpadf  34       /* pad field data on right with fill char */
#define flnop  35       /* perform 'line operation' on field lines */
#define ffild  36       /* set whole data area to fill characters */

#ifdef LINT_ARGS        /* arg checking enabled */

char *PAIX(char *, char);
int   PAINIT(char *);
int   PACINP(void);
int   PAROUT(char); 
int   PACSTA(void);
int   PACOUT(char);
int   PASOUT(char *);
uint  PAGETF(void);
int   PACURS(int,int);
int   PASBAD(int,int);
int   PAHION(int);
int   PAHIOF(void);           
int   PAHTYP(int);
int   PAFUNC(int);
int   PANELF(int,);       /* may be full or abbreviated */

#ifdef IBMBIOS
int   PAPAGE(int, int);   /* IBM PC and PC-DOS only */
int   PACHCL(int, int);   /* IBM PC and PC-DOS only */
#endif

#else

EXTFUNC int   PABM();
EXTFUNC int   PABF();
EXTFUNC char *PAIX();

EXTFUNC int   PAINIT();
EXTFUNC int   PACINP();
EXTFUNC int   PAROUT(); 
EXTFUNC int   PACSTA();
EXTFUNC int   PACOUT();
EXTFUNC int   PASOUT();
EXTFUNC uint  PAGETF();
EXTFUNC int   PACURS();
EXTFUNC int   PASBAD();
EXTFUNC int   PAHION();
EXTFUNC int   PAHIOF();           
EXTFUNC int   PAHTYP();
EXTFUNC int   PAFUNC();
EXTFUNC int   PANELF();

#ifdef IBMBIOS
EXTFUNC int   PAPAGE();   /* IBM PC and PC-DOS only */
EXTFUNC int   PACHCL();   /* IBM PC and PC-DOS only */
#endif

#endif

#define PNL3 pnl3       /* prevent multiple inclusion */
#endif                  /* end of ifndef PNL3 */
