diff options
Diffstat (limited to 'linenoise')
-rw-r--r-- | linenoise/linenoise.c | 13 | ||||
-rw-r--r-- | linenoise/linenoise.h | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index 90fd1529..1209816a 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -124,6 +124,7 @@ struct lino_state { int need_refresh; /* Need refresh. */ int selmode; /* Visual selection being made. */ int selinclusive; /* Selections include character right of endpoint. */ + int noninteractive; /* No character editing, even if input is tty. */ struct lino_undo *undo_stack; lino_error_t error; /* Most recent error. */ }; @@ -174,6 +175,16 @@ int lino_get_selinculsive(lino_t *ls) return ls->selinclusive; } +void lino_set_noninteractive(lino_t *ls, int ni) +{ + ls->noninteractive = ni; +} + +int lino_get_noninteractive(lino_t *ls) +{ + return ls->noninteractive; +} + void lino_set_atom_cb(lino_t *l, lino_atom_cb_t *cb, void *ctx) { l->atom_callback = cb; @@ -2186,7 +2197,7 @@ char *linenoise(lino_t *ls, const char *prompt) { int count; - if (ls->ifs || !isatty(ls->ifd)) { + if (ls->ifs || ls->noninteractive || !isatty(ls->ifd)) { if (!ls->ifs) { int fd = dup(ls->ifd); FILE *fi = (fd > 0) ? fdopen(fd, "r") : 0; diff --git a/linenoise/linenoise.h b/linenoise/linenoise.h index 454523a9..28b304a4 100644 --- a/linenoise/linenoise.h +++ b/linenoise/linenoise.h @@ -75,6 +75,8 @@ void lino_set_multiline(lino_t *, int ml); int lino_get_multiline(lino_t *); void lino_set_selinclusive(lino_t *, int si); int lino_get_selinculsive(lino_t *); +void lino_set_noninteractive(lino_t *, int ni); +int lino_get_noninteractive(lino_t *); typedef char *lino_atom_cb_t(lino_t *, const char *line, int n, void *ctx); void lino_set_atom_cb(lino_t *, lino_atom_cb_t *, void *ctx); |