]> granicus.if.org Git - nethack/commitdiff
make recent autocomplete changes conditional
authornethack.allison <nethack.allison>
Sun, 22 Dec 2002 02:46:08 +0000 (02:46 +0000)
committernethack.allison <nethack.allison>
Sun, 22 Dec 2002 02:46:08 +0000 (02:46 +0000)
- there are problems with the changes on
at least the win32 tty port.

win/tty/getline.c

index a62f8764c66bdc3dc130b7035153fb488d7cd2d1..cd0dae2254200ebbc338082a84e9953127149f09 100644 (file)
@@ -59,6 +59,9 @@ getlin_hook_proc hook;
                Sprintf(toplines, "%s ", query);
                Strcat(toplines, obufp);
                if((c = Getchar()) == EOF) {
+#ifndef NEWAUTOCOMP
+                       *bufp = 0;
+#endif /* not NEWAUTOCOMP */
                        break;
                }
                if(c == '\033') {
@@ -100,32 +103,46 @@ getlin_hook_proc hook;
                }
                if(c == erase_char || c == '\b') {
                        if(bufp != obufp) {
+#ifdef NEWAUTOCOMP
                                char *i;
 
+#endif /* NEWAUTOCOMP */
                                bufp--;
+#ifndef NEWAUTOCOMP
+                               putsyms("\b \b");/* putsym converts \b */
+#else /* NEWAUTOCOMP */
                                putsyms("\b");
                                for (i = bufp; *i; ++i) putsyms(" ");
                                for (; i > bufp; --i) putsyms("\b");
                                *bufp = 0;
+#endif /* NEWAUTOCOMP */
                        } else  tty_nhbell();
 #if defined(apollo)
                } else if(c == '\n' || c == '\r') {
 #else
                } else if(c == '\n') {
 #endif
+#ifndef NEWAUTOCOMP
+                       *bufp = 0;
+#endif /* not NEWAUTOCOMP */
                        break;
                } else if(' ' <= (unsigned char) c && c != '\177' &&
                            (bufp-obufp < BUFSZ-1 && bufp-obufp < COLNO)) {
                                /* avoid isprint() - some people don't have it
                                   ' ' is not always a printing char */
+#ifdef NEWAUTOCOMP
                        char *i = eos(bufp);
 
+#endif /* NEWAUTOCOMP */
                        *bufp = c;
                        bufp[1] = 0;
                        putsyms(bufp);
                        bufp++;
                        if (hook && (*hook)(obufp)) {
                            putsyms(bufp);
+#ifndef NEWAUTOCOMP
+                           bufp = eos(bufp);
+#else /* NEWAUTOCOMP */
                            /* pointer and cursor left where they were */
                            for (i = bufp; *i; ++i) putsyms("\b");
                        } else if (i > bufp) {
@@ -134,12 +151,20 @@ getlin_hook_proc hook;
                            /* erase rest of prior guess */
                            for (; i > bufp; --i) putsyms(" ");
                            for (; s > bufp; --s) putsyms("\b");
+#endif /* NEWAUTOCOMP */
                        }
                } else if(c == kill_char || c == '\177') { /* Robert Viduya */
                                /* this test last - @ might be the kill_char */
+#ifndef NEWAUTOCOMP
+                       while(bufp != obufp) {
+                               bufp--;
+                               putsyms("\b \b");
+                       }
+#else /* NEWAUTOCOMP */
                        for (; *bufp; ++bufp) putsyms(" ");
                        for (; bufp != obufp; --bufp) putsyms("\b \b");
                        *bufp = 0;
+#endif /* NEWAUTOCOMP */
                } else
                        tty_nhbell();
        }