From 5ba35e50b3ffcf93ec56d5a7372c88bd03028ee6 Mon Sep 17 00:00:00 2001 From: otto Date: Mon, 3 Jun 2024 09:43:10 +0000 Subject: [PATCH] Fix input handling wrt redrawing. The new version of curses does not like shortcutting switching windows, especially if you're also using libc for i/o. Reported by Don Wilburn; ok jsg@ --- games/cribbage/io.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/games/cribbage/io.c b/games/cribbage/io.c index ec9ce54badf..7dfa94de8f6 100644 --- a/games/cribbage/io.c +++ b/games/cribbage/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.22 2016/01/10 13:35:09 mestre Exp $ */ +/* $OpenBSD: io.c,v 1.23 2024/06/03 09:43:10 otto Exp $ */ /* $NetBSD: io.c,v 1.9 1997/07/09 06:25:47 phil Exp $ */ /*- @@ -505,14 +505,12 @@ get_line(void) { size_t pos; int c, oy, ox; - WINDOW *oscr; - oscr = stdscr; - stdscr = Msgwin; - getyx(stdscr, oy, ox); - refresh(); + getyx(Msgwin, oy, ox); + wrefresh(Msgwin); /* loop reading in the string, and put it in a temporary buffer */ - for (pos = 0; (c = readchar()) != '\n'; clrtoeol(), refresh()) { + for (pos = 0; (c = readchar()) != '\n'; wclrtoeol(Msgwin), + wrefresh(Msgwin)) { if (c == -1) continue; if (c == ' ' && (pos == 0 || linebuf[pos - 1] == ' ')) @@ -522,13 +520,13 @@ get_line(void) int i; pos--; for (i = strlen(unctrl(linebuf[pos])); i; i--) - addch('\b'); + waddch(Msgwin, '\b'); } continue; } if (c == killchar()) { pos = 0; - move(oy, ox); + wmove(Msgwin, oy, ox); continue; } if (pos >= LINESIZE - 1 || !(isalnum(c) || c == ' ')) { @@ -538,12 +536,11 @@ get_line(void) if (islower(c)) c = toupper(c); linebuf[pos++] = c; - addstr(unctrl(c)); + waddstr(Msgwin, unctrl(c)); Mpos++; } while (pos < sizeof(linebuf)) linebuf[pos++] = '\0'; - stdscr = oscr; return (linebuf); } -- 2.20.1