aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2014-07-11 14:35:23 +0200
committerMichael Albinus2014-07-11 14:35:23 +0200
commitfb96e203d8830bc40eb2f5b599f24c606efcd4b3 (patch)
treeec3eaea79aee2aa0c6777cf4d94f778bfbc3fe95
parent3aa96ff51efd72767f1a4e04c546187269b008c0 (diff)
downloademacs-fb96e203d8830bc40eb2f5b599f24c606efcd4b3.tar.gz
emacs-fb96e203d8830bc40eb2f5b599f24c606efcd4b3.zip
* sysdep.c (suppress_echo_on_tty): New function.
* minibuf.c (read_minibuf_noninteractive): Use it.
-rw-r--r--src/ChangeLog5
-rw-r--r--src/minibuf.c14
-rw-r--r--src/sysdep.c15
3 files changed, 25 insertions, 9 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 52ba04d2f5f..a5debc00acf 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12014-07-11 Michael Albinus <michael.albinus@gmx.de>
2
3 * sysdep.c (suppress_echo_on_tty): New function.
4 * minibuf.c (read_minibuf_noninteractive): Use it.
5
12014-07-11 Dmitry Antipov <dmantipov@yandex.ru> 62014-07-11 Dmitry Antipov <dmantipov@yandex.ru>
2 7
3 * alloc.c (Fmemory_info) [HAVE_LINUX_SYSINFO]: Return nil if 8 * alloc.c (Fmemory_info) [HAVE_LINUX_SYSINFO]: Return nil if
diff --git a/src/minibuf.c b/src/minibuf.c
index 6c6ab7f5865..44d319c5e67 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -38,6 +38,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
38#include "systty.h" 38#include "systty.h"
39extern void emacs_get_tty (int, struct emacs_tty *); 39extern void emacs_get_tty (int, struct emacs_tty *);
40extern int emacs_set_tty (int, struct emacs_tty *, bool); 40extern int emacs_set_tty (int, struct emacs_tty *, bool);
41extern void suppress_echo_on_tty (int);
41 42
42/* List of buffers for use as minibuffers. 43/* List of buffers for use as minibuffers.
43 The first element of the list is used for the outermost minibuffer 44 The first element of the list is used for the outermost minibuffer
@@ -229,7 +230,7 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial,
229 Lisp_Object val; 230 Lisp_Object val;
230 int c; 231 int c;
231 unsigned char hide_char = 0; 232 unsigned char hide_char = 0;
232 struct emacs_tty old, new; 233 struct emacs_tty etty;
233 234
234 /* Check, whether we need to suppress echoing. */ 235 /* Check, whether we need to suppress echoing. */
235 if (CHARACTERP (Vread_hide_char)) 236 if (CHARACTERP (Vread_hide_char))
@@ -238,13 +239,8 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial,
238 /* Manipulate tty. */ 239 /* Manipulate tty. */
239 if (hide_char) 240 if (hide_char)
240 { 241 {
241 emacs_get_tty (fileno (stdin), &old); 242 emacs_get_tty (fileno (stdin), &etty);
242 new = old; 243 suppress_echo_on_tty (fileno (stdin));
243#ifndef WINDOWSNT
244 new.main.c_lflag &= ~ICANON; /* Disable buffering */
245 new.main.c_lflag &= ~ECHO; /* Disable echoing */
246#endif
247 emacs_set_tty (fileno (stdin), &new, 0);
248 } 244 }
249 245
250 fprintf (stdout, "%s", SDATA (prompt)); 246 fprintf (stdout, "%s", SDATA (prompt));
@@ -281,7 +277,7 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial,
281 if (hide_char) 277 if (hide_char)
282 { 278 {
283 fprintf (stdout, "\n"); 279 fprintf (stdout, "\n");
284 emacs_set_tty (fileno (stdin), &old, 0); 280 emacs_set_tty (fileno (stdin), &etty, 0);
285 } 281 }
286 282
287 if (len || c == '\n') 283 if (len || c == '\n')
diff --git a/src/sysdep.c b/src/sysdep.c
index 14d9f43c4db..46078807b43 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -1140,6 +1140,21 @@ tabs_safe_p (int fd)
1140 return 0; 1140 return 0;
1141#endif /* DOS_NT */ 1141#endif /* DOS_NT */
1142} 1142}
1143
1144/* Discard echoing. */
1145
1146void
1147suppress_echo_on_tty (int fd)
1148{
1149 struct emacs_tty etty;
1150
1151 emacs_get_tty (fd, &etty);
1152#ifndef WINDOWSNT
1153 etty.main.c_lflag &= ~ICANON; /* Disable buffering */
1154 etty.main.c_lflag &= ~ECHO; /* Disable echoing */
1155#endif /* ! WINDOWSNT */
1156 emacs_set_tty (fd, &etty, 0);
1157}
1143 1158
1144/* Get terminal size from system. 1159/* Get terminal size from system.
1145 Store number of lines into *HEIGHTP and width into *WIDTHP. 1160 Store number of lines into *HEIGHTP and width into *WIDTHP.