Thu Oct 4 10:20:13 2018 UTC ()
Pull up following revision(s) (requested by roy in ticket #1047):

	lib/libcurses/curses_private.h: revision 1.64
	lib/libcurses/curses_private.h: revision 1.65
	lib/libcurses/initscr.c: revision 1.33
	lib/libcurses/curses_screen.3: revision 1.24
	lib/libcurses/curses_screen.3: revision 1.25
	lib/libcurses/newwin.c: revision 1.52
	lib/libcurses/fileio.c: revision 1.6
	lib/libcurses/ripoffline.c: revision 1.4
	lib/libcurses/resize.c: revision 1.28
	lib/libcurses/ripoffline.c: revision 1.5
	lib/libcurses/resize.c: revision 1.29
	lib/libcurses/screen.c: revision 1.34
	lib/libcurses/setterm.c: revision 1.67

curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.

LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635

 -

curses: resize ripped off windows
The application must still redraw them though.

 -

Fix typos in curses_screen.3
Fn -> Ft in the resize_term(3) prototype
funcion -> function


(martin)
diff -r1.62.4.1 -r1.62.4.2 src/lib/libcurses/curses_private.h
diff -r1.23 -r1.23.4.1 src/lib/libcurses/curses_screen.3
diff -r1.5 -r1.5.6.1 src/lib/libcurses/fileio.c
diff -r1.32 -r1.32.6.1 src/lib/libcurses/initscr.c
diff -r1.50 -r1.50.6.1 src/lib/libcurses/newwin.c
diff -r1.26.4.1 -r1.26.4.2 src/lib/libcurses/resize.c
diff -r1.3 -r1.3.6.1 src/lib/libcurses/ripoffline.c
diff -r1.33 -r1.33.4.1 src/lib/libcurses/screen.c
diff -r1.66 -r1.66.4.1 src/lib/libcurses/setterm.c

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

--- src/lib/libcurses/curses_private.h 2018/09/27 15:12:15 1.62.4.1
+++ src/lib/libcurses/curses_private.h 2018/10/04 10:20:12 1.62.4.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: curses_private.h,v 1.62.4.1 2018/09/27 15:12:15 martin Exp $ */ 1/* $NetBSD: curses_private.h,v 1.62.4.2 2018/10/04 10:20:12 martin 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.
@@ -358,39 +358,40 @@ void __init_acs(SCREEN *); @@ -358,39 +358,40 @@ void __init_acs(SCREEN *);
358#ifdef HAVE_WCHAR 358#ifdef HAVE_WCHAR
359void __init_get_wch(SCREEN *); 359void __init_get_wch(SCREEN *);
360void __init_wacs(SCREEN *); 360void __init_wacs(SCREEN *);
361int __cputwchar_args( wchar_t, void * ); 361int __cputwchar_args( wchar_t, void * );
362int _cursesi_copy_nsp(nschar_t *, struct __ldata *); 362int _cursesi_copy_nsp(nschar_t *, struct __ldata *);
363void __cursesi_free_nsp(nschar_t *); 363void __cursesi_free_nsp(nschar_t *);
364void __cursesi_win_free_nsp(WINDOW *); 364void __cursesi_win_free_nsp(WINDOW *);
365void __cursesi_putnsp(nschar_t *, const int, const int); 365void __cursesi_putnsp(nschar_t *, const int, const int);
366void __cursesi_chtype_to_cchar(chtype, cchar_t *); 366void __cursesi_chtype_to_cchar(chtype, cchar_t *);
367#endif /* HAVE_WCHAR */ 367#endif /* HAVE_WCHAR */
368int __fgetc_resize(FILE *); 368int __fgetc_resize(FILE *);
369int __unget(wint_t); 369int __unget(wint_t);
370int __mvcur(int, int, int, int, int); 370int __mvcur(int, int, int, int, int);
371WINDOW *__newwin(SCREEN *, int, int, int, int, int); 371WINDOW *__newwin(SCREEN *, int, int, int, int, int, int);
372int __nodelay(void); 372int __nodelay(void);
373int __notimeout(void); 373int __notimeout(void);
374void __restartwin(void); 374void __restartwin(void);
375void __restore_colors(void); 375void __restore_colors(void);
376void __restore_cursor_vis(void); 376void __restore_cursor_vis(void);
377void __restore_meta_state(void); 377void __restore_meta_state(void);
378void __restore_termios(void); 378void __restore_termios(void);
379void __restore_stophandler(void); 379void __restore_stophandler(void);
380void __restore_winchhandler(void); 380void __restore_winchhandler(void);
381int __ripoffscreen(SCREEN *, int *); 381int __ripoffscreen(SCREEN *);
382void __ripoffresize(SCREEN *); 382int __ripoffresize(SCREEN *);
383int __rippedlines(const SCREEN *); 383void __ripofftouch(SCREEN *);
 384int __rippedlines(const SCREEN *, int);
384void __save_termios(void); 385void __save_termios(void);
385void __set_color(WINDOW *win, attr_t attr); 386void __set_color(WINDOW *win, attr_t attr);
386void __set_stophandler(void); 387void __set_stophandler(void);
387void __set_winchhandler(void); 388void __set_winchhandler(void);
388void __set_subwin(WINDOW *, WINDOW *); 389void __set_subwin(WINDOW *, WINDOW *);
389int __slk_init(SCREEN *); 390int __slk_init(SCREEN *);
390void __slk_free(SCREEN *); 391void __slk_free(SCREEN *);
391int __slk_resize(SCREEN *, int cols); 392int __slk_resize(SCREEN *, int cols);
392int __slk_noutrefresh(SCREEN *); 393int __slk_noutrefresh(SCREEN *);
393void __startwin(SCREEN *); 394void __startwin(SCREEN *);
394void __stop_signal_handler(int); 395void __stop_signal_handler(int);
395int __stopwin(void); 396int __stopwin(void);
396void __swflags(WINDOW *); 397void __swflags(WINDOW *);

cvs diff -r1.23 -r1.23.4.1 src/lib/libcurses/curses_screen.3 (expand / switch to unified diff)

--- src/lib/libcurses/curses_screen.3 2017/01/24 16:45:41 1.23
+++ src/lib/libcurses/curses_screen.3 2018/10/04 10:20:12 1.23.4.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1.\" $NetBSD: curses_screen.3,v 1.23 2017/01/24 16:45:41 roy Exp $ 1.\" $NetBSD: curses_screen.3,v 1.23.4.1 2018/10/04 10:20:12 martin Exp $
2.\" 2.\"
3.\" Copyright (c) 2002 3.\" Copyright (c) 2002
4.\" Brett Lymn (blymn@NetBSD.org, brett_lymn@yahoo.com.au) 4.\" Brett Lymn (blymn@NetBSD.org, brett_lymn@yahoo.com.au)
5.\" 5.\"
6.\" This code is donated to the NetBSD Foundation by the Author. 6.\" This code is donated to the NetBSD Foundation by the Author.
7.\" 7.\"
8.\" Redistribution and use in source and binary forms, with or without 8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions 9.\" modification, are permitted provided that the following conditions
10.\" are met: 10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright 11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer. 12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the 14.\" notice, this list of conditions and the following disclaimer in the
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND 20.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE. 30.\" SUCH DAMAGE.
31.\" 31.\"
32.\" 32.\"
33.Dd January 24, 2017 33.Dd October 2, 2018
34.Dt CURSES_SCREEN 3 34.Dt CURSES_SCREEN 3
35.Os 35.Os
36.Sh NAME 36.Sh NAME
37.Nm curses_screen , 37.Nm curses_screen ,
38.Nm filter , 38.Nm filter ,
39.Nm ripoffline , 39.Nm ripoffline ,
40.Nm use_env , 40.Nm use_env ,
41.Nm newterm , 41.Nm newterm ,
42.Nm set_term , 42.Nm set_term ,
43.Nm delscreen , 43.Nm delscreen ,
44.Nm endwin , 44.Nm endwin ,
45.Nm initscr , 45.Nm initscr ,
46.Nm isendwin , 46.Nm isendwin ,
@@ -64,27 +64,27 @@ @@ -64,27 +64,27 @@
64.Fn newterm "char *type" "FILE *outfd" "FILE *infd" 64.Fn newterm "char *type" "FILE *outfd" "FILE *infd"
65.Ft SCREEN * 65.Ft SCREEN *
66.Fn set_term "SCREEN *screen" 66.Fn set_term "SCREEN *screen"
67.Ft void 67.Ft void
68.Fn delscreen "SCREEN *screen" 68.Fn delscreen "SCREEN *screen"
69.Ft int 69.Ft int
70.Fn endwin "void" 70.Fn endwin "void"
71.Ft WINDOW * 71.Ft WINDOW *
72.Fn initscr "void" 72.Fn initscr "void"
73.Ft bool 73.Ft bool
74.Fn isendwin "void" 74.Fn isendwin "void"
75.Ft bool 75.Ft bool
76.Fn is_term_resized "int lines" "int cols" 76.Fn is_term_resized "int lines" "int cols"
77.Fn int 77.Ft int
78.Fn resize_term "int lines" "int cols" 78.Fn resize_term "int lines" "int cols"
79.Ft int 79.Ft int
80.Fn resizeterm "int lines" "int cols" 80.Fn resizeterm "int lines" "int cols"
81.Ft int 81.Ft int
82.Fn setterm "char *name" 82.Fn setterm "char *name"
83.Ft int 83.Ft int
84.Fn set_tabsize "int value" 84.Fn set_tabsize "int value"
85.Pp 85.Pp
86.Va extern int LINES ; 86.Va extern int LINES ;
87.Pp 87.Pp
88.Va extern int COLS ; 88.Va extern int COLS ;
89.Sh DESCRIPTION 89.Sh DESCRIPTION
90These functions initialize terminals and screens. 90These functions initialize terminals and screens.
@@ -206,51 +206,49 @@ or @@ -206,51 +206,49 @@ or
206.Fn newterm 206.Fn newterm
207performs the following additonal actions: 207performs the following additonal actions:
208.Bl -bullet -compact 208.Bl -bullet -compact
209.It 209.It
210Disable use of clear, cud, cud1, cup, cuu, cuu1 and vpa. 210Disable use of clear, cud, cud1, cup, cuu, cuu1 and vpa.
211.It 211.It
212Set the value of the home string to the value of the cr string. 212Set the value of the home string to the value of the cr string.
213.It 213.It
214Set lines equal to 1. 214Set lines equal to 1.
215.El 215.El
216.Pp 216.Pp
217The 217The
218.Fn ripoffline 218.Fn ripoffline
219funcion will rip a line from 219function will rip a line from
220.Dv stdscr 220.Dv stdscr
221at the top if 221at the top if
222.Fa line 222.Fa line
223is positive, or at the bottom if negative. 223is positive, or at the bottom if negative.
224When 224When
225.Fn initscr 225.Fn initscr
226or 226or
227.Fn newterm 227.Fn newterm
228is called, a window will be created for each line ripped and passed 228is called, a window will be created for each line ripped and passed
229to the 229to the
230.Fa init 230.Fa init
231function pointer alongwith the number of columns in the window. 231function pointer alongwith the number of columns in the window.
232This init function cannot use the 232This init function cannot use the
233.Dv LINES 233.Dv LINES
234or 234or
235.Dv COLS 235.Dv COLS
236variables and cannot call 236variables and cannot call
237.Xr wrefresh 3 237.Xr wrefresh 3
238or 238or
239.Xr doupdate 3 , 239.Xr doupdate 3 ,
240but may call 240but may call
241.Xr wnoutrefresh 3 . 241.Xr wnoutrefresh 3 .
242.Dv LINES 
243will be reduced by the total number of lines ripped off. 
244.Fn ripoffline 242.Fn ripoffline
245can be called up to five times. 243can be called up to five times.
246.Pp 244.Pp
247The 245The
248.Fn use_env 246.Fn use_env
249function determines whether the environment variables 247function determines whether the environment variables
250.Ev LINES 248.Ev LINES
251and 249and
252.Ev COLUMNS 250.Ev COLUMNS
253override the normal values. 251override the normal values.
254The default is true. 252The default is true.
255Any call to 253Any call to
256.Fn use_env 254.Fn use_env

cvs diff -r1.5 -r1.5.6.1 src/lib/libcurses/fileio.c (expand / switch to unified diff)

--- src/lib/libcurses/fileio.c 2016/10/22 21:55:06 1.5
+++ src/lib/libcurses/fileio.c 2018/10/04 10:20:12 1.5.6.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: fileio.c,v 1.5 2016/10/22 21:55:06 christos Exp $ */ 1/* $NetBSD: fileio.c,v 1.5.6.1 2018/10/04 10:20:12 martin Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Julian Coleman. 8 * by Julian Coleman.
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.
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34__RCSID("$NetBSD: fileio.c,v 1.5 2016/10/22 21:55:06 christos Exp $"); 34__RCSID("$NetBSD: fileio.c,v 1.5.6.1 2018/10/04 10:20:12 martin Exp $");
35#endif /* not lint */ 35#endif /* not lint */
36 36
37#include "curses.h" 37#include "curses.h"
38#include "curses_private.h" 38#include "curses_private.h"
39#include "fileio.h" 39#include "fileio.h"
40#include <stdio.h> 40#include <stdio.h>
41#include <stdlib.h> 41#include <stdlib.h>
42 42
43#ifdef HAVE_WCHAR 43#ifdef HAVE_WCHAR
44static int __putnsp(nschar_t *, FILE *); 44static int __putnsp(nschar_t *, FILE *);
45static int __getnsp(nschar_t *, FILE *); 45static int __getnsp(nschar_t *, FILE *);
46#endif /* HAVE_WCHAR */ 46#endif /* HAVE_WCHAR */
47 47
@@ -185,27 +185,27 @@ getwin(FILE *fp) @@ -185,27 +185,27 @@ getwin(FILE *fp)
185 return NULL; 185 return NULL;
186 if (fread(&minor, sizeof(int), 1, fp) != 1) 186 if (fread(&minor, sizeof(int), 1, fp) != 1)
187 return NULL; 187 return NULL;
188 if(major != CURSES_LIB_MAJOR || minor != CURSES_LIB_MINOR) 188 if(major != CURSES_LIB_MAJOR || minor != CURSES_LIB_MINOR)
189 return NULL; 189 return NULL;
190 190
191 /* Window parameters */ 191 /* Window parameters */
192 wtmp = malloc(sizeof(WINDOW)); 192 wtmp = malloc(sizeof(WINDOW));
193 if (wtmp == NULL) 193 if (wtmp == NULL)
194 return NULL; 194 return NULL;
195 if (fread(wtmp, sizeof(WINDOW), 1, fp) != 1) 195 if (fread(wtmp, sizeof(WINDOW), 1, fp) != 1)
196 goto error0; 196 goto error0;
197 win = __newwin(_cursesi_screen, wtmp->maxy, wtmp->maxx, 197 win = __newwin(_cursesi_screen, wtmp->maxy, wtmp->maxx,
198 wtmp->begy, wtmp->begx, FALSE); 198 wtmp->begy, wtmp->begx, FALSE, FALSE);
199 if (win == NULL) 199 if (win == NULL)
200 goto error0; 200 goto error0;
201 win->cury = wtmp->cury; 201 win->cury = wtmp->cury;
202 win->curx = wtmp->curx; 202 win->curx = wtmp->curx;
203 win->reqy = wtmp->reqy; 203 win->reqy = wtmp->reqy;
204 win->reqx = wtmp->reqx; 204 win->reqx = wtmp->reqx;
205 win->flags = wtmp->flags; 205 win->flags = wtmp->flags;
206 win->delay = wtmp->delay; 206 win->delay = wtmp->delay;
207 win->wattr = wtmp->wattr; 207 win->wattr = wtmp->wattr;
208 win->bch = wtmp->bch; 208 win->bch = wtmp->bch;
209 win->battr = wtmp->battr; 209 win->battr = wtmp->battr;
210 win->scr_t = wtmp->scr_t; 210 win->scr_t = wtmp->scr_t;
211 win->scr_b = wtmp->scr_b; 211 win->scr_b = wtmp->scr_b;

cvs diff -r1.32 -r1.32.6.1 src/lib/libcurses/initscr.c (expand / switch to unified diff)

--- src/lib/libcurses/initscr.c 2017/01/11 17:15:27 1.32
+++ src/lib/libcurses/initscr.c 2018/10/04 10:20:12 1.32.6.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: initscr.c,v 1.32 2017/01/11 17:15:27 roy Exp $ */ 1/* $NetBSD: initscr.c,v 1.32.6.1 2018/10/04 10:20:12 martin 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[] = "@(#)initscr.c 8.2 (Berkeley) 5/4/94"; 35static char sccsid[] = "@(#)initscr.c 8.2 (Berkeley) 5/4/94";
36#else 36#else
37__RCSID("$NetBSD: initscr.c,v 1.32 2017/01/11 17:15:27 roy Exp $"); 37__RCSID("$NetBSD: initscr.c,v 1.32.6.1 2018/10/04 10:20:12 martin 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
46 46
47/* 47/*
48 * initscr -- 48 * initscr --
49 * Initialize the current and standard screen. 49 * Initialize the current and standard screen.
50 */ 50 */
@@ -60,16 +60,17 @@ initscr(void) @@ -60,16 +60,17 @@ initscr(void)
60 /* 60 /*
61 * If My_term is set, or can't find a terminal in the environment, 61 * If My_term is set, or can't find a terminal in the environment,
62 * use Def_term. 62 * use Def_term.
63 */ 63 */
64 if (My_term || (sp = getenv("TERM")) == NULL) 64 if (My_term || (sp = getenv("TERM")) == NULL)
65 sp = Def_term; 65 sp = Def_term;
66 66
67 /* LINTED const castaway; newterm does not modify sp! */ 67 /* LINTED const castaway; newterm does not modify sp! */
68 if ((_cursesi_screen = newterm((char *) sp, stdout, stdin)) == NULL) 68 if ((_cursesi_screen = newterm((char *) sp, stdout, stdin)) == NULL)
69 return NULL; 69 return NULL;
70 70
71 set_term(_cursesi_screen); 71 set_term(_cursesi_screen);
72 wrefresh(curscr); 72 wrefresh(curscr);
 73 __ripofftouch(_cursesi_screen);
73 74
74 return stdscr; 75 return stdscr;
75} 76}

cvs diff -r1.50 -r1.50.6.1 src/lib/libcurses/newwin.c (expand / switch to unified diff)

--- src/lib/libcurses/newwin.c 2017/01/06 13:53:18 1.50
+++ src/lib/libcurses/newwin.c 2018/10/04 10:20:12 1.50.6.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: newwin.c,v 1.50 2017/01/06 13:53:18 roy Exp $ */ 1/* $NetBSD: newwin.c,v 1.50.6.1 2018/10/04 10:20:12 martin 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[] = "@(#)newwin.c 8.3 (Berkeley) 7/27/94"; 35static char sccsid[] = "@(#)newwin.c 8.3 (Berkeley) 7/27/94";
36#else 36#else
37__RCSID("$NetBSD: newwin.c,v 1.50 2017/01/06 13:53:18 roy Exp $"); 37__RCSID("$NetBSD: newwin.c,v 1.50.6.1 2018/10/04 10:20:12 martin 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
46 46
47static WINDOW *__makenew(SCREEN *screen, int nlines, int ncols, int by, 47static WINDOW *__makenew(SCREEN *screen, int nlines, int ncols, int by,
48 int bx, int sub, int ispad); 48 int bx, int sub, int ispad);
49static WINDOW *__subwin(WINDOW *orig, int nlines, int ncols, int by, int bx, 49static WINDOW *__subwin(WINDOW *orig, int nlines, int ncols, int by, int bx,
50 int ispad); 50 int ispad);
@@ -75,70 +75,78 @@ subpad(WINDOW *orig, int nlines, int nco @@ -75,70 +75,78 @@ subpad(WINDOW *orig, int nlines, int nco
75 TRUE); 75 TRUE);
76} 76}
77 77
78/* 78/*
79 * dupwin -- 79 * dupwin --
80 * Create a copy of the given window. 80 * Create a copy of the given window.
81 */ 81 */
82WINDOW * 82WINDOW *
83dupwin(WINDOW *win) 83dupwin(WINDOW *win)
84{ 84{
85 WINDOW *new_one; 85 WINDOW *new_one;
86 86
87 if ((new_one = __newwin(_cursesi_screen, win->maxy, win->maxx, 87 if ((new_one = __newwin(_cursesi_screen, win->maxy, win->maxx,
88 win->begy, win->begx, FALSE)) == NULL) 88 win->begy, win->begx, FALSE,
 89 win == stdscr ? TRUE : FALSE)) == NULL)
89 return NULL; 90 return NULL;
90 91
91 overwrite(win, new_one); 92 overwrite(win, new_one);
92 return new_one; 93 return new_one;
93} 94}
94 95
95/* 96/*
96 * newwin -- 97 * newwin --
97 * Allocate space for and set up defaults for a new window. 98 * Allocate space for and set up defaults for a new window.
98 */ 99 */
99WINDOW * 100WINDOW *
100newwin(int nlines, int ncols, int by, int bx) 101newwin(int nlines, int ncols, int by, int bx)
101{ 102{
102 103
103 return __newwin(_cursesi_screen, nlines, ncols, by, bx, FALSE); 104 return __newwin(_cursesi_screen, nlines, ncols, by, bx, FALSE, FALSE);
104} 105}
105 106
106/* 107/*
107 * newpad -- 108 * newpad --
108 * Allocate space for and set up defaults for a new pad. 109 * Allocate space for and set up defaults for a new pad.
109 */ 110 */
110WINDOW * 111WINDOW *
111newpad(int nlines, int ncols) 112newpad(int nlines, int ncols)
112{ 113{
113 114
114 if (nlines < 1 || ncols < 1) 115 if (nlines < 1 || ncols < 1)
115 return NULL; 116 return NULL;
116 return __newwin(_cursesi_screen, nlines, ncols, 0, 0, TRUE); 117 return __newwin(_cursesi_screen, nlines, ncols, 0, 0, TRUE, FALSE);
117} 118}
118 119
119WINDOW * 120WINDOW *
120__newwin(SCREEN *screen, int nlines, int ncols, int by, int bx, int ispad) 121__newwin(SCREEN *screen, int nlines, int ncols, int by, int bx, int ispad,
 122 int isstdscr)
121{ 123{
122 WINDOW *win; 124 WINDOW *win;
123 __LINE *lp; 125 __LINE *lp;
124 int i, j; 126 int i, j;
125 int maxy, maxx; 127 int ry, maxy, maxx;
126 __LDATA *sp; 128 __LDATA *sp;
127 129
128 if (by < 0 || bx < 0) 130 if (by < 0 || bx < 0)
129 return NULL; 131 return NULL;
130 132
131 maxy = nlines > 0 ? nlines : LINES - by + nlines; 133 if (isstdscr) {
 134 ry = __rippedlines(screen, -1);
 135 by += __rippedlines(screen, 1);
 136 } else
 137 ry = 0;
 138
 139 maxy = nlines > 0 ? nlines : LINES - by - ry + nlines;
132 maxx = ncols > 0 ? ncols : COLS - bx + ncols; 140 maxx = ncols > 0 ? ncols : COLS - bx + ncols;
133 141
134 if ((win = __makenew(screen, maxy, maxx, by, bx, 0, ispad)) == NULL) 142 if ((win = __makenew(screen, maxy, maxx, by, bx, 0, ispad)) == NULL)
135 return NULL; 143 return NULL;
136 144
137 win->bch = ' '; 145 win->bch = ' ';
138 if (__using_color) 146 if (__using_color)
139 win->battr = __default_color; 147 win->battr = __default_color;
140 else 148 else
141 win->battr = 0; 149 win->battr = 0;
142 win->nextp = win; 150 win->nextp = win;
143 win->ch_off = 0; 151 win->ch_off = 0;
144 win->orig = NULL; 152 win->orig = NULL;

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

--- src/lib/libcurses/resize.c 2018/10/03 17:49:06 1.26.4.1
+++ src/lib/libcurses/resize.c 2018/10/04 10:20:12 1.26.4.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: resize.c,v 1.26.4.1 2018/10/03 17:49:06 martin Exp $ */ 1/* $NetBSD: resize.c,v 1.26.4.2 2018/10/04 10:20:12 martin 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.26.4.1 2018/10/03 17:49:06 martin Exp $"); 43__RCSID("$NetBSD: resize.c,v 1.26.4.2 2018/10/04 10:20:12 martin 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 --
@@ -166,30 +166,27 @@ resizeterm(int nlines, int ncols) @@ -166,30 +166,27 @@ resizeterm(int nlines, int ncols)
166 /* Unconditionally inform application screen has been resized. */ 166 /* Unconditionally inform application screen has been resized. */
167 _cursesi_screen->resized = 1; 167 _cursesi_screen->resized = 1;
168 168
169 if (!is_term_resized(nlines, ncols)) 169 if (!is_term_resized(nlines, ncols))
170 return OK; 170 return OK;
171 171
172 result = resize_term(nlines, ncols); 172 result = resize_term(nlines, ncols);
173 173
174 /* Screen contents are unknown, libcurses is not libpanel, we don't 174 /* Screen contents are unknown, libcurses is not libpanel, we don't
175 * know the correct draw order. */ 175 * know the correct draw order. */
176 clearok(curscr, TRUE); 176 clearok(curscr, TRUE);
177 177
178 if (result == OK) { 178 if (result == OK) {
179 /* We know how to repaint the ripoffs */ 179 /* Redraw the soft label keys to the new size. */
180 __ripoffresize(_cursesi_screen); 
181 
182 /* We do need to reposition our slks. */ 
183 __slk_resize(_cursesi_screen, ncols); 180 __slk_resize(_cursesi_screen, ncols);
184 __slk_noutrefresh(_cursesi_screen); 181 __slk_noutrefresh(_cursesi_screen);
185 } 182 }
186 183
187 return result; 184 return result;
188} 185}
189 186
190/* 187/*
191 * resize_term -- 188 * resize_term --
192 * Resize the terminal window, resizing the dependent windows. 189 * Resize the terminal window, resizing the dependent windows.
193 */ 190 */
194int 191int
195resize_term(int nlines, int ncols) 192resize_term(int nlines, int ncols)
@@ -199,48 +196,47 @@ resize_term(int nlines, int ncols) @@ -199,48 +196,47 @@ resize_term(int nlines, int ncols)
199 int rlines; 196 int rlines;
200 197
201#ifdef DEBUG 198#ifdef DEBUG
202 __CTRACE(__CTRACE_WINDOW, "resize_term: (%d, %d)\n", nlines, ncols); 199 __CTRACE(__CTRACE_WINDOW, "resize_term: (%d, %d)\n", nlines, ncols);
203#endif 200#endif
204 201
205 if (!is_term_resized(nlines, ncols)) 202 if (!is_term_resized(nlines, ncols))
206 return OK; 203 return OK;
207 204
208 if (__resizeterm(curscr, nlines, ncols) == ERR) 205 if (__resizeterm(curscr, nlines, ncols) == ERR)
209 return ERR; 206 return ERR;
210 if (__resizeterm(__virtscr, nlines, ncols) == ERR) 207 if (__resizeterm(__virtscr, nlines, ncols) == ERR)
211 return ERR; 208 return ERR;
212 rlines = nlines - __rippedlines(_cursesi_screen); 209 rlines = nlines - __rippedlines(_cursesi_screen, 0);
213 if (__resizeterm(stdscr, rlines, ncols) == ERR) 210 if (__resizeterm(stdscr, rlines, ncols) == ERR)
214 return ERR; 211 return ERR;
215 212
216 _cursesi_screen->LINES = nlines; 213 _cursesi_screen->LINES = nlines;
217 _cursesi_screen->COLS = ncols; 214 _cursesi_screen->COLS = ncols;
218 LINES = rlines; 215 LINES = nlines;
219 COLS = ncols; 216 COLS = ncols;
220 217
221 if (_cursesi_screen->slk_window != NULL && 218 /* tweak the flags now that we have updated the LINES and COLS */
222 __resizewin(_cursesi_screen->slk_window, 
223 _cursesi_screen->slk_window->reqy, ncols) == ERR) 
224 return ERR; 
225 
226 /* tweak the flags now that we have updated the LINES and COLS */ 
227 for (list = _cursesi_screen->winlistp; list != NULL; list = list->nextp) { 219 for (list = _cursesi_screen->winlistp; list != NULL; list = list->nextp) {
228 win = list->winp; 220 win = list->winp;
229 221
230 if (!(win->flags & __ISPAD)) 222 if (!(win->flags & __ISPAD))
231 __swflags(win); 223 __swflags(win);
232 } 224 }
233 225
 226 /* Resize and re-position the ripped off windows. */
 227 if (__ripoffresize(_cursesi_screen) == ERR)
 228 return ERR;
 229
234 return OK; 230 return OK;
235} 231}
236 232
237/* 233/*
238 * __resizeterm 234 * __resizeterm
239 * Setup window for resizing. 235 * Setup window for resizing.
240 */ 236 */
241static int 237static int
242__resizeterm(WINDOW *win, int nlines, int ncols) 238__resizeterm(WINDOW *win, int nlines, int ncols)
243{ 239{
244 int newlines, newcols; 240 int newlines, newcols;
245 241
246 newlines = win->reqy; 242 newlines = win->reqy;

cvs diff -r1.3 -r1.3.6.1 src/lib/libcurses/ripoffline.c (expand / switch to unified diff)

--- src/lib/libcurses/ripoffline.c 2017/01/24 17:27:30 1.3
+++ src/lib/libcurses/ripoffline.c 2018/10/04 10:20:12 1.3.6.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ripoffline.c,v 1.3 2017/01/24 17:27:30 roy Exp $ */ 1/* $NetBSD: ripoffline.c,v 1.3.6.1 2018/10/04 10:20:12 martin Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2017 The NetBSD Foundation, Inc. 4 * Copyright (c) 2017 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Roy Marples. 8 * by Roy Marples.
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.
@@ -21,145 +21,169 @@ @@ -21,145 +21,169 @@
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34__RCSID("$NetBSD: ripoffline.c,v 1.3 2017/01/24 17:27:30 roy Exp $"); 34__RCSID("$NetBSD: ripoffline.c,v 1.3.6.1 2018/10/04 10:20:12 martin Exp $");
35#endif /* not lint */ 35#endif /* not lint */
36 36
37#include "curses.h" 37#include "curses.h"
38#include "curses_private.h" 38#include "curses_private.h"
39 39
40/* List of ripoffline calls */ 40/* List of ripoffline calls */
41static struct ripoff { 41static struct ripoff {
42 int nlines; 42 int nlines;
43 int (*init)(WINDOW *, int); 43 int (*init)(WINDOW *, int);
44} ripoffs[MAX_RIPS]; 44} ripoffs[MAX_RIPS];
45static int nrips; 45static int nrips;
46 46
47/* 47/*
48 * ripoffline -- 48 * ripoffline --
49 * Ripoff a line from the top of bottom of stdscr. 49 * Ripoff a line from the top of bottom of stdscr.
50 * Must be called before initscr or newterm. 50 * Must be called before initscr or newterm.
51 */ 51 */
52int 52int
53ripoffline(int line, int (*init)(WINDOW *, int)) 53ripoffline(int line, int (*init)(WINDOW *, int))
54{ 54{
55 55
56#ifdef DEBUG 56#ifdef DEBUG
57 __CTRACE(__CTRACE_SCREEN, "ripoffline: %d\n", line); 57 __CTRACE(__CTRACE_WINDOW, "ripoffline: %d\n", line);
58#endif 58#endif
59 59
60 if (nrips >= MAX_RIPS || init == NULL) 60 if (nrips >= MAX_RIPS || init == NULL)
61 return ERR; /* This makes sense, but not standards compliant. */ 61 return ERR; /* This makes sense, but not standards compliant. */
62 if (line == 0) 62 if (line == 0)
63 return OK; 63 return OK;
64 ripoffs[nrips].nlines = line < 0 ? -1 : 1; 64 ripoffs[nrips].nlines = line < 0 ? -1 : 1;
65 ripoffs[nrips++].init = init; 65 ripoffs[nrips++].init = init;
66 return OK; 66 return OK;
67} 67}
68 68
69/* 69/*
70 * __rippedlines -- 70 * __rippedlines --
71 * Returns the number of ripped lines from the screen. 71 * Returns the number of ripped lines from the screen.
72 */ 72 */
73int 73int
74__rippedlines(const SCREEN *screen) 74__rippedlines(const SCREEN *screen, int line)
75{ 75{
76 const struct __ripoff *rip; 76 const struct __ripoff *rip;
77 int i, n; 77 int i, n;
78 78
79 n = 0; 79 n = 0;
80 for (i = 0, rip = screen->ripped; i < screen->nripped; i++, rip++) { 80 for (i = 0, rip = screen->ripped; i < screen->nripped; i++, rip++) {
81 if (rip->nlines < 0) 81 if (line < 1 && rip->nlines < 0)
82 n += -rip->nlines; 82 n += -rip->nlines;
83 else 83 else if (line > 0 && rip->nlines > 0)
84 n += rip->nlines; 84 n += rip->nlines;
85 } 85 }
86 return n; 86 return n;
87} 87}
88 88
89/* 89/*
90 * __ripoffscreen -- 90 * __ripoffscreen --
91 * Rips lines from the screen by creating a WINDOW per ripoffline call. 91 * Rips lines from the screen by creating a WINDOW per ripoffline call.
92 * Although the POSIX API only allows for one line WINDOWS to be created, 92 * Although the POSIX API only allows for one line WINDOWS to be created,
93 * this implemenation allows for N lines if needed. 93 * this implemenation allows for N lines if needed.
94 */ 94 */
95int 95int
96__ripoffscreen(SCREEN *screen, int *rtop) 96__ripoffscreen(SCREEN *screen)
97{ 97{
98 int i, nlines; 98 int i, nlines, rbot, rtop;
99 const struct ripoff *srip; 99 const struct ripoff *srip;
100 struct __ripoff *rip; 100 struct __ripoff *rip;
101 WINDOW *w; 101 WINDOW *w;
102 102
103 *rtop = 0; 
104 rip = screen->ripped; 103 rip = screen->ripped;
 104 rbot = LINES;
 105 rtop = 0;
105 for (i = 0, srip = ripoffs; i < nrips; i++, srip++) { 106 for (i = 0, srip = ripoffs; i < nrips; i++, srip++) {
106 if (srip->nlines == 0) 107 if (srip->nlines == 0)
107 continue; 108 continue;
108 nlines = srip->nlines < 0 ? -srip->nlines : srip->nlines; 109 nlines = srip->nlines < 0 ? -srip->nlines : srip->nlines;
109 w = __newwin(screen, nlines, 0, 110 w = __newwin(screen, nlines, 0,
110 srip->nlines < 0 ? LINES - nlines : *rtop, 111 srip->nlines < 0 ? rbot - nlines : rtop,
111 0, FALSE); 112 0, FALSE, FALSE);
112 if (w != NULL) { 113 if (w != NULL) {
113 rip->win = w; 114 rip->win = w;
114 rip->nlines = srip->nlines; 115 rip->nlines = srip->nlines;
115 rip++; 116 rip++;
116 screen->nripped++; 117 screen->nripped++;
117 if (rip->nlines > 0) 118 if (srip->nlines > 0)
118 (*rtop) += rip->nlines; 119 rtop += nlines;
119 LINES -= nlines; 120 else
 121 rbot -= nlines;
120 } 122 }
121 if (srip->init(w, COLS) == ERR) 123 if (srip->init(w, COLS) == ERR)
122 return ERR; 124 return ERR;
123#ifdef DEBUG 125#ifdef DEBUG
124 if (w != NULL) 126 if (w != NULL)
125 __CTRACE(__CTRACE_SCREEN, 127 __CTRACE(__CTRACE_WINDOW,
126 "newterm: ripped %d lines from the %s\n", 128 "newterm: %p ripped %d line(s) from the %s\n",
127 nlines, srip->nlines < 0 ? "bottom" : "top"); 129 w, nlines, srip->nlines < 0 ? "bottom" : "top");
128#endif 130#endif
129 } 131 }
130 nrips = 0; /* Reset the stack. */ 132 nrips = 0; /* Reset the stack. */
131 return OK; 133 return OK;
132} 134}
133 135
134/* 136/*
135 * __ripoffresize -- 137 * __ripoffresize --
136 * Called from resizeterm to ensure the ripped off lines are correctly 138 * Called from resizeterm to ensure the ripped off lines are correctly
137 * placed and refreshed. 139 * placed and refreshed.
138 */ 140 */
139void 141int
140__ripoffresize(SCREEN *screen) 142__ripoffresize(SCREEN *screen)
141{ 143{
142 int rbot = screen->LINES, i; 144 int rbot = screen->LINES, i, nlines, ret = OK;
143 struct __ripoff *rip; 145 struct __ripoff *rip;
144 146
145 for (i = 0, rip = screen->ripped; i < screen->nripped; i++, rip++) { 147 for (i = 0, rip = screen->ripped; i < screen->nripped; i++, rip++) {
146 if (rip->nlines > 0) 148 if (rip->nlines == 0)
147 touchwin(rip->win); 149 continue;
148 else { 150 nlines = rip->nlines < 0 ? -rip->nlines : rip->nlines;
 151 if (wresize(rip->win, nlines, screen->COLS) == ERR)
 152 ret = ERR;
 153 if (rip->nlines < 0) {
149 /* Reposition the lower windows. */ 154 /* Reposition the lower windows. */
150 mvwin(rip->win, rbot + rip->nlines, 0); 155 if (mvwin(rip->win, rbot + rip->nlines, 0) == ERR)
151 rbot += rip->nlines; 156 ret = ERR;
 157 else
 158 rbot += rip->nlines;
152 } 159 }
 160 }
 161
 162 return ret;
 163}
 164
 165/*
 166 * __ripofftouch --
 167 * Displays the ripped off lines from initscr.
 168 */
 169void
 170__ripofftouch(SCREEN *screen)
 171{
 172 int i;
 173 struct __ripoff *rip;
 174
 175 for (i = 0, rip = screen->ripped; i < screen->nripped; i++, rip++) {
 176 touchwin(rip->win);
153 wnoutrefresh(rip->win); 177 wnoutrefresh(rip->win);
154 } 178 }
155} 179}
156 180
157/* 181/*
158 * __unripoffline -- 182 * __unripoffline --
159 * Used by __slk_init to remove the ripoffline reservation it made 183 * Used by __slk_init to remove the ripoffline reservation it made
160 * because the terminal natively supports soft label keys. 184 * because the terminal natively supports soft label keys.
161 */ 185 */
162int 186int
163__unripoffline(int (*init)(WINDOW *, int)) 187__unripoffline(int (*init)(WINDOW *, int))
164{ 188{
165 struct ripoff *rip; 189 struct ripoff *rip;

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

--- src/lib/libcurses/screen.c 2017/03/20 10:20:16 1.33
+++ src/lib/libcurses/screen.c 2018/10/04 10:20:12 1.33.4.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: screen.c,v 1.33 2017/03/20 10:20:16 roy Exp $ */ 1/* $NetBSD: screen.c,v 1.33.4.1 2018/10/04 10:20:12 martin 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[] = "@(#)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.33 2017/03/20 10:20:16 roy Exp $"); 37__RCSID("$NetBSD: screen.c,v 1.33.4.1 2018/10/04 10:20:12 martin 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
48static void __delscreen(SCREEN *); 48static void __delscreen(SCREEN *);
49 49
50/* 50/*
@@ -64,44 +64,44 @@ filter(void) @@ -64,44 +64,44 @@ filter(void)
64 */ 64 */
65SCREEN * 65SCREEN *
66set_term(SCREEN *new) 66set_term(SCREEN *new)
67{ 67{
68 SCREEN *old_screen = _cursesi_screen; 68 SCREEN *old_screen = _cursesi_screen;
69 69
70 if (_cursesi_screen != NULL) { 70 if (_cursesi_screen != NULL) {
71 /* save changes made to the current screen... */ 71 /* save changes made to the current screen... */
72 old_screen->echoit = __echoit; 72 old_screen->echoit = __echoit;
73 old_screen->pfast = __pfast; 73 old_screen->pfast = __pfast;
74 old_screen->rawmode = __rawmode; 74 old_screen->rawmode = __rawmode;
75 old_screen->noqch = __noqch; 75 old_screen->noqch = __noqch;
76 old_screen->COLS = COLS; 76 old_screen->COLS = COLS;
77 old_screen->LINES = LINES + __rippedlines(old_screen); 77 old_screen->LINES = LINES;
78 old_screen->ESCDELAY = ESCDELAY; 78 old_screen->ESCDELAY = ESCDELAY;
79 old_screen->TABSIZE = TABSIZE; 79 old_screen->TABSIZE = TABSIZE;
80 old_screen->COLORS = COLORS; 80 old_screen->COLORS = COLORS;
81 old_screen->COLOR_PAIRS = COLOR_PAIRS; 81 old_screen->COLOR_PAIRS = COLOR_PAIRS;
82 old_screen->GT = __GT; 82 old_screen->GT = __GT;
83 old_screen->NONL = __NONL; 83 old_screen->NONL = __NONL;
84 old_screen->UPPERCASE = __UPPERCASE; 84 old_screen->UPPERCASE = __UPPERCASE;
85 } 85 }
86 86
87 _cursesi_screen = new; 87 _cursesi_screen = new;
88 88
89 __echoit = new->echoit; 89 __echoit = new->echoit;
90 __pfast = new->pfast; 90 __pfast = new->pfast;
91 __rawmode = new->rawmode; 91 __rawmode = new->rawmode;
92 __noqch = new->noqch; 92 __noqch = new->noqch;
93 COLS = new->COLS; 93 COLS = new->COLS;
94 LINES = new->LINES - __rippedlines(new); 94 LINES = new->LINES;
95 ESCDELAY = new->ESCDELAY; 95 ESCDELAY = new->ESCDELAY;
96 TABSIZE = new->TABSIZE; 96 TABSIZE = new->TABSIZE;
97 COLORS = new->COLORS; 97 COLORS = new->COLORS;
98 COLOR_PAIRS = new->COLOR_PAIRS; 98 COLOR_PAIRS = new->COLOR_PAIRS;
99 __GT = new->GT; 99 __GT = new->GT;
100 __NONL = new->NONL; 100 __NONL = new->NONL;
101 __UPPERCASE = new->UPPERCASE; 101 __UPPERCASE = new->UPPERCASE;
102 102
103 _cursesi_resetterm(new); 103 _cursesi_resetterm(new);
104 104
105 curscr = new->curscr; 105 curscr = new->curscr;
106 clearok(curscr, new->clearok); 106 clearok(curscr, new->clearok);
107 stdscr = new->stdscr; 107 stdscr = new->stdscr;
@@ -120,27 +120,26 @@ set_term(SCREEN *new) @@ -120,27 +120,26 @@ set_term(SCREEN *new)
120 return old_screen; 120 return old_screen;
121} 121}
122 122
123/* 123/*
124 * newterm -- 124 * newterm --
125 * Set up a new screen. 125 * Set up a new screen.
126 * 126 *
127 */ 127 */
128SCREEN * 128SCREEN *
129newterm(char *type, FILE *outfd, FILE *infd) 129newterm(char *type, FILE *outfd, FILE *infd)
130{ 130{
131 SCREEN *new_screen; 131 SCREEN *new_screen;
132 char *sp; 132 char *sp;
133 int rtop; 
134 133
135 sp = type; 134 sp = type;
136 if (type == NULL && (sp = getenv("TERM")) == NULL) 135 if (type == NULL && (sp = getenv("TERM")) == NULL)
137 return NULL; 136 return NULL;
138 137
139 if ((new_screen = calloc(1, sizeof(SCREEN))) == NULL) 138 if ((new_screen = calloc(1, sizeof(SCREEN))) == NULL)
140 return NULL; 139 return NULL;
141 140
142#ifdef DEBUG 141#ifdef DEBUG
143 __CTRACE(__CTRACE_INIT, "newterm\n"); 142 __CTRACE(__CTRACE_INIT, "newterm\n");
144#endif 143#endif
145 144
146 new_screen->infd = infd; 145 new_screen->infd = infd;
@@ -183,41 +182,41 @@ newterm(char *type, FILE *outfd, FILE *i @@ -183,41 +182,41 @@ newterm(char *type, FILE *outfd, FILE *i
183 goto error_exit; 182 goto error_exit;
184 183
185 if (_cursesi_setterm((char *)sp, new_screen) == ERR) 184 if (_cursesi_setterm((char *)sp, new_screen) == ERR)
186 goto error_exit; 185 goto error_exit;
187 186
188 /* Need either homing or cursor motion for refreshes */ 187 /* Need either homing or cursor motion for refreshes */
189 if (!t_cursor_home(new_screen->term) && 188 if (!t_cursor_home(new_screen->term) &&
190 !t_cursor_address(new_screen->term)) 189 !t_cursor_address(new_screen->term))
191 goto error_exit; 190 goto error_exit;
192 191
193 new_screen->winlistp = NULL; 192 new_screen->winlistp = NULL;
194 193
195 if ((new_screen->curscr = __newwin(new_screen, 0, 194 if ((new_screen->curscr = __newwin(new_screen, 0,
196 0, 0, 0, FALSE)) == NULL) 195 0, 0, 0, FALSE, FALSE)) == NULL)
197 goto error_exit; 196 goto error_exit;
198 197
199 if ((new_screen->__virtscr = __newwin(new_screen, 0, 198 if ((new_screen->__virtscr = __newwin(new_screen, 0,
200 0, 0, 0, FALSE)) == NULL) 199 0, 0, 0, FALSE, FALSE)) == NULL)
201 goto error_exit; 200 goto error_exit;
202 201
203 /* If Soft Label Keys are setup, they will ripoffline. */ 202 /* If Soft Label Keys are setup, they will ripoffline. */
204 if (__slk_init(new_screen) == ERR) 203 if (__slk_init(new_screen) == ERR)
205 goto error_exit; 204 goto error_exit;
206 205
207 if (__ripoffscreen(new_screen, &rtop) == ERR) 206 if (__ripoffscreen(new_screen) == ERR)
208 goto error_exit; 207 goto error_exit;
209 208
210 new_screen->stdscr = __newwin(new_screen, LINES, 0, rtop, 0, FALSE); 209 new_screen->stdscr = __newwin(new_screen, 0, 0, 0, 0, FALSE, TRUE);
211 if (new_screen->stdscr == NULL) 210 if (new_screen->stdscr == NULL)
212 goto error_exit; 211 goto error_exit;
213 212
214 clearok(new_screen->stdscr, 1); 213 clearok(new_screen->stdscr, 1);
215 214
216 __init_getch(new_screen); 215 __init_getch(new_screen);
217 __init_acs(new_screen); 216 __init_acs(new_screen);
218#ifdef HAVE_WCHAR 217#ifdef HAVE_WCHAR
219 __init_get_wch(new_screen); 218 __init_get_wch(new_screen);
220 __init_wacs(new_screen); 219 __init_wacs(new_screen);
221#endif /* HAVE_WCHAR */ 220#endif /* HAVE_WCHAR */
222 221
223 __set_stophandler(); 222 __set_stophandler();

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

--- src/lib/libcurses/setterm.c 2017/03/23 00:55:39 1.66
+++ src/lib/libcurses/setterm.c 2018/10/04 10:20:12 1.66.4.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: setterm.c,v 1.66 2017/03/23 00:55:39 roy Exp $ */ 1/* $NetBSD: setterm.c,v 1.66.4.1 2018/10/04 10:20:12 martin 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.66 2017/03/23 00:55:39 roy Exp $"); 37__RCSID("$NetBSD: setterm.c,v 1.66.4.1 2018/10/04 10:20:12 martin Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <stdlib.h> 41#include <stdlib.h>
42#include <string.h> 42#include <string.h>
43#include <termios.h> 43#include <termios.h>
44#include <unistd.h> 44#include <unistd.h>
45 45
46#include "curses.h" 46#include "curses.h"
47#include "curses_private.h" 47#include "curses_private.h"
48 48
49static int does_esc_m(const char *cap); 49static int does_esc_m(const char *cap);
50static int does_ctrl_o(const char *exit_cap, const char *acs_cap); 50static int does_ctrl_o(const char *exit_cap, const char *acs_cap);
@@ -112,27 +112,27 @@ _cursesi_setterm(char *type, SCREEN *scr @@ -112,27 +112,27 @@ _cursesi_setterm(char *type, SCREEN *scr
112 screen->ESCDELAY = ESCDELAY_DEFAULT; 112 screen->ESCDELAY = ESCDELAY_DEFAULT;
113 if ((p = getenv("TABSIZE")) != NULL) 113 if ((p = getenv("TABSIZE")) != NULL)
114 screen->TABSIZE = (int)strtol(p, NULL, 0); 114 screen->TABSIZE = (int)strtol(p, NULL, 0);
115 else if (t_init_tabs(screen->term) >= 0) 115 else if (t_init_tabs(screen->term) >= 0)
116 screen->TABSIZE = (int)t_init_tabs(screen->term); 116 screen->TABSIZE = (int)t_init_tabs(screen->term);
117 else 117 else
118 screen->TABSIZE = TABSIZE_DEFAULT; 118 screen->TABSIZE = TABSIZE_DEFAULT;
119 /* 119 /*
120 * Want cols > 4, otherwise things will fail. 120 * Want cols > 4, otherwise things will fail.
121 */ 121 */
122 if (screen->COLS <= 4) 122 if (screen->COLS <= 4)
123 return ERR; 123 return ERR;
124 124
125 LINES = screen->LINES - __rippedlines(screen); 125 LINES = screen->LINES;
126 COLS = screen->COLS; 126 COLS = screen->COLS;
127 ESCDELAY = screen->ESCDELAY; 127 ESCDELAY = screen->ESCDELAY;
128 TABSIZE = screen->TABSIZE; 128 TABSIZE = screen->TABSIZE;
129 129
130#ifdef DEBUG 130#ifdef DEBUG
131 __CTRACE(__CTRACE_INIT, 131 __CTRACE(__CTRACE_INIT,
132 "setterm: LINES = %d, COLS = %d, TABSIZE = %d\n", 132 "setterm: LINES = %d, COLS = %d, TABSIZE = %d\n",
133 LINES, COLS, TABSIZE); 133 LINES, COLS, TABSIZE);
134#endif 134#endif
135 135
136 /* 136 /*
137 * set the pad char, only take the first char of the pc capability 137 * set the pad char, only take the first char of the pc capability
138 * as this is all we can use. 138 * as this is all we can use.
@@ -238,27 +238,27 @@ _cursesi_setterm(char *type, SCREEN *scr @@ -238,27 +238,27 @@ _cursesi_setterm(char *type, SCREEN *scr
238 238
239 return unknown ? ERR : OK; 239 return unknown ? ERR : OK;
240} 240}
241 241
242/* 242/*
243 * _cursesi_resetterm -- 243 * _cursesi_resetterm --
244 * Copy the terminal instance data for the given screen to the global 244 * Copy the terminal instance data for the given screen to the global
245 * variables. 245 * variables.
246 */ 246 */
247void 247void
248_cursesi_resetterm(SCREEN *screen) 248_cursesi_resetterm(SCREEN *screen)
249{ 249{
250 250
251 LINES = screen->LINES - __rippedlines(screen); 251 LINES = screen->LINES;
252 COLS = screen->COLS; 252 COLS = screen->COLS;
253 ESCDELAY = screen->ESCDELAY; 253 ESCDELAY = screen->ESCDELAY;
254 TABSIZE = screen->TABSIZE; 254 TABSIZE = screen->TABSIZE;
255 __GT = screen->GT; 255 __GT = screen->GT;
256 256
257 __noqch = screen->noqch; 257 __noqch = screen->noqch;
258 __mask_op = screen->mask_op; 258 __mask_op = screen->mask_op;
259 __mask_me = screen->mask_me; 259 __mask_me = screen->mask_me;
260 __mask_ue = screen->mask_ue; 260 __mask_ue = screen->mask_ue;
261 __mask_se = screen->mask_se; 261 __mask_se = screen->mask_se;
262 262
263 set_curterm(screen->term); 263 set_curterm(screen->term);
264} 264}