]> granicus.if.org Git - nethack/commitdiff
clear stale prompt
authornethack.rankin <nethack.rankin>
Sat, 7 May 2005 03:52:52 +0000 (03:52 +0000)
committernethack.rankin <nethack.rankin>
Sat, 7 May 2005 03:52:52 +0000 (03:52 +0000)
     From the newsgroup:  applying various types of tools (example was a
mirror; figurine is another case) and then typing <ESC> 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
src/cmd.c
src/do_name.c

index c8da32f45081ea60c595a42278946f8de721ecc5..0e135111c6fa7a2a717a1df8317fcdce622478b5 100644 (file)
@@ -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
index 35629ffe84bd268fe6f8796aaecdd18e63de4cc8..7282edad56ceb69066d3ee89f7508e1cc4ed22d5 100644 (file)
--- 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,
index 611d385bcddbafdf69a8e0a9e3da596172bcab3d..0f6e7a1a76943ef3c3b67776a6a5ec9ced389180 100644 (file)
@@ -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];