From bb190167850c9fbc7f86c18cf1546ee1e25231d4 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Sat, 7 May 2005 03:52:52 +0000 Subject: [PATCH] clear stale prompt From the newsgroup: applying various types of tools (example was a mirror; figurine is another case) and then typing at the "In what direction?" prompt would leave the prompt displayed. User complained that he tried to answer the no longer valid prompt--even though the cursor had correctly moved back to the '@' on his map--and ended up walking into lava instead. Suggested fix in the newsgroup was to use pline("Never mind.") the way many commands already do, but it's simpler and more robust to clear the message window before getdir() returns. Callers can issue Never_mind feedback on a case by case basis as before; I haven't added any here. Perhaps getpos() should get passed an extra argument telling it to issue that message; then a dozen or so pline(Never_mind) calls could be removed. I also was annoyed that ^R gave me the command assist display instead of redrawing the screen with the prompt intact. This fixes it for getdir(). The corresponding fix for getpos() doesn't work correctly; it successfully redraws the screen but leaves the cursor at the end of the 2nd status line, despite the fact that it is followed by an existing cursor position call. Can someone who understands the relevant windowing code fix ^R in getpos()? (Easiest test case is probably just ^T in wizard mode.) I have't added an entry for ^R to the fixes file since it isn't fixed yet. And I didn't look to see whether yn_function() ought to handle ^R too; it might be used in contexts where map redraws don't make sense. --- doc/fixes34.4 | 1 + src/cmd.c | 13 +++++++++++-- src/do_name.c | 11 +++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/doc/fixes34.4 b/doc/fixes34.4 index c8da32f45..0e135111c 100644 --- a/doc/fixes34.4 +++ b/doc/fixes34.4 @@ -120,6 +120,7 @@ probing the resulting double-gold monster caused "static object freed" panic cursed wand might explode if used to engrave fatal wish from magic lamp left functional magic lamp in bones data fatal wish granted by monster left that monster in bones data +clear prompt from screen after ESC is used to abort "In what direction?" Platform- and/or Interface-Specific Fixes diff --git a/src/cmd.c b/src/cmd.c index 35629ffe8..7282edad5 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)cmd.c 3.5 2004/10/27 */ +/* SCCS Id: @(#)cmd.c 3.5 2005/05/06 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2170,15 +2170,24 @@ const char *s; #endif dirsym = yn_function((s && *s != '^') ? s : "In what direction?", (char *)0, '\0'); + + if (dirsym == C('r')) { /* ^R */ + docrt(); /* redraw */ + goto retry; + } #ifdef REDO savech(dirsym); #endif + if (dirsym == '.' || dirsym == 's') { u.dx = u.dy = u.dz = 0; } else if (!movecmd(dirsym) && !u.dz) { boolean did_help = FALSE, help_requested; - if (!index(quitchars, dirsym)) { + if (index(quitchars, dirsym)) { + /* remove the prompt string */ + clear_nhwindow(WIN_MESSAGE); + } else { help_requested = (dirsym == '?'); if (help_requested || iflags.cmdassist) { did_help = help_dir((s && *s == '^') ? dirsym : 0, diff --git a/src/do_name.c b/src/do_name.c index 611d385bc..0f6e7a1a7 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)do_name.c 3.5 2003/01/14 */ +/* SCCS Id: @(#)do_name.c 3.5 2005/05/06 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -23,6 +23,11 @@ nextmbuf() return bufs[bufidx]; } +/* same definition as in cmd.c */ +#ifndef C +#define C(a) ((a) & 0x1f) /* ^a */ +#endif + /* the response for '?' help request in getpos() */ STATIC_OVL void getpos_help(force, goal) @@ -97,7 +102,7 @@ const char *goal; } if ((cp = index(pick_chars, c)) != 0) { /* '.' => 0, ',' => 1, ';' => 2, ':' => 3 */ - result = cp - pick_chars; + result = (int)(cp - pick_chars); break; } for (i = 0; i < 8; i++) { @@ -136,6 +141,8 @@ const char *goal; if(c == '?'){ getpos_help(force, goal); + } else if (c == C('r')) { /* ^R */ + docrt(); /* redraw */ } else { if (!index(quitchars, c)) { char matching[MAXPCHARS]; -- 2.40.0