]> git.eshelyaron.com Git - emacs.git/commitdiff
Implement echo suppression in non-interactive mode for MS-Windows.
authorEli Zaretskii <eliz@gnu.org>
Fri, 11 Jul 2014 13:58:02 +0000 (16:58 +0300)
committerEli Zaretskii <eliz@gnu.org>
Fri, 11 Jul 2014 13:58:02 +0000 (16:58 +0300)
 src/minibuf.c (read_minibuf_noninteractive): Finish reading on '\r',
 not only on '\n'.
 src/sysdep.c (emacs_get_tty, emacs_set_tty, suppress_echo_on_tty)
 [DOS_NT]: Implement for WINDOWSNT.
 src/systty.h (struct emacs_tty) [DOS_NT]: The struct member is now
 unsigned.

Fixes: debbugs:17839
src/ChangeLog
src/minibuf.c
src/sysdep.c
src/systty.h

index a5debc00acf98ea86b6902abf0c4c173bb8b690f..a016f3cadc2a4f2aef30a2300e6be8d6068bb128 100644 (file)
@@ -1,3 +1,14 @@
+2014-07-11  Eli Zaretskii  <eliz@gnu.org>
+
+       * minibuf.c (read_minibuf_noninteractive): Finish reading on '\r',
+       not only on '\n'.
+
+       * sysdep.c (emacs_get_tty, emacs_set_tty, suppress_echo_on_tty)
+       [DOS_NT]: Implement for WINDOWSNT.
+
+       * systty.h (struct emacs_tty) [DOS_NT]: The struct member is now
+       unsigned.
+
 2014-07-11  Michael Albinus  <michael.albinus@gmx.de>
 
        * sysdep.c (suppress_echo_on_tty): New function.
index 44d319c5e67aff9cc04000863ed6bc277c4dfcf3..c77f5955d86f1bcdf5b0756a3e87abd3f0a3d1ef 100644 (file)
@@ -251,7 +251,7 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial,
   len = 0;
   line = xmalloc (size);
 
-  while ((c = getchar ()) != '\n')
+  while ((c = getchar ()) != '\n' && c != '\r')
     {
       if (c == EOF)
        {
@@ -280,7 +280,7 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial,
       emacs_set_tty (fileno (stdin), &etty, 0);
     }
 
-  if (len || c == '\n')
+  if (len || c == '\n' || c == '\r')
     {
       val = make_string (line, len);
       xfree (line);
index 46078807b4368b82948ab694c7d760ea524fdc54..c5b3c43ea6dbd71b42726236f57cd986ada23574 100644 (file)
@@ -783,9 +783,20 @@ void
 emacs_get_tty (int fd, struct emacs_tty *settings)
 {
   /* Retrieve the primary parameters - baud rate, character size, etcetera.  */
-#ifndef DOS_NT
-  /* We have those nifty POSIX tcmumbleattr functions.  */
   memset (&settings->main, 0, sizeof (settings->main));
+#ifdef DOS_NT
+#ifdef WINDOWSNT
+  HANDLE h = (HANDLE)_get_osfhandle (fd);
+  DWORD console_mode;
+
+  if (h && h != INVALID_HANDLE_VALUE)
+    {
+      if (GetConsoleMode (h, &console_mode))
+       settings->main = console_mode;
+    }
+#endif /* WINDOWSNT */
+#else  /* !DOS_NT */
+  /* We have those nifty POSIX tcmumbleattr functions.  */
   tcgetattr (fd, &settings->main);
 #endif
 }
@@ -799,7 +810,22 @@ int
 emacs_set_tty (int fd, struct emacs_tty *settings, bool flushp)
 {
   /* Set the primary parameters - baud rate, character size, etcetera.  */
-#ifndef DOS_NT
+#ifdef DOS_NT
+#ifdef WINDOWSNT
+  HANDLE h = (HANDLE)_get_osfhandle (fd);
+
+  if (h && h != INVALID_HANDLE_VALUE)
+    {
+      DWORD new_mode;
+
+      /* Assume the handle is open for input.  */
+      if (flushp)
+       FlushConsoleInputBuffer (h);
+      new_mode = settings->main;
+      SetConsoleMode (h, new_mode);
+    }
+#endif /* WINDOWSNT */
+#else  /* !DOS_NT */
   int i;
   /* We have those nifty POSIX tcmumbleattr functions.
      William J. Smith <wjs@wiis.wang.com> writes:
@@ -1149,7 +1175,10 @@ suppress_echo_on_tty (int fd)
   struct emacs_tty etty;
 
   emacs_get_tty (fd, &etty);
-#ifndef WINDOWSNT
+#ifdef DOS_NT
+  /* Set raw input mode.  */
+  etty.main = 0;
+#else
   etty.main.c_lflag &= ~ICANON;        /* Disable buffering */
   etty.main.c_lflag &= ~ECHO;  /* Disable echoing */
 #endif /* ! WINDOWSNT */
index 6eb0c11ef6e7014a65f88272b589d7c30bb92ad6..dd4c07d32d95b63566d108059536f7e6699d7a24 100644 (file)
@@ -74,7 +74,7 @@ struct emacs_tty {
 #ifndef DOS_NT
   struct termios main;
 #else /* DOS_NT */
-  int main;
+  unsigned main;
 #endif /* DOS_NT */
 };
 \f