/*********************************
*  MAIN.H  01/02/91
*  Header file for STV
*  © Copyright 1990 Timm Martin
*  All Rights Reserved Worldwide
**********************************/

#ifndef STV_MAIN_H
#define STV_MAIN_H

#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif
#ifndef GRAPHICS_TEXT_H
#include <graphics/text.h>
#endif
#ifndef INTUITION_INTUITION_H
#include <intuition/intuition.h>
#endif
#ifndef INTUITION_SCREENS_H
#include <intuition/screens.h>
#endif
#ifndef WORKBENCH_STARTUP_H
#include <workbench/startup.h>
#endif

/*--- Argument Structure ---*/
struct Argument
{
  short           Files;      /* number of files to read */
  char **         Names;      /* names of those files */
  struct WBArg *  ArgList;    /* argument list if run from WB */
  short           Left;       /* window left edge */
  short           Top;        /* window top edge */
  short           Width;      /* window width */
  short           Height;     /* window height */
  short           TextColor;  /* FrontPen color of display text */
  struct Screen * Screen;     /* custom screen pointer */
};

/* means no argument was specified */
#define NO_ARGUMENT -1

/*--- Colors ---*/
#define BLUE  0L
#define WHITE 1L
#define BLACK 2L
#define RED   3L

/*--- FileBuffer Structure ---*/
struct FileBuffer
{
  char *  Name;       /* full name of this file (including path) */
  char *  Partial;    /* just the name of the file itself */
  char *  Buffer;     /* buffer holding file in RAM */
  char ** Table;      /* table of line pointers */
  long    BufferSize; /* buffer size in bytes */
  long    FileSize;   /* file size in bytes */
  long    TableSize;  /* table size in bytes */
  long    Lines;      /* number of lines in file */
};

/*--- File Selection ---*/
typedef short SELECT;

/* corresponding gadget should be disabled */  #define SELECT_NONE -2
/* want to read previous file              */  #define SELECT_PREV -1
/* want to end program                     */  #define SELECT_STOP  0
/* want to read next file                  */  #define SELECT_NEXT  1
/* want some file, but not sure which      */  #define SELECT_SOME  2

/*--- Intuition ---*/
#define MENUNUMBER(m,i,s) ((long)(m|(i<<5)|(s<<11)))
#define WAIT_FOR_INPUT    Wait( 1L<<win->UserPort->mp_SigBit );
#define WINDOW_INPUT      (imessage=(struct IntuiMessage *)GetMsg(win->UserPort))

/*--- Pointer ---*/
#define   SET_POINTER SetPointer(win,pointer,25L,16L,-7L,-11L)
#define CLEAR_POINTER ClearPointer(win)

/*--- Statistics Structure ---*/
struct Statistics
{
  long Top;               /* array element # of top line in display */
  long PrevTop;           /* previous top element # */
  short Rows;             /* number of visible rows in window */
  short Cols;             /* number of visible columns in window */
  short LeftEdge;         /* left edge of first column */
  short RightEdge;        /* right edge of last column */
  short TopEdge;          /* top edge of first row */
  short BottomEdge;       /* bottom edge of last row */
  short VCenter;          /* vertical center of scrolling window */
  struct TextFont *Font;  /* font used for rendering */
  short TextWidth;        /* width of each character */
  short TextHeight;       /* height of each character */
  short Baseline;         /* text baseline */
  long VPropPot;          /* prop pot value */
  long VPropBody;         /* prop body value */
  BOOL Scrolling;         /* if user is scrolling display with mouse */
  BOOL Propping;          /* if user is scrolling display with prop gadget */
};
#define SCROLLING stats.Scrolling
#define PROPPING  stats.Propping

/*--- Values ---*/
#define YES 1
#define NO 0
#define REG register
#define LATER NULL

/*--- Global Variables ---*/
/* main.c    */  extern struct Argument   arguments;
/* file.c    */  extern struct FileBuffer current_file;
/* pointer.c */  extern USHORT *          pointer;
/* window.c  */  extern struct RastPort * rp;
/* display.c */  extern struct Statistics stats;
/* window.c  */  extern struct TextAttr   text_attr;
/* main.c    */  extern BOOL              wb2;
/* window.c  */  extern struct Window *   win;

#endif
