aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2014-07-11 16:58:02 +0300
committerEli Zaretskii2014-07-11 16:58:02 +0300
commite8963bd757bce1a58d5c5b081f53a873857d25df (patch)
tree47d62ff10f9d4ff0be4b8ce7234b4b8669493e82 /src
parentca849522fe8484b111d6f3a244ff7ef4fa97fa99 (diff)
downloademacs-e8963bd757bce1a58d5c5b081f53a873857d25df.tar.gz
emacs-e8963bd757bce1a58d5c5b081f53a873857d25df.zip
Implement echo suppression in non-interactive mode for MS-Windows.
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
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog11
-rw-r--r--src/minibuf.c4
-rw-r--r--src/sysdep.c37
-rw-r--r--src/systty.h2
4 files changed, 47 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index a5debc00acf..a016f3cadc2 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
12014-07-11 Eli Zaretskii <eliz@gnu.org>
2
3 * minibuf.c (read_minibuf_noninteractive): Finish reading on '\r',
4 not only on '\n'.
5
6 * sysdep.c (emacs_get_tty, emacs_set_tty, suppress_echo_on_tty)
7 [DOS_NT]: Implement for WINDOWSNT.
8
9 * systty.h (struct emacs_tty) [DOS_NT]: The struct member is now
10 unsigned.
11
12014-07-11 Michael Albinus <michael.albinus@gmx.de> 122014-07-11 Michael Albinus <michael.albinus@gmx.de>
2 13
3 * sysdep.c (suppress_echo_on_tty): New function. 14 * sysdep.c (suppress_echo_on_tty): New function.
diff --git a/src/minibuf.c b/src/minibuf.c
index 44d319c5e67..c77f5955d86 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -251,7 +251,7 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial,
251 len = 0; 251 len = 0;
252 line = xmalloc (size); 252 line = xmalloc (size);
253 253
254 while ((c = getchar ()) != '\n') 254 while ((c = getchar ()) != '\n' && c != '\r')
255 { 255 {
256 if (c == EOF) 256 if (c == EOF)
257 { 257 {
@@ -280,7 +280,7 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial,
280 emacs_set_tty (fileno (stdin), &etty, 0); 280 emacs_set_tty (fileno (stdin), &etty, 0);
281 } 281 }
282 282
283 if (len || c == '\n') 283 if (len || c == '\n' || c == '\r')
284 { 284 {
285 val = make_string (line, len); 285 val = make_string (line, len);
286 xfree (line); 286 xfree (line);
diff --git a/src/sysdep.c b/src/sysdep.c
index 46078807b43..c5b3c43ea6d 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -783,9 +783,20 @@ void
783emacs_get_tty (int fd, struct emacs_tty *settings) 783emacs_get_tty (int fd, struct emacs_tty *settings)
784{ 784{
785 /* Retrieve the primary parameters - baud rate, character size, etcetera. */ 785 /* Retrieve the primary parameters - baud rate, character size, etcetera. */
786#ifndef DOS_NT
787 /* We have those nifty POSIX tcmumbleattr functions. */
788 memset (&settings->main, 0, sizeof (settings->main)); 786 memset (&settings->main, 0, sizeof (settings->main));
787#ifdef DOS_NT
788#ifdef WINDOWSNT
789 HANDLE h = (HANDLE)_get_osfhandle (fd);
790 DWORD console_mode;
791
792 if (h && h != INVALID_HANDLE_VALUE)
793 {
794 if (GetConsoleMode (h, &console_mode))
795 settings->main = console_mode;
796 }
797#endif /* WINDOWSNT */
798#else /* !DOS_NT */
799 /* We have those nifty POSIX tcmumbleattr functions. */
789 tcgetattr (fd, &settings->main); 800 tcgetattr (fd, &settings->main);
790#endif 801#endif
791} 802}
@@ -799,7 +810,22 @@ int
799emacs_set_tty (int fd, struct emacs_tty *settings, bool flushp) 810emacs_set_tty (int fd, struct emacs_tty *settings, bool flushp)
800{ 811{
801 /* Set the primary parameters - baud rate, character size, etcetera. */ 812 /* Set the primary parameters - baud rate, character size, etcetera. */
802#ifndef DOS_NT 813#ifdef DOS_NT
814#ifdef WINDOWSNT
815 HANDLE h = (HANDLE)_get_osfhandle (fd);
816
817 if (h && h != INVALID_HANDLE_VALUE)
818 {
819 DWORD new_mode;
820
821 /* Assume the handle is open for input. */
822 if (flushp)
823 FlushConsoleInputBuffer (h);
824 new_mode = settings->main;
825 SetConsoleMode (h, new_mode);
826 }
827#endif /* WINDOWSNT */
828#else /* !DOS_NT */
803 int i; 829 int i;
804 /* We have those nifty POSIX tcmumbleattr functions. 830 /* We have those nifty POSIX tcmumbleattr functions.
805 William J. Smith <wjs@wiis.wang.com> writes: 831 William J. Smith <wjs@wiis.wang.com> writes:
@@ -1149,7 +1175,10 @@ suppress_echo_on_tty (int fd)
1149 struct emacs_tty etty; 1175 struct emacs_tty etty;
1150 1176
1151 emacs_get_tty (fd, &etty); 1177 emacs_get_tty (fd, &etty);
1152#ifndef WINDOWSNT 1178#ifdef DOS_NT
1179 /* Set raw input mode. */
1180 etty.main = 0;
1181#else
1153 etty.main.c_lflag &= ~ICANON; /* Disable buffering */ 1182 etty.main.c_lflag &= ~ICANON; /* Disable buffering */
1154 etty.main.c_lflag &= ~ECHO; /* Disable echoing */ 1183 etty.main.c_lflag &= ~ECHO; /* Disable echoing */
1155#endif /* ! WINDOWSNT */ 1184#endif /* ! WINDOWSNT */
diff --git a/src/systty.h b/src/systty.h
index 6eb0c11ef6e..dd4c07d32d9 100644
--- a/src/systty.h
+++ b/src/systty.h
@@ -74,7 +74,7 @@ struct emacs_tty {
74#ifndef DOS_NT 74#ifndef DOS_NT
75 struct termios main; 75 struct termios main;
76#else /* DOS_NT */ 76#else /* DOS_NT */
77 int main; 77 unsigned main;
78#endif /* DOS_NT */ 78#endif /* DOS_NT */
79}; 79};
80 80