/* display.h -- defines for niftyterm display routines
 *
 * (C) Copyright 1988, Chris Newman
 * All Rights Reserved
 * Permission is granted ot copy, modify, and use this as long
 * as this notice remains intact.  This is a nifty program.
 *
 * $Author: ppessi $ $Revision: 3.1 $ $Date: 1994/01/07 22:51:16 $
 */

/* emulation types  */
/* similar to ANSI -- may be software switched to VT52 */
#define	EMU_VT102   0	
/* may be switched by software to VT102 */
#define	EMU_VT52    1	
/* codes from h19 program */
#define	EMU_H19	    2	

/*******************************************
 * Display Generic Routines:
 *******************************************/

/* types for dscursormove() */
#define	CURSOR_UP	    1
#define	CURSOR_DOWN	    2
#define	CURSOR_LEFT	    3
#define	CURSOR_RIGHT	    4
#define	BEGIN_LINE	    5
#define	END_LINE	    6
#define	NEXT_LINE	    7
#define	BOTTOM_HOME	    8
#define	SAVE_CURSOR	    9
#define	RESTORE_CURSOR	    10
#define	INDEX		    11
#define DOWN1_AND_SCROLL    12
#define	REVERSE_INDEX	    13
#define	INSERT_LINE	    14
#define	DELETE_LINE	    15
#define	INSERT_CHAR	    16
#define	TAB_STOP	    17
void dscursormove(int move, int n); 

/* see list of functions above */
void dsfunction(int what);	
/* types for dsfunction */
#define	ERASETO_EOL	    1
#define	ERASETO_EOS	    2
#define	ERASETO_SOL	    3
#define	ERASETO_SOS	    4
#define	ERASE_LINE	    5
#define	RESET_DISPLAY	    6
#define	SCROLL_UP	    7
#define	SCROLL_DOWN	    8
#define	ORIGIN_ON	    9
#define	ORIGIN_OFF	    10
#define	BLOCK_CURSOR	    11
#define	UNDERLINE_CURSOR    12
#define	INVISIBLE_CURSOR    13
#define VISIBLE_CURSOR	    14
#define	WRAP_ON		    15
#define	WRAP_OFF	    16
#define	INSERT_ON	    17
#define	INSERT_OFF	    18
#define	SET_TAB		    19
#define	CLEAR_TAB	    20
#define	CLEAR_ALL_TABS	    21

/* get the current cursor position */
void dsgetcursor(int * x, int * y);

/* set the current cursor position */
void dscursorto(int x, int y);

/* print formatted output */
void dsprintf(char *fmat, ...);

/* set the scrolling region */
void dssetscroll(int top, int bot);

/* get the size of the window */
void dsgetsize(int * x, int * y);

/* returns 0 if cursor on bottom line, otherwise 
 * moves cursor down a line and returns new line number.
 */
int dscheckdown(void);
/* 
 * Change the style to 
 */
int dsstyle(int style);
#define	BOLD1		1
#define	BOLD0		2
#define	ITALIC1		3
#define	ITALIC0		4
#define	UNDERLINE1	5
#define	UNDERLINE0	6
#define	INVERSE1	7
#define	INVERSE0	8
#define	HALFBRITE1	9
#define	HALFBRITE0	10
#define	BLINK1		11
#define	BLINK0		12
#define	BLANK1		13
#define	BLANK0		14
#define	ALTERNATE1	15
#define	ALTERNATE0	16
#define	DWIDTH1		17
#define	DWIDTHTOP	18
#define	DWIDTHBOT	19
#define	DWIDTH0		20
#define	STYLESOFF	255
/* these are used internally to display.c */
#define	SAVE_STYLE	256
#define	RESTORE_STYLE	257

/* types for dsinvert() */
#define	INVERT_ON	    1
#define	INVERT_OFF	    2
#define	VISUAL_BELL	    3


/*******************************************
 * Display Specific Routines:
 *******************************************/


/*
 * Start the display, return intuition mask
 */
void dsinit(void);
/*
 * Clean up window 
 */
void dsquit(void);
/*
 * Return intuition mask
 */
long dsmask(void);
void dspoll(void);
/*
 * set window size
 */
void dssizewindow(int width, int height, int maxwidthp);
/*
 * fill display with E's for testing purposes
 */
void dstestscreen(void);
/*
 * delete n characters from under the cursor
 */
void dsdelete(int n);
/*
 * put a string to the display.
 */
void dsputs(char *s);
/*
 * high speed clear of entire screen
 */
void dsclearscreen(void);
/*
 * clear a rectangular region
 */
void dsclear(int x, int y, int x1, int y1);
/*
 * scroll a region
 */
void dsscroll(int y, int numlines, int amount);
/*
 * Invert display
 */
void dsinvert(int invtype);
/*
 * Special bells
 */
void displaybell(void);
void audiobell(void);		
/*
 * Cursor on/off, and flush output
 */
void dscursoron(void);
void dscursoroff(void);
void dscursorblink(void);
/*
 * initialize blinking, poll blinking intervals
 */
void dscheckflash(void);
long dsflashinit(void);
/*
 * set the appropriate font for given attribs & line
 */
void dssetfont(short style, int line);
/*
 * keyboard functions
 */
void dskeyboard(int cmd, int val);

/* commands for dskeyboard */
#define DS_AUTOREPEAT	    1	/* on if val is true */
#define DS_LEDS		    2   /* val is bit pattern */
#define DS_KEYCLICK	    3	/* on if val is true */
#define DS_CURSORMODE	    4   /* modes for the cursor keys */
#define DS_KEYPADMODE	    5   /* modes for the numeric keypad */
#define DS_KEYPADAPPMODE    6   /* on if val is true */

/* arguments for dskeyboard cursor modes */
#define CURSOR_VT100  	    0	/* vt100 cursor key mode */
#define CURSOR_ANSI	    1	/* ansi cursor key mode */
#define CURSOR_VT52	    2	/* vt52 cursor key mode */

/* arguments for dskeyboard keypad modes */
#define KEYPAD_ANSI	    0	/* ansi numeric */
#define KEYPAD_VT52	    2	/* vt52 numeric */
#define KEYPAD_H19	    4	/* h19 numeric */
#define KEYPAD_H19S	    6	/* h19 shifted numeric */
#define KEYPAD_H19ANSI	    8	/* h19 ansi numeric */
#define KEYPAD_H19SANSI	    10  /* h19 shifted ansi numeric */

/* Allocate display area */
void allocate_display(int width, int height);
void free_display(void);

/* Clear display buffer */
void clear_display(void);

/* tabstops */
void clear_tabstops(void);
void init_tabstops(void);

/* Display reset */
void reset_display(int soft);

/* Redrawing functions */
void redraw_line(int line);
void redraw_display(int resize);

/* Handle window size change */
int resize_display(void);
