summaryrefslogtreecommitdiffstats
path: root/sys/ddb/db_output.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2004-11-01 22:15:15 +0000
committerjhb <jhb@FreeBSD.org>2004-11-01 22:15:15 +0000
commita9860ec891d255363fab82ffc00c1be83f7d857c (patch)
tree2d51ddc5baf115819b8b07497742acacc8965e22 /sys/ddb/db_output.c
parent28f5ed05c5d8e2b6e4fbadf576613fdcc0f27676 (diff)
downloadFreeBSD-src-a9860ec891d255363fab82ffc00c1be83f7d857c.zip
FreeBSD-src-a9860ec891d255363fab82ffc00c1be83f7d857c.tar.gz
- Change the ddb paging "support" to use a variable (db_lines_per_page) to
control the number of lines per page rather than a constant. The variable can be examined and changed in ddb as '$lines'. Setting the variable to 0 will effectively turn off paging. - Change db_putchar() to force out pending whitespace before outputting newlines and carriage returns so that one can rub out content on the current line via '\r \r' type strings. - Change the simple pager to rub out the --More-- prompt explicitly when the routine exits. - Add some aliases to the simple pager to make it more compatible with more(1): 'e' and 'j' do a single line. 'd' does half a page, and 'f' does a full page. MFC after: 1 month Inspired by: kris
Diffstat (limited to 'sys/ddb/db_output.c')
-rw-r--r--sys/ddb/db_output.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/sys/ddb/db_output.c b/sys/ddb/db_output.c
index ff2734c..27e57a5 100644
--- a/sys/ddb/db_output.c
+++ b/sys/ddb/db_output.c
@@ -65,8 +65,9 @@ db_expr_t db_tab_stop_width = 8; /* how wide are tab stops? */
#define NEXT_TAB(i) \
((((i) + db_tab_stop_width) / db_tab_stop_width) * db_tab_stop_width)
db_expr_t db_max_width = 79; /* output line width */
+db_expr_t db_lines_per_page = 20; /* lines per page */
static int db_newlines; /* # lines this page */
-static int db_maxlines = -1; /* max lines per page */
+static int db_maxlines = -1; /* max lines/page when paging */
static db_page_calloutfcn_t *db_page_callout = NULL;
static void *db_page_callout_arg = NULL;
static int ddb_use_printf = 0;
@@ -143,6 +144,7 @@ db_putchar(c, arg)
}
else if (c == '\n') {
/* Newline */
+ db_force_whitespace();
cnputc(c);
db_output_position = 0;
db_last_non_space = 0;
@@ -157,6 +159,7 @@ db_putchar(c, arg)
}
else if (c == '\r') {
/* Return */
+ db_force_whitespace();
cnputc(c);
db_output_position = 0;
db_last_non_space = 0;
@@ -197,21 +200,33 @@ db_setup_paging(db_page_calloutfcn_t *callout, void *arg, int maxlines)
void
db_simple_pager(void *arg)
{
- int c;
+ int c, done;
db_printf("--More--\r");
- for (;;) {
+ done = 0;
+ while (!done) {
c = cngetc();
switch (c) {
+ case 'e':
+ case 'j':
case '\n':
/* Just one more line. */
db_setup_paging(db_simple_pager, arg, 1);
- return;
+ done++;
+ break;
+ case 'd':
+ /* Half a page. */
+ db_setup_paging(db_simple_pager, arg,
+ db_lines_per_page / 2);
+ done++;
+ break;
+ case 'f':
case ' ':
/* Another page. */
db_setup_paging(db_simple_pager, arg,
- DB_LINES_PER_PAGE);
- return;
+ db_lines_per_page);
+ done++;
+ break;
case 'q':
case 'Q':
case 'x':
@@ -219,8 +234,8 @@ db_simple_pager(void *arg)
/* Quit */
if (arg != NULL) {
*(int *)arg = 1;
- db_printf("\n");
- return;
+ done++;
+ break;
}
#if 0
/* FALLTHROUGH */
@@ -229,6 +244,7 @@ db_simple_pager(void *arg)
#endif
}
}
+ db_printf(" \r");
}
/*
OpenPOWER on IntegriCloud