Source-Changes-HG archive

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

[src/trunk]: src/lib/libcurses curses: resize ripped off windows



details:   https://anonhg.NetBSD.org/src/rev/3273a071db7d
branches:  trunk
changeset: 836213:3273a071db7d
user:      roy <roy%NetBSD.org@localhost>
date:      Wed Oct 03 13:22:29 2018 +0000

description:
curses: resize ripped off windows

The application must still redraw them though.

diffstat:

 lib/libcurses/curses_private.h |   4 ++--
 lib/libcurses/resize.c         |  20 ++++++++------------
 lib/libcurses/ripoffline.c     |  26 ++++++++++++++++----------
 3 files changed, 26 insertions(+), 24 deletions(-)

diffs (128 lines):

diff -r 40fed249bee9 -r 3273a071db7d lib/libcurses/curses_private.h
--- a/lib/libcurses/curses_private.h    Wed Oct 03 10:02:08 2018 +0000
+++ b/lib/libcurses/curses_private.h    Wed Oct 03 13:22:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: curses_private.h,v 1.64 2018/10/02 17:35:44 roy Exp $  */
+/*     $NetBSD: curses_private.h,v 1.65 2018/10/03 13:22:29 roy Exp $  */
 
 /*-
  * Copyright (c) 1998-2000 Brett Lymn
@@ -379,7 +379,7 @@
 void    __restore_stophandler(void);
 void    __restore_winchhandler(void);
 int     __ripoffscreen(SCREEN *);
-void    __ripoffresize(SCREEN *);
+int     __ripoffresize(SCREEN *);
 void    __ripofftouch(SCREEN *);
 int     __rippedlines(const SCREEN *, int);
 void    __save_termios(void);
diff -r 40fed249bee9 -r 3273a071db7d lib/libcurses/resize.c
--- a/lib/libcurses/resize.c    Wed Oct 03 10:02:08 2018 +0000
+++ b/lib/libcurses/resize.c    Wed Oct 03 13:22:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: resize.c,v 1.28 2018/10/02 17:35:44 roy Exp $  */
+/*     $NetBSD: resize.c,v 1.29 2018/10/03 13:22:29 roy 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.28 2018/10/02 17:35:44 roy Exp $");
+__RCSID("$NetBSD: resize.c,v 1.29 2018/10/03 13:22:29 roy 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);
        }
@@ -218,12 +215,7 @@
        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 40fed249bee9 -r 3273a071db7d lib/libcurses/ripoffline.c
--- a/lib/libcurses/ripoffline.c        Wed Oct 03 10:02:08 2018 +0000
+++ b/lib/libcurses/ripoffline.c        Wed Oct 03 13:22:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ripoffline.c,v 1.4 2018/10/02 17:35:44 roy Exp $       */
+/*     $NetBSD: ripoffline.c,v 1.5 2018/10/03 13:22:29 roy Exp $       */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ripoffline.c,v 1.4 2018/10/02 17:35:44 roy Exp $");
+__RCSID("$NetBSD: ripoffline.c,v 1.5 2018/10/03 13:22:29 roy Exp $");
 #endif                         /* not lint */
 
 #include "curses.h"
@@ -138,22 +138,28 @@
  *     Called from resizeterm to ensure the ripped off lines are correctly
  *     placed and refreshed.
  */
-void
+int
 __ripoffresize(SCREEN *screen)
 {
-       int rbot = screen->LINES, i;
+       int rbot = screen->LINES, i, nlines, ret = OK;
        struct __ripoff *rip;
 
        for (i = 0, rip = screen->ripped; i < screen->nripped; i++, rip++) {
-               if (rip->nlines > 0)
-                       touchwin(rip->win);
-               else {
+               if (rip->nlines == 0)
+                       continue;
+               nlines = rip->nlines < 0 ? -rip->nlines : rip->nlines;
+               if (wresize(rip->win, nlines, screen->COLS) == ERR)
+                       ret = ERR;
+               if (rip->nlines < 0) {
                        /* Reposition the lower windows. */
-                       mvwin(rip->win, rbot + rip->nlines, 0);
-                       rbot += rip->nlines;
+                       if (mvwin(rip->win, rbot + rip->nlines, 0) == ERR)
+                               ret = ERR;
+                       else
+                               rbot += rip->nlines;
                }
-               wnoutrefresh(rip->win);
        }
+
+       return ret;
 }
 
 /*



Home | Main Index | Thread Index | Old Index