diff options
Diffstat (limited to 'linenoise')
-rw-r--r-- | linenoise/linenoise.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index 1440a68a..0622d258 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -756,13 +756,15 @@ static int edit(lino_t *l, const char *prompt) return -1; } while(1) { - char c; + unsigned char byte; + int c; int nread; char seq[3]; - nread = read(l->ifd,&c,1); + nread = read(l->ifd,&byte,1); if (nread <= 0) return l->len ? (int) l->len : -1; + c = byte; if (verbatim) { if (edit_insert(l,c)) { @@ -776,14 +778,18 @@ static int edit(lino_t *l, const char *prompt) /* Only autocomplete when the callback is set. It returns < 0 when * there was an error reading from fd. Otherwise it will return the * character that should be handled next. */ - if (c == 9 && l->completion_callback != NULL) { - c = complete_line(l); - /* Return on errors */ - if (c < 0) return l->len; - /* Read next character when 0 */ - if (c == 0) continue; + switch (c) { + case TAB: + if (l->completion_callback != NULL) + c = complete_line(l); + break; } + if (c < 0) + return l->len; + if (c == 0) + continue; + switch(c) { case ENTER: if (l->history_len > 0) { |