Mon Jul 6 23:33:38 2020 UTC ()
Pads are not to be automatically refreshed on input.

X/Open Curses says in the documentation for newpad():

  Automatic refreshes of pads (e.g., from scrolling or echoing of
  input) do not occur.

And in the documentation for get*():

  If the current or specified window is not a pad, and it has been
  moved or modified since the last refresh operation, then it will be
  refreshed before another character is read.

>From Michael Forney in PR lib/55457


(uwe)
diff -r1.23 -r1.24 src/lib/libcurses/get_wch.c
diff -r1.74 -r1.75 src/lib/libcurses/getch.c

cvs diff -r1.23 -r1.24 src/lib/libcurses/get_wch.c (expand / switch to unified diff)

--- src/lib/libcurses/get_wch.c 2019/06/09 07:40:14 1.23
+++ src/lib/libcurses/get_wch.c 2020/07/06 23:33:38 1.24
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: get_wch.c,v 1.23 2019/06/09 07:40:14 blymn Exp $ */ 1/* $NetBSD: get_wch.c,v 1.24 2020/07/06 23:33:38 uwe Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2005 The NetBSD Foundation Inc. 4 * Copyright (c) 2005 The NetBSD Foundation Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from code donated to the NetBSD Foundation 7 * This code is derived from code donated to the NetBSD Foundation
8 * by Ruibiao Qiu <ruibiao@arl.wustl.edu,ruibiao@gmail.com>. 8 * by Ruibiao Qiu <ruibiao@arl.wustl.edu,ruibiao@gmail.com>.
9 * 9 *
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -26,27 +26,27 @@ @@ -26,27 +26,27 @@
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 */ 35 */
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38#ifndef lint 38#ifndef lint
39__RCSID("$NetBSD: get_wch.c,v 1.23 2019/06/09 07:40:14 blymn Exp $"); 39__RCSID("$NetBSD: get_wch.c,v 1.24 2020/07/06 23:33:38 uwe Exp $");
40#endif /* not lint */ 40#endif /* not lint */
41 41
42#include <errno.h> 42#include <errno.h>
43#include <string.h> 43#include <string.h>
44#include <stdlib.h> 44#include <stdlib.h>
45#include <unistd.h> 45#include <unistd.h>
46#include <stdio.h> 46#include <stdio.h>
47#include "curses.h" 47#include "curses.h"
48#include "curses_private.h" 48#include "curses_private.h"
49#include "keymap.h" 49#include "keymap.h"
50 50
51static short wstate; /* state of the wcinkey function */ 51static short wstate; /* state of the wcinkey function */
52extern short _cursesi_state; /* storage declared in getch.c */ 52extern short _cursesi_state; /* storage declared in getch.c */
@@ -489,27 +489,27 @@ wget_wch(WINDOW *win, wint_t *ch) @@ -489,27 +489,27 @@ wget_wch(WINDOW *win, wint_t *ch)
489 int ret, weset; 489 int ret, weset;
490 int c; 490 int c;
491 FILE *infd = _cursesi_screen->infd; 491 FILE *infd = _cursesi_screen->infd;
492 cchar_t wc; 492 cchar_t wc;
493 wchar_t inp, ws[2]; 493 wchar_t inp, ws[2];
494 494
495 if (!(win->flags & __SCROLLOK) 495 if (!(win->flags & __SCROLLOK)
496 && (win->flags & __FULLWIN) 496 && (win->flags & __FULLWIN)
497 && win->curx == win->maxx - 1 497 && win->curx == win->maxx - 1
498 && win->cury == win->maxy - 1 498 && win->cury == win->maxy - 1
499 && __echoit) 499 && __echoit)
500 return ERR; 500 return ERR;
501 501
502 if (is_wintouched(win)) 502 if (!(win->flags & __ISPAD) && is_wintouched(win))
503 wrefresh(win); 503 wrefresh(win);
504#ifdef DEBUG 504#ifdef DEBUG
505 __CTRACE(__CTRACE_INPUT, "wget_wch: __echoit = %d, " 505 __CTRACE(__CTRACE_INPUT, "wget_wch: __echoit = %d, "
506 "__rawmode = %d, __nl = %d, flags = %#.4x\n", 506 "__rawmode = %d, __nl = %d, flags = %#.4x\n",
507 __echoit, __rawmode, _cursesi_screen->nl, win->flags); 507 __echoit, __rawmode, _cursesi_screen->nl, win->flags);
508#endif 508#endif
509 if (_cursesi_screen->resized) { 509 if (_cursesi_screen->resized) {
510 resizeterm(LINES, COLS); 510 resizeterm(LINES, COLS);
511 _cursesi_screen->resized = 0; 511 _cursesi_screen->resized = 0;
512 *ch = KEY_RESIZE; 512 *ch = KEY_RESIZE;
513 return KEY_CODE_YES; 513 return KEY_CODE_YES;
514 } 514 }
515 if (_cursesi_screen->unget_pos) { 515 if (_cursesi_screen->unget_pos) {

cvs diff -r1.74 -r1.75 src/lib/libcurses/getch.c (expand / switch to unified diff)

--- src/lib/libcurses/getch.c 2020/05/14 11:50:04 1.74
+++ src/lib/libcurses/getch.c 2020/07/06 23:33:38 1.75
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: getch.c,v 1.74 2020/05/14 11:50:04 simonb Exp $ */ 1/* $NetBSD: getch.c,v 1.75 2020/07/06 23:33:38 uwe 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[] = "@(#)getch.c 8.2 (Berkeley) 5/4/94"; 35static char sccsid[] = "@(#)getch.c 8.2 (Berkeley) 5/4/94";
36#else 36#else
37__RCSID("$NetBSD: getch.c,v 1.74 2020/05/14 11:50:04 simonb Exp $"); 37__RCSID("$NetBSD: getch.c,v 1.75 2020/07/06 23:33:38 uwe Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <errno.h> 41#include <errno.h>
42#include <string.h> 42#include <string.h>
43#include <stdlib.h> 43#include <stdlib.h>
44#include <unistd.h> 44#include <unistd.h>
45#include <stdio.h> 45#include <stdio.h>
46#include "curses.h" 46#include "curses.h"
47#include "curses_private.h" 47#include "curses_private.h"
48#include "keymap.h" 48#include "keymap.h"
49 49
50short _cursesi_state; /* state of the inkey function */ 50short _cursesi_state; /* state of the inkey function */
@@ -808,31 +808,31 @@ wgetch(WINDOW *win) @@ -808,31 +808,31 @@ wgetch(WINDOW *win)
808 int c; 808 int c;
809 FILE *infd = _cursesi_screen->infd; 809 FILE *infd = _cursesi_screen->infd;
810 810
811#ifdef DEBUG 811#ifdef DEBUG
812 __CTRACE(__CTRACE_INPUT, "wgetch: win(%p)\n", win); 812 __CTRACE(__CTRACE_INPUT, "wgetch: win(%p)\n", win);
813#endif 813#endif
814 if (win == NULL) 814 if (win == NULL)
815 return ERR; 815 return ERR;
816 if (!(win->flags & __SCROLLOK) && (win->flags & __FULLWIN) 816 if (!(win->flags & __SCROLLOK) && (win->flags & __FULLWIN)
817 && win->curx == win->maxx - 1 && win->cury == win->maxy - 1 817 && win->curx == win->maxx - 1 && win->cury == win->maxy - 1
818 && __echoit) 818 && __echoit)
819 return ERR; 819 return ERR;
820 820
821 if (is_wintouched(win)) 821 if (!(win->flags & __ISPAD)) {
822 wrefresh(win); 822 if (is_wintouched(win))
823 else { 823 wrefresh(win);
824 if ((_cursesi_screen->curscr->cury != (win->begy + win->cury)) 824 else if ((_cursesi_screen->curscr->cury != (win->begy + win->cury))
825 || (_cursesi_screen->curscr->curx != (win->begx + win->curx))) { 825 || (_cursesi_screen->curscr->curx != (win->begx + win->curx))) {
826#ifdef DEBUG 826#ifdef DEBUG
827 __CTRACE(__CTRACE_INPUT, "wgetch: curscr cury %d cury %d curscr curx %d curx %d\n", 827 __CTRACE(__CTRACE_INPUT, "wgetch: curscr cury %d cury %d curscr curx %d curx %d\n",
828 _cursesi_screen->curscr->cury, win->begy + win->cury, 828 _cursesi_screen->curscr->cury, win->begy + win->cury,
829 _cursesi_screen->curscr->curx, win->begx + win->curx); 829 _cursesi_screen->curscr->curx, win->begx + win->curx);
830#endif 830#endif
831 /* 831 /*
832 * Just in case the window is not dirty but the 832 * Just in case the window is not dirty but the
833 * cursor was moved, check and update the  833 * cursor was moved, check and update the
834 * cursor location. 834 * cursor location.
835 */ 835 */
836 mvcur(_cursesi_screen->curscr->cury, 836 mvcur(_cursesi_screen->curscr->cury,
837 _cursesi_screen->curscr->curx, 837 _cursesi_screen->curscr->curx,
838 win->cury + win->begy, win->curx + win->begx); 838 win->cury + win->begy, win->curx + win->begx);