summaryrefslogtreecommitdiff
path: root/src/minibuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/minibuf.c')
-rw-r--r--src/minibuf.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/minibuf.c b/src/minibuf.c
index 3042b13b7d6..122f77fff96 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -35,6 +35,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "keymap.h"
#include "termhooks.h"
+#include "systty.h"
+extern void emacs_get_tty (int, struct emacs_tty *);
+extern int emacs_set_tty (int, struct emacs_tty *, bool);
+
/* List of buffers for use as minibuffers.
The first element of the list is used for the outermost minibuffer
invocation, the next element is used for a recursive minibuffer
@@ -224,6 +228,22 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial,
char *line;
Lisp_Object val;
int c;
+ unsigned char hide_char = 0;
+ struct emacs_tty old, new;
+
+ /* Check, whether we need to suppress echoing. */
+ if (CHARACTERP (Vread_hide_char))
+ hide_char = XFASTINT (Vread_hide_char);
+
+ /* Manipulate tty. */
+ if (hide_char)
+ {
+ emacs_get_tty (fileno (stdin), &old);
+ new = old;
+ new.main.c_lflag &= ~ICANON; /* Disable buffering */
+ new.main.c_lflag &= ~ECHO; /* Disable echoing */
+ emacs_set_tty (fileno (stdin), &new, 0);
+ }
fprintf (stdout, "%s", SDATA (prompt));
fflush (stdout);
@@ -242,6 +262,8 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial,
}
else
{
+ if (hide_char)
+ fprintf (stdout, "%c", hide_char);
if (len == size)
{
if (STRING_BYTES_BOUND / 2 < size)
@@ -253,6 +275,13 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial,
}
}
+ /* Reset tty. */
+ if (hide_char)
+ {
+ fprintf (stdout, "\n");
+ emacs_set_tty (fileno (stdin), &old, 0);
+ }
+
if (len || c == '\n')
{
val = make_string (line, len);
@@ -2079,6 +2108,12 @@ properties. */);
initialization-order problems. */
Vminibuffer_prompt_properties = list2 (intern_c_string ("read-only"), Qt);
+ DEFVAR_LISP ("read-hide-char", Vread_hide_char,
+ doc: /* Whether to hide input characters in noninteractive mode.
+It must be a character, which will be used to mask the input
+characters. This variable should never be set globally. */);
+ Vread_hide_char = Qnil;
+
defsubr (&Sactive_minibuffer_window);
defsubr (&Sset_minibuffer_window);
defsubr (&Sread_from_minibuffer);