From 4e323643130d11977f6b83e0021a752ad5372ddf Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 2 Jun 2023 11:42:18 -0700 Subject: [PATCH] fix #K3934 - curses menu bug when entering count Entering a multi-digit count when selecting from a menu in the curses interface causes the menu to disappear. Report was about putting a large subset of an object stack into a container but the bug affected all menus that accepted counts. curses_get_count() was changed to call core's get_count() quite a while back. get_count() calls mark_synch() when more that one digit is typed or when backspace to remove the first digit occurs. curses_mark_synch() had been a no-op but more recently it was changed to try to make sure that the screen was up to date. But it did that by refreshing the persistent windows, making any temporary popup menu or text window become hidden. Also, the count-in-progress is being sent to the message window with the no-history flag, so refreshing the message window removed that too. Switch curses_mark_synch() to use the basic screen refresh call that doesn't do anything window-specific. This also changes menu count handling to have get_count() echo the number starting with the first digit instead of waiting until the second. If anything in the menu makes it be very wide it can cover up the message window and any count being echoed there won't be visible. I'm not going to try to figure out how to deal with that; it isn't all that different from the old single-digit/unseen-count behavior. --- doc/fixes3-7-0.txt | 3 +++ win/curses/cursmain.c | 6 +++++- win/curses/cursmisc.c | 8 ++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index f9cf10c96..fd4c4d094 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1642,6 +1642,9 @@ curses: typing ESC to cancel something issued a beep; if the terminal was set curses: with window borders on and align_status:left, restoring brought up a screen where the message window's border wasn't shown; once it needed to be scrolled to fit a new message, the border appeared +curses: after changing curses_mark_synch() to do something, making a menu + selection by entering a count that uses more than 1 digit caused the + menu to vanish Qt: at Xp levels above 20 with 'showexp' On, the combined status field "Level:NN/nnnnnnnn" was too big and truncated by a char at each end Qt: searching a text window for something that wasn't found and then searching diff --git a/win/curses/cursmain.c b/win/curses/cursmain.c index 2c0c8a16a..ba76ecf4e 100644 --- a/win/curses/cursmain.c +++ b/win/curses/cursmain.c @@ -751,7 +751,11 @@ mark_synch() -- Don't go beyond this point in I/O on any channel until void curses_mark_synch(void) { - curses_refresh_nethack_windows(); + /* full refresh has unintended side-effect of making a menu window + that has called core's get_count() to vanish; do a basic screen + refresh instead */ + /*curses_refresh_nethack_windows();*/ + refresh(); } /* diff --git a/win/curses/cursmisc.c b/win/curses/cursmisc.c index ef07fb602..2ee464fe1 100644 --- a/win/curses/cursmisc.c +++ b/win/curses/cursmisc.c @@ -712,11 +712,11 @@ curses_get_count(int first_digit) curses's message window will display that in count window instead */ current_char = get_count(NULL, (char) first_digit, /* 0L => no limit on value unless it wraps - to negative */ + * to negative */ 0L, ¤t_count, - /* default: don't put into message history, - don't echo until second digit entered */ - GC_NOFLAGS); + /* don't put into message history, echo full + * number rather than waiting until 2nd digit */ + GC_ECHOFIRST); ungetch(current_char); if (current_char == '\033') { /* Cancelled with escape */