diff options
author | antirez <antirez@gmail.com> | 2011-02-22 17:40:33 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2011-02-22 17:40:33 +0100 |
commit | 58418d7c3eda50f9f6a8af6aca7369eae49a5a67 (patch) | |
tree | 8a085582ca78d25055846d13dbfbb9c7fd257bee | |
parent | c02bda324f5ea00bfa494e895ef085ee49a9106b (diff) | |
download | redis-58418d7c3eda50f9f6a8af6aca7369eae49a5a67.tar.gz |
linenoise updated
-rw-r--r-- | deps/linenoise/linenoise.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/deps/linenoise/linenoise.c b/deps/linenoise/linenoise.c index bfed5ea86..18a15cc45 100644 --- a/deps/linenoise/linenoise.c +++ b/deps/linenoise/linenoise.c @@ -320,10 +320,9 @@ static int linenoisePrompt(int fd, char *buf, size_t buflen, const char *prompt) switch(c) { case 13: /* enter */ - case 4: /* ctrl-d */ history_len--; free(history[history_len]); - return (len == 0 && c == 4) ? -1 : (int)len; + return (int)len; case 3: /* ctrl-c */ errno = EAGAIN; return -1; @@ -337,6 +336,18 @@ static int linenoisePrompt(int fd, char *buf, size_t buflen, const char *prompt) refreshLine(fd,prompt,buf,len,pos,cols); } break; + case 4: /* ctrl-d, remove char at right of cursor */ + if (len > 1 && pos < (len-1)) { + memmove(buf+pos,buf+pos+1,len-pos); + len--; + buf[len] = '\0'; + refreshLine(fd,prompt,buf,len,pos,cols); + } else if (len == 0) { + history_len--; + free(history[history_len]); + return -1; + } + break; case 20: /* ctrl-t */ if (pos > 0 && pos < len) { int aux = buf[pos-1]; |