#include <exec/types.h>
#include <exec/ports.h>
#include <exec/semaphores.h>
#include <exec/libraries.h>
#include <exec/memory.h>
#include <dos/dos.h>
#include <string.h>
#include <utility/tagitem.h>
#include <diskfont/diskfont.h>
#include <rexx/errors.h>
#include <rexx/rxslib.h>

#include <clib/exec_protos.h>
#include <clib/alib_protos.h>
#include <clib/dos_protos.h>
#include <clib/intuition_protos.h>
#include <clib/diskfont_protos.h>
#include <clib/graphics_protos.h>
#include <clib/rexxsyslib_protos.h>

#define LibCall    __geta4 __regargs
#define Prototype  extern

#include "golded:developer/api/include/apilib.h"

#include "golded:developer/include/editor.h"

#include "o/lib-protos.h"

#ifndef RC_OK
#define RC_OK   0L
#endif

#ifndef RC_WARN
#define RC_WARN 5L
#endif

/* private defines */

#define MAX_FILELEN       32
#define MAX_PATHLEN       512
#define MAX_COMMANDLEN    560

/* global data */

struct AppContext {

    struct MsgPort *MsgPort;                         /* reply port for sending messages */
    UWORD           Outstanding;                     /* outstanding messages */

};

/* we allocate a context structure for each instance of this client to store local data */

struct PlugInContext {

    struct APIClient      APIClient;                 /* API handle (exposed to host) */
    struct APIArea        APIArea;                   /* area request */
    BOOL                  Attached;                  /* attached to dispay ? */
    UWORD                 Buttons;                   /* number of buttons in stripe */
    UWORD                 MinX;                      /* stripe dimensions */
    UWORD                 MinY;                      /* stripe dimensions */
    UWORD                 MaxX;                      /* stripe dimensions */
    UWORD                 MaxY;                      /* stripe dimensions */
    UWORD                 Height;                    /* stripe height */
    struct ButtonContext *ButtonContext;             /* layout data array */
    UWORD                 ButtonContextSize;         /* layout data size (number of buttons) */
    struct TextFont      *Font;                      /* font to be used */
    BOOL                  Backfill;                  /* fill background of selected tab ? */
    UWORD                 Separator;                 /* height of separator line */
};

/* the button context structure describes a button in the stripe */

struct ButtonContext {

    UWORD                 X;                         /* x position */
    UWORD                 Y;                         /* y position */
    UWORD                 W;                         /* button width */
    UWORD                 H;                         /* button height */
    UWORD                 TextX;                     /* text position */
    UWORD                 TextY;                     /* text position */
    UWORD                 State;                     /* current state */
    UBYTE                 Label[MAX_FILELEN];        /* label */
    UBYTE                 Path [MAX_PATHLEN];        /* buffer name */
};

#define BUTTON_STATE_INDETERMINED (0)
#define BUTTON_STATE_NORMAL       (1L<<0)
#define BUTTON_STATE_SELECTED     (1L<<1)
#define BUTTON_STATE_HIDDEN       (1L<<2)

/* global data */

extern struct AppContext AppContext;
extern const  char       LibName[];
extern const  char       LibId[];
