#ifndef _PARAMS
#if defined(__STDC__) || defined(__cplusplus)
#define _PARAMS(ARGS) ARGS
#else
#define _PARAMS(ARGS) ()
#endif
#endif /* _PARAMS */
#ifndef _AIX32_CURSES

#ifdef _POWER_PROLOG_
/* @(#)03    1.1  src/bos/usr/ccs/lib/libcurses/copyright.h, libcurses, bos411, 9428A410j 9/3/93 15:07:06 */
/*
 *   COMPONENT_NAME: LIBCURSES
 *
 *   FUNCTIONS:
 *
 *   ORIGINS: 27, 4
 *
 *   This module contains IBM CONFIDENTIAL code. -- (IBM
 *   Confidential Restricted when combined with the aggregated
 *   modules for this product)
 *   OBJECT CODE ONLY SOURCE MATERIALS
 *
 *   (C) COPYRIGHT International Business Machines Corp. 1993
 *   All Rights Reserved
 *   US Government Users Restricted Rights - Use, duplication or
 *   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 *
 */
#endif /* _POWER_PROLOG_ */


/*
 *	Copyright (c) 1984 AT&T	
 *	  All Rights Reserved 

 *	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
 *	The copyright notice above does not evidence any 
 *	actual or intended publication of such source code.
 */

/* #ident	"@(#)curses:screen/curses.ed	1.33"	*/


/*
 * curses.h - this file is automatically made from caps and
 *	curses.ed. Don't make changes directly to curses.h!
 */
#ifndef _H_CURSES

#define _H_CURSES	/* define prevents multiple includes */

#include  <stdio.h>

  /*
   * This trick is used to distinguish between SYSV and V7 systems.
   * We assume that L_ctermid is only defined in stdio.h in SYSV
   * systems, but not in V7 or Berkeley UNIX.
   */
#ifdef L_ctermid
# define SYSV
#endif
   /* Some V7 systems define L_ctermid - we list those here */
#ifdef __sun__
# undef SYSV
#endif

#ifdef SYSV
# ifndef VINTR
#  include <termio.h>
# endif /* VINTR */
    typedef struct termio SGTTY;
#else /* !SYSV */
# ifndef _SGTTYB_
#  include <sgtty.h>
# endif /* _SGTTYB_ */
    typedef struct sgttyb SGTTY;
/*
 * Here we attempt to improve portability by providing some #defines
 * for SYSV functions on non-SYSV systems.
 */

# define memcpy(dst, src, len)	bcopy((src), (dst), (len))
# define strchr			index
# define strrchr		rindex
#endif /* SYSV */

#ifndef __cplusplus
typedef	char bool;
#endif

#define _VR3_COMPAT_CODE
/*
 * chtype is the type used to store a character together with attributes.
 * It can be set to "char" to save space, or "long" to get more attributes.
 */
#ifdef	CHTYPE
	typedef	CHTYPE chtype;
#else
	typedef unsigned long chtype;
#endif /* CHTYPE */

typedef chtype attr_t;

/*
	Define for the 'old' definition of chtype is required
	when we are running in compatibility mode
*/
#ifdef _VR3_COMPAT_CODE
typedef unsigned short _ochtype;
#endif

/* TRUE and FALSE get defined so many times, */
/* let's not get in the way of other definitions. */
#if	!defined(TRUE) || ((TRUE) != 1)
#define	TRUE	(1)
#endif
#if	!defined(FALSE) || ((FALSE) != 0)
#define	FALSE	(0)
#endif
#if	!defined(ERR) || ((ERR) != -1)
#define	ERR	(-1)
#endif
#if	!defined(OK) || ((OK) != 0)
#define	OK	(0)
#endif

/* short-hand notations */
typedef struct _win_st	WINDOW;
typedef struct screen	SCREEN;

struct _win_st
{
	short		_cury, _curx;	/* current coordinates */
	short		_maxy, _maxx;	/* max coordinates */
	short		_begy, _begx;	/* (0,0) screen coordinates */
	char		_flags;
	short		_yoffset;	/* actual begy is _begy+_yoffset */
	bool		_clear,	/* clearok() info */
			_leave,	/* leaveok() info */
			_immed,	/* window in immediate mode */
			_sync;		/* auto syncup of parent */
	WINDOW		*_padwin;	/* "pad" area for current window */
#ifdef	_VR3_COMPAT_CODE
	_ochtype	**_y16;	/* MUST stay at this offset in WINDOW */
#endif
	short		*_firstch;	/* first change in line */
	short		*_lastch;	/* last change in line */
	short		_tmarg, _bmarg;	/* scrolling region bounds */
				/* MUST stay at this offset in WINDOW */
	unsigned	_scroll		: 1;	/* scrollok() info */
	unsigned	_use_idl	: 1;	
	unsigned	_use_keypad	: 1;
	unsigned	_notimeout	: 1;
	unsigned	_use_idc	: 1;	
	chtype		_attrs;	/* current window attributes */
	chtype		_bkgd;		/* background, normally blank */
	int		_delay;		/* delay period on wgetch
					 * 0:  for nodelay
					 * <0: for infinite delay
					 * >0: delay time in units of millisec
					 */
	short		_ndescs;	/* number of descendants */
	short		_parx, _pary;	/* coords relative to parent (0,0) */
	WINDOW		*_parent;	/* the parent if this is a subwin */
	chtype		**_y;			/* lines of data */
};

/* _lastch is initially set to this, _firstch is set to win->_maxx */
#define	_NOCHANGE	-1
#define _INFINITY	16000	/* no line can be longer than this */

/* values for win->_flags */
#define		_SUBWIN     01
#define		_ENDLINE    02
#define		_FULLWIN    04
#define		_SCROLLWIN  010
#define		_FLUSH      020
#define		_ISPAD      040

#define     _WINCHANGED     0100
#define     _WINMOVED       0200
#define     _WINSDEL        0400
#define     _CANT_BE_IMMED  01000
#define     _WIN_ADD_ONE    02000
#define     _WIN_INS_ONE    04000

#define STUPID		0
#define UNKNOWN		1
#define CURS_BAD_MALLOC	2

/*
 * Various tricks to shut up lint about things that are perfectly fine.
 */
#if	defined(lint) && !defined(CURSES) /* if not internal to curses source */
 struct screen {
	 int _nobody_;
 };
#endif /* lint */

/* common external variables */

extern	int	LINES, COLS, TABSIZE, COLORS, COLOR_PAIRS;

extern	short	curs_errno;

extern	WINDOW	*stdscr, *curscr;

extern	char	ttytype[];

/* Function declarations */

extern	SCREEN	*newscreen _PARAMS((char *, int, int, int, FILE *, FILE *)),
		*setcurscreen _PARAMS((SCREEN *));

extern	WINDOW	*initscr(),
		*newwin _PARAMS((int, int, int, int)),
		*newpad _PARAMS((int, int)),
		*derwin _PARAMS((WINDOW *, int, int, int, int)),
		*dupwin _PARAMS((WINDOW *)),
		*getwin _PARAMS((FILE *));

extern	chtype	winch _PARAMS((WINDOW *));

extern	int	wgetch _PARAMS((WINDOW *)); /* because it can return KEY_*, for instance. */

extern	char	*longname(),	/* long name of terminal */
		*termname(),	/* effective terminal name */
		*keyname _PARAMS((int)), /* name of token returned by wgetch() */
		*slk_label _PARAMS((int)),
		curs_parm_err[],
		*curs_err_strings[],
		erasechar(),
		killchar();


extern	void	vidupdate _PARAMS((int , int , int (*) (char))), wsyncup _PARAMS((WINDOW *)), wsyncdown _PARAMS((WINDOW *)),
		delkeymap(), 
		_ring _PARAMS((int)), delscreen _PARAMS((SCREEN *)), curserr(),
		_setqiflush _PARAMS((int)), 
		immedok _PARAMS((WINDOW *, int)), 
		wtimeout _PARAMS((WINDOW *, int)), wbkgdset _PARAMS((WINDOW *, int )),
		wcursyncup _PARAMS((WINDOW *));

extern	int	cbreak(), nocbreak(), 
		reset_prog_mode(), reset_shell_mode(), def_prog_mode(),
		_setecho _PARAMS((int)), _setnonl _PARAMS((int)),
		def_shell_mode(), raw(),
		savetty(), traceon(), _meta _PARAMS((int)), 
		traceoff(), noraw(), flushinp(), _getsyx _PARAMS((int *, int *)),
		nodelay _PARAMS((WINDOW *, int)), resetty(), ripoffline _PARAMS((int, int (*) (WINDOW *, int))), setsyx _PARAMS((int, int)), slk_refresh(),
		slk_restore(), notimeout _PARAMS((WINDOW *, int)), clearok _PARAMS((WINDOW *, int)), leaveok _PARAMS((WINDOW *, int)),
		scrollok _PARAMS((WINDOW *, int)), wstandend _PARAMS((WINDOW *)), wstandout _PARAMS((WINDOW *)); 

extern	int	crmode(), nocrmode(), ungetch _PARAMS((int));

#define getsyx(y,x)		_getsyx(&(y),&(x))

/* 
 * Functions to get at the window structure.
 */

#define getyx(win,y,x)		((y) = getcury(win), (x) = getcurx(win))
#define	getbegyx(win,y,x)	((y) = getbegy(win), (x) = getbegx(win))
#define	getmaxyx(win,y,x)	((y) = getmaxy(win), (x) = getmaxx(win))
#define	getparyx(win,y,x)	((y) = getpary(win), (x) = getparx(win))

#if	defined(PERFORMANCE) && !defined(lint)
#define getcury(win)		((win)->_cury)
#define getcurx(win)		((win)->_curx)
#define	getbegy(win)		((win)->_begy)
#define	getbegx(win)		((win)->_begx)
#define	getmaxy(win)		((win)->_maxy)
#define	getmaxx(win)		((win)->_maxx)
#define	getpary(win)		((win)->_pary)
#define	getparx(win)		((win)->_parx)
#define getbkgd(win)		((win)->_bkgd)
#define getattrs(win)		((win)->_attrs)
#endif	/* defined(PERFORMANCE) && !defined(lint) */

#ifdef	_VR3_COMPAT_CODE

#define newterm		newterm32
extern	SCREEN	*newterm(/*termname,fout,fin*/),
		*set_term(/*screenptr*/);

extern	WINDOW	*initscr32(),
		*subwin _PARAMS((WINDOW *, int, int, int, int)),
		*subpad _PARAMS((WINDOW *, int, int, int, int));

extern	_ochtype	*acs_map;

extern	chtype	*acs32map;

/* definitions for Vr3 source compatibility */

#define initscr		initscr32
#define waddch		w32addch
#define wechochar	w32echochar
#define pechochar	p32echochar
#define winsch		w32insch
#define vidputs		vid32puts
#define vidattr		vid32attr
#define wattroff	w32attroff
#define wattron		w32attron
#define wattrset	w32attrset
#define acs_map		acs32map
#define box		box32

#else	/* _VR3_COMPAT_CODE */

extern	chtype	*acs_map;

#endif	/* _VR3_COMPAT_CODE */

extern	int	wattroff(), wattron(), wattrset();

#if	defined(NOMACROS) || defined(lint)

extern	SCREEN	*newterm(/*termname,fout,fin*/),
		*set_term(/*screenptr*/);

extern	WINDOW	*subpad(),
		*subwin();

extern	char	*unctrl();

extern	chtype	inch(),
		mvinch(),
		mvwinch();

extern	int	intrflush(), meta(), noecho(), echo(), nl(), nonl(), beep(),
		flash(), attroff(), attron(), attrset(), standend(),
		standout();

extern	void	bkgdset(), timeout();

#else	/* NOMACROS || lint */

/*
 * The defines from here down to the #endif for NOMACROS
 * define macros, which may be more efficient than their
 * function versions. The functions may be accessed by defining
 * NOMACROS in C code. This is useful for debugging purposes.
 */

#include  <unctrl.h>

/* pseudo functions for stdscr */
#define	addch(ch)	waddch(stdscr, ch)
#define	addnstr(s,n)	waddnstr(stdscr,s,n)
#define	addstr(str)	waddstr(stdscr, str)
#define	attroff(at)	wattroff(stdscr,at)
#define	attron(at)	wattron(stdscr,at)
#define	attrset(at)	wattrset(stdscr,at)
#define	bkgd(c)		wbkgd(stdscr,c)
#define	border(ls, rs, ts, bs, tl, tr, bl, br)	wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br)	
#define	clear()		wclear(stdscr)
#define	clrtobot()	wclrtobot(stdscr)
#define	clrtoeol()	wclrtoeol(stdscr)
#define	delch()		wdelch(stdscr)
#define	deleteln()	wdeleteln(stdscr)
#define	echochar(ch)	wechochar(stdscr, ch)
#define	erase()		werase(stdscr)
#define	getch()		wgetch(stdscr)
#define	getstr(str)	wgetstr(stdscr, str)
#define	inch()		winch(stdscr)
#define	insch(c)	winsch(stdscr,c)
#define	insdelln(id)	winsdelln(stdscr,id)
#define	insertln()	winsertln(stdscr)
#define	insnstr(s,n)	winsnstr(stdscr,s,n)
#define	insstr(s)	winsstr(stdscr,s)
#define	move(y, x)	wmove(stdscr, y, x)
#define	refresh()	wrefresh(stdscr)
#define	scrl(n)		wscrl(stdscr,n)
#define	setscrreg(t,b)	wsetscrreg(stdscr, t, b)
#define	standend()	wstandend(stdscr)
#define	standout()	wstandout(stdscr)
#define	timeout(tm)	wtimeout(stdscr,tm)
#define	hline(c,num)	whline(stdscr,c,num)
#define	vline(c,num)	wvline(stdscr,c,num)
#define	addchstr(str)	waddchstr(stdscr,str)
#define	addchnstr(str,n)	waddchnstr(stdscr,str,n)
#define	instr(str)	winstr(stdscr,(str))
#define	innstr(str,n)	winnstr(stdscr,(str),(n))
#define	inchstr(str)	winchstr(stdscr,str)
#define	inchnstr(str,n)	winchnstr(stdscr,str,n)
#define	bkgdset(c)	wbkgdset(stdscr,c)

/* functions to define environment flags of a window */
#ifdef	PERFORMANCE
#define	wbkgdset(win,c)		(((win)->_attrs = (((win)->_attrs & ~((win)->_bkgd & A_ATTRIBUTES)) | (c & A_ATTRIBUTES))), ((win)->_bkgd = (c)))
#define syncok(win,bf)		((win)->_parent?(win)->_sync=(bf):ERR)
#define	notimeout(win,bf)	((win)->_notimeout = ((bf) ? TRUE : FALSE))
#define	clearok(win,bf)		((win)->_clear = (bf))
#define	leaveok(win,bf)		((win)->_leave = (bf))
#define	scrollok(win,bf)	((win)->_scroll = ((bf) ? TRUE : FALSE))
#define	idcok(win,bf)		((win)->_use_idc = ((bf) ? TRUE : FALSE))
#define	nodelay(win,bf)		((win)->_delay = (bf) ? 0 : -1)
#define is_wintouched(win)	((win)->_flags & _WINCHANGED)
#define is_linetouched(win,line)	((((line) >= (win)->_maxy) || \
				     ((line) < 0)) ? ERR : \
				    (((win)->_firstch[(line)] == _INFINITY) ? \
								  FALSE : TRUE))
#endif	/* PERFORMANCE */

/* functions for move and update */
#define	mvaddch(y,x,ch)		mvwaddch(stdscr,y,x,ch)
#define	mvaddnstr(y,x,s,n)	mvwaddnstr(stdscr,y,x,s,n)
#define	mvaddstr(y,x,str)	mvwaddstr(stdscr,y,x,str)
#define	mvdelch(y,x)		mvwdelch(stdscr,y,x)
#define	mvgetch(y,x)		mvwgetch(stdscr,y,x)
#define	mvgetstr(y,x,str)	mvwgetstr(stdscr,y,x,str)
#define	mvinch(y,x)		mvwinch(stdscr,y,x)
#define	mvinsch(y,x,c)		mvwinsch(stdscr,y,x,c)
#define	mvinsnstr(y,x,s,n)	mvwinsnstr(stdscr,y,x,s,n)
#define	mvinsstr(y,x,s)		mvwinsstr(stdscr,y,x,s)
#define	mvaddchstr(y,x,str)	mvwaddchstr(stdscr,y,x,str)
#define	mvaddchnstr(y,x,str,n)	mvwaddchnstr(stdscr,y,x,str,n)
#define	mvinstr(y,x,str)	mvwinstr(stdscr,y,x,(str))
#define	mvinnstr(y,x,str,n)	mvwinnstr(stdscr,y,x,(str),(n))
#define	mvinchstr(y,x,str)	mvwinchstr(stdscr,y,x,str)
#define	mvinchnstr(y,x,str,n)	mvwinchnstr(stdscr,y,x,str,n)
#define	mvhline(y,x,c,num)	mvwhline(stdscr,y,x,c,num)
#define	mvvline(y,x,c,num)	mvwvline(stdscr,y,x,c,num)

#define	mvwaddch(win,y,x,ch)	(wmove(win,y,x)==ERR?ERR:waddch(win,ch))
#define	mvwaddnstr(win,y,x,s,n)	(wmove(win,y,x)==ERR?ERR:waddnstr(win,s,n))
#define	mvwaddstr(win,y,x,str)	(wmove(win,y,x)==ERR?ERR:waddstr(win,str))
#define	mvwdelch(win,y,x)	(wmove(win,y,x)==ERR?ERR:wdelch(win))
#define	mvwgetch(win,y,x)	(wmove(win,y,x)==ERR?ERR:wgetch(win))
#define	mvwgetstr(win,y,x,str)	(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
#define	mvwinch(win,y,x)	(wmove(win,y,x)==ERR?(chtype) ERR:winch(win))
#define	mvwinsch(win,y,x,c)	(wmove(win,y,x)==ERR?ERR:winsch(win,c))
#define	mvwinsnstr(win,y,x,s,n)	(wmove(win,y,x)==ERR?ERR:winsnstr(win,s,n))
#define	mvwinsstr(win,y,x,s)	(wmove(win,y,x)==ERR?ERR:winsstr(win,s))
#define	mvwhline(win,y,x,c,num)	(wmove(win,y,x)==ERR?ERR:whline(win,c,num))
#define	mvwvline(win,y,x,c,num)	(wmove(win,y,x)==ERR?ERR:wvline(win,c,num))
#define	mvwaddchstr(win,y,x,str)	(wmove(win,y,x)==ERR?ERR:waddchstr(win,str))
#define	mvwaddchnstr(win,y,x,str,n)	(wmove(win,y,x)==ERR?ERR:waddchnstr(win,str,n))
#define	mvwinstr(win,y,x,str)	(wmove(win,y,x)==ERR?ERR:winstr(win,str))
#define	mvwinnstr(win,y,x,str,n)	(wmove(win,y,x)==ERR?ERR:winnstr(win,str,n))
#define	mvwinchstr(win,y,x,str)	(wmove(win,y,x)==ERR?ERR:winchstr(win,str))
#define	mvwinchnstr(win,y,x,str,n)	(wmove(win,y,x)==ERR?ERR:winchnstr(win,str,n))

#ifdef CURSES_MACROS
#define overlay(src,dst)	_overlap((src),(dst),TRUE)
#define overwrite(src,dst)	_overlap((src),(dst),FALSE)
#define wdeleteln(win)		winsdelln((win),-1)
#define winsertln(win)		winsdelln((win),1)
#define wstandend(win)		wattrset((win),A_NORMAL)
#define wstandout(win)		wattron((win),A_STANDOUT)
#define beep()			_ring(TRUE)
#define flash()			_ring(FALSE)
#define scroll(win)		wscrl((win),1)
#define slk_init(f)		slk_start(((f == 0) ? 3 : 2),NULL)
#define	scr_init(file)		_scr_all(file,0)
#define	scr_restore(file)	_scr_all(file,1)
#define subpad(win,nl,nc,by,bx)	derwin((win),(nl),(nc),(by),(bx))
#define box(win,v,h)		wborder((win),(v),(v),(h),(h),0,0,0,0)
#define newterm(type,fout,fin)	newscreen((type),0,0,0,(fout),(fin))
#define touchline(win,y,n)	wtouchln((win),(y),(n),TRUE)
#endif /* CURSES_MACROS */

#define garbagedlines		wredrawln
#define garbagedwin		redrawwin
#ifdef	PERFORMANCE
#define subwin(win,nl,nc,by,bx)	derwin((win),(nl),(nc),(by-win->_begy),(bx-win->_begx))
#define touchwin(win)		wtouchln((win),0,(win)->_maxy,TRUE)
#define redrawwin(win)		wredrawln((win),0,(win)->_maxy)
#define	winchstr(win,str)	winchnstr((win),str,((win)->_maxx - (win)->_curx))
#define	winstr(win,str)		winnstr((win),str,((win)->_maxx - (win)->_curx))
#define untouchwin(win)		wtouchln((win),0,((win)->_maxy),FALSE)
#define	winch(win)		((win)->_y[(win)->_cury][(win)->_curx])
#endif	/* PERFORMANCE */

#ifdef CURSES_MACROS
#define waddstr(win,str)	waddnstr((win),(str),-1)
#define werase(win)		(wmove((win),0,0), wclrtobot(win))
#define wclear(win)		(clearok((win),TRUE), werase(win))
#define intrflush(win,flag)	_setqiflush(flag)
#define meta(win,flag)		_meta(flag)
#endif /* CURSES_MACROS */

#define crmode			cbreak
#define nocrmode		nocbreak
#define saveterm		def_prog_mode
#define fixterm			reset_prog_mode
#define resetterm		reset_shell_mode

#ifdef CURSES_MACROS
#define setterm(name)		setupterm((name),1,(char*)NULL)
#define gettmode()		(OK)
#define halfdelay(tens)		ttimeout((tens)*100)
#endif /* CURSES_MACROS */

#define	waddchstr(win,str)	waddchnstr((win),(str),-1)
#define winsstr(win,str)	winsnstr((win),(str),-1)

/* iocontrol functions */
#define qiflush()		_setqiflush(TRUE)
#define noqiflush()		_setqiflush(FALSE)

#ifdef CURSES_MACROS
#define echo()			_setecho(TRUE)
#define noecho()		_setecho(FALSE)
#define nl()			_setnonl(FALSE)
#define nonl()			_setnonl(TRUE)
#endif /* CURSES_MACROS */

/* functions for setting time-out length on inputs */
#ifdef	PERFORMANCE
#define wtimeout(win,tm)	((win)->_delay = (tm))

/* functions for accessing selected TERMINAL fields	*/
#define	can_change_color()	can_change
#define has_colors()		((max_pairs == -1) ? FALSE : TRUE)
#endif	/* PERFORMANCE */

#define set_term		setcurscreen
#define	scr_set(file)		_scr_all(file,2)

#endif	/* NOMACROS || lint */

/*
 * Standard alternate character set.  The current ACS world is evolving,
 * so we support only a widely available subset: the line drawing characters
 * from the VT100, plus a few from the Teletype 5410v1.  Eventually there
 * may be support of more sophisticated ACS line drawing, such as that
 * in the Teletype 5410, the HP line drawing set, and the like.  There may
 * be support for some non line oriented characters as well.
 *
 * Line drawing ACS names are of the form ACS_trbl, where t is the top, r
 * is the right, b is the bottom, and l is the left.  t, r, b, and l might
 * be B (blank), S (single), D (double), or T (thick).  The subset defined
 * here only uses B and S.
 */

#define ACS_BSSB	(acs_map['l'])
#define ACS_SSBB	(acs_map['m'])
#define ACS_BBSS	(acs_map['k'])
#define ACS_SBBS	(acs_map['j'])
#define ACS_SBSS	(acs_map['u'])
#define ACS_SSSB	(acs_map['t'])
#define ACS_SSBS	(acs_map['v'])
#define ACS_BSSS	(acs_map['w'])
#define ACS_BSBS	(acs_map['q'])
#define ACS_SBSB	(acs_map['x'])
#define ACS_SSSS	(acs_map['n'])

/*
 * Human readable names for the most commonly used characters.
 * "Upper", "right", etc. are chosen to be consistent with the vt100 manual.
 */

#define ACS_ULCORNER	ACS_BSSB
#define ACS_LLCORNER	ACS_SSBB
#define ACS_URCORNER	ACS_BBSS
#define ACS_LRCORNER	ACS_SBBS
#define ACS_RTEE	ACS_SBSS
#define ACS_LTEE	ACS_SSSB
#define ACS_BTEE	ACS_SSBS
#define ACS_TTEE	ACS_BSSS
#define ACS_HLINE	ACS_BSBS
#define ACS_VLINE	ACS_SBSB
#define ACS_PLUS	ACS_SSSS
#define ACS_S1		(acs_map['o'])	/* scan line 1 */
#define ACS_S9		(acs_map['s'])	/* scan line 9 */
#define ACS_DIAMOND	(acs_map['`'])	/* diamond */
#define ACS_CKBOARD	(acs_map['a'])	/* checker board (stipple) */
#define ACS_DEGREE	(acs_map['f'])	/* degree symbol */
#define ACS_PLMINUS	(acs_map['g'])	/* plus/minus */
#define ACS_BULLET	(acs_map['~'])	/* bullet */
	/* Teletype 5410v1 symbols */
#define ACS_LARROW	(acs_map[','])	/* arrow pointing left */
#define ACS_RARROW	(acs_map['+'])	/* arrow pointing right */
#define ACS_DARROW	(acs_map['.'])	/* arrow pointing down */
#define ACS_UARROW	(acs_map['-'])	/* arrow pointing up */
#define ACS_BOARD	(acs_map['h'])	/* board of squares */
#define ACS_LANTERN	(acs_map['i'])	/* lantern symbol */
#define ACS_BLOCK	(acs_map['0'])	/* solid square block */

/* Funny "characters" enabled for various special function keys for input */
/* This list is created from caps and curses.ed. Do not edit it! */
#define KEY_MIN		03501		/* Minimum curses key */
#define KEY_BREAK	03501		/* break key (unreliable) */
#define KEY_DOWN	03502		/* Sent by terminal down arrow key */
#define KEY_UP		03503		/* Sent by terminal up arrow key */
#define KEY_LEFT	03504		/* Sent by terminal left arrow key */
#define KEY_RIGHT	03505		/* Sent by terminal right arrow key */
#define KEY_HOME	03506		/* Sent by home key. */
#define KEY_BACKSPACE	03507		/* Sent by backspace key */
#define KEY_F0		03510		/* function key f0. */
#define KEY_F(n)	(KEY_F0+(n))	/* Space for 64 function keys is reserved. */
#define KEY_DL		03610		/* Sent by delete line key. */
#define KEY_IL		03611		/* Sent by insert line. */
#define KEY_DC		03612		/* Sent by delete character key. */
#define KEY_IC		03613		/* Sent by ins char/enter ins mode key. */
#define KEY_EIC		03614		/* Sent by rmir or smir in insert mode. */
#define KEY_CLEAR	03615		/* Sent by clear screen or erase key. */
#define KEY_EOS		03616		/* Sent by clear-to-end-of-screen key. */
#define KEY_EOL		03617		/* Sent by clear-to-end-of-line key. */
#define KEY_SF		03620		/* Sent by scroll-forward/down key */
#define KEY_SR		03621		/* Sent by scroll-backward/up key */
#define KEY_NPAGE	03622		/* Sent by next-page key */
#define KEY_PPAGE	03623		/* Sent by previous-page key */
#define KEY_STAB	03624		/* Sent by set-tab key */
#define KEY_CTAB	03625		/* Sent by clear-tab key */
#define KEY_CATAB	03626		/* Sent by clear-all-tabs key. */
#define KEY_ENTER	03627		/* Enter/send (unreliable) */
#define KEY_SRESET	03630		/* soft (partial) reset (unreliable) */
#define KEY_RESET	03631		/* reset or hard reset (unreliable) */
#define KEY_PRINT	03632		/* print or copy */
#define KEY_LL		03633		/* Sent by home-down key */
					/* The keypad is arranged like this: */
					/*    a1    up    a3   */
					/*   left   b2  right  */
					/*    c1   down   c3   */
#define KEY_A1		03634		/* Upper left of keypad */
#define KEY_A3		03635		/* Upper right of keypad */
#define KEY_B2		03636		/* Center of keypad */
#define KEY_C1		03637		/* Lower left of keypad */
#define KEY_C3		03640		/* Lower right of keypad */
#define KEY_BTAB	03641		/* Back tab key */
#define KEY_BEG		03642		/* beg(inning) key */
#define KEY_CANCEL	03643		/* cancel key */
#define KEY_CLOSE	03644		/* close key */
#define KEY_COMMAND	03645		/* cmd (command) key */
#define KEY_COPY	03646		/* copy key */
#define KEY_CREATE	03647		/* create key */
#define KEY_END		03650		/* end key */
#define KEY_EXIT	03651		/* exit key */
#define KEY_FIND	03652		/* find key */
#define KEY_HELP	03653		/* help key */
#define KEY_MARK	03654		/* mark key */
#define KEY_MESSAGE	03655		/* message key */
#define KEY_MOVE	03656		/* move key */
#define KEY_NEXT	03657		/* next object key */
#define KEY_OPEN	03660		/* open key */
#define KEY_OPTIONS	03661		/* options key */
#define KEY_PREVIOUS	03662		/* previous object key */
#define KEY_REDO	03663		/* redo key */
#define KEY_REFERENCE	03664		/* ref(erence) key */
#define KEY_REFRESH	03665		/* refresh key */
#define KEY_REPLACE	03666		/* replace key */
#define KEY_RESTART	03667		/* restart key */
#define KEY_RESUME	03670		/* resume key */
#define KEY_SAVE	03671		/* save key */
#define KEY_SBEG	03672		/* shifted beginning key */
#define KEY_SCANCEL	03673		/* shifted cancel key */
#define KEY_SCOMMAND	03674		/* shifted command key */
#define KEY_SCOPY	03675		/* shifted copy key */
#define KEY_SCREATE	03676		/* shifted create key */
#define KEY_SDC		03677		/* shifted delete char key */
#define KEY_SDL		03700		/* shifted delete line key */
#define KEY_SELECT	03701		/* select key */
#define KEY_SEND	03702		/* shifted end key */
#define KEY_SEOL	03703		/* shifted clear line key */
#define KEY_SEXIT	03704		/* shifted exit key */
#define KEY_SFIND	03705		/* shifted find key */
#define KEY_SHELP	03706		/* shifted help key */
#define KEY_SHOME	03707		/* shifted home key */
#define KEY_SIC		03710		/* shifted input key */
#define KEY_SLEFT	03711		/* shifted left arrow key */
#define KEY_SMESSAGE	03712		/* shifted message key */
#define KEY_SMOVE	03713		/* shifted move key */
#define KEY_SNEXT	03714		/* shifted next key */
#define KEY_SOPTIONS	03715		/* shifted options key */
#define KEY_SPREVIOUS	03716		/* shifted prev key */
#define KEY_SPRINT	03717		/* shifted print key */
#define KEY_SREDO	03720		/* shifted redo key */
#define KEY_SREPLACE	03721		/* shifted replace key */
#define KEY_SRIGHT	03722		/* shifted right arrow */
#define KEY_SRSUME	03723		/* shifted resume key */
#define KEY_SSAVE	03724		/* shifted save key */
#define KEY_SSUSPEND	03725		/* shifted suspend key */
#define KEY_SUNDO	03726		/* shifted undo key */
#define KEY_SUSPEND	03727		/* suspend key */
#define KEY_UNDO	03730		/* undo key */
#define KEY_ACTION	03731		/* Sent by the action key. */
#define KEY_MAX		03777		/* Maximum curses key */

/*
	The definition for 'reg' is not standard, and is provided for
	compatibility reasons. User's are discouraged from using this.
*/
#define	reg	register

/* Various video attributes */
/*
   We start from the left and attributes bits from left to right to permit
  larger collating sequences.  Add attributes in this fashion if necessary.
*/

#define A_STANDOUT  0x00010000
#define	_STANDOUT	A_STANDOUT    /* for compatability with old curses */
#define A_UNDERLINE 0x00020000
#define A_REVERSE   0x00040000
#define A_BLINK     0x00080000
#define A_DIM       0x00100000
#define A_BOLD      0x00200000

/* The next two are subject to change so don't depend on them */
#define A_INVIS     0x00400000
#define A_PROTECT   0x00800000

#define A_ALTCHARSET    0x01000000

#define A_NORMAL    0x00000000
#define A_ATTRIBUTES    0xffff0000
#define A_CHARTEXT  0x0000ffff

#define A_COLOR		0x7e000000

#define COLOR_PAIR(n)	((n) << 25)
#define PAIR_NUMBER(n)	(((n) & A_COLOR) >> 25)

/* definition of 8 basic color	*/
#define COLOR_BLACK	0
#define COLOR_BLUE	1
#define COLOR_GREEN	2
#define COLOR_CYAN	3
#define COLOR_RED	4
#define COLOR_MAGENTA	5
#define COLOR_YELLOW	6
#define COLOR_WHITE	7
#endif /* _H_CURSES */

#else /* _AIX32_CURSES */

/* @(#)42    1.1  src/bos/usr/ccs/lib/libcurses/compat/curses3.h, libcurses, bos411, 9428A410j 2/9/94 07:20:47 */
#ifndef _H_CURSES
#define _H_CURSES

/*
 *   COMPONENT_NAME: LIBCURSES
 *
 *   FUNCTIONS: curses3.h
 *
 *   ORIGINS: 3,10,27
 *
 *   This module contains IBM CONFIDENTIAL code. -- (IBM
 *   Confidential Restricted when combined with the aggregated
 *   modules for this product)
 *   OBJECT CODE ONLY SOURCE MATERIALS
 *
 *   (C) COPYRIGHT International Business Machines Corp. 1985,1988
 *   All Rights Reserved
 *   US Government Users Restricted Rights - Use, duplication or
 *   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 */



#ifndef WINDOW

#ifndef _H_NLCHAR
#include <sys/NLchar.h>
#endif

# ifndef 	NONSTANDARD
#  include  <stdio.h>
  /*
   * This is used to distinguish between USG and V7 systems.
   * Assume that L_ctermid is only defined in stdio.h in USG
   * systems, but not in V7 or Berkeley UNIX.
   */
#  ifdef L_ctermid
#  define USG
#  endif
#  include  <unctrl.h>
#  ifdef USG
#   include <termio.h>
   typedef struct termio SGTTY;
#  else
#   include <sgtty.h>
   typedef struct sgttyb SGTTY;
#  endif
# else          /* NONSTANDARD */
/*
 * NONSTANDARD is intended for a standalone program (no UNIX)
 * that manages screens.  The specific program is Alan Hewett's
 * ITC, which runs standalone on an 11/23 (at least for now).
 * It is unclear whether this code needs to be supported anymore.
 */
#define NULL 0
# endif		/* NONSTANDARD */

/*
 * chtype is the type used to store a character together with attributes.
 * It can be set to "char" to save space, or "long" to get more attributes.
 */
# ifdef	CHTYPE
	typedef	CHTYPE chtype;
# else
	typedef unsigned long chtype;
# endif /* CHTYPE */

# define        TRUE    1
# define        FALSE   0

# define        ERR     (-1)
# define        OK      0

# define	_SUBWIN		01
# define	_ENDLINE	02
# define	_FULLWIN	04
# define	_SCROLLWIN	010
# define	_FLUSH		020
# define	_ISPAD		040
# define	_STANDOUT	0x80000000
# define        _NOCHANGE       (-1)

#ifndef __cplusplus
typedef char bool ; /* bool type required by X/open */
#endif

struct _win_st {
	short	_cury, _curx;
	short	_maxy, _maxx;
	short	_begy, _begx;
	short   _flags;
	chtype  _attrs;
	char    _clear;
	char    _leave;
	char    _scroll;
	char    _use_idl;
	char    _use_keypad;    /* 0=no, 1=yes, 2=yes/timeout */
	char    _use_meta;      /* T=use the meta key */
	char    _nodelay;       /* T=don't wait for tty input */
	chtype	**_y;
	short	*_firstch;
	short	*_lastch;
	short	_tmarg,_bmarg;
};

extern int	LINES, COLS;

typedef struct _win_st	WINDOW;
extern WINDOW	*stdscr, *curscr;

extern char	*Def_term, ttytype[];

typedef struct screen	SCREEN;

# ifndef NOMACROS 
#  ifndef MINICURSES
/*
 * psuedo functions for standard screen
 */
# define	addch(ch)	waddch(stdscr, ch)
# define	getch()		wgetch(stdscr)
# define	NLgetch()	NLwgetch(stdscr)
# define	addstr(str)	waddstr(stdscr, str)
# define	getstr(str)	wgetstr(stdscr, str)
# define	move(y, x)	wmove(stdscr, y, x)
# define	clear()		wclear(stdscr)
# define	erase()		werase(stdscr)
# define	clrtobot()	wclrtobot(stdscr)
# define	clrtoeol()	wclrtoeol(stdscr)
# define	insertln()	winsertln(stdscr)
# define	deleteln()	wdeleteln(stdscr)
# define	refresh()	wrefresh(stdscr)
# define	inch()		winch(stdscr)
# define	insch(c)	winsch(stdscr,c)
# define	delch()		wdelch(stdscr)
# define	standout()	wstandout(stdscr)
# define	standend()	wstandend(stdscr)
# define	attron(at)	wattron(stdscr,at)
# define	attroff(at)	wattroff(stdscr,at)
# define	attrset(at)	wattrset(stdscr,at)

# define	setscrreg(t,b)	wsetscrreg(stdscr, t, b)
# define	wsetscrreg(win,t,b)	(win->_tmarg=(t),win->_bmarg=(b))

/*
 * mv functions
 */
#define	mvwaddch(win,y,x,ch)	(wmove(win,y,x)==ERR?ERR:waddch(win,ch))
#define	mvwgetch(win,y,x)	(wmove(win,y,x)==ERR?ERR:wgetch(win))
#define	mvwaddstr(win,y,x,str)	(wmove(win,y,x)==ERR?ERR:waddstr(win,str))
#define	mvwgetstr(win,y,x,str)	(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
#define	mvwinch(win,y,x)	(wmove(win,y,x)==ERR?ERR:winch(win))
#define	mvwdelch(win,y,x)	(wmove(win,y,x)==ERR?ERR:wdelch(win))
#define	mvwinsch(win,y,x,c)	(wmove(win,y,x)==ERR?ERR:winsch(win,c))
#define	mvaddch(y,x,ch)		mvwaddch(stdscr,y,x,ch)
#define	mvgetch(y,x)		mvwgetch(stdscr,y,x)
#define	mvaddstr(y,x,str)	mvwaddstr(stdscr,y,x,str)
#define	mvgetstr(y,x,str)	mvwgetstr(stdscr,y,x,str)
#define	mvinch(y,x)		mvwinch(stdscr,y,x)
#define	mvdelch(y,x)		mvwdelch(stdscr,y,x)
#define	mvinsch(y,x,c)		mvwinsch(stdscr,y,x,c)

#  else /* MINICURSES */

# define	addch(ch)		m_addch(ch)
# define	addstr(str)		m_addstr(str)
# define	move(y, x)		m_move(y, x)
# define	clear()			m_clear()
# define	erase()			m_erase()
# define	refresh()		m_refresh()
# define	standout()		wstandout(stdscr)
# define	standend()		wstandend(stdscr)
# define	attron(at)		wattron(stdscr,at)
# define	attroff(at)		wattroff(stdscr,at)
# define	attrset(at)		wattrset(stdscr,at)
# define	mvaddch(y,x,ch)		move(y, x), addch(ch)
# define	mvaddstr(y,x,str)	move(y, x), addstr(str)
# define	initscr			m_initscr
# define	newterm			m_newterm

/*
 * These functions don't exist in minicurses, so we define them
 * to nonexistent functions to help the user catch the error.
 */
#define	getch		m_getch
#define	getstr		m_getstr
#define	clrtobot	m_clrtobot
#define	clrtoeol	m_clrtoeol
#define	insertln	m_insertln
#define	deleteln	m_deleteln
#define	inch		m_inch
#define	insch		m_insch
#define	delch		m_delch
/* mv functions that aren't valid */
#define	mvwaddch	m_mvwaddch
#define	mvwgetch	m_mvwgetch
#define	mvwaddstr	m_mvaddstr
#define	mvwgetstr	m_mvwgetstr
#define	mvwinch		m_mvwinch
#define	mvwdelch	m_mvwdelch
#define	mvwinsch	m_mvwinsch
#define	mvgetch		m_mvwgetch
#define	mvgetstr	m_mvwgetstr
#define	mvinch		m_mvwinch
#define	mvdelch		m_mvwdelch
#define	mvinsch		m_mvwinsch
/* Real functions that aren't valid */
#define box		m_box
#define delwin		m_delwin
#define longname	m_longname
#define makenew		m_makenew
#define mvprintw	m_mvprintw
#define mvscanw		m_mvscanw
#define mvwin		m_mvwin
#define mvwprintw	m_mvwprintw
#define mvwscanw	m_mvwscanw
#define newwin		m_newwin
#define _outchar        m_outchar
#define overlay		m_overlay
#define overwrite	m_overwrite
#define printw		m_printw
#define putp		m_putp
#define scanw		m_scanw
#define scroll		m_scroll
#define subwin		m_subwin
#define touchwin	m_touchwin
#define _tscroll        m_tscroll
#define _tstp		m_tstp
#define vidattr		m_vidattr
#define waddch		m_waddch
#define waddstr		m_waddstr
#define wclear		m_wclear
#define wclrtobot	m_wclrtobot
#define wclrtoeol	m_wclrtoeol
#define wdelch		m_wdelch
#define wdeleteln	m_wdeleteln
#define werase		m_werase
#define wgetch		m_wgetch
#define wgetstr		m_wgetstr
#define winsch		m_winsch
#define winsertln	m_winsertln
#define wmove		m_wmove
#define wprintw		m_wprintw
#define wrefresh	m_wrefresh
#define wscanw		m_wscanw
#define setscrreg	m_setscrreg
#define wsetscrreg	m_wsetscrreg

#  endif /* MINICURSES */

/*
 * psuedo functions
 */

#define	getyx(win,y,x)	 y = win->_cury, x = win->_curx
#define	winch(win)	 (win->_y[win->_cury][win->_curx])
#define flushok(win,bf)  (bf ? (win->_flags|=_FLUSH):(win->_flags&=~_FLUSH))

WINDOW	*initscr(), *newwin(), *subwin(), *newpad();
char	*longname();
char	erasechar(), killchar();
int	wgetch();	/* because it can return KEY_*, for instance. */
SCREEN	*newterm();

/* Various video attributes */
/*
   We start from the left and attributes bits from left to right to permit
   larger collating sequences.  Add attributes in this fashion if necessary.
*/

#define A_STANDOUT	0x80000000
#define A_UNDERLINE	0x40000000
#define A_REVERSE	0x20000000
#define A_BLINK		0x10000000
#define A_DIM		0x08000000
#define A_BOLD		0x04000000

#define A_INVIS		0x02000000
#define A_PROTECT	0x01000000
#define A_ALTCHARSET	0x00800000

#define A_NORMAL	0x00000000
#define A_ATTRIBUTES	0xff800000
#define A_CHARTEXT	0x007fffff

/* Funny "characters" enabled for various special function keys for input */
/*
 * Under NLS, we start their collation around 3500 octal (1856 decimal)
 * to permit room for NLS characters with large values
*/
#define KEY_BREAK	03501		/* break key (unreliable) */
#define KEY_DOWN	03502		/* The four arrow keys ... */
#define KEY_UP		03503
#define KEY_LEFT	03504
#define KEY_RIGHT	03505		/* ... */
#define KEY_HOME	03506		/* Home key (upward+left arrow) */
#define KEY_BACKSPACE	03507		/* backspace (unreliable) */
#define KEY_F0		03510		/* Function keys.  Space for 64 */
#define KEY_F(n)	(KEY_F0+(n))	/* keys is reserved. */
#define KEY_DL		03610		/* Delete line */
#define KEY_IL		03611		/* Insert line */
#define KEY_DC		03612		/* Delete character */
#define KEY_IC		03613		/* Insert char or enter insert mode */
#define KEY_EIC		03614		/* Exit insert char mode */
#define KEY_CLEAR	03615		/* Clear screen */
#define KEY_EOS		03616		/* Clear to end of screen */
#define KEY_EOL		03617		/* Clear to end of line */
#define KEY_SF		03620		/* Scroll 1 line forward */
#define KEY_SR          03621           /* Scroll 1 line backwards (reverse)*/
#define KEY_NPAGE	03622		/* Next page */
#define KEY_PPAGE	03623		/* Previous page */
#define KEY_STAB	03624		/* Set tab */
#define KEY_CTAB	03625		/* Clear tab */
#define KEY_CATAB	03626		/* Clear all tabs */
#define KEY_ENTER	03627		/* Enter or send (unreliable) */
#define KEY_SRESET      03630           /* soft (partial) reset (unreliable)*/
#define KEY_RESET	03631		/* reset or hard reset (unreliable) */
#define KEY_PRINT	03632		/* print or copy */
#define KEY_LL		03633		/* home down or bottom (lower left) */
					/* The keypad is arranged like this:*/
					/*    a1    up    a3   */
					/*   left   b2  right  */
					/*    c1   down   c3   */
#define KEY_A1		03634		/* upper left of keypad */
#define KEY_A3		03635		/* upper right of keypad */
#define KEY_B2		03636		/* center of keypad */
#define KEY_C1		03637		/* lower left of keypad */
#define KEY_C3		03640		/* lower right of keypad */
#define KEY_ACTION      03641           /* Action key            */
#define KEY_END         03642           /* End key               */
#define KEY_BTAB        03643           /* Back-tab key          */

SCREEN * set_term (SCREEN * n) ; /* prototype for set_term */

# endif /* NOMACROS */
#endif /* WINDOW */

#endif /* _H_CURSES */


#endif /* _AIX32_CURSES */
#if defined(__USE_FIXED_PROTOTYPES__) || defined(__cplusplus) || defined (__STRICT_ANSI__)
extern int delwin (WINDOW *);
extern int endwin (void);
extern int getcurx (WINDOW *);
extern int getcury (WINDOW *);
extern int mvcur (int, int, int, int);
extern int mvwprintw (WINDOW *, int, int, ...);
extern int mvwscanw (WINDOW *, int, int, ...);
extern int overlay (WINDOW *, WINDOW *);
extern int overwrite (WINDOW *, WINDOW *);
extern int scroll (WINDOW *);
extern int touchwin (WINDOW *);
extern int waddstr (WINDOW *, char *);
extern int wclear (WINDOW *);
extern int wclrtobot (WINDOW *);
extern int wclrtoeol (WINDOW *);
extern int wdelch (WINDOW *);
extern int wdeleteln (WINDOW *);
extern int werase (WINDOW *);
extern int wgetstr (WINDOW *, char *);
extern int winsertln (WINDOW *);
extern int wmove (WINDOW *, int, int);
extern int wprintw (WINDOW *, ...);
extern int wrefresh (WINDOW *);
extern int wscanw (WINDOW *, ...);
#endif /* defined(__USE_FIXED_PROTOTYPES__) || ... */
