#ifndef GOLDED_SYNTAX_H
#define GOLDED_SYNTAX_H
/*
**      $Filename: fd/Syntax.h
**      $Release: 2
**
**      GoldED syntax scanner definitions.
**
**      (C) Copyright 1995 Dietmar Eilert
**          All Rights Reserved
*/

#ifndef GOLDED_API_H
#include "golded:api/include/golded.h"
#endif

#ifndef MAKE_ID
#define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
#endif

#define PARSER_MAGIC  MAKE_ID('S','C','A','N')

/* library base */

struct ParserBase {

    struct Library  Libary;                          /* standard library */
    UWORD           pad;                             /* we are now longwod aligned */
    ULONG           Magic;                           /* used to recognize scanner libraries */
};

/* description of parser abilities */

struct ParserData {

    ULONG           pd_Release;                      /* version code of scanner interface (SCANLIBVERSION) */
    ULONG           pd_Version;                      /* private release code of parser (optional) */
    ULONG           pd_Serial;                       /* private serial code of parser  (optional) */
    UBYTE          *pd_Info;                         /* short description */
    UWORD           pd_Levels;                       /* syntax levels */
    UBYTE         **pd_Names;                        /* syntax level descriptions (NULL terminated) */
    ULONG          *pd_Colors;                       /* suggested colors (RGB 4 bits per gun right justified) */
    BOOL            pd_Flags;                        /* ability flags (see below) */
    UBYTE         **pd_Example;                      /* example text array or NULL */
};

#define MAKE_RGB4(r,g,b) ((ULONG) ((r) & 15)<<8 | (ULONG) ((g) & 15)<<4 | (ULONG) ((b) & 15))

/* ability flags */

#define SCPRB_CONFIGWIN     1L                       /* user configuration supported ? */
#define SCPRF_CONFIGWIN    (1L<<SCPRB_CONFIGWIN)

#define SCPRB_SYNTAXCACHE   2L                       /* syntax cache used */
#define SCPRF_SYNTAXCACHE  (1L<<SCPRB_SYNTAXCACHE)

#define SCPRB_CONTEXT       3L                       /* context scanner */
#define SCPRF_CONTEXT      (1L<<SCPRB_CONTEXT)

#define SCANLIBVERSION 2

/* syntax chunk created by scanner */

struct SyntaxChunk {

    UWORD           sc_Start;                        /* column: start */
    UWORD           sc_End;                          /* column: end   */
    UWORD           sc_Level;                        /* syntax level  */
};

/* scanner notification message passed to scanner */

struct ScannerNotify {

    ULONG           sn_Class;                        /* action class */
    ULONG           sn_Code;                         /* action code */
    ULONG           sn_Line;                         /* line of operation */
    LONG            sn_Lines;                        /* lines affected by operation */
    LONG            sn_Removed;                      /* lines removed during operation */
    APTR            sn_Reserved;                     /* reserved (set to NULL) */
};

/* action classes */

#define SCANNER_NOTIFY_MODIFIED 1L                   /* lines have been inserted, deleted or modified */

/* display refresh request issued by scanner */

struct RefreshRequest {

    ULONG           rr_Line;                         /* first line to be refreshed */
    ULONG           rr_Lines;                        /* lines to be refreshed */
};

#endif
