rdline: don't display prompt if stopped by user
authorOlivier Matz <zer0@droids-corp.org>
Thu, 27 Oct 2011 20:44:38 +0000 (22:44 +0200)
committerOlivier Matz <zer0@droids-corp.org>
Thu, 27 Oct 2011 20:46:51 +0000 (22:46 +0200)
Signed-off-by: Olivier Matz <zer0@droids-corp.org>
src/lib/cmdline.c
src/lib/cmdline_rdline.c
src/lib/cmdline_rdline.h

index 7423cc0..70267de 100644 (file)
@@ -194,6 +194,10 @@ cmdline_in(struct cmdline *cl, const char *buf, int size)
        for (i = 0; i < size; i++) {
                ret = rdline_char_in(&cl->rdl, buf[i]);
 
+               if (ret == RDLINE_RES_VALIDATED &&
+                   cl->rdl.status == RDLINE_STOPPED)
+                       break;
+
                if (ret == RDLINE_RES_VALIDATED)
                        rdline_newline(&cl->rdl, cl->prompt);
                else if (ret == RDLINE_RES_EOF)
index 5632a87..785a23c 100644 (file)
@@ -107,7 +107,7 @@ rdline_init(struct rdline *rdl,
        rdl->validate = validate;
        rdl->complete = complete;
        rdl->help = help;
-       rdl->status = RDLINE_INIT;
+       rdl->status = RDLINE_STOPPED;
 #ifndef NO_RDLINE_HISTORY
        cirbuf_init(&rdl->history, rdl->history_buf, 0, RDLINE_HISTORY_BUF_SIZE);
 #endif /* !NO_RDLINE_HISTORY */
@@ -135,7 +135,7 @@ rdline_newline(struct rdline *rdl, const char *prompt)
 void
 rdline_stop(struct rdline *rdl)
 {
-       rdl->status = RDLINE_INIT;
+       rdl->status = RDLINE_STOPPED;
 }
 
 void
@@ -499,7 +499,6 @@ rdline_parse_char(struct rdline *rdl, char c)
                        }
 
                        rdline_asyncpager_reset(rdl);
-                       rdl->status = RDLINE_INIT;
 #else
                        if (rdl->status == RDLINE_EXITED)
                                return RDLINE_RES_EXITED;
index bda4465..47ab6c9 100644 (file)
@@ -90,7 +90,7 @@
 #define RDLINE_MAX_LINES 23
 
 enum rdline_status {
-       RDLINE_INIT,
+       RDLINE_STOPPED,
        RDLINE_RUNNING,
        RDLINE_EXITED
 };