/* $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
*/

/*	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	"$Header: compat.c 1.1 89/10/23 $@(#)curses:screen/compat.c	1.3"
#include	"curses_inc.h"

#ifdef _VR3_COMPAT_CODE

#undef	waddch
waddch(win,c)
WINDOW	*win;
_ochtype	c;
{
    return (w32addch(win,from_ochtype(c)));
}

#undef	wattrset
wattrset(win,attrs)
WINDOW * win;
_ochtype attrs;
{
    win->_attrs = (from_ochtype(attrs) | win->_bkgd) & A_ATTRIBUTES;
    return (OK);
}

#undef	wattron
wattron(win,attrs)
WINDOW * win;
_ochtype attrs;
{
    win->_attrs |= from_ochtype(attrs) & A_ATTRIBUTES;
    return (OK);
}

#undef	wattroff
wattroff(win,attrs)
WINDOW *win;
_ochtype attrs;
{
    win->_attrs &= (~from_ochtype(attrs) | win->_bkgd) & A_ATTRIBUTES;
    return (OK);
}

#undef	box
box(win,v,h)
WINDOW *win;
_ochtype v,h;
{
    return (wborder(win,from_ochtype(v),from_ochtype(v),from_ochtype(h),from_ochtype(h)));
}

#undef	pechochar
pechochar(win,c)
WINDOW	*win;
_ochtype	c;
{
    return (p32echochar(win,from_ochtype(c)));
}

#undef	wechochar
wechochar(win,c)
WINDOW	*win;
_ochtype	c;
{
    return (w32echochar(win,from_ochtype(c)));
}

#undef	winsch
winsch(win,c)
WINDOW	*win;
_ochtype	c;
{
    return (w32insch(win,from_ochtype(c)));
}

#undef	vidputs
vidputs(a,o)
_ochtype	a;
int (*o)();
{
    vidupdate(from_ochtype(a),cur_term->sgr_mode,o);
}

#undef	vidattr
vidattr(a)
_ochtype	a;
{
    vidupdate(from_ochtype(a),cur_term->sgr_mode,_outchar);
}

void
update_old_y_area(win,nlines,ncols,start_line,start_col)
WINDOW	*win;
int	nlines,ncols,start_line,start_col;
{
    int	row, col, num_cols;

    for (row = start_line; nlines > 0; nlines--, row++)
	for (num_cols = ncols, col = start_col; num_cols > 0; num_cols--, col++)
	    win->_y16[row][col] = to_ochtype(win->_y[row][col]);
}

#undef	initscr
WINDOW *
initscr()
{
    _y16update = update_old_y_area;
    return (initscr32());
}

#undef	newterm
SCREEN *
newterm(type, outfptr, infptr)
char	*type;
FILE	*outfptr, *infptr;
{
    _y16update = update_old_y_area;
    return (newscreen(type, 0, 0, 0, outfptr, infptr));
}

m_addch(c)
_ochtype	c;
{
    return (waddch(stdscr,c));
}

WINDOW *
m_initscr()
{
    return (initscr());
}

SCREEN *
m_newterm(type, outfptr, infptr)
char	*type;
FILE	*outfptr, *infptr;
{
    return (newterm(type, outfptr, infptr));
}

m_addstr(str)
char	*str;
{
    return (waddstr(stdscr, str));
}

m_clear()
{
    return (wclear(stdscr));
}

m_erase()	
{
    return (werase(stdscr));
}

m_move(y, x)
int	y, x;
{
    return (wmove(stdscr, y, x));
}

m_refresh()
{
    return (wrefresh(stdscr));
}

#undef crmode
void
crmode()
{
    cbreak();
}

#undef gettmode
gettmode()
{
	return(OK);
}

#undef nocrmode
void
nocrmode()
{
    nocbreak();
}

#undef setterm
setterm(name)
char	*name;
{
    return (setupterm(name,1,(int *) NULL));
}

#endif /* _VR3_COMPAT_CODE */
