Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src/lib/libcurses Pull up following revision(s) (requested by...



details:   https://anonhg.NetBSD.org/src/rev/e295414c9dbf
branches:  netbsd-8
changeset: 435291:e295414c9dbf
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Oct 04 10:20:12 2018 +0000

description:
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

diffstat:

 lib/libcurses/curses_private.h |  11 +++--
 lib/libcurses/curses_screen.3  |  10 ++---
 lib/libcurses/fileio.c         |   6 +-
 lib/libcurses/initscr.c        |   5 +-
 lib/libcurses/newwin.c         |  24 +++++++++----
 lib/libcurses/resize.c         |  24 +++++--------
 lib/libcurses/ripoffline.c     |  72 ++++++++++++++++++++++++++++--------------
 lib/libcurses/screen.c         |  17 ++++-----
 lib/libcurses/setterm.c        |   8 ++--
 9 files changed, 102 insertions(+), 75 deletions(-)

diffs (truncated from 522 to 300 lines):

diff -r 642e99e34b88 -r e295414c9dbf lib/libcurses/curses_private.h
--- a/lib/libcurses/curses_private.h    Wed Oct 03 18:08:28 2018 +0000
+++ b/lib/libcurses/curses_private.h    Thu Oct 04 10:20:12 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: curses_private.h,v 1.62.4.1 2018/09/27 15:12:15 martin Exp $   */
+/*     $NetBSD: curses_private.h,v 1.62.4.2 2018/10/04 10:20:12 martin Exp $   */
 
 /*-
  * Copyright (c) 1998-2000 Brett Lymn
@@ -368,7 +368,7 @@
 int     __fgetc_resize(FILE *);
 int     __unget(wint_t);
 int     __mvcur(int, int, int, int, int);
-WINDOW  *__newwin(SCREEN *, int, int, int, int, int);
+WINDOW  *__newwin(SCREEN *, int, int, int, int, int, int);
 int     __nodelay(void);
 int     __notimeout(void);
 void    __restartwin(void);
@@ -378,9 +378,10 @@
 void    __restore_termios(void);
 void    __restore_stophandler(void);
 void    __restore_winchhandler(void);
-int     __ripoffscreen(SCREEN *, int *);
-void    __ripoffresize(SCREEN *);
-int     __rippedlines(const SCREEN *);
+int     __ripoffscreen(SCREEN *);
+int     __ripoffresize(SCREEN *);
+void    __ripofftouch(SCREEN *);
+int     __rippedlines(const SCREEN *, int);
 void    __save_termios(void);
 void    __set_color(WINDOW *win, attr_t attr);
 void    __set_stophandler(void);
diff -r 642e99e34b88 -r e295414c9dbf lib/libcurses/curses_screen.3
--- a/lib/libcurses/curses_screen.3     Wed Oct 03 18:08:28 2018 +0000
+++ b/lib/libcurses/curses_screen.3     Thu Oct 04 10:20:12 2018 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: curses_screen.3,v 1.23 2017/01/24 16:45:41 roy Exp $
+.\"    $NetBSD: curses_screen.3,v 1.23.4.1 2018/10/04 10:20:12 martin Exp $
 .\"
 .\" Copyright (c) 2002
 .\"    Brett Lymn (blymn%NetBSD.org@localhost, brett_lymn%yahoo.com.au@localhost)
@@ -30,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"
-.Dd January 24, 2017
+.Dd October 2, 2018
 .Dt CURSES_SCREEN 3
 .Os
 .Sh NAME
@@ -74,7 +74,7 @@
 .Fn isendwin "void"
 .Ft bool
 .Fn is_term_resized "int lines" "int cols"
-.Fn int
+.Ft int
 .Fn resize_term "int lines" "int cols"
 .Ft int
 .Fn resizeterm "int lines" "int cols"
@@ -216,7 +216,7 @@
 .Pp
 The
 .Fn ripoffline
-funcion will rip a line from
+function will rip a line from
 .Dv stdscr
 at the top if
 .Fa line
@@ -239,8 +239,6 @@
 .Xr doupdate 3 ,
 but may call
 .Xr wnoutrefresh 3 .
-.Dv LINES
-will be reduced by the total number of lines ripped off.
 .Fn ripoffline
 can be called up to five times.
 .Pp
diff -r 642e99e34b88 -r e295414c9dbf lib/libcurses/fileio.c
--- a/lib/libcurses/fileio.c    Wed Oct 03 18:08:28 2018 +0000
+++ b/lib/libcurses/fileio.c    Thu Oct 04 10:20:12 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fileio.c,v 1.5 2016/10/22 21:55:06 christos Exp $      */
+/*     $NetBSD: fileio.c,v 1.5.6.1 2018/10/04 10:20:12 martin Exp $    */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: fileio.c,v 1.5 2016/10/22 21:55:06 christos Exp $");
+__RCSID("$NetBSD: fileio.c,v 1.5.6.1 2018/10/04 10:20:12 martin Exp $");
 #endif                         /* not lint */
 
 #include "curses.h"
@@ -195,7 +195,7 @@
        if (fread(wtmp, sizeof(WINDOW), 1, fp) != 1)
                goto error0;
        win = __newwin(_cursesi_screen, wtmp->maxy, wtmp->maxx,
-           wtmp->begy, wtmp->begx, FALSE);
+           wtmp->begy, wtmp->begx, FALSE, FALSE);
        if (win == NULL)
                goto error0;
        win->cury = wtmp->cury;
diff -r 642e99e34b88 -r e295414c9dbf lib/libcurses/initscr.c
--- a/lib/libcurses/initscr.c   Wed Oct 03 18:08:28 2018 +0000
+++ b/lib/libcurses/initscr.c   Thu Oct 04 10:20:12 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: initscr.c,v 1.32 2017/01/11 17:15:27 roy Exp $ */
+/*     $NetBSD: initscr.c,v 1.32.6.1 2018/10/04 10:20:12 martin Exp $  */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)initscr.c  8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: initscr.c,v 1.32 2017/01/11 17:15:27 roy Exp $");
+__RCSID("$NetBSD: initscr.c,v 1.32.6.1 2018/10/04 10:20:12 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -70,6 +70,7 @@
 
        set_term(_cursesi_screen);
        wrefresh(curscr);
+       __ripofftouch(_cursesi_screen);
 
        return stdscr;
 }
diff -r 642e99e34b88 -r e295414c9dbf lib/libcurses/newwin.c
--- a/lib/libcurses/newwin.c    Wed Oct 03 18:08:28 2018 +0000
+++ b/lib/libcurses/newwin.c    Thu Oct 04 10:20:12 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: newwin.c,v 1.50 2017/01/06 13:53:18 roy Exp $  */
+/*     $NetBSD: newwin.c,v 1.50.6.1 2018/10/04 10:20:12 martin Exp $   */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)newwin.c   8.3 (Berkeley) 7/27/94";
 #else
-__RCSID("$NetBSD: newwin.c,v 1.50 2017/01/06 13:53:18 roy Exp $");
+__RCSID("$NetBSD: newwin.c,v 1.50.6.1 2018/10/04 10:20:12 martin Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -85,7 +85,8 @@
        WINDOW *new_one;
 
        if ((new_one = __newwin(_cursesi_screen, win->maxy, win->maxx,
-                               win->begy, win->begx, FALSE)) == NULL)
+                               win->begy, win->begx, FALSE,
+                               win == stdscr ? TRUE : FALSE)) == NULL)
                return NULL;
 
        overwrite(win, new_one);
@@ -100,7 +101,7 @@
 newwin(int nlines, int ncols, int by, int bx)
 {
 
-       return __newwin(_cursesi_screen, nlines, ncols, by, bx, FALSE);
+       return __newwin(_cursesi_screen, nlines, ncols, by, bx, FALSE, FALSE);
 }
 
 /*
@@ -113,22 +114,29 @@
 
        if (nlines < 1 || ncols < 1)
                return NULL;
-       return __newwin(_cursesi_screen, nlines, ncols, 0, 0, TRUE);
+       return __newwin(_cursesi_screen, nlines, ncols, 0, 0, TRUE, FALSE);
 }
 
 WINDOW *
-__newwin(SCREEN *screen, int nlines, int ncols, int by, int bx, int ispad)
+__newwin(SCREEN *screen, int nlines, int ncols, int by, int bx, int ispad,
+    int isstdscr)
 {
        WINDOW *win;
        __LINE *lp;
        int     i, j;
-       int     maxy, maxx;
+       int     ry, maxy, maxx;
        __LDATA *sp;
 
        if (by < 0 || bx < 0)
                return NULL;
 
-       maxy = nlines > 0 ? nlines : LINES - by + nlines;
+       if (isstdscr) {
+               ry = __rippedlines(screen, -1);
+               by += __rippedlines(screen, 1);
+       } else
+               ry = 0;
+
+       maxy = nlines > 0 ? nlines : LINES - by - ry + nlines;
        maxx = ncols > 0 ? ncols : COLS - bx + ncols;
 
        if ((win = __makenew(screen, maxy, maxx, by, bx, 0, ispad)) == NULL)
diff -r 642e99e34b88 -r e295414c9dbf lib/libcurses/resize.c
--- a/lib/libcurses/resize.c    Wed Oct 03 18:08:28 2018 +0000
+++ b/lib/libcurses/resize.c    Thu Oct 04 10:20:12 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: resize.c,v 1.26.4.1 2018/10/03 17:49:06 martin Exp $   */
+/*     $NetBSD: resize.c,v 1.26.4.2 2018/10/04 10:20:12 martin Exp $   */
 
 /*
  * Copyright (c) 2001
@@ -40,7 +40,7 @@
 #if 0
 static char sccsid[] = "@(#)resize.c   blymn 2001/08/26";
 #else
-__RCSID("$NetBSD: resize.c,v 1.26.4.1 2018/10/03 17:49:06 martin Exp $");
+__RCSID("$NetBSD: resize.c,v 1.26.4.2 2018/10/04 10:20:12 martin Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -176,10 +176,7 @@
        clearok(curscr, TRUE);
 
        if (result == OK) {
-               /* We know how to repaint the ripoffs */
-               __ripoffresize(_cursesi_screen);
-
-               /* We do need to reposition our slks. */
+               /* Redraw the soft label keys to the new size. */
                __slk_resize(_cursesi_screen, ncols);
                __slk_noutrefresh(_cursesi_screen);
        }
@@ -209,21 +206,16 @@
                return ERR;
        if (__resizeterm(__virtscr, nlines, ncols) == ERR)
                return ERR;
-       rlines = nlines - __rippedlines(_cursesi_screen);
+       rlines = nlines - __rippedlines(_cursesi_screen, 0);
        if (__resizeterm(stdscr, rlines, ncols) == ERR)
                return ERR;
 
        _cursesi_screen->LINES = nlines;
        _cursesi_screen->COLS = ncols;
-       LINES = rlines;
+       LINES = nlines;
        COLS = ncols;
 
-       if (_cursesi_screen->slk_window != NULL &&
-           __resizewin(_cursesi_screen->slk_window,
-                       _cursesi_screen->slk_window->reqy, ncols) == ERR)
-               return ERR;
-
-         /* tweak the flags now that we have updated the LINES and COLS */
+       /* tweak the flags now that we have updated the LINES and COLS */
        for (list = _cursesi_screen->winlistp; list != NULL; list = list->nextp) {
                win = list->winp;
 
@@ -231,6 +223,10 @@
                        __swflags(win);
        }
 
+       /* Resize and re-position the ripped off windows. */
+       if (__ripoffresize(_cursesi_screen) == ERR)
+               return ERR;
+
        return OK;
 }
 
diff -r 642e99e34b88 -r e295414c9dbf lib/libcurses/ripoffline.c
--- a/lib/libcurses/ripoffline.c        Wed Oct 03 18:08:28 2018 +0000
+++ b/lib/libcurses/ripoffline.c        Thu Oct 04 10:20:12 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ripoffline.c,v 1.3 2017/01/24 17:27:30 roy Exp $       */
+/*     $NetBSD: ripoffline.c,v 1.3.6.1 2018/10/04 10:20:12 martin Exp $        */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ripoffline.c,v 1.3 2017/01/24 17:27:30 roy Exp $");
+__RCSID("$NetBSD: ripoffline.c,v 1.3.6.1 2018/10/04 10:20:12 martin Exp $");
 #endif                         /* not lint */
 
 #include "curses.h"
@@ -54,7 +54,7 @@
 {
 
 #ifdef DEBUG
-       __CTRACE(__CTRACE_SCREEN, "ripoffline: %d\n", line);
+       __CTRACE(__CTRACE_WINDOW, "ripoffline: %d\n", line);
 #endif
 
        if (nrips >= MAX_RIPS || init == NULL)
@@ -71,16 +71,16 @@
  *     Returns the number of ripped lines from the screen.
  */
 int
-__rippedlines(const SCREEN *screen)
+__rippedlines(const SCREEN *screen, int line)



Home | Main Index | Thread Index | Old Index