From: PatR Date: Thu, 8 Apr 2021 18:42:55 +0000 (-0700) Subject: Qt text windows X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4445e06d1cce3d109fae18bbd322b6825a5f9d7d;p=nethack 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. --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 8618ab6dc..22bcbecfe 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -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 but - 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 diff --git a/win/Qt/qt_menu.cpp b/win/Qt/qt_menu.cpp index dd22e402d..b33058ae5 100644 --- a/win/Qt/qt_menu.cpp +++ b/win/Qt/qt_menu.cpp @@ -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); }