Source-Changes-HG archive

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

[src/trunk]: src/lib/libcurses Back out incorrect fix for PR 53617 and fix it...



details:   https://anonhg.NetBSD.org/src/rev/a3fff95209aa
branches:  trunk
changeset: 999129:a3fff95209aa
user:      blymn <blymn%NetBSD.org@localhost>
date:      Mon May 20 22:17:41 2019 +0000

description:
Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly.  Doing this prevents unnecessary refreshes.

diffstat:

 lib/libcurses/add_wch.c        |  11 ++++++-----
 lib/libcurses/add_wchstr.c     |   6 +++---
 lib/libcurses/addbytes.c       |  20 +++++++++++++-------
 lib/libcurses/addch.c          |   6 +++---
 lib/libcurses/addchnstr.c      |   8 ++++----
 lib/libcurses/addnstr.c        |   6 +++---
 lib/libcurses/addwstr.c        |   6 +++---
 lib/libcurses/copywin.c        |   6 +++---
 lib/libcurses/cr_put.c         |   6 +++---
 lib/libcurses/curses_private.h |   4 +++-
 lib/libcurses/delch.c          |   6 +++---
 lib/libcurses/erase.c          |   6 +++---
 lib/libcurses/fileio.h         |   2 +-
 lib/libcurses/get_wch.c        |   8 ++++----
 lib/libcurses/get_wstr.c       |  24 ++++++++++++------------
 lib/libcurses/getch.c          |  28 +++++++++++++++++++++++++---
 lib/libcurses/getstr.c         |  24 ++++++++++++------------
 lib/libcurses/in_wch.c         |   6 +++---
 lib/libcurses/in_wchstr.c      |   8 ++++----
 lib/libcurses/inch.c           |   6 +++---
 lib/libcurses/inchstr.c        |   8 ++++----
 lib/libcurses/ins_wch.c        |   6 +++---
 lib/libcurses/ins_wstr.c       |   8 ++++----
 lib/libcurses/insch.c          |   7 ++++---
 lib/libcurses/insstr.c         |   8 ++++----
 lib/libcurses/instr.c          |   8 ++++----
 lib/libcurses/inwstr.c         |   8 ++++----
 lib/libcurses/line.c           |  20 ++++++++++----------
 lib/libcurses/move.c           |  34 ++++++++++++++++++++++++----------
 lib/libcurses/newwin.c         |   6 +++---
 lib/libcurses/printw.c         |   6 +++---
 lib/libcurses/putchar.c        |  18 ++++++++++++------
 lib/libcurses/refresh.c        |  12 ++++++++----
 lib/libcurses/scroll.c         |   8 ++++----
 34 files changed, 205 insertions(+), 149 deletions(-)

diffs (truncated from 1412 to 300 lines):

diff -r 43d90421d6db -r a3fff95209aa lib/libcurses/add_wch.c
--- a/lib/libcurses/add_wch.c   Mon May 20 20:35:45 2019 +0000
+++ b/lib/libcurses/add_wch.c   Mon May 20 22:17:41 2019 +0000
@@ -1,4 +1,4 @@
-/*   $NetBSD: add_wch.c,v 1.7 2019/04/24 07:09:44 blymn Exp $ */
+/*   $NetBSD: add_wch.c,v 1.8 2019/05/20 22:17:41 blymn Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: add_wch.c,v 1.7 2019/04/24 07:09:44 blymn Exp $");
+__RCSID("$NetBSD: add_wch.c,v 1.8 2019/05/20 22:17:41 blymn Exp $");
 #endif /* not lint */
 
 #include <stdlib.h>
@@ -76,7 +76,7 @@
 int
 mvwadd_wch(WINDOW *win, int y, int x, const cchar_t *wch)
 {
-       if (wmove(win, y, x) == ERR)
+       if (_cursesi_wmove(win, y, x, 0) == ERR)
                return ERR;
 
        return wadd_wch(win, wch);
@@ -92,11 +92,12 @@
 int
 wadd_wch(WINDOW *win, const cchar_t *wch)
 {
-       int x = win->curx, y = win->cury;
+       int y = win->cury;
        __LINE *lnp = NULL;
 
 #ifdef DEBUG
        int i;
+       int x = win->curx;
 
        for (i = 0; i < win->maxy; i++) {
                assert(win->alines[i]->sentinel == SENTINEL_VALUE);
@@ -105,5 +106,5 @@
            win, x, y);
 #endif
        lnp = win->alines[y];
-       return _cursesi_addwchar(win, &lnp, &y, &x, wch, 1);
+       return _cursesi_addwchar(win, &lnp, &(win->cury), &(win->curx), wch, 1);
 }
diff -r 43d90421d6db -r a3fff95209aa lib/libcurses/add_wchstr.c
--- a/lib/libcurses/add_wchstr.c        Mon May 20 20:35:45 2019 +0000
+++ b/lib/libcurses/add_wchstr.c        Mon May 20 22:17:41 2019 +0000
@@ -1,4 +1,4 @@
-/*   $NetBSD: add_wchstr.c,v 1.6 2018/11/22 22:16:45 uwe Exp $ */
+/*   $NetBSD: add_wchstr.c,v 1.7 2019/05/20 22:17:41 blymn Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: add_wchstr.c,v 1.6 2018/11/22 22:16:45 uwe Exp $");
+__RCSID("$NetBSD: add_wchstr.c,v 1.7 2019/05/20 22:17:41 blymn Exp $");
 #endif                         /* not lint */
 
 #include <stdlib.h>
@@ -120,7 +120,7 @@
 int
 mvwadd_wchnstr(WINDOW *win, int y, int x, const cchar_t *wchstr, int n)
 {
-       if (wmove(win, y, x) == ERR)
+       if (_cursesi_wmove(win, y, x, 0) == ERR)
                return ERR;
 
        return wadd_wchnstr(win, wchstr, n);
diff -r 43d90421d6db -r a3fff95209aa lib/libcurses/addbytes.c
--- a/lib/libcurses/addbytes.c  Mon May 20 20:35:45 2019 +0000
+++ b/lib/libcurses/addbytes.c  Mon May 20 22:17:41 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: addbytes.c,v 1.50 2019/05/12 02:29:00 blymn Exp $      */
+/*     $NetBSD: addbytes.c,v 1.51 2019/05/20 22:17:41 blymn Exp $      */
 
 /*
  * Copyright (c) 1987, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)addbytes.c 8.4 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: addbytes.c,v 1.50 2019/05/12 02:29:00 blymn Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.51 2019/05/20 22:17:41 blymn Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -47,9 +47,9 @@
 #endif
 
 #define        SYNCH_IN        {y = win->cury; x = win->curx;}
-#define        SYNCH_OUT       {win->cury = y; win->curx = x;}
+#define        SYNCH_OUT       {win->cury = y; win->curx = x; win->ocury = y; win->ocurx = x;}
 #define        PSYNCH_IN       {*y = win->cury; *x = win->curx;}
-#define        PSYNCH_OUT      {win->cury = *y; win->curx = *x;}
+#define        PSYNCH_OUT      {win->cury = *y; win->curx = *x; win->ocury = *y; win->ocurx = *x;}
 
 #ifndef _CURSES_USE_MACROS
 
@@ -94,7 +94,7 @@
 mvwaddbytes(WINDOW *win, int y, int x, const char *bytes, int count)
 {
 
-       if (wmove(win, y, x) == ERR)
+       if (_cursesi_wmove(win, y, x, 0) == ERR)
                return ERR;
 
        return _cursesi_waddbytes(win, bytes, count, 0, 1);
@@ -241,12 +241,14 @@
                case '\r':
                        *x = 0;
                        win->curx = *x;
+                       win->ocurx = *x;
                        return OK;
 
                case '\b':
                        if (--(*x) < 0)
                                *x = 0;
                        win->curx = *x;
+                       win->ocurx = *x;
                        return OK;
                }
        }
@@ -362,10 +364,12 @@
                        if (--*x < 0)
                                *x = 0;
                        win->curx = *x;
+                       win->ocurx = *x;
                        return OK;
                case L'\r':
                        *x = 0;
                        win->curx = *x;
+                       win->ocurx = *x;
                        return OK;
                case L'\n':
                        wclrtoeol(win);
@@ -508,6 +512,7 @@
                (*lnp) = win->alines[*y];
        }
        win->cury = *y;
+       win->ocury = *y;
 
        /* add spacing character */
 #ifdef DEBUG
@@ -597,10 +602,11 @@
                }
                lp = &win->alines[*y]->line[0];
                (*lnp) = win->alines[*y];
-               win->curx = *x;
-               win->cury = *y;
+               win->curx = win->ocurx = *x;
+               win->cury = win->ocury = *y;
        } else {
                win->curx = *x;
+               win->ocurx = *x;
 
                /* clear the remining of the current characer */
                if (*x && *x < win->maxx) {
diff -r 43d90421d6db -r a3fff95209aa lib/libcurses/addch.c
--- a/lib/libcurses/addch.c     Mon May 20 20:35:45 2019 +0000
+++ b/lib/libcurses/addch.c     Mon May 20 22:17:41 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: addch.c,v 1.19 2018/10/29 01:19:54 uwe Exp $   */
+/*     $NetBSD: addch.c,v 1.20 2019/05/20 22:17:41 blymn Exp $ */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)addch.c    8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: addch.c,v 1.19 2018/10/29 01:19:54 uwe Exp $");
+__RCSID("$NetBSD: addch.c,v 1.20 2019/05/20 22:17:41 blymn Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -74,7 +74,7 @@
 mvwaddch(WINDOW *win, int y, int x, chtype ch)
 {
 
-       if (wmove(win, y, x) == ERR)
+       if (_cursesi_wmove(win, y, x, 0) == ERR)
                return ERR;
 
        return waddch(win, ch);
diff -r 43d90421d6db -r a3fff95209aa lib/libcurses/addchnstr.c
--- a/lib/libcurses/addchnstr.c Mon May 20 20:35:45 2019 +0000
+++ b/lib/libcurses/addchnstr.c Mon May 20 22:17:41 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: addchnstr.c,v 1.6 2013/11/09 11:16:59 blymn Exp $      */
+/*     $NetBSD: addchnstr.c,v 1.7 2019/05/20 22:17:41 blymn Exp $      */
 
 /*
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: addchnstr.c,v 1.6 2013/11/09 11:16:59 blymn Exp $");
+__RCSID("$NetBSD: addchnstr.c,v 1.7 2019/05/20 22:17:41 blymn Exp $");
 #endif                         /* not lint */
 
 #include <stdlib.h>
@@ -111,7 +111,7 @@
 int
 mvwaddchnstr(WINDOW *win, int y, int x, const chtype *chstr, int n)
 {
-       if (wmove(win, y, x) == ERR)
+       if (_cursesi_wmove(win, y, x, 0) == ERR)
                return ERR;
 
        return waddchnstr(win, chstr, n);
@@ -180,6 +180,6 @@
        *cp = '\0';
        ret = _cursesi_waddbytes(win, start, i, attr, 0);
        free(ocp);
-       wmove(win, oy, ox);
+       _cursesi_wmove(win, oy, ox, 1);
        return ret;
 }
diff -r 43d90421d6db -r a3fff95209aa lib/libcurses/addnstr.c
--- a/lib/libcurses/addnstr.c   Mon May 20 20:35:45 2019 +0000
+++ b/lib/libcurses/addnstr.c   Mon May 20 22:17:41 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: addnstr.c,v 1.15 2017/01/06 13:53:18 roy Exp $ */
+/*     $NetBSD: addnstr.c,v 1.16 2019/05/20 22:17:41 blymn Exp $       */
 
 /*
  * Copyright (c) 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)addnstr.c  8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: addnstr.c,v 1.15 2017/01/06 13:53:18 roy Exp $");
+__RCSID("$NetBSD: addnstr.c,v 1.16 2019/05/20 22:17:41 blymn Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -115,7 +115,7 @@
 int
 mvwaddnstr(WINDOW *win, int y, int x, const char *str, int count)
 {
-       if (wmove(win, y, x) == ERR)
+       if (_cursesi_wmove(win, y, x, 0) == ERR)
                return ERR;
 
        return waddnstr(win, str, count);
diff -r 43d90421d6db -r a3fff95209aa lib/libcurses/addwstr.c
--- a/lib/libcurses/addwstr.c   Mon May 20 20:35:45 2019 +0000
+++ b/lib/libcurses/addwstr.c   Mon May 20 22:17:41 2019 +0000
@@ -1,4 +1,4 @@
-/*   $NetBSD: addwstr.c,v 1.4 2018/11/22 22:16:45 uwe Exp $ */
+/*   $NetBSD: addwstr.c,v 1.5 2019/05/20 22:17:41 blymn Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: addwstr.c,v 1.4 2018/11/22 22:16:45 uwe Exp $");
+__RCSID("$NetBSD: addwstr.c,v 1.5 2019/05/20 22:17:41 blymn Exp $");
 #endif                                           /* not lint */
 
 #include <string.h>
@@ -114,7 +114,7 @@
 int
 mvwaddnwstr(WINDOW *win, int y, int x, const wchar_t *str, int count)
 {
-       if (wmove(win, y, x) == ERR)
+       if (_cursesi_wmove(win, y, x, 0) == ERR)
                return ERR;
 
        return waddnwstr(win, str, count);
diff -r 43d90421d6db -r a3fff95209aa lib/libcurses/copywin.c
--- a/lib/libcurses/copywin.c   Mon May 20 20:35:45 2019 +0000
+++ b/lib/libcurses/copywin.c   Mon May 20 22:17:41 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: copywin.c,v 1.17 2017/01/06 13:53:18 roy Exp $ */
+/*     $NetBSD: copywin.c,v 1.18 2019/05/20 22:17:41 blymn Exp $       */
 
 /*-
  * Copyright (c) 1998-1999 Brett Lymn
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: copywin.c,v 1.17 2017/01/06 13:53:18 roy Exp $");
+__RCSID("$NetBSD: copywin.c,v 1.18 2019/05/20 22:17:41 blymn Exp $");
 #endif                         /* not lint */
 
 #include <ctype.h>
@@ -119,7 +119,7 @@
                         * background character



Home | Main Index | Thread Index | Old Index