Merge el_no_echo patch from Festival speech-tools editline fork

This commit is contained in:
Joachim Nilsson 2010-07-24 03:38:25 +02:00
parent 83e4837f39
commit be921400bb
2 changed files with 15 additions and 3 deletions

View File

@ -40,6 +40,7 @@ extern int rl_mark;
extern int rl_end; extern int rl_end;
extern char *rl_line_buffer; extern char *rl_line_buffer;
extern const char *rl_readline_name; 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_reset_terminal(char *p);
extern void rl_initialize(void); extern void rl_initialize(void);

View File

@ -106,6 +106,7 @@ static char *backspace;
static int tty_cols; static int tty_cols;
static int tty_rows; static int tty_rows;
int el_no_echo = 0; /* e.g., under Emacs */
int rl_point; int rl_point;
int rl_mark; int rl_mark;
int rl_end; int rl_end;
@ -133,7 +134,8 @@ static void tty_flush(void)
ssize_t res; ssize_t res;
if (ScreenCount) { if (ScreenCount) {
res = write (1, Screen, ScreenCount); if (!el_no_echo)
res = write (1, Screen, ScreenCount);
ScreenCount = 0; ScreenCount = 0;
} }
} }
@ -1052,8 +1054,17 @@ char *readline(const char *prompt)
return NULL; return NULL;
Prompt = prompt ? prompt : NIL; Prompt = prompt ? prompt : NIL;
tty_puts(Prompt); if (el_no_echo) {
if ((line = editinput()) != NULL) { 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); line = strdup(line);
tty_puts(NEWLINE); tty_puts(NEWLINE);
tty_flush(); tty_flush();