]> granicus.if.org Git - nethack/commitdiff
TTY: Treat carriage return as newline
authorPasi Kallinen <paxed@alt.org>
Tue, 14 Nov 2017 13:57:18 +0000 (15:57 +0200)
committerPasi Kallinen <paxed@alt.org>
Tue, 14 Nov 2017 14:14:06 +0000 (16:14 +0200)
Before this change, more-prompts and input text -prompts could not
be accepted with carriage return. Now, just like in menus, carriage
return is treated the same as a newline.

To test, use 'stty -icrnl'

doc/fixes36.1
win/tty/getline.c
win/tty/wintty.c

index 04d4f53a18590579b721f5978834612982479bed..c064ebb7f59372a47d8a32ba47e55131c4978b14 100644 (file)
@@ -596,6 +596,7 @@ PANICTRACE: PANICTRACE_GDB used wrong value for ARGV0 when launching gdb if
 win32gui: gather raw_print error messages into a single dialog window
 win32tty: fix display errors when using a font with double wide or ambiguous
        width characters
+tty: treat carriage return as a newline for input text and more-prompts
 
 
 General New Features
index f3dd6cbf2f0ec64a50ab339b3a762c30fb4f0878..a73fa4060d01867ca28993f9bd2ae9e82eae5145 100644 (file)
@@ -129,11 +129,7 @@ getlin_hook_proc hook;
 #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 */
@@ -213,7 +209,7 @@ register const char *s; /* chars allowed besides return */
         !program_state.done_hup &&
 #endif
         (c = tty_nhgetch()) != EOF) {
-        if (c == '\n')
+        if (c == '\n' || c == '\r')
             break;
 
         if (iflags.cbreak) {
@@ -223,7 +219,7 @@ register const char *s; /* chars allowed besides return */
                 morc = '\033';
                 break;
             }
-            if ((s && index(s, c)) || c == x) {
+            if ((s && index(s, c)) || c == x || (x == '\n' && c == '\r')) {
                 morc = (char) c;
                 break;
             }
index 821239c68c6fe9cb40eb5da87f1ededa8cc835de..32dc6b3c57a6113e4cdc4c581ede7ee3569e7d9b 100644 (file)
@@ -1167,6 +1167,8 @@ tty_askname()
         while ((c = tty_nhgetch()) != '\n') {
             if (c == EOF)
                 c = '\033';
+            if (c == '\r')
+                break;
             if (c == '\033') {
                 ct = 0;
                 break;