]> granicus.if.org Git - nethack/commitdiff
Fix bz66: Count number cannot be backspaced
authorPasi Kallinen <paxed@alt.org>
Wed, 6 Jan 2016 09:50:07 +0000 (11:50 +0200)
committerPasi Kallinen <paxed@alt.org>
Wed, 6 Jan 2016 09:50:10 +0000 (11:50 +0200)
... or at least partially fix it - ^H does now backspace.
I can't be bothered to dive into the (n)curses raw-mode stuff.

src/cmd.c

index 191ab71f3443466f3767d5756f8e808efc048de3..dc1ae79dff4b2f080e6e72579bdc8f9c8c006511 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -3874,6 +3874,7 @@ parse()
 #endif
     register int foo;
     boolean prezero = FALSE;
+    boolean backspaced = FALSE;
 
     multi = 0;
     context.move = 1;
@@ -3885,13 +3886,23 @@ parse()
     if (!Cmd.num_pad || (foo = readchar()) == 'n')
         for (;;) {
             foo = readchar();
-            if (foo >= '0' && foo <= '9') {
-                multi = 10 * multi + foo - '0';
+            if ((foo >= '0' && foo <= '9') || (foo == '\b')) {
+                if (foo >= '0' && foo <= '9')
+                    multi = 10 * multi + foo - '0';
+                else {
+                    multi = multi / 10;
+                    backspaced = TRUE;
+                }
                 if (multi < 0 || multi >= LARGEST_INT)
                     multi = LARGEST_INT;
-                if (multi > 9) {
+                if (multi > 9 || backspaced) {
                     clear_nhwindow(WIN_MESSAGE);
-                    Sprintf(in_line, "Count: %d", multi);
+                    if (backspaced && !multi)
+                        Sprintf(in_line, "Count: ");
+                    else {
+                        Sprintf(in_line, "Count: %d", multi);
+                        backspaced = FALSE;
+                    }
                     pline1(in_line);
                     mark_synch();
                 }