2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A/* Copyright (c) 1988 AT&T */
2N/A/* All Rights Reserved */
2N/A
2N/A/*
2N/A * University Copyright- Copyright (c) 1982, 1986, 1988
2N/A * The Regents of the University of California
2N/A * All Rights Reserved
2N/A *
2N/A * University Acknowledgment- Portions of this document are derived from
2N/A * software developed by the University of California, Berkeley, and its
2N/A * contributors.
2N/A */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A/*LINTLIBRARY*/
2N/A
2N/A#include <stdlib.h>
2N/A#include <string.h>
2N/A#include <sys/types.h>
2N/A#include "curses_inc.h"
2N/A
2N/A/* This routine sets up a window buffer and returns a pointer to it. */
2N/A
2N/AWINDOW *
2N/A_makenew(int nlines, int ncols, int begy, int begx)
2N/A{
2N/A /* order the register allocations against highest usage */
2N/A WINDOW *win;
2N/A
2N/A#ifdef DEBUG
2N/A if (outf)
2N/A fprintf(outf, "MAKENEW(%d, %d, %d, %d)\n",
2N/A nlines, ncols, begy, begx);
2N/A#endif /* DEBUG */
2N/A
2N/A if ((win = (WINDOW *) malloc(sizeof (WINDOW))) == NULL)
2N/A goto out_no_win;
2N/A if ((win->_y = (chtype **) malloc(nlines * sizeof (chtype *))) == NULL)
2N/A goto out_win;
2N/A#ifdef _VR3_COMPAT_CODE
2N/A if ((_y16update) && ((win->_y16 = (_ochtype **)
2N/A calloc(1, nlines * sizeof (_ochtype *))) == NULL)) {
2N/A goto out_y16;
2N/A }
2N/A#endif /* _VR3_COMPAT_CODE */
2N/A if ((win->_firstch = (short *) malloc(2 * nlines * sizeof (short)))
2N/A == NULL) {
2N/A#ifdef _VR3_COMPAT_CODE
2N/A if ((_y16update) && (win->_y16 != NULL))
2N/A free((char *) win->_y16);
2N/Aout_y16:
2N/A#endif /* _VR3_COMPAT_CODE */
2N/A free((char *) win->_y);
2N/Aout_win:
2N/A free((char *) win);
2N/Aout_no_win:
2N/A curs_errno = CURS_BAD_MALLOC;
2N/A#ifdef DEBUG
2N/A strcpy(curs_parm_err, "_makenew");
2N/A#endif /* DEBUG */
2N/A return ((WINDOW *) NULL);
2N/A } else
2N/A win->_lastch = win->_firstch + nlines;
2N/A
2N/A win->_cury = win->_curx = 0;
2N/A /*LINTED*/
2N/A win->_maxy = (short) nlines;
2N/A /*LINTED*/
2N/A win->_maxx = (short) ncols;
2N/A /*LINTED*/
2N/A win->_begy = (short) begy;
2N/A /*LINTED*/
2N/A win->_begx = (short) begx;
2N/A win->_clear = (((begy + SP->Yabove + begx) == 0) &&
2N/A (nlines >= (LINES + SP->Yabove)) && (ncols >= COLS));
2N/A win->_leave = win->_scroll = win->_use_idl = win->_use_keypad =
2N/A win->_notimeout = win->_immed = win->_sync = FALSE;
2N/A win->_use_idc = TRUE;
2N/A win->_ndescs = win->_tmarg = 0;
2N/A win->_bmarg = nlines - 1;
2N/A win->_bkgd = _BLNKCHAR;
2N/A win->_delay = win->_parx = win->_pary = -1;
2N/A win->_attrs = A_NORMAL;
2N/A win->_flags = _WINCHANGED;
2N/A win->_parent = win->_padwin = (WINDOW *) NULL;
2N/A (void) memset((char *) win->_firstch, 0, (nlines * sizeof (short)));
2N/A {
2N/A short *lastch = win->_lastch,
2N/A *elastch = lastch + nlines;
2N/A
2N/A ncols--;
2N/A while (lastch < elastch)
2N/A /*LINTED*/
2N/A *lastch++ = (short) ncols;
2N/A }
2N/A
2N/A win->_insmode = FALSE;
2N/A win->_index = 0;
2N/A win->_nbyte = -1;
2N/A
2N/A#ifdef DEBUG
2N/A if (outf) {
2N/A fprintf(outf, "MAKENEW: win->_clear = %d\n", win->_clear);
2N/A fprintf(outf, "MAKENEW: win->_flags = %0.2o\n", win->_flags);
2N/A fprintf(outf, "MAKENEW: win->_maxy = %d\n", win->_maxy);
2N/A fprintf(outf, "MAKENEW: win->_maxx = %d\n", win->_maxx);
2N/A fprintf(outf, "MAKENEW: win->_begy = %d\n", win->_begy);
2N/A fprintf(outf, "MAKENEW: win->_begx = %d\n", win->_begx);
2N/A }
2N/A#endif /* DEBUG */
2N/A return (win);
2N/A}