+2005-08-04 Marco Gerards <metgerards@student.han.nl>
+
+ * kern/term.c (grub_putcode): Use `grub_getwh' instead of
+ hardcoded value.
+
+ From Vincent Pelletier <subdino2004@yahoo.fr>
+ * include/grub/term.h (GRUB_TERM_WIDTH, GRUB_TERM_HEIGHT):
+ Redefined to use grub_getwh.
+ (grub_term): New member named getwh.
+ (grub_getwh): New prototype.
+ * kern/term.c (grub_getwh): New function.
+ * term/i386/pc/console.c (grub_console_getwh): New function.
+ (grub_console_term): New member `getwh'.
+ * term/i386/pc/vga.c (grub_vga_getwh): New function.
+ (grub_vga_term): New member `getwh'.
+ * term/sparc64/ofconsole.c (grub_ofconsole_readkey): Use
+ grub_ssize_t.
+ (grub_ofconsole_getw): New function.
+ (grub_ofconsole_init): Use grub_ssize_t and unsigned char.
+ (grub_ofconsole_term): New field named getwh and new initial
+ value.
+
2005-08-03 Hollis Blanchard <hollis@penguinppc.org>
* include/grub/powerpc/ieee1275/ieee1275.h: Move ...
/* 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
/* 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);
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);
/*
* GRUB -- GRand Unified Bootloader
- * Copyright (C) 2002,2003 Free Software Foundation, Inc.
+ * Copyright (C) 2002,2003,2005 Free Software Foundation, Inc.
*
* GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
void
grub_putcode (grub_uint32_t code)
{
+ int height = grub_getwh () & 255;
+
if (code == '\t' && grub_cur_term->getxy)
{
int n;
grub_putcode ('\r');
grub_more_lines++;
- /* XXX: Don't use a fixed height! */
- if (grub_more && grub_more_lines == 24 - 1)
+
+ if (grub_more && grub_more_lines == height - 1)
{
char key;
int pos = grub_getxy ();
/* Show --MORE-- on the lower left side of the screen. */
- grub_gotoxy (1, 24 - 1);
+ 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, 24 -1);
+ grub_gotoxy (1, height - 1);
grub_printf (" ");
grub_gotoxy (pos >> 8, pos & 0xFF);
return (grub_cur_term->getxy) ();
}
+grub_uint16_t
+grub_getwh (void)
+{
+ return (grub_cur_term->getwh) ();
+}
+
void
grub_gotoxy (grub_uint8_t x, grub_uint8_t y)
{
grub_console_real_putchar (c);
}
+static grub_uint16_t
+grub_console_getwh (void)
+{
+ return (80 << 8) | 25;
+}
+
static void
grub_console_setcolorstate (grub_term_color_state state)
{
.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,
/*
* GRUB -- GRand Unified Bootloader
- * Copyright (C) 2000,2001,2002,2003,2004 Free Software Foundation, Inc.
+ * Copyright (C) 2000,2001,2002,2003,2004,2005 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#endif
}
+static grub_uint16_t
+grub_vga_getwh (void)
+{
+ return (TEXT_WIDTH << 8) | TEXT_HEIGHT;
+}
+
static grub_uint16_t
grub_vga_getxy (void)
{
.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,
/* ofconsole.c -- Open Firmware console for GRUB. */
/*
* GRUB -- GRand Unified Bootloader
- * Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ * Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
grub_ofconsole_readkey (int *key)
{
char c;
- int actual = 0;
+ grub_ssize_t actual = 0;
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
return ((grub_curr_x - 1) << 8) | grub_curr_y;
}
+static grub_uint16_t
+grub_ofconsole_getwh (void)
+{
+ grub_ieee1275_ihandle_t options;
+ char *val;
+ grub_ssize_t lval;
+ static grub_uint8_t w, h;
+
+ /* Once we have them, don't ask them again. */
+ if (!w || !h)
+ {
+ if (! grub_ieee1275_finddevice ("/options", &options)
+ && options != -1)
+ {
+ if (! grub_ieee1275_get_property_length (options, "screen-#columns",
+ &lval) && lval != -1)
+ {
+ val = grub_malloc (lval);
+ if (val)
+ {
+ if (! grub_ieee1275_get_property (options, "screen-#columns",
+ val, lval, 0))
+ w = (grub_uint8_t) grub_strtoul (val, val + lval, 10);
+
+ grub_free (val);
+ }
+ }
+ if (! grub_ieee1275_get_property_length (options, "screen-#rows",
+ &lval) && lval != -1)
+ {
+ val = grub_malloc (lval);
+ if (val)
+ {
+ if (! grub_ieee1275_get_property (options, "screen-#rows",
+ val, lval, 0))
+ h = (grub_uint8_t) grub_strtoul (val, val + lval, 10);
+
+ grub_free (val);
+ }
+ }
+ }
+ }
+
+ /* Use a small console by default. */
+ if (! w)
+ w = 80;
+ if (! h)
+ h = 24;
+
+ return (w << 8) | h;
+}
+
static void
grub_ofconsole_gotoxy (grub_uint8_t x, grub_uint8_t y)
{
static grub_err_t
grub_ofconsole_init (void)
{
- char data[4];
- grub_size_t actual;
+ unsigned char data[4];
+ grub_ssize_t actual;
int col;
if (grub_ieee1275_get_property (grub_ieee1275_chosen, "stdout", data,
.checkkey = grub_ofconsole_checkkey,
.getkey = grub_ofconsole_getkey,
.getxy = grub_ofconsole_getxy,
+ .getwh = grub_ofconsole_getwh,
.gotoxy = grub_ofconsole_gotoxy,
.cls = grub_ofconsole_cls,
.setcolorstate = grub_ofconsole_setcolorstate,