Index: include/grub/term.h =================================================================== RCS file: /cvsroot/grub/grub2/include/grub/term.h,v retrieving revision 1.6 diff -u -r1.6 term.h --- include/grub/term.h 4 Apr 2004 13:46:00 -0000 1.6 +++ include/grub/term.h 8 Oct 2004 18:07:42 -0000 @@ -75,11 +75,14 @@ /* Get a character. */ int (*getkey) (void); - /* Get the cursor position. The return value is ((X << 8) | Y). */ - grub_uint16_t (*getxy) (void); + /* Get the window size. */ + void (*getgeometry) (int *x, int *y); + + /* Get the cursor position. */ + void (*getxy) (int *x, int *y); /* Go to the position (X, Y). */ - void (*gotoxy) (grub_uint8_t x, grub_uint8_t y); + void (*gotoxy) (int x, int y); /* Clear the screen. */ void (*cls) (void); @@ -116,8 +119,9 @@ 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_getxy) (void); -void EXPORT_FUNC(grub_gotoxy) (grub_uint8_t x, grub_uint8_t y); +void EXPORT_FUNC(grub_getgeometry) (int *x, int *y); +void EXPORT_FUNC(grub_getxy) (int *x, int *y); +void EXPORT_FUNC(grub_gotoxy) (int x, int y); void EXPORT_FUNC(grub_cls) (void); void EXPORT_FUNC(grub_setcolorstate) (grub_term_color_state state); void EXPORT_FUNC(grub_setcolor) (grub_uint8_t normal_color, Index: include/grub/i386/pc/console.h =================================================================== RCS file: /cvsroot/grub/grub2/include/grub/i386/pc/console.h,v retrieving revision 1.4 diff -u -r1.4 console.h --- include/grub/i386/pc/console.h 4 Apr 2004 13:46:01 -0000 1.4 +++ include/grub/i386/pc/console.h 8 Oct 2004 18:07:42 -0000 @@ -43,8 +43,9 @@ void grub_console_real_putchar (int c); int EXPORT_FUNC(grub_console_checkkey) (void); int EXPORT_FUNC(grub_console_getkey) (void); -grub_uint16_t grub_console_getxy (void); -void grub_console_gotoxy (grub_uint8_t x, grub_uint8_t y); +void grub_console_getgeometry (int *x, int *y); +void grub_console_getxy (int *x, int *y); +void grub_console_gotoxy (int x, int y); void grub_console_cls (void); void grub_console_setcursor (int on); Index: kern/term.c =================================================================== RCS file: /cvsroot/grub/grub2/kern/term.c,v retrieving revision 1.7 diff -u -r1.7 term.c --- kern/term.c 4 Apr 2004 13:46:02 -0000 1.7 +++ kern/term.c 8 Oct 2004 18:07:42 -0000 @@ -92,9 +92,10 @@ { if (code == '\t' && grub_cur_term->getxy) { - int n; + int n, dummy; - n = 8 - ((grub_getxy () >> 8) & 7); + grub_getxy(&n, &dummy); + n = 8 - (n & 7); while (n--) grub_putcode (' '); @@ -112,7 +113,8 @@ if (grub_more && grub_more_lines == 24 - 1) { char key; - int pos = grub_getxy (); + int x, y; + grub_getxy (&x, &y); /* Show --MORE-- on the lower left side of the screen. */ grub_gotoxy (1, 24 - 1); @@ -125,7 +127,7 @@ /* Remove the message. */ grub_gotoxy (1, 24 -1); grub_printf (" "); - grub_gotoxy (pos >> 8, pos & 0xFF); + grub_gotoxy (x, y); /* Scroll one lines or an entire page, depending on the key. */ if (key == '\r' || key =='\n') @@ -212,14 +214,20 @@ return (grub_cur_term->checkkey) (); } -grub_uint16_t -grub_getxy (void) +void +grub_getgeometry (int *x, int *y) +{ + (grub_cur_term->getgeometry) (x, y); +} + +void +grub_getxy (int *x, int *y) { - return (grub_cur_term->getxy) (); + (grub_cur_term->getxy) (x, y); } void -grub_gotoxy (grub_uint8_t x, grub_uint8_t y) +grub_gotoxy (int x, int y) { (grub_cur_term->gotoxy) (x, y); } Index: kern/i386/pc/startup.S =================================================================== RCS file: /cvsroot/grub/grub2/kern/i386/pc/startup.S,v retrieving revision 1.13 diff -u -r1.13 startup.S --- kern/i386/pc/startup.S 4 Apr 2004 13:46:02 -0000 1.13 +++ kern/i386/pc/startup.S 8 Oct 2004 18:07:42 -0000 @@ -1310,7 +1310,41 @@ /* - * grub_uint16_t grub_console_getxy (void) + * grub_console_getgeometry (int *x, int *y) + * BIOS call "INT 10H Function 0Fh" to get video parameters + * Call with %ah = 0x0F + * Returns %al = video mode + * %ah = number of columns + * %bh = active page + */ + + +FUNCTION(grub_console_getgeometry) + pushl %ebp + pushl %edx + pushl %eax + + call prot_to_real + .code16 + + movb $0xF, %ah + int $0x10 /* get video parameters */ + + DATA32 call real_to_prot + .code32 + + popl %eax + movzbl %ah, %ecx + movl %ecx, (%eax) + popl %eax + movl $25, (%eax) /* FIXME: Don't assume width */ + +1: popl %ebp + ret + + +/* + * grub_uint16_t grub_console_getxy (int *x, int *y) * BIOS call "INT 10H Function 03h" to get cursor position * Call with %ah = 0x03 * %bh = page @@ -1324,6 +1358,8 @@ FUNCTION(grub_console_getxy) pushl %ebp pushl %ebx /* save EBX */ + pushl %edx + pushl %eax call prot_to_real .code16 @@ -1335,16 +1371,21 @@ DATA32 call real_to_prot .code32 - movb %dl, %ah - movb %dh, %al + popl %eax + movzbl %dl, %ecx + movl %ecx, (%eax) + popl %eax + movzbl %dh, %ecx + movl %ecx, (%eax) + popl %ebx popl %ebp ret /* - * void grub_console_gotoxy(grub_uint8_t x, grub_uint8_t y) + * void grub_console_gotoxy (int x, int y) * BIOS call "INT 10H Function 02h" to set cursor position * Call with %ah = 0x02 * %bh = page Index: normal/cmdline.c =================================================================== RCS file: /cvsroot/grub/grub2/normal/cmdline.c,v retrieving revision 1.8 diff -u -r1.8 cmdline.c --- normal/cmdline.c 27 Jun 2004 11:03:24 -0000 1.8 +++ normal/cmdline.c 8 Oct 2004 18:07:42 -0000 @@ -465,7 +465,7 @@ grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, int echo_char, int readline) { - unsigned xpos, ypos, ystart; + unsigned xpos, ypos, ystart, dummy; grub_size_t lpos, llen; grub_size_t plen; char buf[max_len]; @@ -491,10 +491,12 @@ { if (xpos++ > 78) { + int xtemp, ytemp; grub_putchar ('\n'); xpos = 1; - if (ypos == (unsigned) (grub_getxy () & 0xFF)) + grub_getxy(&xtemp, &ytemp); + if (ypos == ytemp) ystart--; else ypos++; @@ -546,13 +548,15 @@ lpos = llen = 0; buf[0] = '\0'; - if ((grub_getxy () >> 8) != 0) + grub_getxy (&xpos, &dummy); + if (xpos != 0) grub_putchar ('\n'); grub_printf (prompt); xpos = plen; - ystart = ypos = (grub_getxy () & 0xFF); + grub_getxy (&dummy, &ypos); + ystart = ypos; cl_insert (cmdline); @@ -610,7 +614,8 @@ /* Restore the prompt. */ grub_printf ("\n%s%s", prompt, buf); xpos = plen; - ystart = ypos = (grub_getxy () & 0xFF); + grub_getxy (&dummy, &ypos); + ystart = ypos; } if (insert) Index: normal/menu.c =================================================================== RCS file: /cvsroot/grub/grub2/normal/menu.c,v retrieving revision 1.8 diff -u -r1.8 menu.c --- normal/menu.c 18 Sep 2004 13:42:05 -0000 1.8 +++ normal/menu.c 8 Oct 2004 18:07:42 -0000 @@ -37,9 +37,8 @@ #define DISP_LL 0x2517 #define DISP_LR 0x251B -/* FIXME: These should be dynamically obtained from a terminal. */ -#define TERM_WIDTH (80 - 1) -#define TERM_HEIGHT 25 +static int TERM_WIDTH = (80 - 1); +static int TERM_HEIGHT = 25; /* The number of lines of "GRUB version..." at the top. */ #define TERM_INFO_HEIGHT 1 @@ -228,6 +227,7 @@ init_page (int nested, int edit) { grub_normal_init_page (); + grub_getgeometry(&TERM_WIDTH, &TERM_HEIGHT); draw_border (); print_message (nested, edit); } Index: term/i386/pc/console.c =================================================================== RCS file: /cvsroot/grub/grub2/term/i386/pc/console.c,v retrieving revision 1.4 diff -u -r1.4 console.c --- term/i386/pc/console.c 4 Apr 2004 13:46:03 -0000 1.4 +++ term/i386/pc/console.c 8 Oct 2004 18:07:42 -0000 @@ -107,6 +107,7 @@ .putchar = grub_console_putchar, .checkkey = grub_console_checkkey, .getkey = grub_console_getkey, + .getgeometry = grub_console_getgeometry, .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.5 diff -u -r1.5 vga.c --- term/i386/pc/vga.c 4 Apr 2004 13:46:03 -0000 1.5 +++ term/i386/pc/vga.c 8 Oct 2004 18:07:42 -0000 @@ -396,25 +396,34 @@ #if DEBUG_VGA if (show) { - grub_uint16_t pos = grub_getxy (); + int xpos, ypos; + grub_getxy (&xpos, &ypos); show = 0; grub_gotoxy (0, 0); - grub_printf ("[%u:%u]", (unsigned) (pos >> 8), (unsigned) (pos & 0xff)); - grub_gotoxy (pos >> 8, pos & 0xff); + grub_printf ("[%u:%u]", (unsigned) xpos, (unsigned) ypos); + grub_gotoxy (xpos, ypos); show = 1; } #endif } -static grub_uint16_t -grub_vga_getxy (void) +static void +grub_vga_getgeometry (int *x, int *y) +{ + *x = TEXT_WIDTH; + *y = TEXT_HEIGHT; +} + +static void +grub_vga_getxy (int *x, int *y) { - return ((xpos << 8) | ypos); + *x = xpos; + *y = ypos; } static void -grub_vga_gotoxy (grub_uint8_t x, grub_uint8_t y) +grub_vga_gotoxy (int x, int y) { if (x >= TEXT_WIDTH || y >= TEXT_HEIGHT) { @@ -500,6 +509,7 @@ .putchar = grub_vga_putchar, .checkkey = grub_console_checkkey, .getkey = grub_console_getkey, + .getgeometry = grub_vga_getgeometry, .getxy = grub_vga_getxy, .gotoxy = grub_vga_gotoxy, .cls = grub_vga_cls, Index: term/powerpc/ieee1275/ofconsole.c =================================================================== RCS file: /cvsroot/grub/grub2/term/powerpc/ieee1275/ofconsole.c,v retrieving revision 1.3 diff -u -r1.3 ofconsole.c --- term/powerpc/ieee1275/ofconsole.c 14 Sep 2004 21:21:12 -0000 1.3 +++ term/powerpc/ieee1275/ofconsole.c 8 Oct 2004 18:07:42 -0000 @@ -201,14 +201,22 @@ return key; } -static grub_uint16_t -grub_ofconsole_getxy (void) +static void +grub_ofconsole_getgeometry (int *x, int *y) +{ + *x = 80; + *y = 25; +} + +static void +grub_ofconsole_getxy (int *x, int *y) { - return ((grub_curr_x - 1) << 8) | grub_curr_y; + *x = grub_curr_x - 1; + *y = grub_curr_y; } static void -grub_ofconsole_gotoxy (grub_uint8_t x, grub_uint8_t y) +grub_ofconsole_gotoxy (int x, int y) { char s[11]; /* 5 + 3 + 3. */ grub_curr_x = x; @@ -289,6 +297,7 @@ .putchar = grub_ofconsole_putchar, .checkkey = grub_ofconsole_checkkey, .getkey = grub_ofconsole_getkey, + .getgeometry = grub_ofconsole_getgeometry, .getxy = grub_ofconsole_getxy, .gotoxy = grub_ofconsole_gotoxy, .cls = grub_ofconsole_cls, Index: util/console.c =================================================================== RCS file: /cvsroot/grub/grub2/util/console.c,v retrieving revision 1.5 diff -u -r1.5 console.c --- util/console.c 4 Apr 2004 13:46:03 -0000 1.5 +++ util/console.c 8 Oct 2004 18:07:42 -0000 @@ -121,19 +121,20 @@ return c; } -static grub_uint16_t -grub_ncurses_getxy (void) +static void +grub_ncurses_getgeometry (int *x, int *y) { - int x; - int y; - - getyx (stdscr, y, x); + getmaxyx (stdscr, *y, *x); +} - return (x << 8) | y; +static void +grub_ncurses_getxy (int *x, int *y) +{ + getyx (stdscr, *y, *x); } static void -grub_ncurses_gotoxy (grub_uint8_t x, grub_uint8_t y) +grub_ncurses_gotoxy (int x, int y) { move (y, x); } @@ -189,6 +190,7 @@ .putchar = grub_ncurses_putchar, .checkkey = grub_ncurses_checkkey, .getkey = grub_ncurses_getkey, + .getgeometry = grub_ncurses_getgeometry, .getxy = grub_ncurses_getxy, .gotoxy = grub_ncurses_gotoxy, .cls = grub_ncurses_cls,