#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_asyncpager_reset(rdl);
- if (rdl->pager_cb != NULL) {
- rdl->pager_cb(rdl, rdl->pager_arg);
- rdl->pager_cb = NULL;
- }
- rdline_redisplay(rdl);
- return RDLINE_RES_SUCCESS;
- }
- /* last page is displayed */
- else if (rdline_pager_next_page(rdl) == 0) {
+ /* user ask to exit pager, or last page is displayed*/
+ if ((cmd == VT100_STD_CHAR && c == 'q') ||
+ rdline_pager_next_page(rdl) == 0) {
+ int ret;
+
+ ret = rdl->pager_ret;
rdline_asyncpager_reset(rdl);
if (rdl->pager_cb != NULL) {
rdl->pager_cb(rdl, rdl->pager_arg);
rdl->pager_cb = NULL;
}
+ /* maybe the pager was reloaded in the
+ * callback */
+ if (rdl->pager_buf != NULL)
+ return RDLINE_RES_SUCCESS;
+
+ /* else, redisplay prompt and return the saved status */
rdline_redisplay(rdl);
+ return ret;
}
- /* pages remain, async printf was called in cb() */
+ /* Some pages remain, lines were displayed in
+ * rdline_pager_next_page() */
return RDLINE_RES_SUCCESS;
}
#endif
#endif
if (rdl->validate)
- rdl->validate(rdl, rdl->left_buf, CIRBUF_GET_LEN(&rdl->left)+2);
+ rdl->validate(rdl, rdl->left_buf,
+ CIRBUF_GET_LEN(&rdl->left)+2);
#ifndef NO_PAGER
/* user may have stopped rdline */
if (rdl->status == RDLINE_EXITED) {
rdline_asyncpager_reset(rdl);
return RDLINE_RES_EXITED;
}
- if (rdl->pager_buf != NULL)
+ /* there is something in pager buffer, save
+ * return value that will be return once
+ * paging is finished */
+ if (rdl->pager_buf != NULL) {
+ rdl->pager_ret = RDLINE_RES_VALIDATED;
return RDLINE_RES_SUCCESS;
- else
- rdline_asyncpager_reset(rdl);
+ }
+ rdline_asyncpager_reset(rdl);
rdl->status = RDLINE_INIT;
#else
if (rdl->status == RDLINE_EXITED)
rdl->pager_lines = 0;
rdl->pager_len = 0;
rdl->pager_off = 0;
+ rdl->pager_cb = NULL;
+ rdl->pager_arg = NULL;
+ rdl->pager_ret = RDLINE_RES_SUCCESS;
}
/* Return the offset of the i-th occurence of char c in string s. If