diff options
| author | blymn <blymn@NetBSD.org> | 2019-05-20 22:17:41 +0000 |
|---|---|---|
| committer | blymn <blymn@NetBSD.org> | 2019-05-20 22:17:41 +0000 |
| commit | 5bb367becb905575ff0ff349ab1af2fa7ff66dda (patch) | |
| tree | 44142646920b2b5bc3524ec1d14998bfaee8896e /lib | |
| parent | 39db47374eb64952da5c75a94cf63ac646ecccf9 (diff) | |
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 (limited to 'lib')
34 files changed, 205 insertions, 149 deletions
diff --git a/lib/libcurses/add_wch.c b/lib/libcurses/add_wch.c index 23c06a8aaee..2bbdf65ad7b 100644 --- a/lib/libcurses/add_wch.c +++ b/lib/libcurses/add_wch.c @@ -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 @@ mvadd_wch(int y, int x, const cchar_t *wch) 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 @@ mvwadd_wch(WINDOW *win, int y, int x, const cchar_t *wch) 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 @@ wadd_wch(WINDOW *win, const cchar_t *wch) 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 --git a/lib/libcurses/add_wchstr.c b/lib/libcurses/add_wchstr.c index b92622c4438..7a1c361de03 100644 --- a/lib/libcurses/add_wchstr.c +++ b/lib/libcurses/add_wchstr.c @@ -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 @@ mvadd_wchnstr(int y, int x, const cchar_t *wchstr, int n) 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 --git a/lib/libcurses/addbytes.c b/lib/libcurses/addbytes.c index bc3da9fc023..538199fc7aa 100644 --- a/lib/libcurses/addbytes.c +++ b/lib/libcurses/addbytes.c @@ -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 @@ __RCSID("$NetBSD: addbytes.c,v 1.50 2019/05/12 02:29:00 blymn Exp $"); #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 @@ int 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 @@ _cursesi_addbyte(WINDOW *win, __LINE **lp, int *y, int *x, int c, 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 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x, 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 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x, (*lnp) = win->alines[*y]; } win->cury = *y; + win->ocury = *y; /* add spacing character */ #ifdef DEBUG @@ -597,10 +602,11 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x, } 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 --git a/lib/libcurses/addch.c b/lib/libcurses/addch.c index 98d8ef27010..9f530ae548c 100644 --- a/lib/libcurses/addch.c +++ b/lib/libcurses/addch.c @@ -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 @@ int 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 --git a/lib/libcurses/addchnstr.c b/lib/libcurses/addchnstr.c index 2ebad828dd7..1241a9b5934 100644 --- a/lib/libcurses/addchnstr.c +++ b/lib/libcurses/addchnstr.c @@ -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 @@ mvaddchnstr(int y, int x, const chtype *chstr, int n) 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 @@ waddchnstr(WINDOW *win, const chtype *chstr, int n) *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 --git a/lib/libcurses/addnstr.c b/lib/libcurses/addnstr.c index 78cc20966fe..c75549f6fab 100644 --- a/lib/libcurses/addnstr.c +++ b/lib/libcurses/addnstr.c @@ -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 @@ mvaddnstr(int y, int x, const char *str, int count) 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 --git a/lib/libcurses/addwstr.c b/lib/libcurses/addwstr.c index 84567536baa..dbce25a99ab 100644 --- a/lib/libcurses/addwstr.c +++ b/lib/libcurses/addwstr.c @@ -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 @@ mvaddnwstr(int y, int x, const wchar_t *str, int count) 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 --git a/lib/libcurses/copywin.c b/lib/libcurses/copywin.c index f53bb111819..035cbfabb9f 100644 --- a/lib/libcurses/copywin.c +++ b/lib/libcurses/copywin.c @@ -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 @@ int copywin(const WINDOW *srcwin, WINDOW *dstwin, * background character */ if ((dooverlay && !isspace(sp->ch)) || !dooverlay) { - wmove(dstwin, dminrow, dcol); + _cursesi_wmove(dstwin, dminrow, dcol, 0); #ifdef DEBUG __CTRACE(__CTRACE_WINDOW, "copywin: dcol = %d\n", dcol); #endif diff --git a/lib/libcurses/cr_put.c b/lib/libcurses/cr_put.c index 21932b7ae1f..e2f418b58f4 100644 --- a/lib/libcurses/cr_put.c +++ b/lib/libcurses/cr_put.c @@ -1,4 +1,4 @@ -/* $NetBSD: cr_put.c,v 1.33 2017/03/20 18:19:34 christos Exp $ */ +/* $NetBSD: cr_put.c,v 1.34 2019/05/20 22:17:41 blymn Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)cr_put.c 8.3 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: cr_put.c,v 1.33 2017/03/20 18:19:34 christos Exp $"); +__RCSID("$NetBSD: cr_put.c,v 1.34 2019/05/20 22:17:41 blymn Exp $"); #endif #endif /* not lint */ @@ -75,7 +75,7 @@ __mvcur(int ly, int lx, int y, int x, int in_refresh) { #ifdef DEBUG __CTRACE(__CTRACE_OUTPUT, - "mvcur: moving cursor from (%d, %d) to (%d, %d)\n", ly, lx, y, x); + "mvcur: moving cursor from (%d, %d) to (%d, %d) in refresh %d\n", ly, lx, y, x, in_refresh); #endif destcol = x; destline = y; diff --git a/lib/libcurses/curses_private.h b/lib/libcurses/curses_private.h index 346fa6cc5e3..d733223db36 100644 --- a/lib/libcurses/curses_private.h +++ b/lib/libcurses/curses_private.h @@ -1,4 +1,4 @@ -/* $NetBSD: curses_private.h,v 1.69 2019/04/01 11:39:15 roy Exp $ */ +/* $NetBSD: curses_private.h,v 1.70 2019/05/20 22:17:41 blymn Exp $ */ /*- * Copyright (c) 1998-2000 Brett Lymn @@ -111,6 +111,7 @@ struct __window { /* Window structure. */ struct __window *nextp, *orig; /* Subwindows list and parent. */ int begy, begx; /* Window home. */ int cury, curx; /* Current x, y coordinates. */ + int ocury, ocurx; /* Previous x, y coordinates. */ int maxy, maxx; /* Maximum values for curx, cury. */ int reqy, reqx; /* Size requested when created */ int ch_off; /* x offset for firstch/lastch. */ @@ -351,6 +352,7 @@ void _cursesi_reset_wacs(SCREEN *); #endif /* HAVE_WCHAR */ void _cursesi_resetterm(SCREEN *); int _cursesi_setterm(char *, SCREEN *); +int _cursesi_wmove(WINDOW *, int, int, int); int __delay(void); unsigned int __hash_more(const void *, size_t, unsigned int); #define __hash(s, len) __hash_more((s), (len), 0u) diff --git a/lib/libcurses/delch.c b/lib/libcurses/delch.c index 3d3b39fda0f..75a96d79584 100644 --- a/lib/libcurses/delch.c +++ b/lib/libcurses/delch.c @@ -1,4 +1,4 @@ -/* $NetBSD: delch.c,v 1.24 2017/01/06 13:53:18 roy Exp $ */ +/* $NetBSD: delch.c,v 1.25 2019/05/20 22:17:41 blymn Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)delch.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: delch.c,v 1.24 2017/01/06 13:53:18 roy Exp $"); +__RCSID("$NetBSD: delch.c,v 1.25 2019/05/20 22:17:41 blymn Exp $"); #endif #endif /* not lint */ @@ -72,7 +72,7 @@ mvdelch(int y, int x) int mvwdelch(WINDOW *win, int y, int x) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return wdelch(win); diff --git a/lib/libcurses/erase.c b/lib/libcurses/erase.c index ec15317d3b5..ef7154ce09b 100644 --- a/lib/libcurses/erase.c +++ b/lib/libcurses/erase.c @@ -1,4 +1,4 @@ -/* $NetBSD: erase.c,v 1.26 2017/01/06 13:53:18 roy Exp $ */ +/* $NetBSD: erase.c,v 1.27 2019/05/20 22:17:41 blymn Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)erase.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: erase.c,v 1.26 2017/01/06 13:53:18 roy Exp $"); +__RCSID("$NetBSD: erase.c,v 1.27 2019/05/20 22:17:41 blymn Exp $"); #endif #endif /* not lint */ @@ -105,6 +105,6 @@ werase(WINDOW *win) * windows - this will result in the (intended) clearing of the * screen over the area covered by the window. */ __touchwin(win); - wmove(win, 0, 0); + _cursesi_wmove(win, 0, 0, 0); return OK; } diff --git a/lib/libcurses/fileio.h b/lib/libcurses/fileio.h index 2aea3a6a7cd..78beec16bc7 100644 --- a/lib/libcurses/fileio.h +++ b/lib/libcurses/fileio.h @@ -1,6 +1,6 @@ /* * Do not edit! Automatically generated file: - * from: NetBSD: shlib_version,v 1.42 2017/01/02 12:38:16 roy Exp + * from: NetBSD: shlib_version,v 1.43 2018/11/16 10:12:00 blymn Exp * by : NetBSD: genfileioh.awk,v 1.2 2008/05/02 11:13:02 martin Exp */ diff --git a/lib/libcurses/get_wch.c b/lib/libcurses/get_wch.c index 8aefee0f032..57f9e2c7da1 100644 --- a/lib/libcurses/get_wch.c +++ b/lib/libcurses/get_wch.c @@ -1,4 +1,4 @@ -/* $NetBSD: get_wch.c,v 1.21 2019/03/14 00:36:06 rin Exp $ */ +/* $NetBSD: get_wch.c,v 1.22 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: get_wch.c,v 1.21 2019/03/14 00:36:06 rin Exp $"); +__RCSID("$NetBSD: get_wch.c,v 1.22 2019/05/20 22:17:41 blymn Exp $"); #endif /* not lint */ #include <errno.h> @@ -473,7 +473,7 @@ mvget_wch(int y, int x, wint_t *ch) int mvwget_wch(WINDOW *win, int y, int x, wint_t *ch) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return wget_wch(win, ch); @@ -608,7 +608,7 @@ wget_wch(WINDOW *win, wint_t *ch) ( inp == KEY_DC || inp == KEY_BACKSPACE || inp == KEY_LEFT )) { - wmove( win, win->cury, win->curx - 1 ); + _cursesi_wmove( win, win->cury, win->curx - 1, 0 ); wdelch( win ); } } else { diff --git a/lib/libcurses/get_wstr.c b/lib/libcurses/get_wstr.c index c4fbdb7716d..b7c9a9a4575 100644 --- a/lib/libcurses/get_wstr.c +++ b/lib/libcurses/get_wstr.c @@ -1,4 +1,4 @@ -/* $NetBSD: get_wstr.c,v 1.6 2019/02/24 20:20:18 roy Exp $ */ +/* $NetBSD: get_wstr.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: get_wstr.c,v 1.6 2019/02/24 20:20:18 roy Exp $"); +__RCSID("$NetBSD: get_wstr.c,v 1.7 2019/05/20 22:17:41 blymn Exp $"); #endif /* not lint */ #include "curses.h" @@ -98,7 +98,7 @@ mvget_wstr(int y, int x, wchar_t *wstr) int mvwgetn_wstr(WINDOW *win, int y, int x, wchar_t *wstr, int n) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return wgetn_wstr(win, wstr, n); @@ -113,7 +113,7 @@ __warn_references(mvget_wstr, int mvwget_wstr(WINDOW *win, int y, int x, wchar_t *wstr) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return wget_wstr(win, wstr); @@ -188,7 +188,7 @@ __wgetn_wstr(WINDOW *win, wchar_t *wstr, int n) if ((wchar_t)wc == ec) { mvwadd_wch(win, win->cury, win->curx, &cc); - wmove(win, win->cury, win->curx - 1); + _cursesi_wmove(win, win->cury, win->curx - 1, 1); } if (wc == KEY_BACKSPACE || wc == KEY_LEFT) { /* getch() displays the key sequence */ @@ -196,7 +196,7 @@ __wgetn_wstr(WINDOW *win, wchar_t *wstr, int n) win->curx - 1, &cc); mvwadd_wch(win, win->cury, win->curx - 2, &cc); - wmove(win, win->cury, win->curx - 1); + _cursesi_wmove(win, win->cury, win->curx - 1, 1); } wstr--; if (n != -1) { @@ -208,7 +208,7 @@ __wgetn_wstr(WINDOW *win, wchar_t *wstr, int n) /* getch() displays the other keys */ mvwadd_wch(win, win->cury, win->curx - 1, &cc); - wmove(win, win->cury, oldx); + _cursesi_wmove(win, win->cury, oldx, 1); } } else if (wc == kc) { *wstr = L'\0'; @@ -219,29 +219,29 @@ __wgetn_wstr(WINDOW *win, wchar_t *wstr, int n) while (wstr != ostr) { mvwadd_wch(win, win->cury, win->curx - 1, &cc); - wmove(win, win->cury, win->curx - 1); + _cursesi_wmove(win, win->cury, win->curx - 1, 1); wstr--; if (n != -1) /* We're counting chars */ remain++; } mvwadd_wch(win, win->cury, win->curx - 1, &cc); - wmove(win, win->cury, win->curx - 1); + _cursesi_wmove(win, win->cury, win->curx - 1, 1); } else /* getch() displays the kill character */ mvwadd_wch( win, win->cury, oldx, &cc ); - wmove(win, win->cury, oldx); + _cursesi_wmove(win, win->cury, oldx, 0); } else if (wc >= KEY_MIN && wc <= KEY_MAX) { /* get_wch() displays these characters */ mvwadd_wch( win, win->cury, win->curx - 1, &cc ); - wmove(win, win->cury, win->curx - 1); + _cursesi_wmove(win, win->cury, win->curx - 1, 1); } else { if (remain) { wstr++; remain--; } else { mvwadd_wch(win, win->cury, win->curx - 1, &cc); - wmove(win, win->cury, win->curx - 1); + _cursesi_wmove(win, win->cury, win->curx - 1, 1); } } } diff --git a/lib/libcurses/getch.c b/lib/libcurses/getch.c index 2948b5038cd..ff2eb71f531 100644 --- a/lib/libcurses/getch.c +++ b/lib/libcurses/getch.c @@ -1,4 +1,4 @@ -/* $NetBSD: getch.c,v 1.71 2019/03/14 00:36:06 rin Exp $ */ +/* $NetBSD: getch.c,v 1.72 2019/05/20 22:17:41 blymn Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)getch.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: getch.c,v 1.71 2019/03/14 00:36:06 rin Exp $"); +__RCSID("$NetBSD: getch.c,v 1.72 2019/05/20 22:17:41 blymn Exp $"); #endif #endif /* not lint */ @@ -716,7 +716,7 @@ mvgetch(int y, int x) int mvwgetch(WINDOW *win, int y, int x) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return wgetch(win); @@ -820,6 +820,28 @@ wgetch(WINDOW *win) if (is_wintouched(win)) wrefresh(win); + else { + if ((win->ocury != win->cury) || (win->ocurx != win->curx)) { +#ifdef DEBUG + __CTRACE(__CTRACE_INPUT, "wgetch: ocury %d cury %d ocurx %d curx %d\n", + win->ocury, win->cury, win->ocurx, win->curx); +#endif + /* + * Just in case the window is not dirty but the + * cursor was moved, check and update the + * cursor location. + */ + mvcur(win->ocury + win->begy, win->ocurx + win->begx, + win->cury + win->begy, win->curx + win->begx); + _cursesi_screen->curscr->cury = + win->cury + _cursesi_screen->curscr->begy; + _cursesi_screen->curscr->curx = + win->curx + _cursesi_screen->curscr->begx; + win->ocurx = win->curx; + win->ocury = win->cury; + } + } + #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "wgetch: __echoit = %d, " "__rawmode = %d, __nl = %d, flags = %#.4x, delay = %d\n", diff --git a/lib/libcurses/getstr.c b/lib/libcurses/getstr.c index 91c32498ce4..7981ca1cfb7 100644 --- a/lib/libcurses/getstr.c +++ b/lib/libcurses/getstr.c @@ -1,4 +1,4 @@ -/* $NetBSD: getstr.c,v 1.25 2019/02/24 20:20:18 roy Exp $ */ +/* $NetBSD: getstr.c,v 1.26 2019/05/20 22:17:41 blymn Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -35,7 +35,7 @@ #if 0 static char sccsid[] = "@(#)getstr.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: getstr.c,v 1.25 2019/02/24 20:20:18 roy Exp $"); +__RCSID("$NetBSD: getstr.c,v 1.26 2019/05/20 22:17:41 blymn Exp $"); #endif #endif /* not lint */ @@ -98,7 +98,7 @@ mvgetstr(int y, int x, char *str) int mvwgetnstr(WINDOW *win, int y, int x, char *str, int n) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return wgetnstr(win, str, n); @@ -113,7 +113,7 @@ __warn_references(mvgetstr, int mvwgetstr(WINDOW *win, int y, int x, char *str) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return wgetstr(win, str); @@ -188,7 +188,7 @@ __wgetnstr(WINDOW *win, char *str, int n) mvwaddch(win, win->cury, xpos - 1, ' '); if (win->curx > xpos - 1) - wmove(win, win->cury, xpos - 1); + _cursesi_wmove(win, win->cury, xpos - 1, 1); xpos--; } if (c == KEY_BACKSPACE || c == KEY_LEFT) { @@ -198,7 +198,7 @@ __wgetnstr(WINDOW *win, char *str, int n) mvwaddch(win, win->cury, win->curx - 1, ' '); if (win->curx > xpos) - wmove(win, win->cury, xpos - 1); + _cursesi_wmove(win, win->cury, xpos - 1, 1); xpos--; } str--; @@ -211,7 +211,7 @@ __wgetnstr(WINDOW *win, char *str, int n) if (win->curx > oldx) mvwaddch(win, win->cury, win->curx - 1, ' '); - wmove(win, win->cury, oldx); + _cursesi_wmove(win, win->cury, oldx, 1); xpos = oldx; } } else if (c == kc) { @@ -223,22 +223,22 @@ __wgetnstr(WINDOW *win, char *str, int n) while (str != ostr) { mvwaddch(win, win->cury, win->curx - 1, ' '); - wmove(win, win->cury, win->curx - 1); + _cursesi_wmove(win, win->cury, win->curx - 1, 1); str--; if (n != -1) /* We're counting chars */ remain++; } mvwaddch(win, win->cury, win->curx - 1, ' '); - wmove(win, win->cury, win->curx - 1); + _cursesi_wmove(win, win->cury, win->curx - 1, 1); } else /* getch() displays the kill character */ mvwaddch(win, win->cury, oldx, ' '); - wmove(win, win->cury, oldx); + _cursesi_wmove(win, win->cury, oldx, 1); } else if (c >= KEY_MIN && c <= KEY_MAX) { /* getch() displays these characters */ mvwaddch(win, win->cury, xpos, ' '); - wmove(win, win->cury, xpos); + _cursesi_wmove(win, win->cury, xpos, 1); } else { if (remain) { if (iscntrl((unsigned char)c)) @@ -248,7 +248,7 @@ __wgetnstr(WINDOW *win, char *str, int n) remain--; } else mvwaddch(win, win->cury, xpos, ' '); - wmove(win, win->cury, xpos); + _cursesi_wmove(win, win->cury, xpos, 1); } } diff --git a/lib/libcurses/in_wch.c b/lib/libcurses/in_wch.c index 280ed18c91b..879f72c6fa4 100644 --- a/lib/libcurses/in_wch.c +++ b/lib/libcurses/in_wch.c @@ -1,4 +1,4 @@ -/* $NetBSD: in_wch.c,v 1.5 2018/11/22 22:16:45 uwe Exp $ */ +/* $NetBSD: in_wch.c,v 1.6 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: in_wch.c,v 1.5 2018/11/22 22:16:45 uwe Exp $"); +__RCSID("$NetBSD: in_wch.c,v 1.6 2019/05/20 22:17:41 blymn Exp $"); #endif /* not lint */ #include "curses.h" @@ -69,7 +69,7 @@ mvin_wch(int y, int x, cchar_t *wcval) int mvwin_wch(WINDOW *win, int y, int x, cchar_t *wcval) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return win_wch(win, wcval); diff --git a/lib/libcurses/in_wchstr.c b/lib/libcurses/in_wchstr.c index 8a56f9e300c..63177c039be 100644 --- a/lib/libcurses/in_wchstr.c +++ b/lib/libcurses/in_wchstr.c @@ -1,4 +1,4 @@ -/* $NetBSD: in_wchstr.c,v 1.6 2019/02/24 20:20:18 roy Exp $ */ +/* $NetBSD: in_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: in_wchstr.c,v 1.6 2019/02/24 20:20:18 roy Exp $"); +__RCSID("$NetBSD: in_wchstr.c,v 1.7 2019/05/20 22:17:41 blymn Exp $"); #endif /* not lint */ #include "curses.h" @@ -87,7 +87,7 @@ __warn_references(mvwin_wchstr, int mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wchstr) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return win_wchstr(win, wchstr); @@ -96,7 +96,7 @@ mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wchstr) int mvwin_wchnstr(WINDOW *win, int y, int x, cchar_t *wchstr, int n) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return win_wchnstr(win, wchstr, n); diff --git a/lib/libcurses/inch.c b/lib/libcurses/inch.c index c020a26cd40..729aeb6f7fd 100644 --- a/lib/libcurses/inch.c +++ b/lib/libcurses/inch.c @@ -1,4 +1,4 @@ -/* $NetBSD: inch.c,v 1.12 2018/11/18 22:34:32 uwe Exp $ */ +/* $NetBSD: inch.c,v 1.13 2019/05/20 22:17:41 blymn Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: inch.c,v 1.12 2018/11/18 22:34:32 uwe Exp $"); +__RCSID("$NetBSD: inch.c,v 1.13 2019/05/20 22:17:41 blymn Exp $"); #endif /* not lint */ #include "curses.h" @@ -69,7 +69,7 @@ chtype mvwinch(WINDOW *win, int y, int x) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return winch(win); diff --git a/lib/libcurses/inchstr.c b/lib/libcurses/inchstr.c index 8960b10248c..8a13ee3ad5b 100644 --- a/lib/libcurses/inchstr.c +++ b/lib/libcurses/inchstr.c @@ -1,4 +1,4 @@ -/* $NetBSD: inchstr.c,v 1.8 2019/02/24 20:20:18 roy Exp $ */ +/* $NetBSD: inchstr.c,v 1.9 2019/05/20 22:17:41 blymn Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: inchstr.c,v 1.8 2019/02/24 20:20:18 roy Exp $"); +__RCSID("$NetBSD: inchstr.c,v 1.9 2019/05/20 22:17:41 blymn Exp $"); #endif /* not lint */ #include "curses.h" @@ -95,7 +95,7 @@ int mvwinchstr(WINDOW *win, int y, int x, chtype *chstr) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return winchstr(win, chstr); @@ -105,7 +105,7 @@ int mvwinchnstr(WINDOW *win, int y, int x, chtype *chstr, int n) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return winchnstr(win, chstr, n); diff --git a/lib/libcurses/ins_wch.c b/lib/libcurses/ins_wch.c index acffaade172..ea7e6776ab7 100644 --- a/lib/libcurses/ins_wch.c +++ b/lib/libcurses/ins_wch.c @@ -1,4 +1,4 @@ -/* $NetBSD: ins_wch.c,v 1.12 2018/11/22 22:16:45 uwe Exp $ */ +/* $NetBSD: ins_wch.c,v 1.13 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: ins_wch.c,v 1.12 2018/11/22 22:16:45 uwe Exp $"); +__RCSID("$NetBSD: ins_wch.c,v 1.13 2019/05/20 22:17:41 blymn Exp $"); #endif /* not lint */ #include <string.h> @@ -72,7 +72,7 @@ mvins_wch(int y, int x, const cchar_t *wch) int mvwins_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 wins_wch(stdscr, wch); diff --git a/lib/libcurses/ins_wstr.c b/lib/libcurses/ins_wstr.c index c48f8fec799..eb37f0c107b 100644 --- a/lib/libcurses/ins_wstr.c +++ b/lib/libcurses/ins_wstr.c @@ -1,4 +1,4 @@ -/* $NetBSD: ins_wstr.c,v 1.12 2018/11/22 22:16:45 uwe Exp $ */ +/* $NetBSD: ins_wstr.c,v 1.13 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: ins_wstr.c,v 1.12 2018/11/22 22:16:45 uwe Exp $"); +__RCSID("$NetBSD: ins_wstr.c,v 1.13 2019/05/20 22:17:41 blymn Exp $"); #endif /* not lint */ #include <string.h> @@ -93,7 +93,7 @@ mvins_nwstr(int y, int x, const wchar_t *wstr, int n) int mvwins_wstr(WINDOW *win, int y, int x, const wchar_t *wstr) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return wins_wstr(stdscr, wstr); @@ -106,7 +106,7 @@ mvwins_wstr(WINDOW *win, int y, int x, const wchar_t *wstr) int mvwins_nwstr(WINDOW *win, int y, int x, const wchar_t *wstr, int n) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return wins_nwstr(stdscr, wstr, n); diff --git a/lib/libcurses/insch.c b/lib/libcurses/insch.c index 9b1a8b1ba12..e2794fc2822 100644 --- a/lib/libcurses/insch.c +++ b/lib/libcurses/insch.c @@ -1,4 +1,4 @@ -/* $NetBSD: insch.c,v 1.23 2017/01/06 13:53:18 roy Exp $ */ +/* $NetBSD: insch.c,v 1.24 2019/05/20 22:17:41 blymn Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)insch.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: insch.c,v 1.23 2017/01/06 13:53:18 roy Exp $"); +__RCSID("$NetBSD: insch.c,v 1.24 2019/05/20 22:17:41 blymn Exp $"); #endif #endif /* not lint */ @@ -76,7 +76,7 @@ int mvwinsch(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 winsch(stdscr, ch); @@ -126,6 +126,7 @@ winsch(WINDOW *win, chtype ch) wrefresh(win); scroll(win); win->cury--; + win->ocury = win->cury; } else return ERR; } diff --git a/lib/libcurses/insstr.c b/lib/libcurses/insstr.c index 0edb94b2b88..ee35e9c7ae6 100644 --- a/lib/libcurses/insstr.c +++ b/lib/libcurses/insstr.c @@ -1,4 +1,4 @@ -/* $NetBSD: insstr.c,v 1.5 2017/01/06 13:53:18 roy Exp $ */ +/* $NetBSD: insstr.c,v 1.6 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: insstr.c,v 1.5 2017/01/06 13:53:18 roy Exp $"); +__RCSID("$NetBSD: insstr.c,v 1.6 2019/05/20 22:17:41 blymn Exp $"); #endif /* not lint */ #include <string.h> @@ -100,7 +100,7 @@ int mvwinsstr(WINDOW *win, int y, int x, const char *str) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return winsstr(stdscr, str); @@ -114,7 +114,7 @@ int mvwinsnstr(WINDOW *win, int y, int x, const char *str, int n) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return winsnstr(stdscr, str, n); diff --git a/lib/libcurses/instr.c b/lib/libcurses/instr.c index fb25e87fa18..b890d5f8577 100644 --- a/lib/libcurses/instr.c +++ b/lib/libcurses/instr.c @@ -1,4 +1,4 @@ -/* $NetBSD: instr.c,v 1.5 2019/02/24 20:20:18 roy Exp $ */ +/* $NetBSD: instr.c,v 1.6 2019/05/20 22:17:41 blymn Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: instr.c,v 1.5 2019/02/24 20:20:18 roy Exp $"); +__RCSID("$NetBSD: instr.c,v 1.6 2019/05/20 22:17:41 blymn Exp $"); #endif /* not lint */ #include "curses.h" @@ -92,7 +92,7 @@ __warn_references(mvwinstr, int mvwinstr(WINDOW *win, int y, int x, char *str) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return winstr(win, str); @@ -101,7 +101,7 @@ mvwinstr(WINDOW *win, int y, int x, char *str) int mvwinnstr(WINDOW *win, int y, int x, char *str, int n) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return winnstr(win, str, n); diff --git a/lib/libcurses/inwstr.c b/lib/libcurses/inwstr.c index c1ddd441d4d..6f351c8d9b8 100644 --- a/lib/libcurses/inwstr.c +++ b/lib/libcurses/inwstr.c @@ -1,4 +1,4 @@ -/* $NetBSD: inwstr.c,v 1.6 2019/02/24 20:20:18 roy Exp $ */ +/* $NetBSD: inwstr.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: inwstr.c,v 1.6 2019/02/24 20:20:18 roy Exp $"); +__RCSID("$NetBSD: inwstr.c,v 1.7 2019/05/20 22:17:41 blymn Exp $"); #endif /* not lint */ #include "curses.h" @@ -87,7 +87,7 @@ __warn_references(mvwinwstr, int mvwinwstr(WINDOW *win, int y, int x, wchar_t *wstr) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return winwstr(win, wstr); @@ -96,7 +96,7 @@ mvwinwstr(WINDOW *win, int y, int x, wchar_t *wstr) int mvwinnwstr(WINDOW *win, int y, int x, wchar_t *wstr, int n) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return winnwstr(win, wstr, n); diff --git a/lib/libcurses/line.c b/lib/libcurses/line.c index 2c490b23be5..00964e098ea 100644 --- a/lib/libcurses/line.c +++ b/lib/libcurses/line.c @@ -1,4 +1,4 @@ -/* $NetBSD: line.c,v 1.9 2017/01/06 13:53:18 roy Exp $ */ +/* $NetBSD: line.c,v 1.10 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: line.c,v 1.9 2017/01/06 13:53:18 roy Exp $"); +__RCSID("$NetBSD: line.c,v 1.10 2019/05/20 22:17:41 blymn Exp $"); #endif /* not lint */ #include <string.h> @@ -71,7 +71,7 @@ int mvwhline(WINDOW *win, int y, int x, chtype ch, int count) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return whline(win, ch, count); @@ -97,7 +97,7 @@ whline(WINDOW *win, chtype ch, int count) for (i = 0; i < n; i++) mvwaddch(win, win->cury, ocurx + i, ch); - wmove(win, win->cury, ocurx); + _cursesi_wmove(win, win->cury, ocurx, 1); return OK; #else cchar_t cch, *cchp; @@ -143,7 +143,7 @@ int mvwvline(WINDOW *win, int y, int x, chtype ch, int count) { - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return wvline(win, ch, count); @@ -170,7 +170,7 @@ wvline(WINDOW *win, chtype ch, int count) for (i = 0; i < n; i++) mvwaddch(win, ocury + i, ocurx, ch); - wmove(win, ocury, ocurx); + _cursesi_wmove(win, ocury, ocurx, 1); return OK; #else cchar_t cch, *cchp; @@ -208,7 +208,7 @@ int mvwhline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n) #ifndef HAVE_WCHAR return ERR; #else - if ( wmove( win, y , x ) == ERR ) + if ( _cursesi_wmove( win, y , x , 0) == ERR ) return ERR; return whline_set( win, wch, n ); @@ -245,7 +245,7 @@ int whline_set(WINDOW *win, const cchar_t *wch, int n) mvwadd_wch(win, win->cury, ocurx + i * cw, &cc); } - wmove(win, win->cury, ocurx); + _cursesi_wmove(win, win->cury, ocurx, 1); __sync(win); return OK; #endif /* HAVE_WCHAR */ @@ -274,7 +274,7 @@ int mvwvline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n) #ifndef HAVE_WCHAR return ERR; #else - if (wmove(win, y, x) == ERR) + if (_cursesi_wmove(win, y, x, 0) == ERR) return ERR; return wvline_set(win, wch, n); @@ -307,7 +307,7 @@ int wvline_set(WINDOW *win, const cchar_t *wch, int n) #endif /* DEBUG */ } - wmove(win, ocury, ocurx); + _cursesi_wmove(win, ocury, ocurx, 1); __sync(win); return OK; #endif /* HAVE_WCHAR */ diff --git a/lib/libcurses/move.c b/lib/libcurses/move.c index 4bb2061b0e7..79ea6574f23 100644 --- a/lib/libcurses/move.c +++ b/lib/libcurses/move.c @@ -1,4 +1,4 @@ -/* $NetBSD: move.c,v 1.19 2018/09/26 18:51:45 kamil Exp $ */ +/* $NetBSD: move.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[] = "@(#)move.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: move.c,v 1.19 2018/09/26 18:51:45 kamil Exp $"); +__RCSID("$NetBSD: move.c,v 1.20 2019/05/20 22:17:41 blymn Exp $"); #endif #endif /* not lint */ @@ -50,7 +50,7 @@ int move(int y, int x) { - return wmove(stdscr, y, x); + return _cursesi_wmove(stdscr, y, x, 1); } #endif @@ -62,20 +62,34 @@ move(int y, int x) int wmove(WINDOW *win, int y, int x) { + return _cursesi_wmove(win, y, x, 1); +} + + +/* + * _cursesi_wmove: + * Moves the cursor to the given point, if keep_old == 0 then + * update the old cursor position. + */ +int +_cursesi_wmove(WINDOW *win, int y, int x, int keep_old) +{ #ifdef DEBUG - __CTRACE(__CTRACE_MISC, "wmove: (%d, %d)\n", y, x); + __CTRACE(__CTRACE_MISC, "_cursesi_wmove: (%d, %d), keep_old: %d\n", y, x, keep_old); #endif if (x < 0 || y < 0) return ERR; if (x >= win->maxx || y >= win->maxy) return ERR; + win->curx = x; - win->alines[win->cury]->flags &= ~__ISPASTEOL; - win->alines[win->cury]->flags |= __ISDIRTY; win->cury = y; - win->alines[y]->flags &= ~__ISPASTEOL; - win->alines[y]->flags |= __ISDIRTY; + if (keep_old == 0) { + win->ocurx = x; + win->ocury = y; + } + return OK; } @@ -84,8 +98,8 @@ wcursyncup(WINDOW *win) { while (win->orig) { - wmove(win->orig, win->cury + win->begy - win->orig->begy, - win->curx + win->begx - win->orig->begx); + _cursesi_wmove(win->orig, win->cury + win->begy - win->orig->begy, + win->curx + win->begx - win->orig->begx, 0); win = win->orig; } } diff --git a/lib/libcurses/newwin.c b/lib/libcurses/newwin.c index 286b31bf716..cb0919dfb2f 100644 --- a/lib/libcurses/newwin.c +++ b/lib/libcurses/newwin.c @@ -1,4 +1,4 @@ -/* $NetBSD: newwin.c,v 1.55 2019/04/01 11:39:15 roy Exp $ */ +/* $NetBSD: newwin.c,v 1.56 2019/05/20 22:17:41 blymn 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.55 2019/04/01 11:39:15 roy Exp $"); +__RCSID("$NetBSD: newwin.c,v 1.56 2019/05/20 22:17:41 blymn Exp $"); #endif #endif /* not lint */ @@ -375,7 +375,7 @@ __makenew(SCREEN *screen, int nlines, int ncols, int by, int bx, int sub, __CTRACE(__CTRACE_WINDOW, "makenew: ncols = %d\n", ncols); #endif win->screen = screen; - win->cury = win->curx = 0; + win->cury = win->curx = win->ocurx = win->ocury = 0; win->maxy = nlines; win->maxx = ncols; win->reqy = nlines; diff --git a/lib/libcurses/printw.c b/lib/libcurses/printw.c index 2d8238b0cf0..295cdea5ebc 100644 --- a/lib/libcurses/printw.c +++ b/lib/libcurses/printw.c @@ -1,4 +1,4 @@ -/* $NetBSD: printw.c,v 1.27 2019/04/01 11:39:15 roy Exp $ */ +/* $NetBSD: printw.c,v 1.28 2019/05/20 22:17:41 blymn Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)printw.c 8.3 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: printw.c,v 1.27 2019/04/01 11:39:15 roy Exp $"); +__RCSID("$NetBSD: printw.c,v 1.28 2019/05/20 22:17:41 blymn Exp $"); #endif #endif /* not lint */ @@ -102,7 +102,7 @@ mvwprintw(WINDOW * win, int y, int x, const char *fmt,...) va_list ap; int ret; - if (wmove(win, y, x) != OK) + if (_cursesi_wmove(win, y, x, 0) != OK) return ERR; va_start(ap, fmt); diff --git a/lib/libcurses/putchar.c b/lib/libcurses/putchar.c index d39d79f739b..14943a5f168 100644 --- a/lib/libcurses/putchar.c +++ b/lib/libcurses/putchar.c @@ -1,4 +1,4 @@ -/* $NetBSD: putchar.c,v 1.22 2017/01/06 13:53:18 roy Exp $ */ +/* $NetBSD: putchar.c,v 1.23 2019/05/20 22:17:41 blymn Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)putchar.c 8.2 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: putchar.c,v 1.22 2017/01/06 13:53:18 roy Exp $"); +__RCSID("$NetBSD: putchar.c,v 1.23 2019/05/20 22:17:41 blymn Exp $"); #endif #endif /* not lint */ @@ -48,7 +48,7 @@ __cputchar(int ch) #ifdef DEBUG __CTRACE(__CTRACE_OUTPUT, "__cputchar: %s\n", unctrl(ch)); #endif - return putc(ch, _cursesi_screen->outfd); + return __cputchar_args(ch, _cursesi_screen->outfd); } /* @@ -60,12 +60,15 @@ int __cputchar_args(int ch, void *args) { FILE *outfd = (FILE *)args; + int status; #ifdef DEBUG __CTRACE(__CTRACE_OUTPUT, "__cputchar_args: %s on fd %d\n", unctrl(ch), outfd->_file); #endif - return putc(ch, outfd); + status = putc(ch, outfd); + fflush(outfd); + return status; } #ifdef HAVE_WCHAR @@ -75,7 +78,7 @@ __cputwchar(wchar_t wch) #ifdef DEBUG __CTRACE(__CTRACE_OUTPUT, "__cputwchar: 0x%x\n", wch); #endif - return putwc(wch, _cursesi_screen->outfd); + return __cputwchar_args(wch, _cursesi_screen->outfd); } /* @@ -87,11 +90,14 @@ int __cputwchar_args(wchar_t wch, void *args) { FILE *outfd = (FILE *)args; + int status; #ifdef DEBUG __CTRACE(__CTRACE_OUTPUT, "__cputwchar_args: 0x%x on fd %d\n", wch, outfd->_file); #endif - return putwc(wch, outfd); + status = putwc(wch, outfd); + fflush(outfd); + return status; } #endif /* HAVE_WCHAR */ diff --git a/lib/libcurses/refresh.c b/lib/libcurses/refresh.c index 167b07a050b..e0344f36c66 100644 --- a/lib/libcurses/refresh.c +++ b/lib/libcurses/refresh.c @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.109 2019/05/12 02:19:23 blymn Exp $ */ +/* $NetBSD: refresh.c,v 1.110 2019/05/20 22:17:41 blymn Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #else -__RCSID("$NetBSD: refresh.c,v 1.109 2019/05/12 02:19:23 blymn Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.110 2019/05/20 22:17:41 blymn Exp $"); #endif #endif /* not lint */ @@ -45,7 +45,7 @@ __RCSID("$NetBSD: refresh.c,v 1.109 2019/05/12 02:19:23 blymn Exp $"); #include "curses.h" #include "curses_private.h" -static void domvcur(const WINDOW *, int, int, int, int); +static void domvcur(WINDOW *, int, int, int, int); static void putattr(__LDATA *); static void putattr_out(__LDATA *); static int putch(__LDATA *, __LDATA *, int, int); @@ -1431,7 +1431,7 @@ makech(int wy) * Do a mvcur, leaving attributes if necessary. */ static void -domvcur(const WINDOW *win, int oy, int ox, int ny, int nx) +domvcur(WINDOW *win, int oy, int ox, int ny, int nx) { #ifdef DEBUG @@ -1452,6 +1452,10 @@ domvcur(const WINDOW *win, int oy, int ox, int ny, int nx) win->alines[oy]->flags &= ~__ISPASTEOL; win->alines[ny]->flags &= ~__ISPASTEOL; + /* Update old cursor positions to current location */ + win->ocury = ny; + win->ocurx = nx; + __mvcur(oy, ox, ny, nx, 1); } diff --git a/lib/libcurses/scroll.c b/lib/libcurses/scroll.c index 0fab6295ec0..0df31da3e2a 100644 --- a/lib/libcurses/scroll.c +++ b/lib/libcurses/scroll.c @@ -1,4 +1,4 @@ -/* $NetBSD: scroll.c,v 1.24 2017/02/10 06:25:28 blymn Exp $ */ +/* $NetBSD: scroll.c,v 1.25 2019/05/20 22:17:41 blymn Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)scroll.c 8.3 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: scroll.c,v 1.24 2017/02/10 06:25:28 blymn Exp $"); +__RCSID("$NetBSD: scroll.c,v 1.25 2019/05/20 22:17:41 blymn Exp $"); #endif #endif /* not lint */ @@ -100,9 +100,9 @@ wscrl(WINDOW *win, int nlines) #ifdef DEBUG __CTRACE(__CTRACE_WINDOW, "wscrl: y=%d\n", oy); #endif - wmove(win, win->scr_t, 0); + wmove(win, win->scr_t, 1); winsdelln(win, 0 - nlines); - wmove(win, oy, ox); + _cursesi_wmove(win, oy, ox, 1); if (win == curscr) { __cputchar('\n'); |
