From: robertkaiser Date: Thu, 13 Mar 2003 17:37:25 +0000 (+0000) Subject: Added pagelength environment variable to pause scrolling X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=01212b5dc0352c81edae208c5791ac9b486deed1;p=users%2Frw%2Farmboot.git Added pagelength environment variable to pause scrolling --- diff --git a/common/cmd_mem.c b/common/cmd_mem.c index bd75e88..c541353 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -129,7 +129,7 @@ int do_mem_md (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) } printf("\n"); nbytes -= linebytes; - } while (nbytes > 0); + } while (nbytes > 0 && !had_ctrlc()); dp_last_addr = addr; dp_last_length = length; diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 93cf6d5..ebcf169 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -37,6 +37,8 @@ #include "net.h" #endif +extern int pagelength; + /* * Table with supported baudrates (defined in config_xyz.h) */ @@ -397,6 +399,11 @@ int _do_setenv (bd_t *bd, int flag, int argc, char *argv[]) return 0; } + if (strcmp(argv[1],"pagelength") == 0) { + pagelength = simple_strtoul(argv[2], NULL, 10); + return 0; + } + #if (CONFIG_COMMANDS & CFG_CMD_NET) if (strcmp(argv[1],"bootfile") == 0) { copy_filename (BootFile, argv[2], sizeof(BootFile)); @@ -598,8 +605,8 @@ void env_relocate(bd_t *bd) s = (*e) ? e+1 : e; } - /* IP address */ #if (CONFIG_COMMANDS & CFG_CMD_NET) + /* IP address */ s = getenv(bd, "ipaddr"); bd->bi_ip_addr = string_to_ip(s); #endif @@ -608,6 +615,10 @@ void env_relocate(bd_t *bd) load_addr = simple_strtoul(s, NULL, 16); } + if ((s = getenv(bd, "pagelength")) != NULL) { + pagelength = simple_strtoul(s, NULL, 10); + } + #if (CONFIG_COMMANDS & CFG_CMD_NET) if ((s = getenv(bd, "bootfile")) != NULL) { copy_filename (BootFile, s, sizeof(BootFile)); diff --git a/common/command.c b/common/command.c index 5f06868..1b7d833 100644 --- a/common/command.c +++ b/common/command.c @@ -121,7 +121,7 @@ int do_help (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) for (cmdtp=&cmd_tbl[0]; cmdtp->name; cmdtp++) { /* allow user abort */ - if (ctrlc()) + if (had_ctrlc() || ctrlc()) return 1; if (cmdtp->usage == NULL) @@ -151,6 +151,8 @@ int do_help (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) if (cmdtp->usage) puts (cmdtp->usage); #endif /* CFG_LONGHELP */ + if(had_ctrlc()) + break; } else { printf ("Unknown command '%s' - try 'help'" diff --git a/common/console.c b/common/console.c index 043a0ff..caeca46 100644 --- a/common/console.c +++ b/common/console.c @@ -44,12 +44,22 @@ extern int kbd_getc(void); # define CONSOLE_TSTC serial_tstc #endif +/* If pagelength is > 1, scrolling will pause every pagelength lines. + * Page length can be set through environment. + */ +#ifdef CONFIG_PAGELENGTH +int pagelength = CONFIG_PAGELENGTH; +#else +int pagelength = 0; +#endif +static int linesout = 0; + void serial_puts (const char *s) { while (*s) { - CONSOLE_PUTC (*s++); + putc(*s++); } } @@ -73,6 +83,7 @@ void serial_printf(const char *fmt, ...) int getc(void) { /* Send directly to the handler */ + linesout = 0; return CONSOLE_GETC(); } @@ -82,12 +93,6 @@ int tstc(void) return CONSOLE_TSTC(); } -void putc(const char c) -{ - /* Send directly to the handler */ - CONSOLE_PUTC (c); -} - void puts(const char *s) { /* Send directly to the handler */ @@ -151,3 +156,25 @@ void clear_ctrlc(void) ctrlc_was_pressed = 0; } +void putc(const char c) +{ + /* Send directly to the handler */ + CONSOLE_PUTC (c); + if(c == '\n') { + if(++linesout == pagelength) { + char *s = "--MORE--"; + while(*s) { + CONSOLE_PUTC(*s); + ++s; + } + if(getc() == 0x03) + ctrlc_was_pressed = 1; + s = "\b\b\b\b\b\b\b\b"; + while(*s) { + CONSOLE_PUTC(*s); + ++s; + } + } + } +} +