* Copyright (c) 1983 Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* Edward Wang at The University of California, Berkeley.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)wwsize.c 3.10 (Berkeley) 8/12/90";
* Resize a window. Should be unattached.
* First allocate new buffers.
win
= wwalloc(w
->ww_w
.t
, w
->ww_w
.l
, nrow
, ncol
, sizeof (char));
fmap
= wwalloc(w
->ww_w
.t
, w
->ww_w
.l
, nrow
, ncol
, sizeof (char));
if (nrow
> w
->ww_b
.nr
|| ncol
> w
->ww_b
.nc
) {
nline
= MAX(w
->ww_b
.nr
, nrow
);
buf
= (union ww_char
**) wwalloc(w
->ww_b
.t
, w
->ww_b
.l
,
nline
, ncol
, sizeof (union ww_char
));
nvis
= (short *)malloc((unsigned) nrow
* sizeof (short));
for (i
= w
->ww_b
.t
; i
< w
->ww_b
.b
; i
++)
for (j
= w
->ww_b
.l
; j
< r
; j
++)
buf
[i
][j
] = w
->ww_buf
[i
][j
];
for (i
= w
->ww_b
.t
; i
< w
->ww_b
.b
; i
++) {
for (j
= w
->ww_b
.l
; j
< w
->ww_b
.r
; j
++)
buf
[i
][j
] = w
->ww_buf
[i
][j
];
for (j
= w
->ww_b
.l
; j
< r
; j
++)
* Now free the old stuff.
wwfree((char **)w
->ww_win
, w
->ww_w
.t
);
wwfree((char **)w
->ww_buf
, w
->ww_b
.t
);
wwfree((char **)w
->ww_fmap
, w
->ww_w
.t
);
free((char *)(w
->ww_nvis
+ w
->ww_w
.t
));
w
->ww_w
.b
= w
->ww_w
.t
+ nrow
;
w
->ww_w
.r
= w
->ww_w
.l
+ ncol
;
w
->ww_b
.b
= w
->ww_b
.t
+ nline
;
w
->ww_b
.r
= w
->ww_b
.l
+ ncol
;
if ((i
= w
->ww_b
.b
- w
->ww_w
.b
) < 0 ||
(i
= w
->ww_cur
.r
- w
->ww_w
.b
+ 1) > 0) {
w
->ww_i
.b
= MIN(w
->ww_w
.b
, wwnrow
);
w
->ww_i
.r
= MIN(w
->ww_w
.r
, wwncol
);
w
->ww_i
.nr
= w
->ww_i
.b
- w
->ww_i
.t
;
w
->ww_i
.nc
= w
->ww_i
.r
- w
->ww_i
.l
;
* Initialize new buffers.
if (w
->ww_oflags
& WWO_GLASS
)
if (w
->ww_oflags
& WWO_REVERSE
)
for (i
= w
->ww_w
.t
; i
< w
->ww_w
.b
; i
++)
for (j
= w
->ww_w
.l
; j
< w
->ww_w
.r
; j
++)
for (i
= w
->ww_w
.t
; i
< w
->ww_w
.b
; i
++)
for (j
= w
->ww_w
.l
; j
< w
->ww_w
.r
; j
++)
for (i
= w
->ww_w
.t
; i
< w
->ww_w
.b
; i
++)
if (w
->ww_ispty
&& w
->ww_pty
>= 0)
(void) wwsetttysize(w
->ww_pty
, nrow
, ncol
);
wwfree((char **)buf
, w
->ww_b
.t
);
free((char *)(nvis
+ w
->ww_w
.t
));