fix part of github issue #1285 - cursed curses

Issue reported by g-branden-robinson:  vertical status panel ended
up with an extra closing paren on the energy line, and sometimes
popups left some text and/or border to the right of the map.

I haven't been able to reproduce the energy anomaly.  It is possible
that it is dependent on the version of curses.

This fixes the leftover popup traces that the base window catches
(and hangs onto) when there is extra space to the right of the map.
Erasing a popup prior to deleting it suffices to make base window
forget it.

I have a more elaborate fix that covers the space to the right of
the map, when there is some, with an extra window and erases that
window when refreshing the map.  It works but adds a bunch of code
that we can get by without.

Issue #1285 is still open.
This commit is contained in:
PatR
2024-09-19 01:41:24 -07:00
parent d126ae9a42
commit 5e572d3d5f
2 changed files with 27 additions and 2 deletions

View File

@@ -199,6 +199,27 @@ curses_set_wid_colors(int wid, WINDOW *win)
void
curses_destroy_win(WINDOW *win)
{
int mapwidth = 0, winwidth, dummyht;
/*
* In case map is narrower than the space alloted for it, if we
* are destroying a popup window and it is wider than the map,
* erase the popup first. It probably has overwritten some of
* the next-to-map empty space. If we don't clear that now, the
* base window will remember it and redisplay it during refreshes.
*
* Note: since we almost never destroy non-popups, we don't really
* need to determine whether 'win' is one. Overhead for unnecessary
* erasure is negligible.
*/
getmaxyx(win, dummyht, winwidth); /* macro, assigns to its args */
if (mapwin)
getmaxyx(mapwin, dummyht, mapwidth);
if (winwidth > mapwidth) {
werase(win);
wnoutrefresh(win);
}
delwin(win);
if (win == activemenu)
activemenu = NULL;
@@ -329,8 +350,9 @@ curses_parse_wid_colors(int wid, char *fg, char *bg)
/* Add curses window pointer and window info to list for given NetHack winid */
void
curses_add_nhwin(winid wid, int height, int width, int y, int x,
orient orientation, boolean border)
curses_add_nhwin(
winid wid, int height, int width, int y, int x,
orient orientation, boolean border)
{
WINDOW *win;
int real_width = width;