Qt text windows

For Qt, always render text windows with fixed width font instead
of switching from proportional to fixed when the text contains
any line(s) with four consecutive spaces.  That was really meant
for menu lines without selector letters which want to be lined
up under or over ones with such, and wasn't a very good heuristic
for text windows.

Most of the text files for the '?' command happen to have such
lines so are already being shown with fixed-width font.  data.base
entries were hit or miss; most have attribution lines indented by
four or more spaces but some don't, so display was inconsistent:
some were shown with fixed-width font and some with proportional.
This commit is contained in:
PatR
2021-04-08 11:42:55 -07:00
parent 28f112fb17
commit 4445e06d1c
2 changed files with 24 additions and 2 deletions

View File

@@ -709,7 +709,14 @@ Qt: when a new message is issued, pan the message window to its left edge if
Qt: there was no way to enter extended command "#version" by typing; command
name matching was waiting to disambiguate it from "#versionshort"
and the only way to that was to type #version<return> but <return>
explicitly triggered rejection, cancelling '#' processing
explicitly triggered rejection, cancelling '#' processing; #drop vs
"droptype, "known vs "knownclass, and #takeoff vs #takeoffall are in
similar ambiguous situation but usually invoked via keystroke
Qt: render all text windows in fixed-width font instead of just ones which
have one or more lines with four consecutive spaces; some data.base
entries do have those (usually final attribution) and some don't,
so display from one entry to another was inconsistent if default
proportional font was ever used
Qt: while a text window was shown (such as the "things that are here" popup
when stepping on items), typing commands had the input passed on to
the map and then executed; sometimes that caused the not-yet-dismissed

View File

@@ -1147,9 +1147,24 @@ void NetHackQtTextWindow::Display(bool block UNUSED)
textsearching = false;
}
// handle a line of text for a text window
void NetHackQtTextWindow::PutStr(int attr UNUSED, const QString& text)
{
str_fixed=str_fixed || text.contains(" ");
#if 1
// 3.7: Always render text windows with fixed-width font. The majority
// of text files we'll ever display including ('license' and 'history')
// happen to have some lines with four spaces anyway and/or they have
// been pre-formatted to fit within less than 80 columns. For data.base
// entries, some do have four spaces (usually the final attribution)
// and some don't, resulting in inconsistent display from one entry to
// another if the default proportional font is ever used.
str_fixed = true;
#else
// if any line contains four consecutive spaces, render this text window
// using fixed-width font; skip substring lookup if flag is already set
str_fixed = str_fixed || text.contains(" ");
#endif
// instead of outputting the line directly, save it for future rendering
lines->addItem(text);
}