/*------------------------------------*
 | File: TS.h - Include file for TS.c |
 *------------------------------------*/

/**
 | #define's:
 | - offset, inside the Bevel Box, of the text scrolling region;
 |   actually defined in terms of the font width/height.
**/

#define TEXT_XOFFSET      (fontWidth)
#define TEXT_YOFFSET      (fontHeight / 2)

/**
 | Local structures:
 | - a double-linked list structure, to hold the text lines to be
 |   presented in the scroller (it is simple to implement, and
 |   to do it myself is funnier that to use OS List structures :-).
**/

typedef struct sLine {
  struct sLine  *sl_Back;
  struct sLine  *sl_Forw;
  size_t         sl_Length;
  char           sl_Text[1];
} Line;

/**
 | Local global variables:
 | - pointers to the first and last line of text;
 | - a pointer to the window raster port;
 | - scroller variables;
 | - variables for Bevel Box and text drawing.
 |
**/

static Line  *firstLine        = NULL;
static Line  *lastLine         = NULL;

static struct RastPort *pRP;

static USHORT numLines       = 0;   /* Number of actual text lines     */
static USHORT topLine        = 0;   /* Actual top line (first is zero) */
static USHORT oldNumLines    = 0;   /* Nr. lines and top line the last */
static USHORT oldTopLine     = 0;   /*   time the scroller was updated */
static USHORT linesVisible;         /* Number of lines and columns in  */
static USHORT columnsVisible;       /*   the scrolling region          */
static USHORT fontHeight;           /* Height and width of the window  */
static USHORT fontWidth;            /*   text font (pixels)            */
static USHORT viewHeight;           /* Height and width of the text    */
static USHORT viewWidth;            /*   scrolling region (pixels)     */
static USHORT usefulHeight;         /* Height and width of the zone to */
static USHORT usefulWidth;          /*   be refreshed                  */

static USHORT bevelLeft, bevelTop, bevelWidth, bevelHeight;
static USHORT textLeft, textTop;

/**
 | Local procedure prototypes
**/

static void RenderLine
  (USHORT x, USHORT y, USHORT w, char *text, size_t len);
static Line *ScanList(register Line *pL, register int n);
static void SetScroller
  (struct Window *pW, struct Gadget *pG, USHORT lV, USHORT nL, USHORT tL);
static void UpdateScroller(void);
