cmdline: display prompt and previous command after pager
authorOlivier Matz <zer0@droids-corp.org>
Sun, 8 May 2011 15:32:49 +0000 (17:32 +0200)
committerOlivier Matz <zer0@droids-corp.org>
Sun, 8 May 2011 15:32:49 +0000 (17:32 +0200)
Signed-off-by: Olivier Matz <zer0@droids-corp.org>
src/lib/cmdline_rdline.c

index d0a116e..5ff851b 100644 (file)
@@ -214,28 +214,28 @@ rdline_parse_char(struct rdline *rdl, char c)
 #ifndef NO_PAGER
        /* display asynchrounous printf if any */
        if (rdl->pager_buf != NULL) {
+               /* user ask to exit pager */
                if (cmd == VT100_STD_CHAR && c == 'q') {
-                       rdline_printf(rdl, vt100_home);
-                       rdline_printf(rdl, vt100_clear_right);
                        rdline_asyncpager_reset(rdl);
                        if (rdl->pager_cb != NULL) {
                                rdl->pager_cb(rdl, rdl->pager_arg);
                                rdl->pager_cb = NULL;
                        }
-                       if (rdl->pager_buf == NULL)
-                               return RDLINE_RES_VALIDATED;
+                       rdline_redisplay(rdl);
+                       return RDLINE_RES_SUCCESS;
                }
 
-               if (rdline_pager_next_page(rdl) == 0) {
+               /* last page is displayed */
+               else if (rdline_pager_next_page(rdl) == 0) {
                        rdline_asyncpager_reset(rdl);
                        if (rdl->pager_cb != NULL) {
                                rdl->pager_cb(rdl, rdl->pager_arg);
                                rdl->pager_cb = NULL;
                        }
-                       if (rdl->pager_buf == NULL)
-                               return RDLINE_RES_VALIDATED;
+                       rdline_redisplay(rdl);
                }
-               /* async printf was called in cb() */
+
+               /* pages remain, async printf was called in cb() */
                return RDLINE_RES_SUCCESS;
        }
 #endif