17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * Copyright 1997 Sun Microsystems, Inc.  All rights reserved.
37c478bdstevel@tonic-gate * Use is subject to license terms.
47c478bdstevel@tonic-gate */
57c478bdstevel@tonic-gate
67c478bdstevel@tonic-gate/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
77c478bdstevel@tonic-gate/*	  All Rights Reserved  	*/
87c478bdstevel@tonic-gate
97c478bdstevel@tonic-gate/*
107c478bdstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California.
117c478bdstevel@tonic-gate * All rights reserved.  The Berkeley software License Agreement
127c478bdstevel@tonic-gate * specifies the terms and conditions for redistribution.
137c478bdstevel@tonic-gate */
147c478bdstevel@tonic-gate
157c478bdstevel@tonic-gate#ifndef	_CURSES_H
167c478bdstevel@tonic-gate#define	_CURSES_H
177c478bdstevel@tonic-gate
187c478bdstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
197c478bdstevel@tonic-gate
207c478bdstevel@tonic-gate#ifdef __cplusplus
217c478bdstevel@tonic-gateextern "C" {
227c478bdstevel@tonic-gate#endif
237c478bdstevel@tonic-gate
247c478bdstevel@tonic-gate#ifndef WINDOW
257c478bdstevel@tonic-gate
267c478bdstevel@tonic-gate#include	<stdio.h>
277c478bdstevel@tonic-gate#include	<sgtty.h>
287c478bdstevel@tonic-gate
297c478bdstevel@tonic-gate#undef		HZ		/* in case they've included <sys/param.h> */
307c478bdstevel@tonic-gate
317c478bdstevel@tonic-gate#if !(defined(__cplusplus) && defined(_BOOL))
327c478bdstevel@tonic-gate#define	bool	char
337c478bdstevel@tonic-gate#endif
347c478bdstevel@tonic-gate
357c478bdstevel@tonic-gate#define	reg	register
367c478bdstevel@tonic-gate
377c478bdstevel@tonic-gate#define	TRUE	(1)
387c478bdstevel@tonic-gate#define	FALSE	(0)
397c478bdstevel@tonic-gate#define	ERR	(0)
407c478bdstevel@tonic-gate#define	OK	(1)
417c478bdstevel@tonic-gate
427c478bdstevel@tonic-gate#define	_ENDLINE	001
437c478bdstevel@tonic-gate#define	_FULLWIN	002
447c478bdstevel@tonic-gate#define	_SCROLLWIN	004
457c478bdstevel@tonic-gate#define	_FLUSH		010
467c478bdstevel@tonic-gate#define	_FULLLINE	020
477c478bdstevel@tonic-gate#define	_IDLINE		040
487c478bdstevel@tonic-gate#define	_STANDOUT	0200
497c478bdstevel@tonic-gate#define	_NOCHANGE	-1
507c478bdstevel@tonic-gate
517c478bdstevel@tonic-gate#define	_puts(s)	tputs(s, 0, _putchar)
527c478bdstevel@tonic-gate
537c478bdstevel@tonic-gatetypedef	struct sgttyb	SGTTY;
547c478bdstevel@tonic-gate
557c478bdstevel@tonic-gate/*
567c478bdstevel@tonic-gate * Capabilities from termcap
577c478bdstevel@tonic-gate */
587c478bdstevel@tonic-gate
597c478bdstevel@tonic-gateextern	bool	AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL,
607c478bdstevel@tonic-gate		XB, XN, XT, XS, XX;
617c478bdstevel@tonic-gateextern	char	*AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
627c478bdstevel@tonic-gate		*DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
637c478bdstevel@tonic-gate		*K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
647c478bdstevel@tonic-gate		*KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
657c478bdstevel@tonic-gate		*SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
667c478bdstevel@tonic-gate		*VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM,
677c478bdstevel@tonic-gate		*LEFT_PARM, *RIGHT_PARM;
687c478bdstevel@tonic-gateextern char	PC;
697c478bdstevel@tonic-gate
707c478bdstevel@tonic-gate/*
717c478bdstevel@tonic-gate * From the tty modes...
727c478bdstevel@tonic-gate */
737c478bdstevel@tonic-gate
747c478bdstevel@tonic-gateextern bool	GT, NONL, UPPERCASE, normtty, _pfast;
757c478bdstevel@tonic-gate
767c478bdstevel@tonic-gatestruct _win_st {
777c478bdstevel@tonic-gate	short		_cury, _curx;
787c478bdstevel@tonic-gate	short		_maxy, _maxx;
797c478bdstevel@tonic-gate	short		_begy, _begx;
807c478bdstevel@tonic-gate	short		_flags;
817c478bdstevel@tonic-gate	short		_ch_off;
827c478bdstevel@tonic-gate	bool		_clear;
837c478bdstevel@tonic-gate	bool		_leave;
847c478bdstevel@tonic-gate	bool		_scroll;
857c478bdstevel@tonic-gate	char		**_y;
867c478bdstevel@tonic-gate	short		*_firstch;
877c478bdstevel@tonic-gate	short		*_lastch;
887c478bdstevel@tonic-gate	struct _win_st	*_nextp, *_orig;
897c478bdstevel@tonic-gate};
907c478bdstevel@tonic-gate
917c478bdstevel@tonic-gate#define	WINDOW	struct _win_st
927c478bdstevel@tonic-gate
937c478bdstevel@tonic-gateextern bool	My_term, _echoit, _rawmode, _endwin;
947c478bdstevel@tonic-gate
957c478bdstevel@tonic-gateextern char	*Def_term, ttytype[50];
967c478bdstevel@tonic-gate
977c478bdstevel@tonic-gateextern int	LINES, COLS, _tty_ch, _res_flg;
987c478bdstevel@tonic-gate
997c478bdstevel@tonic-gateextern SGTTY	_tty;
1007c478bdstevel@tonic-gate
1017c478bdstevel@tonic-gateextern WINDOW	*stdscr, *curscr;
1027c478bdstevel@tonic-gate
1037c478bdstevel@tonic-gate#define	VOID(x)	(x)
1047c478bdstevel@tonic-gate
1057c478bdstevel@tonic-gate/*
1067c478bdstevel@tonic-gate * pseudo functions for standard screen
1077c478bdstevel@tonic-gate */
1087c478bdstevel@tonic-gate#define	addch(ch)	VOID(waddch(stdscr, ch))
1097c478bdstevel@tonic-gate#define	getch()		VOID(wgetch(stdscr))
1107c478bdstevel@tonic-gate#define	addstr(str)	VOID(waddstr(stdscr, str))
1117c478bdstevel@tonic-gate#define	getstr(str)	VOID(wgetstr(stdscr, str))
1127c478bdstevel@tonic-gate#define	move(y, x)	VOID(wmove(stdscr, y, x))
1137c478bdstevel@tonic-gate#define	clear()		VOID(wclear(stdscr))
1147c478bdstevel@tonic-gate#define	erase()		VOID(werase(stdscr))
1157c478bdstevel@tonic-gate#define	clrtobot()	VOID(wclrtobot(stdscr))
1167c478bdstevel@tonic-gate#define	clrtoeol()	VOID(wclrtoeol(stdscr))
1177c478bdstevel@tonic-gate#define	insertln()	VOID(winsertln(stdscr))
1187c478bdstevel@tonic-gate#define	deleteln()	VOID(wdeleteln(stdscr))
1197c478bdstevel@tonic-gate#define	refresh()	VOID(wrefresh(stdscr))
1207c478bdstevel@tonic-gate#define	inch()		VOID(winch(stdscr))
1217c478bdstevel@tonic-gate#define	insch(c)	VOID(winsch(stdscr, c))
1227c478bdstevel@tonic-gate#define	delch()		VOID(wdelch(stdscr))
1237c478bdstevel@tonic-gate#define	standout()	VOID(wstandout(stdscr))
1247c478bdstevel@tonic-gate#define	standend()	VOID(wstandend(stdscr))
1257c478bdstevel@tonic-gate
1267c478bdstevel@tonic-gate/*
1277c478bdstevel@tonic-gate * mv functions
1287c478bdstevel@tonic-gate */
1297c478bdstevel@tonic-gate#define	mvwaddch(win, y, x, ch)	VOID(wmove(win, y, x) == ERR ? \
1307c478bdstevel@tonic-gate				ERR:waddch(win, ch))
1317c478bdstevel@tonic-gate#define	mvwgetch(win, y, x)	VOID(wmove(win, y, x) == ERR?ERR:wgetch(win))
1327c478bdstevel@tonic-gate#define	mvwaddstr(win, y, x, str)	VOID(wmove(win, y, x) == ERR? \
1337c478bdstevel@tonic-gate					ERR:waddstr(win, str))
1347c478bdstevel@tonic-gate#define	mvwgetstr(win, y, x, str)	VOID(wmove(win, y, x) == ERR? \
1357c478bdstevel@tonic-gate					ERR:wgetstr(win, str))
1367c478bdstevel@tonic-gate#define	mvwinch(win, y, x)	VOID(wmove(win, y, x) == ERR ? ERR : winch(win))
1377c478bdstevel@tonic-gate#define	mvwdelch(win, y, x)	VOID(wmove(win, y, x) == ERR ? \
1387c478bdstevel@tonic-gate				ERR : wdelch(win))
1397c478bdstevel@tonic-gate#define	mvwinsch(win, y, x, c)	VOID(wmove(win, y, x) == ERR ? \
1407c478bdstevel@tonic-gate				ERR:winsch(win, c))
1417c478bdstevel@tonic-gate#define	mvaddch(y, x, ch)	mvwaddch(stdscr, y, x, ch)
1427c478bdstevel@tonic-gate#define	mvgetch(y, x)		mvwgetch(stdscr, y, x)
1437c478bdstevel@tonic-gate#define	mvaddstr(y, x, str)	mvwaddstr(stdscr, y, x, str)
1447c478bdstevel@tonic-gate#define	mvgetstr(y, x, str)	mvwgetstr(stdscr, y, x, str)
1457c478bdstevel@tonic-gate#define	mvinch(y, x)		mvwinch(stdscr, y, x)
1467c478bdstevel@tonic-gate#define	mvdelch(y, x)		mvwdelch(stdscr, y, x)
1477c478bdstevel@tonic-gate#define	mvinsch(y, x, c)	mvwinsch(stdscr, y, x, c)
1487c478bdstevel@tonic-gate
1497c478bdstevel@tonic-gate/*
1507c478bdstevel@tonic-gate * pseudo functions
1517c478bdstevel@tonic-gate */
1527c478bdstevel@tonic-gate
1537c478bdstevel@tonic-gate#define	clearok(win, bf)	(win->_clear = bf)
1547c478bdstevel@tonic-gate#define	leaveok(win, bf)	(win->_leave = bf)
1557c478bdstevel@tonic-gate#define	scrollok(win, bf)	(win->_scroll = bf)
1567c478bdstevel@tonic-gate#define	flushok(win, bf)	(bf ? (win->_flags |= _FLUSH): \
1577c478bdstevel@tonic-gate				(win->_flags &= ~_FLUSH))
1587c478bdstevel@tonic-gate#define	getyx(win, y, x)	 y = win->_cury, x = win->_curx
1597c478bdstevel@tonic-gate#define	winch(win)		(win->_y[win->_cury][win->_curx] & 0177)
1607c478bdstevel@tonic-gate
1617c478bdstevel@tonic-gate#define	raw()	 (_tty.sg_flags |= RAW, _pfast = _rawmode = TRUE, \
1627c478bdstevel@tonic-gate		(void) stty(_tty_ch, &_tty))
1637c478bdstevel@tonic-gate#define	noraw()  (_tty.sg_flags &= ~RAW, _rawmode = FALSE, \
1647c478bdstevel@tonic-gate		_pfast = !(_tty.sg_flags & CRMOD), (void) stty(_tty_ch, &_tty))
1657c478bdstevel@tonic-gate#define	cbreak() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, \
1667c478bdstevel@tonic-gate		(void) stty(_tty_ch, &_tty))
1677c478bdstevel@tonic-gate#define	nocbreak() (_tty.sg_flags &= ~CBREAK, _rawmode = FALSE, \
1687c478bdstevel@tonic-gate		(void) stty(_tty_ch, &_tty))
1697c478bdstevel@tonic-gate#define	crmode() cbreak()	/* backwards compatability */
1707c478bdstevel@tonic-gate#define	nocrmode() nocbreak()	/* backwards compatability */
1717c478bdstevel@tonic-gate#define	echo()	 (_tty.sg_flags |= ECHO, _echoit = TRUE, \
1727c478bdstevel@tonic-gate		(void) stty(_tty_ch, &_tty))
1737c478bdstevel@tonic-gate#define	noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, \
1747c478bdstevel@tonic-gate		(void) stty(_tty_ch, &_tty))
1757c478bdstevel@tonic-gate#define	nl()	 (_tty.sg_flags |= CRMOD, _pfast = _rawmode, \
1767c478bdstevel@tonic-gate		(void) stty(_tty_ch, &_tty))
1777c478bdstevel@tonic-gate#define	nonl()	 (_tty.sg_flags &= ~CRMOD, _pfast = TRUE, \
1787c478bdstevel@tonic-gate		(void) stty(_tty_ch, &_tty))
1797c478bdstevel@tonic-gate#define	savetty() ((void) gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags)
1807c478bdstevel@tonic-gate#define	resetty() (_tty.sg_flags = _res_flg, (void) stty(_tty_ch, &_tty))
1817c478bdstevel@tonic-gate
1827c478bdstevel@tonic-gate#define	erasechar()	(_tty.sg_erase)
1837c478bdstevel@tonic-gate#define	killchar()	(_tty.sg_kill)
1847c478bdstevel@tonic-gate#define	baudrate()	(_tty.sg_ospeed)
1857c478bdstevel@tonic-gate
1867c478bdstevel@tonic-gate/*
1877c478bdstevel@tonic-gate * chtype is the type used to store a character together with attributes.
1887c478bdstevel@tonic-gate * It can be set to "char" to save space, or "int" to get more attributes.
1897c478bdstevel@tonic-gate */
1907c478bdstevel@tonic-gate#ifdef CHTYPE
1917c478bdstevel@tonic-gatetypedef CHTYPE chtype;
1927c478bdstevel@tonic-gate#else
1937c478bdstevel@tonic-gatetypedef unsigned int chtype;
1947c478bdstevel@tonic-gate#endif
1957c478bdstevel@tonic-gate
1967c478bdstevel@tonic-gate#ifndef __STDC__
1977c478bdstevel@tonic-gateWINDOW	*initscr(), *newwin(), *subwin();
1987c478bdstevel@tonic-gatechar	*longname(), *getcap();
1997c478bdstevel@tonic-gate#else
2007c478bdstevel@tonic-gateextern WINDOW *initscr(void);
2017c478bdstevel@tonic-gateextern WINDOW *newwin(int, int, int, int);
2027c478bdstevel@tonic-gateextern WINDOW *subwin(WINDOW *, int, int, int, int);
2037c478bdstevel@tonic-gateextern char *longname(char *, char *);
2047c478bdstevel@tonic-gateextern char *getcap(char *);
2057c478bdstevel@tonic-gateextern char *wstandout(WINDOW *);
2067c478bdstevel@tonic-gateextern char *wstandend(WINDOW *);
2077c478bdstevel@tonic-gateextern int gettmode(void);
2087c478bdstevel@tonic-gateextern int idlok(WINDOW *, bool);
2097c478bdstevel@tonic-gateextern int box(WINDOW *, char, char);
2107c478bdstevel@tonic-gateextern int touchwin(WINDOW *);
2117c478bdstevel@tonic-gateextern int touchline(WINDOW *, int, int, int);
2127c478bdstevel@tonic-gateextern int mvcur(int, int, int, int);
2137c478bdstevel@tonic-gateextern int wmove(WINDOW *, int, int);
2147c478bdstevel@tonic-gateextern int scroll(WINDOW *);
2157c478bdstevel@tonic-gateextern int werase(WINDOW *);
2167c478bdstevel@tonic-gateextern int wrefresh(WINDOW *);
2177c478bdstevel@tonic-gateextern int endwin(void);
2187c478bdstevel@tonic-gateextern int mvwin(WINDOW *, int, int);
2197c478bdstevel@tonic-gateextern int delwin(WINDOW *);
2207c478bdstevel@tonic-gateextern int overlay(WINDOW *, WINDOW *);
2217c478bdstevel@tonic-gateextern int overwrite(WINDOW *, WINDOW *);
2227c478bdstevel@tonic-gateextern int winsertln(WINDOW *);
2237c478bdstevel@tonic-gateextern int wdeleteln(WINDOW *);
2247c478bdstevel@tonic-gateextern int wgetstr(WINDOW *, char *);
2257c478bdstevel@tonic-gateextern int wgetch(WINDOW *);
2267c478bdstevel@tonic-gateextern int waddch(WINDOW *, char);
2277c478bdstevel@tonic-gateextern int waddstr(WINDOW *, char *);
2287c478bdstevel@tonic-gateextern int winsch(WINDOW *, char);
2297c478bdstevel@tonic-gateextern int wdelch(WINDOW *);
2307c478bdstevel@tonic-gateextern int wclear(WINDOW *);
2317c478bdstevel@tonic-gateextern int wclrtobot(WINDOW *);
2327c478bdstevel@tonic-gateextern int wclrtoeol(WINDOW *);
2337c478bdstevel@tonic-gateextern int printw(char *, ...);
2347c478bdstevel@tonic-gateextern int wprintw(WINDOW *, char *, ...);
2357c478bdstevel@tonic-gateextern int mvprintw(int, int, char *, ...);
2367c478bdstevel@tonic-gateextern int mvwprintw(WINDOW *, int, int, char *, ...);
2377c478bdstevel@tonic-gateextern int scanw(char *, ...);
2387c478bdstevel@tonic-gateextern int wscanw(WINDOW *, char *, ...);
2397c478bdstevel@tonic-gateextern int mvscanw(int, int, char *, ...);
2407c478bdstevel@tonic-gateextern int mvwscanw(WINDOW *, int, int, char *, ...);
2417c478bdstevel@tonic-gateextern int setterm(char *);
2427c478bdstevel@tonic-gate#endif	/* __STDC__ */
2437c478bdstevel@tonic-gate
2447c478bdstevel@tonic-gate/*
2457c478bdstevel@tonic-gate * Used to be in unctrl.h.
2467c478bdstevel@tonic-gate */
2477c478bdstevel@tonic-gate#define	unctrl(c)	_unctrl[(c) & 0177]
2487c478bdstevel@tonic-gateextern char *_unctrl[];
2497c478bdstevel@tonic-gate#endif
2507c478bdstevel@tonic-gate
2517c478bdstevel@tonic-gate#ifdef __cplusplus
2527c478bdstevel@tonic-gate}
2537c478bdstevel@tonic-gate#endif
2547c478bdstevel@tonic-gate
2557c478bdstevel@tonic-gate#endif	/* _CURSES_H */
256