/* simple curses.h for VT52 */

#ifdef __TURBOC__
# include <tos.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <termcap.h>

#define __STDC__
#define NOSIGNAL

# define	TRUE	(1)
# define	FALSE	(0)
# define	ERR	(0)
# define	OK	(1)

# define	_ENDLINE	001
# define	_FULLWIN	002
# define	_SCROLLWIN	004
# define	_FLUSH		010
# define	_FULLLINE	020
# define	_IDLINE		040
# define	_STANDOUT	0200
# define	_NOCHANGE	-1

extern char AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL,
			XB, XN, XT, XS, XX;
extern char	*AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
			*DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
			*K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
			*KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
			*SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
			*VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM,
			*LEFT_PARM, *RIGHT_PARM;

typedef struct _win_st {
	short		_cury, _curx;
	short		_maxy, _maxx;
	short		_begy, _begx;
	short		_flags;
	short		_ch_off;
	char		_clear;
	char		_leave;
	char		_scroll;
	char		**_y;
	short		*_firstch;
	short		*_lastch;
	struct _win_st	*_nextp, *_orig;
} WINDOW;

extern int		LINES, COLS, _tty_ch, _res_flg;
extern WINDOW	*stdscr, *curscr;

extern int outc(int c);	/* must be a real function */

/* # define	getch()		*/

#define addstr(buf)			Cconws(buf)
#define addch(ch)			Cconout(ch)
#define clear()				tputs(CL,1,outc)
#define clrtoeol()			tputs(CE,1,outc)
#define clrtobot()			tputs(CD,1,outc)
#define insertln()
#define deleteln()			tputs(DL,1,outc)
#define refresh()
#define endscr()
#define crmode()
#define noecho()
#define nonl()
#define	addbytes(da,co)
#define	getstr(str)
#define	erase()				clear()
#define	inch()				
#define	insch(c)			tputs(IC,1,outc)
#define	delch()				tputs(DC,1,outc)
#define	standout()			tputs(SO,1,outc)
#define	standend()			tputs(SE,1,outc)
#define mvcur(a,b,c,d)
#define mvaddch(rw,cl,ch)	{move(rw,cl); addch(ch);}
#define	clearok(win,bf)		(win->_clear=bf)
#define	leaveok(win,bf)		(win->_leave=bf)
#define	scrollok(win,bf)	(win->_scroll=bf)
#define flushok(win,bf)		(bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH))
#define	getyx(win,y,x)		{y=win->_cury; x=win->_curx;}
#define	winch(win)			(win->_y[win->_cury][win->_curx] & 0177)

extern WINDOW	*initscr(void);
extern void		endwin(void);
extern void		move(int rw,int cl);
extern int		printw(char *fmt, ...);
extern int		mvprintw(int rw,int cl,char *fmt, ...);
