]> granicus.if.org Git - nethack/commitdiff
TTY: Prevent accidental escapes from string entries
authorPasi Kallinen <paxed@alt.org>
Sun, 8 Mar 2015 13:11:01 +0000 (15:11 +0200)
committerPasi Kallinen <paxed@alt.org>
Sun, 8 Mar 2015 13:11:01 +0000 (15:11 +0200)
On NAO, one of the major complaints was accidental escaping
from wishing prompt when using cursor keys.  The users were
trying to go "back" on the entry to fix a typo, but lost
the wish instead.

This prevents escaping out of a text prompt if there is any
text entered into the prompt; pressing escape clears the prompt.

win/tty/getline.c

index 4a2d8c25131aacfea40f9db47fc38380510e2cee..1e4e6c43f30cf75c9fc816bd08ce7c9cb73c9e03 100644 (file)
@@ -60,9 +60,19 @@ getlin_hook_proc hook;
                Strcat(strcat(strcpy(toplines, query), " "), obufp);
                c = pgetchar();
                if (c == '\033' || c == EOF) {
-                   obufp[0] = '\033';
-                   obufp[1] = '\0';
-                   break;
+                   if (c == '\033' && obufp[0] != '\0') {
+                       obufp[0] = '\0';
+                       bufp = obufp;
+                       tty_clear_nhwindow(WIN_MESSAGE);
+                       cw->maxcol = cw->maxrow;
+                       addtopl(query);
+                       addtopl(" ");
+                       addtopl(obufp);
+                   } else {
+                       obufp[0] = '\033';
+                       obufp[1] = '\0';
+                       break;
+                   }
                }
                if (ttyDisplay->intr) {
                    ttyDisplay->intr--;