width of curses menus
Menus with wide header or separator lines were rendered wide enough to avoid wrapping those lines, but ones with narrow header/separators and wide selectable entries were limited to half the display even though lots of lines that would fit with full width were being wrapped. Change the latter behavior. Menus are right justified with the edge of the map when narrower than it, left justified otherwise, and if the display is wider than the map, they'll extend beyond its right edge. (That hasn't actually changed; it's just that left-justification is more likely now that menus will be wide enough to show wide inventory lines without wrapping.) Get rid of my ridiculous hack to force wider menu for the 'symset' and 'roguesymset' sub-menus of 'O' since it's no longer useful. There's still room for improvement. If any lines need to be wrapped despite using the full width, or perhaps are just a lot wider than most of the entries, menu width could be narrowed to just enough for 'normal' lines to fit so that one or two really long entries don't distort the menu. That's a bit more complicated than I want to deal with right now. [If implemented, it would be relevant for tty too.]
This commit is contained in:
+4
-2
@@ -1,4 +1,4 @@
|
|||||||
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.168 $ $NHDT-Date: 1573290414 2019/11/09 09:06:54 $
|
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.171 $ $NHDT-Date: 1573505739 2019/11/11 20:55:39 $
|
||||||
|
|
||||||
This fixes36.3 file is here to capture information about updates in the 3.6.x
|
This fixes36.3 file is here to capture information about updates in the 3.6.x
|
||||||
lineage following the release of 3.6.2 in May 2019. Please note, however,
|
lineage following the release of 3.6.2 in May 2019. Please note, however,
|
||||||
@@ -221,7 +221,8 @@ playing music while hallucinating: message misspelled "butterflies"
|
|||||||
putting on gloves while having slippery fingers transfered slipperiness to
|
putting on gloves while having slippery fingers transfered slipperiness to
|
||||||
those gloves; taking off slippery gloves directly was disallowed but
|
those gloves; taking off slippery gloves directly was disallowed but
|
||||||
losing them in other ways transfered slipperiness to bare fingers
|
losing them in other ways transfered slipperiness to bare fingers
|
||||||
fix use of bcsign on a freed obj
|
when a monster reads a scroll of fire to cure sliming, don't access that
|
||||||
|
scroll's memory after it has been used up (bcsign)
|
||||||
|
|
||||||
|
|
||||||
Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository
|
Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository
|
||||||
@@ -329,6 +330,7 @@ curses: enable the 'use_inverse' boolean option (via wincap WC_INVERSE flag)
|
|||||||
to override default of False (for tty's benefit)
|
to override default of False (for tty's benefit)
|
||||||
curses: force 'O' command's menus for 'symset' and 'roguesymset' options to
|
curses: force 'O' command's menus for 'symset' and 'roguesymset' options to
|
||||||
be wider so that fewer entries with set descriptions will wrap
|
be wider so that fewer entries with set descriptions will wrap
|
||||||
|
curses: stop restricting menu width to half the display width
|
||||||
curses+'perm_invent': entries were wrapping without any control; usually not
|
curses+'perm_invent': entries were wrapping without any control; usually not
|
||||||
noticeable because next entry overwrote, but visible for final entry
|
noticeable because next entry overwrote, but visible for final entry
|
||||||
when whole inventory fit within the available height; looked ok with
|
when whole inventory fit within the available height; looked ok with
|
||||||
|
|||||||
+1
-39
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.6 options.c $NHDT-Date: 1572303730 2019/10/28 23:02:10 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.383 $ */
|
/* NetHack 3.6 options.c $NHDT-Date: 1573505739 2019/11/11 20:55:39 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.386 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Michael Allison, 2008. */
|
/*-Copyright (c) Michael Allison, 2008. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -5432,44 +5432,6 @@ boolean setinitial, setfromfile;
|
|||||||
tmpwin = create_nhwindow(NHW_MENU);
|
tmpwin = create_nhwindow(NHW_MENU);
|
||||||
start_menu(tmpwin);
|
start_menu(tmpwin);
|
||||||
any = zeroany;
|
any = zeroany;
|
||||||
#ifdef CURSES_GRAPHICS /* this ought to be handled within curses... */
|
|
||||||
/*
|
|
||||||
* Symbol sets are formatted in two columns, "name description",
|
|
||||||
* on selectable lines. curses bases menu width on the length
|
|
||||||
* of non-selectable lines (main header, separators if present,
|
|
||||||
* with trailing spaces ignored) and defaults to half the map.
|
|
||||||
* Without something like this separator (shown after the menu
|
|
||||||
* title and a blank line which follows that) to force a wider
|
|
||||||
* menu, entries with long descriptions wrap. That would be
|
|
||||||
* ok if wrapping operated on the same two columns, but the
|
|
||||||
* menu doesn't know anything about those and the description
|
|
||||||
* is wrapping into the next line's name column, making long
|
|
||||||
* descriptions--and menus containing them--hard to read.
|
|
||||||
*/
|
|
||||||
if (WINDOWPORT("curses")) {
|
|
||||||
char tmp1[BUFSZ], tmp2[BUFSZ], bigbuf[BUFSZ + 1 + BUFSZ];
|
|
||||||
|
|
||||||
/* 4: room for space+letter+paren+space, fake selector;
|
|
||||||
2: added to 'biggest' when constructing 'fmtstr';
|
|
||||||
1: space between symset name+2 and symset description */
|
|
||||||
if (4 + biggest + 2 + 1 > (int) sizeof tmp1 - 1)
|
|
||||||
biggest = (int) sizeof tmp1 - 1 - (4 + 2 + 1);
|
|
||||||
(void) memset((genericptr_t) tmp1, '-', biggest);
|
|
||||||
tmp1[biggest] = '\0';
|
|
||||||
if (big_desc > (int) sizeof tmp2 - 1)
|
|
||||||
big_desc = (int) sizeof tmp2 - 1;
|
|
||||||
(void) memset((genericptr_t) tmp2, '-', big_desc);
|
|
||||||
tmp2[big_desc] = '\0';
|
|
||||||
Sprintf(bigbuf, "%4s", "");
|
|
||||||
Sprintf(eos(bigbuf), fmtstr, tmp1, tmp2);
|
|
||||||
bigbuf[BUFSZ - 1] = '\0';
|
|
||||||
any.a_int = 0;
|
|
||||||
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE,
|
|
||||||
bigbuf, MENU_UNSELECTED);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
nhUse(big_desc);
|
|
||||||
#endif
|
|
||||||
any.a_int = 1; /* -1 + 2 [see 'if (sl->name) {' below]*/
|
any.a_int = 1; /* -1 + 2 [see 'if (sl->name) {' below]*/
|
||||||
if (!symset_name)
|
if (!symset_name)
|
||||||
defindx = any.a_int;
|
defindx = any.a_int;
|
||||||
|
|||||||
+19
-20
@@ -759,11 +759,10 @@ curses_display_nhmenu(winid wid, int how, MENU_ITEM_P ** _selected)
|
|||||||
menu_determine_pages(current_menu);
|
menu_determine_pages(current_menu);
|
||||||
|
|
||||||
/* Display pre and post-game menus centered */
|
/* Display pre and post-game menus centered */
|
||||||
if (((moves <= 1) && !invent) || program_state.gameover) {
|
if ((moves <= 1 && !invent) || program_state.gameover) {
|
||||||
win = curses_create_window(current_menu->width,
|
win = curses_create_window(current_menu->width,
|
||||||
current_menu->height, CENTER);
|
current_menu->height, CENTER);
|
||||||
} else { /* Display during-game menus on the right out of the way */
|
} else { /* Display during-game menus on the right out of the way */
|
||||||
|
|
||||||
win = curses_create_window(current_menu->width,
|
win = curses_create_window(current_menu->width,
|
||||||
current_menu->height, RIGHT);
|
current_menu->height, RIGHT);
|
||||||
}
|
}
|
||||||
@@ -1000,13 +999,13 @@ static void
|
|||||||
menu_win_size(nhmenu *menu)
|
menu_win_size(nhmenu *menu)
|
||||||
{
|
{
|
||||||
int maxwidth, maxheight, curentrywidth, lastline;
|
int maxwidth, maxheight, curentrywidth, lastline;
|
||||||
int maxentrywidth = (int) strlen(menu->prompt);
|
int maxentrywidth = 0;
|
||||||
int maxheaderwidth = 0;
|
int maxheaderwidth = menu->prompt ? (int) strlen(menu->prompt) : 0;
|
||||||
nhmenu_item *menu_item_ptr;
|
nhmenu_item *menu_item_ptr;
|
||||||
|
|
||||||
if (program_state.gameover) {
|
if (program_state.gameover) {
|
||||||
/* for final inventory disclosure, use full width */
|
/* for final inventory disclosure, use full width */
|
||||||
maxwidth = term_cols - 2;
|
maxwidth = term_cols - 2; /* +2: borders assumed */
|
||||||
} else {
|
} else {
|
||||||
/* this used to be 38, which is 80/2 - 2 (half a 'normal' sized
|
/* this used to be 38, which is 80/2 - 2 (half a 'normal' sized
|
||||||
screen minus room for a border box), but some data files
|
screen minus room for a border box), but some data files
|
||||||
@@ -1029,7 +1028,7 @@ menu_win_size(nhmenu *menu)
|
|||||||
maxheaderwidth = curentrywidth;
|
maxheaderwidth = curentrywidth;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Add space for accelerator */
|
/* Add space for accelerator (selector letter) */
|
||||||
curentrywidth += 4;
|
curentrywidth += 4;
|
||||||
#if 0 /* FIXME: menu glyphs */
|
#if 0 /* FIXME: menu glyphs */
|
||||||
if (menu_item_ptr->glyph != NO_GLYPH && iflags.use_menu_glyphs)
|
if (menu_item_ptr->glyph != NO_GLYPH && iflags.use_menu_glyphs)
|
||||||
@@ -1041,20 +1040,20 @@ menu_win_size(nhmenu *menu)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If widest entry is smaller than maxwidth, reduce maxwidth
|
/*
|
||||||
accordingly (but not too far; minimum width will be applied below) */
|
* 3.6.3: This used to set maxwidth to maxheaderwidth when that was
|
||||||
if (maxentrywidth < maxwidth) {
|
* bigger but only set it to maxentrywidth if the latter was smaller,
|
||||||
maxwidth = maxentrywidth;
|
* so entries wider than the default would always wrap unless at
|
||||||
}
|
* least one header or separator line was long, even when there was
|
||||||
|
* lots of space available to display them without wrapping. The
|
||||||
/* Try not to wrap headers/normal text lines if possible. We can
|
* reason to force narrow menus isn't known. It may have been to
|
||||||
go wider than half the screen for this purpose if need be */
|
* reduce the amount of map rewriting when menu is dismissed, but if
|
||||||
|
* so, that was an issue due to excessive screen writing for the map
|
||||||
if (maxheaderwidth > maxwidth) {
|
* (output was flushed for each character) which was fixed long ago.
|
||||||
if (maxheaderwidth < (term_cols - 2))
|
*/
|
||||||
maxwidth = maxheaderwidth;
|
maxwidth = max(maxentrywidth, maxheaderwidth);
|
||||||
else
|
if (maxwidth > term_cols - 2) { /* -2: space for left and right borders */
|
||||||
maxwidth = term_cols - 2;
|
maxwidth = term_cols - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Possibly reduce height if only 1 page */
|
/* Possibly reduce height if only 1 page */
|
||||||
|
|||||||
Reference in New Issue
Block a user