4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
40 #pragma ident "%Z%%M% %I% %E% SMI"
46 #include <sys/types.h>
47 #include "curses_inc.h"
49 /* This routine sets up a window buffer and returns a pointer to it. */
52 _makenew(int nlines
, int ncols
, int begy
, int begx
)
54 /* order the register allocations against highest usage */
59 fprintf(outf
, "MAKENEW(%d, %d, %d, %d)\n",
60 nlines
, ncols
, begy
, begx
);
63 if ((win
= (WINDOW
*) malloc(sizeof (WINDOW
))) == NULL
)
65 if ((win
->_y
= (chtype
**) malloc(nlines
* sizeof (chtype
*))) == NULL
)
67 #ifdef _VR3_COMPAT_CODE
68 if ((_y16update
) && ((win
->_y16
= (_ochtype
**)
69 calloc(1, nlines
* sizeof (_ochtype
*))) == NULL
)) {
72 #endif /* _VR3_COMPAT_CODE */
73 if ((win
->_firstch
= (short *) malloc(2 * nlines
* sizeof (short)))
75 #ifdef _VR3_COMPAT_CODE
76 if ((_y16update
) && (win
->_y16
!= NULL
))
77 free((char *) win
->_y16
);
79 #endif /* _VR3_COMPAT_CODE */
80 free((char *) win
->_y
);
84 curs_errno
= CURS_BAD_MALLOC
;
86 strcpy(curs_parm_err
, "_makenew");
88 return ((WINDOW
*) NULL
);
90 win
->_lastch
= win
->_firstch
+ nlines
;
92 win
->_cury
= win
->_curx
= 0;
94 win
->_maxy
= (short) nlines
;
96 win
->_maxx
= (short) ncols
;
98 win
->_begy
= (short) begy
;
100 win
->_begx
= (short) begx
;
101 win
->_clear
= (((begy
+ SP
->Yabove
+ begx
) == 0) &&
102 (nlines
>= (LINES
+ SP
->Yabove
)) && (ncols
>= COLS
));
103 win
->_leave
= win
->_scroll
= win
->_use_idl
= win
->_use_keypad
=
104 win
->_notimeout
= win
->_immed
= win
->_sync
= FALSE
;
105 win
->_use_idc
= TRUE
;
106 win
->_ndescs
= win
->_tmarg
= 0;
107 win
->_bmarg
= nlines
- 1;
108 win
->_bkgd
= _BLNKCHAR
;
109 win
->_delay
= win
->_parx
= win
->_pary
= -1;
110 win
->_attrs
= A_NORMAL
;
111 win
->_flags
= _WINCHANGED
;
112 win
->_parent
= win
->_padwin
= (WINDOW
*) NULL
;
113 (void) memset((char *) win
->_firstch
, 0, (nlines
* sizeof (short)));
115 short *lastch
= win
->_lastch
,
116 *elastch
= lastch
+ nlines
;
119 while (lastch
< elastch
)
121 *lastch
++ = (short) ncols
;
124 win
->_insmode
= FALSE
;
130 fprintf(outf
, "MAKENEW: win->_clear = %d\n", win
->_clear
);
131 fprintf(outf
, "MAKENEW: win->_flags = %0.2o\n", win
->_flags
);
132 fprintf(outf
, "MAKENEW: win->_maxy = %d\n", win
->_maxy
);
133 fprintf(outf
, "MAKENEW: win->_maxx = %d\n", win
->_maxx
);
134 fprintf(outf
, "MAKENEW: win->_begy = %d\n", win
->_begy
);
135 fprintf(outf
, "MAKENEW: win->_begx = %d\n", win
->_begx
);