From 8c048e60861d41a6da6b12378556af18fa36fe09 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sun, 8 Mar 2015 15:11:01 +0200 Subject: [PATCH] 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. --- win/tty/getline.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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--;