From: Pasi Kallinen Date: Sun, 8 Mar 2015 13:11:01 +0000 (+0200) Subject: TTY: Prevent accidental escapes from string entries X-Git-Tag: NetHack-3.6.0_RC01~623 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8c048e60861d41a6da6b12378556af18fa36fe09;p=nethack TTY: Prevent accidental escapes from string entries 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. --- diff --git a/win/tty/getline.c b/win/tty/getline.c index 4a2d8c251..1e4e6c43f 100644 --- a/win/tty/getline.c +++ b/win/tty/getline.c @@ -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--;