-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Here is a patch that adds grub_getwh functions. Warning : terms other than console.c & vga.c will be broken by this patch, as long as they don't have the function.
2005-07-12 Vincent Pelletier <[EMAIL PROTECTED]> * include/grub/term.h: (GRUB_TERM_WIDTH, GRUB_TERM_HEIGHT): Redefined to use grub_getwh. (struct grub_term): New field named getwh. (grub_getwh): New exported prototype. * term/i386/pc/console.c: (grub_console_getwh): New function. (grub_console_term): New field and new initial value. * term/i386/pc/vga.c: (grub_vga_getwh): New function. (grub_vga_term): New field and new initial value. Vincent Pelletier -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFC1CKkFEQoKRQyjtURAhQOAJ9kxitoVirko0thecc0gpAzguTyvgCcDyuS VE/VAYMisJ+VwyzyOLjhT5Y= =Yygw -----END PGP SIGNATURE-----
Index: include/grub/term.h =================================================================== RCS file: /cvsroot/grub/grub2/include/grub/term.h,v retrieving revision 1.7 diff -u -p -r1.7 term.h --- include/grub/term.h 19 Feb 2005 20:56:07 -0000 1.7 +++ include/grub/term.h 12 Jul 2005 19:55:33 -0000 @@ -71,9 +71,9 @@ grub_term_color_state; /* Menu-related geometrical constants. */ -/* FIXME: These should be dynamically obtained from a terminal. */ -#define GRUB_TERM_WIDTH 80 -#define GRUB_TERM_HEIGHT 25 +/* FIXME: Ugly way to get them form terminal. */ +#define GRUB_TERM_WIDTH ((grub_getwh()&0xFF00)>>8) +#define GRUB_TERM_HEIGHT (grub_getwh()&0xFF) /* The number of lines of "GRUB version..." at the top. */ #define GRUB_TERM_INFO_HEIGHT 1 @@ -142,6 +142,9 @@ struct grub_term /* Get a character. */ int (*getkey) (void); + /* Get the screen size. The return value is ((Width << 8) | Height). */ + grub_uint16_t (*getwh) (void); + /* Get the cursor position. The return value is ((X << 8) | Y). */ grub_uint16_t (*getxy) (void); @@ -183,6 +186,7 @@ void EXPORT_FUNC(grub_putchar) (int c); void EXPORT_FUNC(grub_putcode) (grub_uint32_t code); int EXPORT_FUNC(grub_getkey) (void); int EXPORT_FUNC(grub_checkkey) (void); +grub_uint16_t EXPORT_FUNC(grub_getwh) (void); grub_uint16_t EXPORT_FUNC(grub_getxy) (void); void EXPORT_FUNC(grub_gotoxy) (grub_uint8_t x, grub_uint8_t y); void EXPORT_FUNC(grub_cls) (void); Index: term/i386/pc/console.c =================================================================== RCS file: /cvsroot/grub/grub2/term/i386/pc/console.c,v retrieving revision 1.5 diff -u -p -r1.5 console.c --- term/i386/pc/console.c 15 Feb 2005 00:07:01 -0000 1.5 +++ term/i386/pc/console.c 12 Jul 2005 19:55:33 -0000 @@ -74,6 +74,12 @@ grub_console_putchar (grub_uint32_t c) grub_console_real_putchar (c); } +static grub_uint16_t +grub_console_getwh (void) +{ + return (80 << 8) | 25; /* FIXME: Always true ? */ +} + static void grub_console_setcolorstate (grub_term_color_state state) { @@ -107,6 +113,7 @@ static struct grub_term grub_console_ter .putchar = grub_console_putchar, .checkkey = grub_console_checkkey, .getkey = grub_console_getkey, + .getwh = grub_console_getwh, .getxy = grub_console_getxy, .gotoxy = grub_console_gotoxy, .cls = grub_console_cls, Index: term/i386/pc/vga.c =================================================================== RCS file: /cvsroot/grub/grub2/term/i386/pc/vga.c,v retrieving revision 1.7 diff -u -p -r1.7 vga.c --- term/i386/pc/vga.c 2 Mar 2005 20:12:46 -0000 1.7 +++ term/i386/pc/vga.c 12 Jul 2005 19:55:34 -0000 @@ -473,6 +473,12 @@ grub_vga_putchar (grub_uint32_t c) } static grub_uint16_t +grub_vga_getwh (void) +{ + return (TEXT_WIDTH << 8) | TEXT_HEIGHT; +} + +static grub_uint16_t grub_vga_getxy (void) { return ((xpos << 8) | ypos); @@ -566,6 +572,7 @@ static struct grub_term grub_vga_term = .putchar = grub_vga_putchar, .checkkey = grub_console_checkkey, .getkey = grub_console_getkey, + .getwh = grub_vga_getwh, .getxy = grub_vga_getxy, .gotoxy = grub_vga_gotoxy, .cls = grub_vga_cls,
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel