#ifndef _PICO_H_
#define _PICO_H_

#ifndef __stdio_h
#include <stdio.h>
#endif
#ifndef __stdlib_h
#include <stdlib.h>
#endif
#ifndef _PICO_SCREEN_H_
#include "screen.h"
#endif

#define PICO_FILENAME_SIZE  256                  /* size of filename buffer */
#define PICO_TEMP_SIZE      256              /* size of temporary workspace */
#define PICO_MEM_BLOCKS     256          /* maximum number of memory blocks */
#define PICO_BLOCK_SIZE     16384              /* size of each memory block */
#define PICO_LINE_SIZE      1024                     /* size of line buffer */

#define PICO_OK             0                      /* return value for "OK" */
#define PICO_ERROR          1                   /* return value for "error" */

typedef struct {
 char *temp;                                         /* temporary workspace */
 char *filename;                                /* filename of current file */
 Screendata *screendata;                           /* screen data structure */
 char **blocks;                      /* pointers to allocated memory blocks */
 char *linebuf;                   /* buffer containing copy of current line */
 short linelength;   /* original length of current line before modification */
 long filesize;                                     /* size of current file */
 short numrows;                                     /* number of lines read */
 long position;                            /* current byte position in file */
 long toppos;                   /* byte position of top-left byte on screen */
 short toprow;                       /* row number of line at top of screen */
 short row;                                           /* current row number */
 short column;                                     /* current column number */
 short leftcol;                  /* leftmost column on current line display */
 char modified;                 /* flag=1 if file modified since last saved */
 long mark;                   /* position in file of mark start, -1 if none */
 short markrow;                       /* row in which marked section starts */
 short markcol;                    /* column at which marked section starts */
 char *clipboard;                 /* clipboard memory pointer, NULL if none */
 long clipsize;                           /* size of clipboard memory space */
 char moved;                             /* flag set if moved since last ^K */
} Picovars;

void pico_banner(Picovars *);                   /* print banner (display.c) */
void pico_displayline(Picovars *,short);   /* show row contents (display.c) */
void pico_down(Picovars *);                 /* move cursor down (display.c) */
void pico_endline(Picovars *);   /* move to end of current line (display.c) */
void pico_fullpos(Picovars *);/* show full position information (display.c) */
int pico_input(Picovars *,char *);   /* input line, eg filename (display.c) */
void pico_left(Picovars *);                 /* move cursor left (display.c) */
void pico_pagedown(Picovars *);           /* move down one page (display.c) */
void pico_pageup(Picovars *);               /* move up one page (display.c) */
void pico_position(Picovars *);        /* show current position (display.c) */
void pico_right(Picovars *);               /* move cursor right (display.c) */
void pico_screen(Picovars *); /* show current screenful of text (display.c) */
void pico_status(Picovars *,char *);         /* set status line (display.c) */
void pico_up(Picovars *);                     /* move cursor up (display.c) */
void pico_character(Picovars *,int);     /* insert typed character (edit.c) */
void pico_cut(Picovars *);    /* cut current line / marked section (edit.c) */
void pico_delete(Picovars *);/* delete character to left of cursor (edit.c) */
long pico_findline(Picovars *,short); /* find file position of row (edit.c) */
void pico_justify(Picovars *);        /* justify current paragraph (edit.c) */
void pico_mark(Picovars *);                /* start marked section (edit.c) */
void pico_newline(Picovars *);   /* deal with Return being pressed (edit.c) */
void pico_paste(Picovars *);           /* paste clipboard contents (edit.c) */
void pico_readline(Picovars *);/* put current row into line buffer (edit.c) */
void pico_storeline(Picovars *);             /* store current line (edit.c) */
void pico_whereis(Picovars *);                        /* find word (edit.c) */
void pico_readfile(Picovars *);                   /* insert file (filing.c) */
void pico_save(Picovars *);                         /* save file (filing.c) */
int pico_main(Picovars *);                    /* main program loop (main.c) */
int pico_allocate(Picovars *,long);           /* allocate memory (memory.c) */
void pico_countlines(Picovars *);       /* count lines in memory (memory.c) */
void pico_insert(Picovars *,long,long);          /* insert bytes (memory.c) */
int pico_readchar(Picovars *,long);     /* read byte from memory (memory.c) */
void pico_remove(Picovars *,long,long);          /* delete bytes (memory.c) */
void pico_writechar(Picovars *,long,int);/* write byte to memory (memory.c) */

#endif
