From be921400bb28fed7418733b0d83d3323ee04b2a1 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sat, 24 Jul 2010 03:38:25 +0200 Subject: [PATCH] Merge el_no_echo patch from Festival speech-tools editline fork --- include/editline.h | 1 + src/editline.c | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/editline.h b/include/editline.h index 802700f..5b8f922 100644 --- a/include/editline.h +++ b/include/editline.h @@ -40,6 +40,7 @@ extern int rl_mark; extern int rl_end; extern char *rl_line_buffer; extern const char *rl_readline_name; +extern int el_no_echo; /* e.g under emacs, don't echo except prompt */ extern void rl_reset_terminal(char *p); extern void rl_initialize(void); diff --git a/src/editline.c b/src/editline.c index e2e3bdf..71a99a3 100644 --- a/src/editline.c +++ b/src/editline.c @@ -106,6 +106,7 @@ static char *backspace; static int tty_cols; static int tty_rows; +int el_no_echo = 0; /* e.g., under Emacs */ int rl_point; int rl_mark; int rl_end; @@ -133,7 +134,8 @@ static void tty_flush(void) ssize_t res; if (ScreenCount) { - res = write (1, Screen, ScreenCount); + if (!el_no_echo) + res = write (1, Screen, ScreenCount); ScreenCount = 0; } } @@ -1052,8 +1054,17 @@ char *readline(const char *prompt) return NULL; Prompt = prompt ? prompt : NIL; - tty_puts(Prompt); - if ((line = editinput()) != NULL) { + if (el_no_echo) { + int old = el_no_echo; + el_no_echo = 0; + tty_puts(Prompt); + tty_flush(); + el_no_echo = old; + } else { + tty_puts(Prompt); + } + line = editinput(); + if (line) { line = strdup(line); tty_puts(NEWLINE); tty_flush();