/*(( "Kopf" */
/* -----------------------------------------------------------------------------

   $Id: smartindent.h,v 1.7 1997/07/17 00:24:10 mshopf Exp mshopf $

   GoldED API client, ©1997 Matthias Hopf.
   Compiled with SasC.


   Smartindent Library base and Client extension.

   ------------------------------------------------------------------------------
*/

/*)) */
#ifndef _SMARTINDENTBASE_H
#define _SMARTINDENTBASE_H

/*(( "Includes" */
#include <exec/libraries.h>

#include "api.h"
#include "golded.h"

#define strcasecmp stricmp /* Grmbl. strange SAS/C naming */

/*)) */
/*(( "Version" */

#define LIBNAME    "smartindent.api"

#define VERSION    37
#define REVISION   6
#define REVSTRING  "37.6"
#define REVSTATE   "[beta] "
#define REVDATE    __AMIGADATE__

#define LIBID      LIBNAME " " REVSTRING " " REVDATE "\0$VER: " LIBNAME " " REVSTRING " " REVSTATE REVDATE


/*)) */
/*(( "Constants" */

#ifndef RC_OK
#  define RC_OK 0
#endif
#ifndef RC_WARN
#  define RC_WARN 5
#endif

/* Return codes of IsWord functions */
#define MATCH_FALSE            0    /* Not a word of the language */
#define MATCH_TRUE             1    /* Word of language */
#define MATCH_EXACT            2    /* Word of language, longer words do not exist (speedup) */

#define MAX_WORD_LEN           20   /* Maximum length of reserved words (+1) */
#define MAX_ERR_LEN            80   /* Maximum length of formated errors */

/*)) */
/*(( "Structures" */

struct SmartindentBase
{
    struct APIBase         API;
    APTR                   SegList;
};

struct SmartOrder
{
	/* !!!It is absolutely necessary that Order is the very first element!!! */
    struct APIOrder         Order;
    struct APIModifyRequest Modify;
    int                     StringSize; /* Maximum size of the attached string */
	/* The string is attached immedeately. */
};

/* Our configuration */

struct SmartConfig {
    short Block_Level;                  /* bla; \n { \n -> bla; */
    short Brace_Level;                  /* bla; \n -> { */
    short Label_Level;                  /* -> bla: */
    short Cont_Level;                   /* void \n -> bla (); */
    short NextLine_Level;               /* bla = \n -> 0; */
    short Comment_Level;                /* \n -> // bla */
    short LineComment_Abs;              /* foo; -> // bla */
} ;

struct SmartClient;

struct Semantic
{
    char   *Name;
    char   *Descr;
    char   *Version;
    int    (*IsWord)   (struct SmartClient *c, char *buf, int len, int maxlen);
    void   (*KeyPress) (struct SmartClient *c, int key);
    void   (*Indent)   (struct SmartClient *c);
    struct SmartConfig StartConf;
};

struct SmartClient
{
    struct APIClient       API;
    struct APIMessage     *Msg;
    struct EditConfig     *Edit;
    struct Semantic       *Sem;
    struct SmartConfig     Conf;

	/* The following entries are nulled at the begining of each request. */
	/* !!!It is absolutely necessary that FirstLine is the very first element!!! */

    int    FirstLine;                   /* First scanned line */
    int    BeginIndent, EndIndent;      /* First, last indented line */
    int    Mode;
    char   *ErrTxt;

    int    CurrentLine, CurrentPos;     /* Current position, reflecting any intendations */
    int    Indent, BlockIndent;         /* Current indentation level, standard and for blocks (override) */

    int    CursorX;                     /* (New) Cursor position */
    int    BlockStartX, BlockEndX;      /* (New) Block position */
    struct LineNode *Node;              /* Current node */
    int    NextPos;                     /* Next pos to scan (node position) (== -1: continue with next line) */
    int    LastPos;                     /* Last scanned position (=-1: Last Line) */
    int    NextPosEOL;                  /* Next pos, used for EOF detection (may be changed) */
    struct SmartOrder *Req;             /* Current APIOrder */

    char   PeekBuffer [MAX_WORD_LEN];   /* Peek buffer */
    char   WordBuffer [MAX_WORD_LEN];   /* Get buffer */
    char   ErrBuffer  [MAX_ERR_LEN];    /* Default Error Buffer */
};

typedef struct SmartClient sc_t;

/*)) */

#endif /* _SMARTINDENTBASE_H */

