The pager=1 setting is not effective for files with very long (or no) lines. This patch fixes this and allows to disable the pager with ESC. The latter is useful in conjunction with the "abort cat command" patch.
Christian 2008-02-14 Christian Franke <[EMAIL PROTECTED]> * kern/term.c (grub_more_columns): New variable. (grub_putcode): Add detection of line wrap for pager. Disable pager on GRUB_TERM_ESC. (grub_set_more): Initialize grub_more_columns.
--- grub2.orig/kern/term.c 2007-12-25 23:15:24.671875000 +0100 +++ grub2/kern/term.c 2008-02-14 21:44:49.640625000 +0100 @@ -31,6 +31,9 @@ static grub_term_t grub_cur_term; /* The amount of lines counted by the pager. */ static int grub_more_lines; +/* The last column count seen by the pager. */ +static int grub_more_columns; + /* If the more pager is active. */ static int grub_more; @@ -94,8 +97,6 @@ grub_term_get_current (void) void grub_putcode (grub_uint32_t code) { - int height = grub_getwh () & 255; - if (code == '\t' && grub_cur_term->getxy) { int n; @@ -110,36 +111,70 @@ grub_putcode (grub_uint32_t code) (grub_cur_term->putchar) (code); if (code == '\n') - { - grub_putcode ('\r'); + (grub_cur_term->putchar) ('\r'); - grub_more_lines++; + /* Return if pager is disabled. */ + if (! grub_more) + return; - if (grub_more && grub_more_lines == height - 1) + /* Return on if no line feed and no line wrap. */ + if (code == '\n') + grub_more_columns = 0; + else if (code == '\r') + { + grub_more_columns = 0; + return; + } + else if (grub_cur_term->getxy) + { + int column = grub_getxy () >> 8; + if (column >= grub_more_columns) { - char key; - int pos = grub_getxy (); - - /* Show --MORE-- on the lower left side of the screen. */ - grub_gotoxy (1, height - 1); - grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); - grub_printf ("--MORE--"); - grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); - - key = grub_getkey (); - - /* Remove the message. */ - grub_gotoxy (1, height - 1); - grub_printf (" "); - grub_gotoxy (pos >> 8, pos & 0xFF); - - /* Scroll one lines or an entire page, depending on the key. */ - if (key == '\r' || key =='\n') - grub_more_lines--; - else - grub_more_lines = 0; + grub_more_columns = column; + return; } + grub_more_columns = column; } + else + return; + + /* Return if line count not exceeded. */ + grub_more_lines++; + int height = grub_getwh () & 0xff; + + if (grub_more_lines < height - 1) + return; + + /* Reset pager to avoid recursion arrives here. */ + int more_lines = grub_more_lines; + grub_more_lines = 0; + grub_more_columns = 0; + + int pos = grub_getxy (); + + /* Show --MORE-- on the lower left side of the screen. */ + grub_gotoxy (1, height - 1); + grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); + grub_printf ("--MORE--"); + grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); + + int key = GRUB_TERM_ASCII_CHAR (grub_getkey ()); + + /* Remove the message. */ + grub_gotoxy (1, height - 1); + grub_printf (" "); + grub_gotoxy (pos >> 8, pos & 0xFF); + + grub_more_columns = pos >> 8; + + /* Scroll one lines or an entire page, depending on the key. + Turn pager off with ESC to allow command abort with another ESC. */ + if (key == '\r' || key == '\n') + grub_more_lines = more_lines - 0; + else if (key == GRUB_TERM_ESC) + grub_more_lines = -10000; + else + grub_more_lines = 0; } /* Put a character. C is one byte of a UTF-8 stream. @@ -273,4 +308,5 @@ grub_set_more (int onoff) grub_more--; grub_more_lines = 0; + grub_more_columns = grub_getxy () >> 8; }
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel