/*
	AMIS Include for Viewers. (V0.98)

	In this file you can everything you need to create you own viewer (at
	least, I hope so).
*/

struct LineInfo
{
	short	li_length;				/* Don't change this !! */
	short	li_height;				/* For more information see the Viewer
											structure. */
	long	li_viewerdata;			/* This is for you... */
};

struct EditWin
{
	long	wn_next;
	long	wn_prev;
	char	wn_type;
	char	wn_pri;
	long	wn_name;
	struct Window	*wn_base;
	struct RastPort	*wn_rast;
	long	wn_gadget;
	short	wn_innerwidth;	
	short	wn_innerheight;
	short	wn_left;
	short	wn_top;

	long	*ed_memlist;
	long	*ed_project;
	struct Font	*ed_font;
	struct Viewer	*ed_display;
	long	ed_bookmarks[10];
	long	ed_viewerdata;
	long	ed_moreviewerdata[16];
	long	ed_viewervar[10];
	long	ed_viewerobj[1];
	char	ed_flags;
	char	ed_flags2;
	char	ed_flags3;
	char	ed_flags4;
	char	ed_flags5;
	char	ed_flags6;
	long	ed_clip;
	short	ed_tabsize;
	long	ed_winchars;
	long	ed_winlines;
	short	ed_top_offset;
	short	ed_pl_y_offset;
	short	ed_pl_own_height;
	long	ed_pl_total_y;
	short	ed_bordertop;
	short	ed_first_y;
	short	ed_last_y;
	long	ed_visible_y;
	long	ed_topline;
	long	ed_topline_tick;
	long	ed_leftchar;
	long	ed_lines;
	long	ed_chars;
	long	ed_line;
	long	ed_oldtopline;
	long	ed_oldtoppos;
	struct LineInfo	*ed_linesinfo;
	long	ed_buffer;
	long	ed_bufsize;
	long	ed_bufpos;
	long	ed_linebuf;
	long	ed_linebuflast;
	long	ed_oldlinelength;
	long	ed_char;
	long	ed_winpos;
	long	ed_cursoffset;
	short	ed_curs_px1;
	short	ed_curs_py1;
	short	ed_curs_px2;
	short	ed_curs_py2;
	short	ed_buttonwidth;
	long	ed_buttonlist;
	long	ed_slidertopline;
	long	ed_sliderlines;
	short	ed_slidersize;
	long	ed_startpos;
	long	ed_endpos;
	long	ed_last_startpos;
	long	ed_last_endpos;
	long	ed_oldline;
	long	ed_oldchar;
	long	ed_mouseline;
	long	ed_mousechar;
	long	ed_mousepos;
	long	ed_blocktemp1;
	long	ed_blocktemp2;
	long	ed_blocktemp3;
	long	ed_blocktemp4;
	long	ed_subpos;
	short	ed_viewerbar_y;
	long	ed_removefunc;
	short	ed_statusbar_y;
	short	ed_codebar_y;
	short	ed_freebar;
	long	ed_title_msg;
	short	ed_tm_time;
	long	ed_timerioreq;
	short	ed_lineheight;

	char	ed_path[144];
	char	ed_filename[144];
	char	ed_name[144];
	char	ed_screenname[100];

/* PRIVATE !! */

	long	ed_tmprastport;
	long	ed_tmplayer;
	long	ed_tmpbitmap;
	long	ed_layerinfo;
};

struct Viewer
{
	struct Node		vw_node;				/* Only fill in name */
	long	vw_loadseg;						/* Set to zero! */

/*
	With the next three options you can tell AMIS for which files this viewer
	should be used. Note that the file must have all three before it will be
	recognized. You can set starttext and typicaltext to zero if neccessery.
*/

	char	*vw_filepattern;				/* filepattern, e.g. "#?" */
	char	*vw_starttext;					/* first text in file, e.g. "@database"*/
	char	*vw_typicaltext;				/* some text somewhere in every file of
													your type, e.g. "@node" */

	void	(*vw_switchfunction)();		/* function to be called after every
													switch to this viewer */

	char	vw_flags1;						/* flags for you, see below */
	char	vw_flags2;						/* AMIS private flags ! */

	void	(*vw_display)();				/* the display function it self */
	void	(*vw_newpos)();				/* function to be called every time the
													cursor is moved */
	void	(*vw_getwinpos)();			/* return winpos when char is given */
	void	(*vw_getchar)();				/* return char when winpos is given */
	void	(*vw_codebar)();				/* return text to be displayed in
													codebar */

/*
	With the following three options you can change the height of the text
	lines. First textheights is multiplied by the height of the selected font
	and then topspacing and bottomspacing are added. The result is the height
	of a line on the screen (in pixels).

	If you wish to give different lines different heights you can add an
	offset in the second word of the linesinfo structure of every line. In
	must cases you will then set the following three options to zero and set
	the whole line height in the linesinfo structure.
*/

	short	vw_textheights;
	short	vw_topspacing;
	short	vw_bottomspacing;

	short	vw_planes;						/* number of bitplanes to be
													cleared/scrolled */
/*
	The next variable is used to reserve some space in the window for the
	viewerbar. The two functions behind it are called every time the
	viewerbar should be drawn and removed (free memory etc., you don't have
	to remove the actual graphics).
*/

	short	vw_barheight;
	void	(*vw_viewerbar)();
	void	(*vw_remove_vb)();

/*
	The next two functions can be used to replace the normal cursright and
	cursleft functions. You can use this the jump the cursor over text
	commands or other places the cursor shouldn't be. Beware that when the
	cursor is in the codebar the normal functions will always be used!
*/

	void	(*vw_cursright)();
	void	(*vw_cursleft)();

/*
	In vw_font you MUST pass an opened font you wish to you use for
	displaying your text. If you wish to use the default font simply copy the
	font passed to you in the AMIS structure.
*/

	struct Font *vw_font;

/*
	The next function is used for breaking lines. When this function is
	called you should return the VISIBLE part of the line that is passed to
	you. This means you should filter out everything that will not appear on
	the screen. AMIS will check this line for spaces to break a line. If
	there are spaces on the screen where the line should be broken you sould
	set an '_' in the line you give back instead of a ' '. This way you have
	complete control over where lines may and may not be broken.
*/

	void	(*vw_plaintext)();

/*
	The next option will be used to make it possible to define different
	functions for keys in different viewers. This isn't completely working
	yet and for now it is best to point to an empty list (you may also pass a
	zero if you wish).
*/

	struct List	*vw_keylist;

/*
	The next two functions are called every time a file is loaded / saved or
	the user switches to this viewer or an other viewer. You may use these
	functions to filter out text that should not be displayed or something
	like that. Please not that the savefilter should set back all this
	information, otherwise some text might 'get lost' without the user
	knowing about it (not very user friendly, don't you think ?).
*/

	void	(*vw_savefilter)();
	void	(*vw_loadfilter)();

/*
	The next function is the unload function wish will be called when AMIS is
	quiting. This function allows you to free recources, close fonts, free
	images, etc.
*/

	void	(*vw_unload)();

/*
	The last option for now is a pointer to the text you want to be displayed
	in the viewer info requester. Lines can be seperated with a '|' sign.
*/

	char	*vw_infotext;
};

struct AMIS
{
	struct IntuitionBase	*AMIS_IntuitionBase;
	struct GfxBase			*AMIS_GfxBase;
	struct Library			*AMIS_GadBase;
	struct Library			*AMIS_DatatypesBase;
	struct Library			*AMIS_DiskfontBase;
	struct Screen			*AMIS_ScreenBase;
	long						*AMIS_VisualInfo;
	struct DisplayInfo	*AMIS_DisplayInfo;
	struct ColorMap		*AMIS_ColorMap;
	char						*AMIS_Flags;
	struct Font				*AMIS_Normal_Font;		/* the default text font */
};

#pragma libcall AMIS AMIS_InternalCommand 6 801
#pragma libcall AMIS AMIS_cursleft c 801
#pragma libcall AMIS AMIS_cursright 12 801
#pragma libcall AMIS AMIS_getwinpos 18 801
#pragma libcall AMIS AMIS_get_image 1e 801
#pragma libcall AMIS AMIS_load_image 24 801
