summaryrefslogtreecommitdiffstats
path: root/linenoise/linenoise.c
diff options
context:
space:
mode:
Diffstat (limited to 'linenoise/linenoise.c')
-rw-r--r--linenoise/linenoise.c13
1 files changed, 12 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;