Wed Jan 11 20:43:03 2017 UTC ()
Move the ripoffline logic out of screen.c and into ripoffline.c.
Store ripped off lines in the SCREEN structure so we can repaint then
when the terminal is resized.
Fix mvwin(3) so it can move windows in the ripped off area.


(roy)
diff -r1.82 -r1.83 src/lib/libcurses/Makefile
diff -r1.58 -r1.59 src/lib/libcurses/curses_private.h
diff -r1.20 -r1.21 src/lib/libcurses/mvwin.c
diff -r1.24 -r1.25 src/lib/libcurses/resize.c
diff -r0 -r1.1 src/lib/libcurses/ripoffline.c
diff -r1.28 -r1.29 src/lib/libcurses/screen.c
diff -r1.60 -r1.61 src/lib/libcurses/setterm.c

cvs diff -r1.82 -r1.83 src/lib/libcurses/Makefile (expand / switch to unified diff)

--- src/lib/libcurses/Makefile 2017/01/10 10:13:24 1.82
+++ src/lib/libcurses/Makefile 2017/01/11 20:43:03 1.83
@@ -1,40 +1,40 @@ @@ -1,40 +1,40 @@
1# $NetBSD: Makefile,v 1.82 2017/01/10 10:13:24 roy Exp $ 1# $NetBSD: Makefile,v 1.83 2017/01/11 20:43:03 roy Exp $
2# @(#)Makefile 8.2 (Berkeley) 1/2/94 2# @(#)Makefile 8.2 (Berkeley) 1/2/94
3 3
4.include <bsd.own.mk> 4.include <bsd.own.mk>
5 5
6WARNS= 2 6WARNS= 2
7 7
8CPPFLAGS+=-I${.CURDIR} -I${NETBSDSRCDIR}/lib/libterminfo 8CPPFLAGS+=-I${.CURDIR} -I${NETBSDSRCDIR}/lib/libterminfo
9.if defined(DEBUG_CURSES) 9.if defined(DEBUG_CURSES)
10CPPFLAGS+=-g -DDEBUG 10CPPFLAGS+=-g -DDEBUG
11.endif 11.endif
12.if defined(SMALL) 12.if defined(SMALL)
13CPPFLAGS+=-DSMALL 13CPPFLAGS+=-DSMALL
14.endif 14.endif
15LIB= curses 15LIB= curses
16SRCS= acs.c addbytes.c addch.c addchnstr.c addnstr.c attributes.c \ 16SRCS= acs.c addbytes.c addch.c addchnstr.c addnstr.c attributes.c \
17 background.c bell.c border.c box.c chgat.c clear.c clearok.c \ 17 background.c bell.c border.c box.c chgat.c clear.c clearok.c \
18 clrtobot.c clrtoeol.c color.c copywin.c cr_put.c \ 18 clrtobot.c clrtoeol.c color.c copywin.c cr_put.c \
19 ctrace.c cur_hash.c curs_set.c \ 19 ctrace.c cur_hash.c curs_set.c \
20 curses.c delch.c deleteln.c delwin.c echochar.c erase.c fileio.c \ 20 curses.c delch.c deleteln.c delwin.c echochar.c erase.c fileio.c \
21 flushok.c fullname.c getch.c getstr.c getyx.c id_subwins.c idlok.c \ 21 flushok.c fullname.c getch.c getstr.c getyx.c id_subwins.c idlok.c \
22 idcok.c immedok.c inch.c inchstr.c initscr.c insch.c insdelln.c \ 22 idcok.c immedok.c inch.c inchstr.c initscr.c insch.c insdelln.c \
23 insertln.c instr.c keypad.c keyname.c leaveok.c line.c meta.c move.c \ 23 insertln.c instr.c keypad.c keyname.c leaveok.c line.c meta.c move.c \
24 mvwin.c newwin.c nodelay.c notimeout.c overlay.c overwrite.c pause.c \ 24 mvwin.c newwin.c nodelay.c notimeout.c overlay.c overwrite.c pause.c \
25 printw.c putchar.c refresh.c resize.c scanw.c screen.c scroll.c \ 25 printw.c putchar.c refresh.c resize.c ripoffline.c scanw.c screen.c \
26 scrollok.c setterm.c standout.c syncok.c timeout.c toucholap.c \ 26 scroll.c scrollok.c setterm.c standout.c syncok.c timeout.c \
27 touchwin.c tstp.c tty.c unctrl.c underscore.c 27 toucholap.c touchwin.c tstp.c tty.c unctrl.c underscore.c
28 28
29MAN= curses.3 curses_addch.3 curses_addchstr.3 curses_addstr.3 \ 29MAN= curses.3 curses_addch.3 curses_addchstr.3 curses_addstr.3 \
30 curses_attributes.3 curses_background.3 curses_border.3 \ 30 curses_attributes.3 curses_background.3 curses_border.3 \
31 curses_chgat.3 curses_clear.3 curses_color.3 \ 31 curses_chgat.3 curses_clear.3 curses_color.3 \
32 curses_cursor.3 curses_default_colors.3 \ 32 curses_cursor.3 curses_default_colors.3 \
33 curses_delch.3 curses_deleteln.3 curses_echochar.3 curses_fileio.3 \ 33 curses_delch.3 curses_deleteln.3 curses_echochar.3 curses_fileio.3 \
34 curses_inch.3 curses_input.3 curses_insertch.3 curses_insertln.3 \ 34 curses_inch.3 curses_input.3 curses_insertch.3 curses_insertln.3 \
35 curses_insdelln.3 curses_keyname.3 curses_line.3 curses_pad.3 \ 35 curses_insdelln.3 curses_keyname.3 curses_line.3 curses_pad.3 \
36 curses_print.3 curses_refresh.3 curses_scanw.3 curses_screen.3 \ 36 curses_print.3 curses_refresh.3 curses_scanw.3 curses_screen.3 \
37 curses_scroll.3 curses_standout.3 curses_termcap.3 curses_touch.3 \ 37 curses_scroll.3 curses_standout.3 curses_termcap.3 curses_touch.3 \
38 curses_tty.3 curses_underscore.3 curses_window.3 38 curses_tty.3 curses_underscore.3 curses_window.3
39INCS= curses.h unctrl.h 39INCS= curses.h unctrl.h
40INCSDIR=/usr/include 40INCSDIR=/usr/include

cvs diff -r1.58 -r1.59 src/lib/libcurses/curses_private.h (expand / switch to unified diff)

--- src/lib/libcurses/curses_private.h 2017/01/10 10:13:24 1.58
+++ src/lib/libcurses/curses_private.h 2017/01/11 20:43:03 1.59
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: curses_private.h,v 1.58 2017/01/10 10:13:24 roy Exp $ */ 1/* $NetBSD: curses_private.h,v 1.59 2017/01/11 20:43:03 roy Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998-2000 Brett Lymn 4 * Copyright (c) 1998-2000 Brett Lymn
5 * (blymn@baea.com.au, brett_lymn@yahoo.com.au) 5 * (blymn@baea.com.au, brett_lymn@yahoo.com.au)
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code has been donated to The NetBSD Foundation by the Author. 8 * This code has been donated to The NetBSD Foundation by the Author.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -179,40 +179,47 @@ struct __color { @@ -179,40 +179,47 @@ struct __color {
179struct __pair { 179struct __pair {
180 short fore; 180 short fore;
181 short back; 181 short back;
182 int flags; 182 int flags;
183}; 183};
184 184
185/* Maximum colours */ 185/* Maximum colours */
186#define MAX_COLORS 256 186#define MAX_COLORS 256
187/* Maximum colour pairs - determined by number of colour bits in attr_t */ 187/* Maximum colour pairs - determined by number of colour bits in attr_t */
188#define MAX_PAIRS PAIR_NUMBER(__COLOR) 188#define MAX_PAIRS PAIR_NUMBER(__COLOR)
189 189
190typedef struct keymap keymap_t; 190typedef struct keymap keymap_t;
191 191
 192
 193#define MAX_RIPS 5
 194struct __ripoff {
 195 int nlines;
 196 WINDOW *win;
 197};
 198
192/* this is the encapsulation of the terminal definition, one for 199/* this is the encapsulation of the terminal definition, one for
193 * each terminal that curses talks to. 200 * each terminal that curses talks to.
194 */ 201 */
195struct __screen { 202struct __screen {
196 FILE *infd, *outfd; /* input and output file descriptors */ 203 FILE *infd, *outfd; /* input and output file descriptors */
197 WINDOW *curscr; /* Current screen. */ 204 WINDOW *curscr; /* Current screen. */
198 WINDOW *stdscr; /* Standard screen. */ 205 WINDOW *stdscr; /* Standard screen. */
199 WINDOW *__virtscr; /* Virtual screen (for doupdate()). */ 206 WINDOW *__virtscr; /* Virtual screen (for doupdate()). */
200 int curwin; /* current window for refresh */ 207 int curwin; /* current window for refresh */
201 int lx, ly; /* loop parameters for refresh */ 208 int lx, ly; /* loop parameters for refresh */
202 int COLS; /* Columns on the screen. */ 209 int COLS; /* Columns on the screen. */
203 int LINES; /* Lines on the screen. */ 210 int LINES; /* Lines on the screen. */
204 int ripped_top; /* Lines ripped from the top of the screen. */ 211 int nripped; /* Number of ripofflines. */
205 int ripped_bottom; /* Lines ripped from the bottom. */ 212 struct __ripoff ripped[MAX_RIPS]; /* ripofflines. */
206 int ESCDELAY; /* Delay between keys in esc seq's. */ 213 int ESCDELAY; /* Delay between keys in esc seq's. */
207#define ESCDELAY_DEFAULT 300 /* milliseconds. */ 214#define ESCDELAY_DEFAULT 300 /* milliseconds. */
208 int TABSIZE; /* Size of a tab. */ 215 int TABSIZE; /* Size of a tab. */
209#define TABSIZE_DEFAULT 8 /* spaces. */ 216#define TABSIZE_DEFAULT 8 /* spaces. */
210 int COLORS; /* Maximum colors on the screen */ 217 int COLORS; /* Maximum colors on the screen */
211 int COLOR_PAIRS; /* Maximum color pairs on the screen */ 218 int COLOR_PAIRS; /* Maximum color pairs on the screen */
212 int My_term; /* Use Def_term regardless. */ 219 int My_term; /* Use Def_term regardless. */
213 char GT; /* Gtty indicates tabs. */ 220 char GT; /* Gtty indicates tabs. */
214 char NONL; /* Term can't hack LF doing a CR. */ 221 char NONL; /* Term can't hack LF doing a CR. */
215 char UPPERCASE; /* Terminal is uppercase only. */ 222 char UPPERCASE; /* Terminal is uppercase only. */
216 223
217 chtype acs_char[NUM_ACS]; 224 chtype acs_char[NUM_ACS];
218#ifdef HAVE_WCHAR 225#ifdef HAVE_WCHAR
@@ -332,26 +339,29 @@ void __cursesi_chtype_to_cchar(chtype, c @@ -332,26 +339,29 @@ void __cursesi_chtype_to_cchar(chtype, c
332#endif /* HAVE_WCHAR */ 339#endif /* HAVE_WCHAR */
333int __unget(wint_t); 340int __unget(wint_t);
334int __mvcur(int, int, int, int, int); 341int __mvcur(int, int, int, int, int);
335WINDOW *__newwin(SCREEN *, int, int, int, int, int); 342WINDOW *__newwin(SCREEN *, int, int, int, int, int);
336int __nodelay(void); 343int __nodelay(void);
337int __notimeout(void); 344int __notimeout(void);
338void __restartwin(void); 345void __restartwin(void);
339void __restore_colors(void); 346void __restore_colors(void);
340void __restore_cursor_vis(void); 347void __restore_cursor_vis(void);
341void __restore_meta_state(void); 348void __restore_meta_state(void);
342void __restore_termios(void); 349void __restore_termios(void);
343void __restore_stophandler(void); 350void __restore_stophandler(void);
344void __restore_winchhandler(void); 351void __restore_winchhandler(void);
 352int __ripoffscreen(SCREEN *, int *);
 353void __ripoffresize(SCREEN *);
 354int __rippedlines(const SCREEN *);
345void __save_termios(void); 355void __save_termios(void);
346void __set_color(WINDOW *win, attr_t attr); 356void __set_color(WINDOW *win, attr_t attr);
347void __set_stophandler(void); 357void __set_stophandler(void);
348void __set_winchhandler(void); 358void __set_winchhandler(void);
349void __set_subwin(WINDOW *, WINDOW *); 359void __set_subwin(WINDOW *, WINDOW *);
350void __startwin(SCREEN *); 360void __startwin(SCREEN *);
351void __stop_signal_handler(int); 361void __stop_signal_handler(int);
352int __stopwin(void); 362int __stopwin(void);
353void __swflags(WINDOW *); 363void __swflags(WINDOW *);
354void __sync(WINDOW *); 364void __sync(WINDOW *);
355int __timeout(int); 365int __timeout(int);
356int __touchline(WINDOW *, int, int, int); 366int __touchline(WINDOW *, int, int, int);
357int __touchwin(WINDOW *); 367int __touchwin(WINDOW *);

cvs diff -r1.20 -r1.21 src/lib/libcurses/mvwin.c (expand / switch to unified diff)

--- src/lib/libcurses/mvwin.c 2017/01/06 13:53:18 1.20
+++ src/lib/libcurses/mvwin.c 2017/01/11 20:43:03 1.21
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mvwin.c,v 1.20 2017/01/06 13:53:18 roy Exp $ */ 1/* $NetBSD: mvwin.c,v 1.21 2017/01/11 20:43:03 roy Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1981, 1993, 1994 4 * Copyright (c) 1981, 1993, 1994
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)mvwin.c 8.2 (Berkeley) 5/4/94"; 35static char sccsid[] = "@(#)mvwin.c 8.2 (Berkeley) 5/4/94";
36#else 36#else
37__RCSID("$NetBSD: mvwin.c,v 1.20 2017/01/06 13:53:18 roy Exp $"); 37__RCSID("$NetBSD: mvwin.c,v 1.21 2017/01/11 20:43:03 roy Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include "curses.h" 41#include "curses.h"
42#include "curses_private.h" 42#include "curses_private.h"
43 43
44/* 44/*
45 * mvderwin -- 45 * mvderwin --
46 * Move a derived window. This does not change the physical screen 46 * Move a derived window. This does not change the physical screen
47 * coordinates of the subwin, rather maps the characters in the subwin 47 * coordinates of the subwin, rather maps the characters in the subwin
48 * sized part of the parent window starting at dy, dx into the subwin. 48 * sized part of the parent window starting at dy, dx into the subwin.
49 * 49 *
50 */ 50 */
@@ -92,39 +92,40 @@ mvderwin(WINDOW *win, int dy, int dx) @@ -92,39 +92,40 @@ mvderwin(WINDOW *win, int dy, int dx)
92 return OK; 92 return OK;
93} 93}
94 94
95/* 95/*
96 * mvwin -- 96 * mvwin --
97 * Relocate the starting position of a window. 97 * Relocate the starting position of a window.
98 */ 98 */
99int 99int
100mvwin(WINDOW *win, int by, int bx) 100mvwin(WINDOW *win, int by, int bx)
101{ 101{
102 WINDOW *orig; 102 WINDOW *orig;
103 int dy, dx; 103 int dy, dx;
104 104
105 if (by < 0 || by + win->maxy > LINES || bx < 0 || bx + win->maxx > COLS) 105 if (by < 0 || by + win->maxy > win->screen->LINES ||
 106 bx < 0 || bx + win->maxx > win->screen->COLS)
106 return ERR; 107 return ERR;
107 dy = by - win->begy; 108 dy = by - win->begy;
108 dx = bx - win->begx; 109 dx = bx - win->begx;
109 orig = win->orig; 110 orig = win->orig;
110 if (orig == NULL) { 111 if (orig == NULL) {
111 orig = win; 112 orig = win;
112 do { 113 do {
113 win->begy += dy; 114 win->begy += dy;
114 win->begx += dx; 115 win->begx += dx;
115 __swflags(win); 116 __swflags(win);
116 win = win->nextp; 117 win = win->nextp;
117 } while (win != orig); 118 } while (win != orig);
118 } else { 119 } else {
119 if (by < orig->begy || win->maxy + dy > orig->maxy) 120 if (by < orig->begy || win->maxy + dy > orig->maxy)
120 return (ERR); 121 return ERR;
121 if (bx < orig->begx || win->maxx + dx > orig->maxx) 122 if (bx < orig->begx || win->maxx + dx > orig->maxx)
122 return (ERR); 123 return ERR;
123 win->begy = by; 124 win->begy = by;
124 win->begx = bx; 125 win->begx = bx;
125 __swflags(win); 126 __swflags(win);
126 __set_subwin(orig, win); 127 __set_subwin(orig, win);
127 } 128 }
128 __touchwin(win); 129 __touchwin(win);
129 return OK; 130 return OK;
130} 131}

cvs diff -r1.24 -r1.25 src/lib/libcurses/resize.c (expand / switch to unified diff)

--- src/lib/libcurses/resize.c 2017/01/10 23:28:45 1.24
+++ src/lib/libcurses/resize.c 2017/01/11 20:43:03 1.25
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: resize.c,v 1.24 2017/01/10 23:28:45 roy Exp $ */ 1/* $NetBSD: resize.c,v 1.25 2017/01/11 20:43:03 roy Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001 4 * Copyright (c) 2001
5 * Brett Lymn. 5 * Brett Lymn.
6 * 6 *
7 * This code has been donated to The NetBSD Foundation by the Author. 7 * This code has been donated to The NetBSD Foundation by the Author.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -30,27 +30,27 @@ @@ -30,27 +30,27 @@
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE. 35 * SUCH DAMAGE.
36 */ 36 */
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39#ifndef lint 39#ifndef lint
40#if 0 40#if 0
41static char sccsid[] = "@(#)resize.c blymn 2001/08/26"; 41static char sccsid[] = "@(#)resize.c blymn 2001/08/26";
42#else 42#else
43__RCSID("$NetBSD: resize.c,v 1.24 2017/01/10 23:28:45 roy Exp $"); 43__RCSID("$NetBSD: resize.c,v 1.25 2017/01/11 20:43:03 roy Exp $");
44#endif 44#endif
45#endif /* not lint */ 45#endif /* not lint */
46 46
47#include <stdlib.h> 47#include <stdlib.h>
48 48
49#include "curses.h" 49#include "curses.h"
50#include "curses_private.h" 50#include "curses_private.h"
51 51
52static int __resizeterm(WINDOW *win, int nlines, int ncols); 52static int __resizeterm(WINDOW *win, int nlines, int ncols);
53static int __resizewin(WINDOW *win, int nlines, int ncols); 53static int __resizewin(WINDOW *win, int nlines, int ncols);
54 54
55/* 55/*
56 * wresize -- 56 * wresize --
@@ -153,60 +153,71 @@ is_term_resized(int nlines, int ncols) @@ -153,60 +153,71 @@ is_term_resized(int nlines, int ncols)
153 * resizeterm -- 153 * resizeterm --
154 * Resize the terminal window, resizing the dependent windows. 154 * Resize the terminal window, resizing the dependent windows.
155 * Handles internal book-keeping. 155 * Handles internal book-keeping.
156 */ 156 */
157int 157int
158resizeterm(int nlines, int ncols) 158resizeterm(int nlines, int ncols)
159{ 159{
160 int result; 160 int result;
161 161
162#ifdef DEBUG 162#ifdef DEBUG
163 __CTRACE(__CTRACE_WINDOW, "resizeterm: (%d, %d)\n", nlines, ncols); 163 __CTRACE(__CTRACE_WINDOW, "resizeterm: (%d, %d)\n", nlines, ncols);
164#endif 164#endif
165 165
 166
166 if (!is_term_resized(nlines, ncols)) 167 if (!is_term_resized(nlines, ncols))
167 return OK; 168 return OK;
168 169
169 result = resize_term(nlines, ncols); 170 result = resize_term(nlines, ncols);
 171
 172 /* Screen contents are unknown, libcurses is not libpanel, we don't
 173 * know the correct draw order. */
170 clearok(curscr, TRUE); 174 clearok(curscr, TRUE);
 175
 176 /* We know how to repaint the ripoffs */
 177 __ripoffresize(_cursesi_screen);
 178
171 return result; 179 return result;
172} 180}
173 181
174/* 182/*
175 * resize_term -- 183 * resize_term --
176 * Resize the terminal window, resizing the dependent windows. 184 * Resize the terminal window, resizing the dependent windows.
177 */ 185 */
178int 186int
179resize_term(int nlines, int ncols) 187resize_term(int nlines, int ncols)
180{ 188{
181 WINDOW *win; 189 WINDOW *win;
182 struct __winlist *list; 190 struct __winlist *list;
 191 int rlines;
183 192
184#ifdef DEBUG 193#ifdef DEBUG
185 __CTRACE(__CTRACE_WINDOW, "resize_term: (%d, %d)\n", nlines, ncols); 194 __CTRACE(__CTRACE_WINDOW, "resize_term: (%d, %d)\n", nlines, ncols);
186#endif 195#endif
187 196
188 if (!is_term_resized(nlines, ncols)) 197 if (!is_term_resized(nlines, ncols))
189 return OK; 198 return OK;
190 199
191 if (__resizeterm(curscr, nlines, ncols) == ERR) 200 if (__resizeterm(curscr, nlines, ncols) == ERR)
192 return ERR; 201 return ERR;
193 if (__resizeterm(__virtscr, nlines, ncols) == ERR) 202 if (__resizeterm(__virtscr, nlines, ncols) == ERR)
194 return ERR; 203 return ERR;
195 nlines -= _cursesi_screen->ripped_top - _cursesi_screen->ripped_bottom; 204 rlines = nlines - __rippedlines(_cursesi_screen);
196 if (__resizeterm(stdscr, nlines, ncols) == ERR) 205 if (__resizeterm(stdscr, rlines, ncols) == ERR)
197 return ERR; 206 return ERR;
198 207
199 LINES = nlines; 208 _cursesi_screen->LINES = nlines;
 209 _cursesi_screen->COLS = ncols;
 210 LINES = rlines;
200 COLS = ncols; 211 COLS = ncols;
201 212
202 /* tweak the flags now that we have updated the LINES and COLS */ 213 /* tweak the flags now that we have updated the LINES and COLS */
203 for (list = _cursesi_screen->winlistp; list != NULL; list = list->nextp) { 214 for (list = _cursesi_screen->winlistp; list != NULL; list = list->nextp) {
204 win = list->winp; 215 win = list->winp;
205 216
206 if (!(win->flags & __ISPAD)) 217 if (!(win->flags & __ISPAD))
207 __swflags(win); 218 __swflags(win);
208 } 219 }
209 220
210 return OK; 221 return OK;
211} 222}
212 223

File Added: src/lib/libcurses/ripoffline.c
/*	$NetBSD: ripoffline.c,v 1.1 2017/01/11 20:43:03 roy Exp $	*/

/*-
 * Copyright (c) 2017 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Roy Marples.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 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.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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 SUCH DAMAGE.
 */

#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: ripoffline.c,v 1.1 2017/01/11 20:43:03 roy Exp $");
#endif				/* not lint */

#include "curses.h"
#include "curses_private.h"

/* List of ripoffline calls */
static struct ripoff {
	int	nlines;
	int	(*init)(WINDOW *, int);
} ripoffs[MAX_RIPS];
static int nrips;

/*
 * ripoffline --
 *	Ripoff a line from the top of bottom of stdscr.
 *	Must be called before initscr or newterm.
 */
int
ripoffline(int line, int (*init)(WINDOW *, int))
{

#ifdef DEBUG
	__CTRACE(__CTRACE_SCREEN, "ripoffline: %d\n", line);
#endif

	if (nrips >= MAX_RIPS || init == NULL)
		return ERR; /* This makes sense, but not standards compliant. */
	if (line == 0)
		return OK;
	ripoffs[nrips].nlines = line < 0 ? -1 : 1;
	ripoffs[nrips++].init = init;
	return OK;
}

/*
 * __rippedlines --
 *	Returns the number of ripped lines from the screen.
 */
int
__rippedlines(const SCREEN *screen)
{
	const struct __ripoff *rip;
	int i, n;

	n = 0;
	for (i = 0, rip = screen->ripped; i < screen->nripped; i++, rip++) {
		if (rip->nlines < 0)
			n += -rip->nlines;
		else
			n += rip->nlines;
	}
	return n;
}

/*
 * __ripoffscreen --
 *	Rips lines from the screen by creating a WINDOW per ripoffline call.
 *	Although the POSIX API only allows for one line WINDOWS to be created,
 *	this implemenation allows for N lines if needed.
 */
int
__ripoffscreen(SCREEN *screen, int *rtop)
{
	int i, nlines;
	const struct ripoff *srip;
	struct __ripoff *rip;
	WINDOW *w;

	*rtop = 0;
	rip = screen->ripped;
	for (i = 0, srip = ripoffs; i < nrips; i++, srip++) {
		nlines = srip->nlines < 0 ? -srip->nlines : srip->nlines;
		w = __newwin(screen, nlines, 0,
		    srip->nlines < 0 ? LINES - nlines : *rtop,
		    0, FALSE);
		if (w != NULL) {
			rip->win = w;
			rip->nlines = srip->nlines;
			rip++;
			screen->nripped++;
			if (rip->nlines > 0)
				(*rtop) += rip->nlines;
			LINES -= nlines;
		}
		if (srip->init(w, COLS) == ERR)
			return ERR;
#ifdef DEBUG
		if (w != NULL)
			__CTRACE(__CTRACE_SCREEN,
			    "newterm: ripped %d lines from the %s\n",
			    nlines, srip->nlines < 0 ? "bottom" : "top");
#endif
	}
	nrips = 0; /* Reset the stack. */
	return OK;
}

/*
 * __ripoffresize --
 *	Called from resizeterm to ensure the ripped off lines are correctly
 *	placed and refreshed.
 */
void
__ripoffresize(SCREEN *screen)
{
	int rbot = _cursesi_screen->LINES, i;
	struct __ripoff *rip;

	for (i = 0, rip = _cursesi_screen->ripped;
	     i < _cursesi_screen->nripped;
	     i++, rip++)
	{
		if (rip->nlines > 0)
			touchwin(rip->win);
		else {
			/* Reposition the lower windows. */
			mvwin(rip->win, rbot + rip->nlines, 0);
			rbot += rip->nlines;
		}
		wnoutrefresh(rip->win);
	}
}

cvs diff -r1.28 -r1.29 src/lib/libcurses/screen.c (expand / switch to unified diff)

--- src/lib/libcurses/screen.c 2017/01/10 10:13:24 1.28
+++ src/lib/libcurses/screen.c 2017/01/11 20:43:03 1.29
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: screen.c,v 1.28 2017/01/10 10:13:24 roy Exp $ */ 1/* $NetBSD: screen.c,v 1.29 2017/01/11 20:43:03 roy Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1981, 1993, 1994 4 * Copyright (c) 1981, 1993, 1994
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,107 +24,73 @@ @@ -24,107 +24,73 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)screen.c 8.2 (blymn) 11/27/2001"; 35static char sccsid[] = "@(#)screen.c 8.2 (blymn) 11/27/2001";
36#else 36#else
37__RCSID("$NetBSD: screen.c,v 1.28 2017/01/10 10:13:24 roy Exp $"); 37__RCSID("$NetBSD: screen.c,v 1.29 2017/01/11 20:43:03 roy Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <stdlib.h> 41#include <stdlib.h>
42 42
43#include "curses.h" 43#include "curses.h"
44#include "curses_private.h" 44#include "curses_private.h"
45 45
46static int filtered; 46static int filtered;
47 47
48/* List of ripoffline calls */ 
49#define NRIPS 5 
50static struct ripoff { 
51 int nlines; 
52 int (*init)(WINDOW *, int); 
53} ripoffs[NRIPS]; 
54static int nrips; 
55 48
56/* 49static void __delscreen(SCREEN *);
57 * filter has to be called before either initscr or newterm. 
58 */ 
59void 
60filter(void) 
61{ 
62 
63 filtered = TRUE; 
64} 
65 
66/* 
67 *ripoffline -- 
68 * Ripoff a line from the top of bottom of stdscr. 
69 * Must be called before initscr or newterm. 
70 */ 
71int 
72ripoffline(int line, int (*init)(WINDOW *, int)) 
73{ 
74 
75 if (nrips >= NRIPS || init == NULL) 
76 return ERR; /* This makes sense, but not standards compliant. */ 
77 if (line == 0) 
78 return OK; 
79 ripoffs[nrips].nlines = line < 0 ? -1 : 1; 
80 ripoffs[nrips++].init = init; 
81 return OK; 
82} 
83 50
84/* 51/*
85 * set_term -- 52 * set_term --
86 * Change the term to the given screen. 53 * Change the term to the given screen.
87 * 54 *
88 */ 55 */
89SCREEN * 56SCREEN *
90set_term(SCREEN *new) 57set_term(SCREEN *new)
91{ 58{
92 SCREEN *old_screen = _cursesi_screen; 59 SCREEN *old_screen = _cursesi_screen;
93 60
94 if (_cursesi_screen != NULL) { 61 if (_cursesi_screen != NULL) {
95 /* save changes made to the current screen... */ 62 /* save changes made to the current screen... */
96 old_screen->echoit = __echoit; 63 old_screen->echoit = __echoit;
97 old_screen->pfast = __pfast; 64 old_screen->pfast = __pfast;
98 old_screen->rawmode = __rawmode; 65 old_screen->rawmode = __rawmode;
99 old_screen->noqch = __noqch; 66 old_screen->noqch = __noqch;
100 old_screen->COLS = COLS; 67 old_screen->COLS = COLS;
101 old_screen->LINES = LINES 68 old_screen->LINES = LINES + __rippedlines(old_screen);
102 + old_screen->ripped_top + old_screen->ripped_bottom; 
103 old_screen->COLORS = COLORS; 69 old_screen->COLORS = COLORS;
104 old_screen->COLOR_PAIRS = COLOR_PAIRS; 70 old_screen->COLOR_PAIRS = COLOR_PAIRS;
105 old_screen->GT = __GT; 71 old_screen->GT = __GT;
106 old_screen->NONL = __NONL; 72 old_screen->NONL = __NONL;
107 old_screen->UPPERCASE = __UPPERCASE; 73 old_screen->UPPERCASE = __UPPERCASE;
108 } 74 }
109 75
110 _cursesi_screen = new; 76 _cursesi_screen = new;
111 77
112 __echoit = new->echoit; 78 __echoit = new->echoit;
113 __pfast = new->pfast; 79 __pfast = new->pfast;
114 __rawmode = new->rawmode; 80 __rawmode = new->rawmode;
115 __noqch = new->noqch; 81 __noqch = new->noqch;
116 COLS = new->COLS; 82 COLS = new->COLS;
117 LINES = new->LINES - new->ripped_top - new->ripped_bottom; 83 LINES = new->LINES - __rippedlines(new);
118 COLORS = new->COLORS; 84 COLORS = new->COLORS;
119 COLOR_PAIRS = new->COLOR_PAIRS; 85 COLOR_PAIRS = new->COLOR_PAIRS;
120 __GT = new->GT; 86 __GT = new->GT;
121 __NONL = new->NONL; 87 __NONL = new->NONL;
122 __UPPERCASE = new->UPPERCASE; 88 __UPPERCASE = new->UPPERCASE;
123 89
124 _cursesi_resetterm(new); 90 _cursesi_resetterm(new);
125 91
126 curscr = new->curscr; 92 curscr = new->curscr;
127 clearok(curscr, new->clearok); 93 clearok(curscr, new->clearok);
128 stdscr = new->stdscr; 94 stdscr = new->stdscr;
129 __virtscr = new->__virtscr; 95 __virtscr = new->__virtscr;
130 96
@@ -141,27 +107,27 @@ set_term(SCREEN *new) @@ -141,27 +107,27 @@ set_term(SCREEN *new)
141 return old_screen; 107 return old_screen;
142} 108}
143 109
144/* 110/*
145 * newterm -- 111 * newterm --
146 * Set up a new screen. 112 * Set up a new screen.
147 * 113 *
148 */ 114 */
149SCREEN * 115SCREEN *
150newterm(char *type, FILE *outfd, FILE *infd) 116newterm(char *type, FILE *outfd, FILE *infd)
151{ 117{
152 SCREEN *new_screen; 118 SCREEN *new_screen;
153 char *sp; 119 char *sp;
154 int i; 120 int rtop;
155 121
156 sp = type; 122 sp = type;
157 if (type == NULL && (sp = getenv("TERM")) == NULL) 123 if (type == NULL && (sp = getenv("TERM")) == NULL)
158 return NULL; 124 return NULL;
159 125
160 if ((new_screen = calloc(1, sizeof(SCREEN))) == NULL) 126 if ((new_screen = calloc(1, sizeof(SCREEN))) == NULL)
161 return NULL; 127 return NULL;
162 128
163#ifdef DEBUG 129#ifdef DEBUG
164 __CTRACE(__CTRACE_INIT, "newterm\n"); 130 __CTRACE(__CTRACE_INIT, "newterm\n");
165#endif 131#endif
166 132
167 new_screen->infd = infd; 133 new_screen->infd = infd;
@@ -201,63 +167,34 @@ newterm(char *type, FILE *outfd, FILE *i @@ -201,63 +167,34 @@ newterm(char *type, FILE *outfd, FILE *i
201 /* Need either homing or cursor motion for refreshes */ 167 /* Need either homing or cursor motion for refreshes */
202 if (!t_cursor_home(new_screen->term) && 168 if (!t_cursor_home(new_screen->term) &&
203 !t_cursor_address(new_screen->term)) 169 !t_cursor_address(new_screen->term))
204 goto error_exit; 170 goto error_exit;
205 171
206 new_screen->winlistp = NULL; 172 new_screen->winlistp = NULL;
207 173
208 if ((new_screen->curscr = __newwin(new_screen, 0, 174 if ((new_screen->curscr = __newwin(new_screen, 0,
209 0, 0, 0, FALSE)) == NULL) 175 0, 0, 0, FALSE)) == NULL)
210 goto error_exit; 176 goto error_exit;
211 177
212 if ((new_screen->__virtscr = __newwin(new_screen, 0, 178 if ((new_screen->__virtscr = __newwin(new_screen, 0,
213 0, 0, 0, FALSE)) == NULL) 179 0, 0, 0, FALSE)) == NULL)
214 { 
215 delwin(new_screen->curscr); 
216 goto error_exit; 180 goto error_exit;
217 } 
218 181
219 for (i = 0; i < nrips; i++) { 182 if (__ripoffscreen(new_screen, &rtop) == ERR)
220 const struct ripoff *r = &ripoffs[i]; 183 goto error_exit;
221 int nlines = r->nlines < 0 ? -r->nlines : r->nlines; 
222 WINDOW *w; 
223 
224 w = __newwin(new_screen, nlines, 0, 
225 r->nlines < 0 ? LINES + r->nlines : new_screen->ripped_top, 
226 0, FALSE); 
227 if (w != NULL) { 
228 if (r->nlines < 0) 
229 new_screen->ripped_bottom += nlines; 
230 else 
231 new_screen->ripped_top += nlines; 
232 LINES -= nlines; 
233 } 
234 r->init(w, COLS); 
235#ifdef DEBUG 
236 if (w != NULL) 
237 __CTRACE(__CTRACE_SCREEN, 
238 "newterm: ripped %d lines from the %s\n", 
239 nlines, r->nlines < 0 ? "bottom" : "top"); 
240#endif 
241 } 
242 nrips = 0; /* Reset the stack. */ 
243 184
244 new_screen->stdscr = __newwin(new_screen, LINES, 0, 185 new_screen->stdscr = __newwin(new_screen, LINES, 0, rtop, 0, FALSE);
245 new_screen->ripped_top, 0, FALSE); 186 if (new_screen->stdscr == NULL)
246 if (new_screen->stdscr == NULL) { 
247 delwin(new_screen->curscr); 
248 delwin(new_screen->__virtscr); 
249 goto error_exit; 187 goto error_exit;
250 } 
251 188
252 clearok(new_screen->stdscr, 1); 189 clearok(new_screen->stdscr, 1);
253 190
254 __init_getch(new_screen); 191 __init_getch(new_screen);
255 __init_acs(new_screen); 192 __init_acs(new_screen);
256#ifdef HAVE_WCHAR 193#ifdef HAVE_WCHAR
257 __init_get_wch( new_screen ); 194 __init_get_wch( new_screen );
258 __init_wacs(new_screen); 195 __init_wacs(new_screen);
259#endif /* HAVE_WCHAR */ 196#endif /* HAVE_WCHAR */
260 197
261 __set_stophandler(); 198 __set_stophandler();
262 __set_winchhandler(); 199 __set_winchhandler();
263 200
@@ -268,54 +205,62 @@ newterm(char *type, FILE *outfd, FILE *i @@ -268,54 +205,62 @@ newterm(char *type, FILE *outfd, FILE *i
268 if (_cursesi_screen == NULL || _cursesi_screen->endwin) { 205 if (_cursesi_screen == NULL || _cursesi_screen->endwin) {
269 set_term(new_screen); 206 set_term(new_screen);
270 } 207 }
271 208
272#ifdef DEBUG 209#ifdef DEBUG
273 __CTRACE(__CTRACE_SCREEN, "newterm: LINES = %d, COLS = %d\n", 210 __CTRACE(__CTRACE_SCREEN, "newterm: LINES = %d, COLS = %d\n",
274 LINES, COLS); 211 LINES, COLS);
275#endif 212#endif
276 __startwin(new_screen); 213 __startwin(new_screen);
277 214
278 return new_screen; 215 return new_screen;
279 216
280 error_exit: 217 error_exit:
281 if (new_screen->term != NULL) 218 __delscreen(new_screen);
282 (void)del_curterm(new_screen->term); 
283 free(new_screen->unget_list); 219 free(new_screen->unget_list);
284 220
285 free(new_screen); 221 free(new_screen);
286 return NULL; 222 return NULL;
287} 223}
288 224
289/* 225/*
290 * delscreen -- 226 * delscreen --
291 * Free resources used by the given screen and destroy it. 227 * Free resources used by the given screen and destroy it.
292 * 228 *
293 */ 229 */
294void 230void
295delscreen(SCREEN *screen) 231delscreen(SCREEN *screen)
296{ 232{
297 struct __winlist *list; 
298 233
299#ifdef DEBUG 234#ifdef DEBUG
300 __CTRACE(__CTRACE_SCREEN, "delscreen(%p)\n", screen); 235 __CTRACE(__CTRACE_SCREEN, "delscreen(%p)\n", screen);
301#endif 236#endif
302 /* free up the terminfo stuff */ 
303 del_curterm(screen->term); 
304 237
305 /* walk the window list and kill all the parent windows */ 238 __delscreen(screen);
306 while ((list = screen->winlistp) != NULL) { 
307 delwin(list->winp); 
308 if (list == screen->winlistp) 
309 /* sanity - abort if window didn't remove itself */ 
310 break; 
311 } 
312 239
313 /* free the storage of the keymaps */ 240 /* free the storage of the keymaps */
314 _cursesi_free_keymap(screen->base_keymap); 241 _cursesi_free_keymap(screen->base_keymap);
315 242
316 free(screen->stdbuf); 243 free(screen->stdbuf);
317 free(screen->unget_list); 244 free(screen->unget_list);
318 if (_cursesi_screen == screen) 245 if (_cursesi_screen == screen)
319 _cursesi_screen = NULL; 246 _cursesi_screen = NULL;
320 free(screen); 247 free(screen);
321} 248}
 249
 250static void
 251__delscreen(SCREEN *screen)
 252{
 253 struct __winlist *list;
 254
 255 /* free up the terminfo stuff */
 256 if (screen->term != NULL)
 257 del_curterm(screen->term);
 258
 259 /* walk the window list and kill all the parent windows */
 260 while ((list = screen->winlistp) != NULL) {
 261 delwin(list->winp);
 262 if (list == screen->winlistp)
 263 /* sanity - abort if window didn't remove itself */
 264 break;
 265 }
 266}

cvs diff -r1.60 -r1.61 src/lib/libcurses/setterm.c (expand / switch to unified diff)

--- src/lib/libcurses/setterm.c 2017/01/10 10:13:24 1.60
+++ src/lib/libcurses/setterm.c 2017/01/11 20:43:03 1.61
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: setterm.c,v 1.60 2017/01/10 10:13:24 roy Exp $ */ 1/* $NetBSD: setterm.c,v 1.61 2017/01/11 20:43:03 roy Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1981, 1993, 1994 4 * Copyright (c) 1981, 1993, 1994
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)setterm.c 8.8 (Berkeley) 10/25/94"; 35static char sccsid[] = "@(#)setterm.c 8.8 (Berkeley) 10/25/94";
36#else 36#else
37__RCSID("$NetBSD: setterm.c,v 1.60 2017/01/10 10:13:24 roy Exp $"); 37__RCSID("$NetBSD: setterm.c,v 1.61 2017/01/11 20:43:03 roy Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <sys/ioctl.h> /* TIOCGWINSZ on old systems. */ 41#include <sys/ioctl.h> /* TIOCGWINSZ on old systems. */
42 42
43#include <stdlib.h> 43#include <stdlib.h>
44#include <string.h> 44#include <string.h>
45#include <termios.h> 45#include <termios.h>
46#include <unistd.h> 46#include <unistd.h>
47 47
48#include "curses.h" 48#include "curses.h"
49#include "curses_private.h" 49#include "curses_private.h"
50 50
@@ -140,27 +140,27 @@ _cursesi_setterm(char *type, SCREEN *scr @@ -140,27 +140,27 @@ _cursesi_setterm(char *type, SCREEN *scr
140 screen->ESCDELAY = ESCDELAY_DEFAULT; 140 screen->ESCDELAY = ESCDELAY_DEFAULT;
141 if ((p = getenv("TABSIZE")) != NULL) 141 if ((p = getenv("TABSIZE")) != NULL)
142 screen->TABSIZE = (int)strtol(p, NULL, 0); 142 screen->TABSIZE = (int)strtol(p, NULL, 0);
143 else if (t_init_tabs(screen->term) >= 0) 143 else if (t_init_tabs(screen->term) >= 0)
144 screen->TABSIZE = (int)t_init_tabs(screen->term); 144 screen->TABSIZE = (int)t_init_tabs(screen->term);
145 else 145 else
146 screen->TABSIZE = TABSIZE_DEFAULT; 146 screen->TABSIZE = TABSIZE_DEFAULT;
147 /* 147 /*
148 * Want cols > 4, otherwise things will fail. 148 * Want cols > 4, otherwise things will fail.
149 */ 149 */
150 if (screen->COLS <= 4) 150 if (screen->COLS <= 4)
151 return ERR; 151 return ERR;
152 152
153 LINES = screen->LINES - screen->ripped_top - screen->ripped_bottom; 153 LINES = screen->LINES - __rippedlines(screen);
154 COLS = screen->COLS; 154 COLS = screen->COLS;
155 ESCDELAY = screen->ESCDELAY; 155 ESCDELAY = screen->ESCDELAY;
156 TABSIZE = screen->TABSIZE; 156 TABSIZE = screen->TABSIZE;
157 157
158#ifdef DEBUG 158#ifdef DEBUG
159 __CTRACE(__CTRACE_INIT, 159 __CTRACE(__CTRACE_INIT,
160 "setterm: LINES = %d, COLS = %d, TABSIZE = %d\n", 160 "setterm: LINES = %d, COLS = %d, TABSIZE = %d\n",
161 LINES, COLS, TABSIZE); 161 LINES, COLS, TABSIZE);
162#endif 162#endif
163 163
164 /* 164 /*
165 * set the pad char, only take the first char of the pc capability 165 * set the pad char, only take the first char of the pc capability
166 * as this is all we can use. 166 * as this is all we can use.
@@ -272,27 +272,27 @@ _cursesi_setterm(char *type, SCREEN *scr @@ -272,27 +272,27 @@ _cursesi_setterm(char *type, SCREEN *scr
272 272
273 return unknown ? ERR : OK; 273 return unknown ? ERR : OK;
274} 274}
275 275
276/* 276/*
277 * _cursesi_resetterm -- 277 * _cursesi_resetterm --
278 * Copy the terminal instance data for the given screen to the global 278 * Copy the terminal instance data for the given screen to the global
279 * variables. 279 * variables.
280 */ 280 */
281void 281void
282_cursesi_resetterm(SCREEN *screen) 282_cursesi_resetterm(SCREEN *screen)
283{ 283{
284 284
285 LINES = screen->LINES - screen->ripped_top - screen->ripped_bottom; 285 LINES = screen->LINES - __rippedlines(screen);
286 COLS = screen->COLS; 286 COLS = screen->COLS;
287 ESCDELAY = screen->ESCDELAY; 287 ESCDELAY = screen->ESCDELAY;
288 TABSIZE = screen->TABSIZE; 288 TABSIZE = screen->TABSIZE;
289 __GT = screen->GT; 289 __GT = screen->GT;
290 290
291 __noqch = screen->noqch; 291 __noqch = screen->noqch;
292 __mask_op = screen->mask_op; 292 __mask_op = screen->mask_op;
293 __mask_me = screen->mask_me; 293 __mask_me = screen->mask_me;
294 __mask_ue = screen->mask_ue; 294 __mask_ue = screen->mask_ue;
295 __mask_se = screen->mask_se; 295 __mask_se = screen->mask_se;
296 296
297 set_curterm(screen->term); 297 set_curterm(screen->term);
298} 298}