From: PatR Date: Sat, 18 May 2019 15:12:43 +0000 (-0700) Subject: curses followup X-Git-Tag: nmake-explicit-path~2^2~128 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a19e64e470;p=nethack curses followup Some prompts were being overwritten by the message that followed. And clear_nhwindow(WIN_MESSAGE) gets called for just about every keystroke so try to reduce the overhead I unwittingly added. The "scroll up one line earlier than the next message" mentioned in the prior commit is much more obvious that I realized and prompt erasure might need to be redone. --- diff --git a/win/curses/cursmesg.c b/win/curses/cursmesg.c index f9a8468d6..a32b6824b 100644 --- a/win/curses/cursmesg.c +++ b/win/curses/cursmesg.c @@ -398,15 +398,27 @@ curses_count_window(const char *count_text) /* if most recent message (probably prompt leading to this instance of counting window) is going to be covered up, scroll mesgs up a line */ - if (!counting && my + 1 >= border + messageh) { + if (!counting && my >= border + (messageh - 1)) { scroll_window(MESSAGE_WIN); - /* last position within the message window */ - my = border + (messageh - 1) - 1; - mx = border; + if (messageh > 1) { + /* handling for next message will behave as if we're currently + positioned at the end of next to last line of message window */ + my = border + (messageh - 1) - 1; + mx = border + (messagew - 1); /* (0 + 80 - 1) or (1 + 78 - 1) */ + } else { + /* for a one-line window, use beginning of only line instead */ + my = mx = border; /* 0 or 1 */ + } /* wmove(curses_get_nhwin(MESSAGE_WIN), my, mx); -- not needed */ } - counting = TRUE; + /* in case we're being called from clear_nhwindow(MESSAGE_WIN) + which gets called for every command keystroke; it sends an + empty string to get the scroll-up-one-line effect above and + we want to avoid the curses overhead for the operations below... */ + if (!*count_text) + return; + counting = TRUE; #ifdef PDCURSES if (countwin) curses_destroy_win(countwin), countwin = NULL;