From de44286d794549d125683594ba87f750564dc099 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 28 Jun 2019 17:00:20 -0700 Subject: [PATCH] curses+EDIT_GETLIN again Turns the "fix" in commit 319dcf4746a81ef0ca413491bdf30b4c08f931c2 handled removing the default answer for single-line-prompt plus multi-line-answer but not for multi-line-prompt plus long-enough- answer-to-reach-another-line. The logic wasn't quite right and I misunderstood what is stored in linestarts[] so even correct logic wouldn't have solved things. --- doc/fixes36.3 | 5 ++++- win/curses/cursmesg.c | 13 +++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/doc/fixes36.3 b/doc/fixes36.3 index 5b177c06e..648ef6902 100644 --- a/doc/fixes36.3 +++ b/doc/fixes36.3 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.77 $ $NHDT-Date: 1561751390 2019/06/28 19:49:50 $ +$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.78 $ $NHDT-Date: 1561766416 2019/06/29 00:00:16 $ This fixes36.3 file is here to capture information about updates in the 3.6.x lineage following the release of 3.6.2 in May 2019. Please note, however, @@ -177,6 +177,9 @@ curses+'popup_dialog': show the text cursor at the end of prompts for single character input curses+EDIT_GETLIN: when a prompt's answer was preloaded, using ESC to discard it deleted it from the answer buffer but didn't erase it from screen +curses+EDIT_GETLIN: the preceding fix handled an answer which spanned more + than one line but didn't remove the answer properly if the prompt + portion of prompt+answer spanned more than one line tty: re-do one optimization used when status conditions have all been removed and remove another that tried to check whether condition text to be displayed next was the same as the existing value; sometimes new diff --git a/win/curses/cursmesg.c b/win/curses/cursmesg.c index b0a28b15b..0e67787a0 100644 --- a/win/curses/cursmesg.c +++ b/win/curses/cursmesg.c @@ -550,12 +550,13 @@ curses_message_win_getline(const char *prompt, char *answer, int buffer) if that is called for; find where the end of the prompt will be without the answer appended */ while (ltmp2 > 0) { - ltmp2 -= ltmp; + if ((ltmp2 -= ltmp) < 0) { + ltmp = -ltmp2; + break; + } promptline -= 1; - ltmp = (int) strlen(linestarts[promptline]); + ltmp = linestarts[promptline + 1] - linestarts[promptline]; } - if (ltmp2 < 0) - ltmp = -ltmp2; promptx = ltmp + border_space; } #endif @@ -597,11 +598,11 @@ curses_message_win_getline(const char *prompt, char *answer, int buffer) #endif curs_set(0); - if (erase_char && ch == erase_char) { + if (erase_char && ch == (int) (uchar) erase_char) { ch = '\177'; /* match switch-case below */ /* honor kill_char if it's ^U or similar, but not if it's '@' */ - } else if (kill_char && ch == kill_char + } else if (kill_char && ch == (int) (uchar) kill_char && (ch < ' ' || ch >= '\177')) { /*ASCII*/ if (len == 0) /* nothing to kill; just start over */ continue;