diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-09-05 08:21:57 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-09-05 08:21:57 -0700 |
commit | 198565656bc40629454a45d019c935c7fa24b76a (patch) | |
tree | 5821b0b69ed82223ad8bf9fce520ce21460d163c | |
parent | 7007754f037dd1d6ef4f9cfd636ef91016809737 (diff) | |
download | txr-198565656bc40629454a45d019c935c7fa24b76a.tar.gz txr-198565656bc40629454a45d019c935c7fa24b76a.tar.bz2 txr-198565656bc40629454a45d019c935c7fa24b76a.zip |
linenoise: hard-coded stream in generate_beep.
* linenoise/linenoise.c (generate_beep): Take line noise
context argument and send BEL character to output file
descriptor, rather than hardcoding to stderr.
(complete_line): Pass context to generate_beep.
-rw-r--r-- | linenoise/linenoise.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index 53a308d6..02be8a53 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -333,9 +333,8 @@ int lino_clear_screen(lino_t *ls) { /* Beep, used for completion when there is nothing to complete or when all * the choices were already shown. */ -static void generate_beep(void) { - fprintf(stderr, "\x7"); - fflush(stderr); +static int generate_beep(lino_t *ls) { + return write(ls->ofd, "\x7", 1) > 0; } /* ============================== Completion ================================ */ @@ -364,7 +363,7 @@ static int complete_line(struct lino_state *ls) { ls->completion_callback(ls->buf, &lc, ls->cb_ctx); if (lc.len == 0) { - generate_beep(); + generate_beep(ls); } else { size_t stop = 0, i = 0; @@ -392,7 +391,7 @@ static int complete_line(struct lino_state *ls) { switch(c) { case 9: /* tab */ i = (i+1) % (lc.len+1); - if (i == lc.len) generate_beep(); + if (i == lc.len) generate_beep(ls); break; case 27: /* escape */ /* Re-show original buffer */ |