]> granicus.if.org Git - nethack/commitdiff
Qt prompt highlighting
authorPatR <rankin@nethack.org>
Thu, 8 Oct 2020 18:24:11 +0000 (11:24 -0700)
committerPatR <rankin@nethack.org>
Thu, 8 Oct 2020 18:24:11 +0000 (11:24 -0700)
When qt_yn_function() or qt_more() is asking for a single character
response, typing anything will cause the prompt line in the message
window to stop being highlighted.  If they reject what's been typed,
they beep (--More-- doesn't start beeping until second rejection);
change both of them to also rehighlight the prompt line to give a
visual indication that the question/acknowledgement is still being
asked.

win/Qt/qt_bind.cpp
win/Qt/qt_msg.cpp
win/Qt/qt_msg.h

index 0e1f362a85f913f3a6a796b16fb707b443353b1b..5fb65f980a1e35b4259a47c9c36aabc55a166a3a 100644 (file)
@@ -588,6 +588,11 @@ char NetHackQtBind::qt_more()
             default:
                 if (++complain > 1)
                     NetHackQtBind::qt_nhbell();
+                // typing anything caused the most recent message line
+                // (which happens to our prompt) from having highlighting
+                // be removed; put that back
+                if (mesgwin)
+                    mesgwin->RehighlightPrompt();
                 retry = true;
                 break;
             }
@@ -669,6 +674,13 @@ char NetHackQtBind::qt_yn_function(const char *question_,
                     Strcpy(cbuf, visctrl(def));
                } else {
                    NetHackQtBind::qt_nhbell();
+                    // typing anything caused the most recent message line
+                    // (which happens to our prompt) from having highlighting
+                    // be removed; put that back
+                    NetHackQtMessageWindow
+                            *mesgwin = main ? main->GetMessageWindow() : NULL;
+                    if (mesgwin)
+                        mesgwin->RehighlightPrompt();
                    // and try again...
                }
            } else {
index bdd8f535c6d5821dcb0847c5fe24c7c6c1c7f4f5..c9c3537b886ac5eaa21bc1783db98a4f1190564c 100644 (file)
@@ -184,6 +184,14 @@ void NetHackQtMessageWindow::AddToStr(const char *answer)
     }
 }
 
+// used when yn_function() or more() rejects player's input and tries again
+void NetHackQtMessageWindow::RehighlightPrompt()
+{
+    // selects most recent message, which causes it to be highlighted
+    if (list && list->count())
+        list->setCurrentRow(list->count() - 1);
+}
+
 // are there any highlighted messages?
 bool NetHackQtMessageWindow::hilit_mesgs()
 {
index c3cd4275c687e78158cad8f902a23ea80e2e2501..ca84acaf57f84ffe84bc3c21d125b941e8be6d61 100644 (file)
@@ -30,6 +30,7 @@ public:
 
        void setMap(NetHackQtMapWindow2*);
 
+        void RehighlightPrompt();
         bool hilit_mesgs();
         void unhighlight_mesgs();
         // for adding the answer for yn() to its prompt string