Lift 255x255 erminal sie restriction to 65535x65535. Also change from
bitmasks to small structures of size chosen to fit in registers.
This commit is contained in:
parent
7abdac8e13
commit
e89c2d48a9
24 changed files with 266 additions and 244 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2013-10-19 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Lift 255x255 erminal sie restriction to 65535x65535. Also change from
|
||||||
|
bitmasks to small structures of size chosen to fit in registers.
|
||||||
|
|
||||||
2013-10-19 Vladimir Serbinenko <phcoder@gmail.com>
|
2013-10-19 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* conf/Makefile.common: Use -freg-struct-return on i386. This
|
* conf/Makefile.common: Use -freg-struct-return on i386. This
|
||||||
|
|
|
@ -34,7 +34,7 @@ static const struct grub_arg_option options[] =
|
||||||
{0, 0, 0, 0, 0, 0}
|
{0, 0, 0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static grub_uint16_t *pos;
|
static struct grub_term_coordinate *pos;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_print (int n)
|
do_print (int n)
|
||||||
|
|
|
@ -53,7 +53,7 @@ grub_putcode_dumb (grub_uint32_t code,
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
n = GRUB_TERM_TAB_WIDTH - ((term->getxy (term) >> 8)
|
n = GRUB_TERM_TAB_WIDTH - ((term->getxy (term).x)
|
||||||
% GRUB_TERM_TAB_WIDTH);
|
% GRUB_TERM_TAB_WIDTH);
|
||||||
while (n--)
|
while (n--)
|
||||||
grub_putcode_dumb (' ', term);
|
grub_putcode_dumb (' ', term);
|
||||||
|
|
|
@ -530,9 +530,9 @@ grub_linux_boot (void)
|
||||||
|| grub_strcmp (term->name, "console") == 0
|
|| grub_strcmp (term->name, "console") == 0
|
||||||
|| grub_strcmp (term->name, "ofconsole") == 0)
|
|| grub_strcmp (term->name, "ofconsole") == 0)
|
||||||
{
|
{
|
||||||
grub_uint16_t pos = grub_term_getxy (term);
|
struct grub_term_coordinate pos = grub_term_getxy (term);
|
||||||
linux_params.video_cursor_x = pos >> 8;
|
linux_params.video_cursor_x = pos.x;
|
||||||
linux_params.video_cursor_y = pos & 0xff;
|
linux_params.video_cursor_y = pos.y;
|
||||||
linux_params.video_width = grub_term_width (term);
|
linux_params.video_width = grub_term_width (term);
|
||||||
linux_params.video_height = grub_term_height (term);
|
linux_params.video_height = grub_term_height (term);
|
||||||
found = 1;
|
found = 1;
|
||||||
|
|
|
@ -206,7 +206,8 @@ print_completion (const char *item, grub_completion_type_t type, int count)
|
||||||
|
|
||||||
struct cmdline_term
|
struct cmdline_term
|
||||||
{
|
{
|
||||||
unsigned xpos, ypos, ystart, width, height;
|
struct grub_term_coordinate pos;
|
||||||
|
unsigned ystart, width, height;
|
||||||
unsigned prompt_len;
|
unsigned prompt_len;
|
||||||
struct grub_term_output *term;
|
struct grub_term_output *term;
|
||||||
};
|
};
|
||||||
|
@ -237,10 +238,10 @@ grub_cmdline_get (const char *prompt_translated)
|
||||||
|
|
||||||
void cl_set_pos (struct cmdline_term *cl_term)
|
void cl_set_pos (struct cmdline_term *cl_term)
|
||||||
{
|
{
|
||||||
cl_term->xpos = (cl_term->prompt_len + lpos) % cl_term->width;
|
cl_term->pos.x = (cl_term->prompt_len + lpos) % cl_term->width;
|
||||||
cl_term->ypos = cl_term->ystart
|
cl_term->pos.y = cl_term->ystart
|
||||||
+ (cl_term->prompt_len + lpos) / cl_term->width;
|
+ (cl_term->prompt_len + lpos) / cl_term->width;
|
||||||
grub_term_gotoxy (cl_term->term, cl_term->xpos, cl_term->ypos);
|
grub_term_gotoxy (cl_term->term, cl_term->pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cl_set_pos_all (void)
|
void cl_set_pos_all (void)
|
||||||
|
@ -260,14 +261,14 @@ grub_cmdline_get (const char *prompt_translated)
|
||||||
grub_putcode (c, cl_term->term);
|
grub_putcode (c, cl_term->term);
|
||||||
else
|
else
|
||||||
grub_putcode (*p, cl_term->term);
|
grub_putcode (*p, cl_term->term);
|
||||||
cl_term->xpos++;
|
cl_term->pos.x++;
|
||||||
if (cl_term->xpos >= cl_term->width - 1)
|
if (cl_term->pos.x >= cl_term->width - 1)
|
||||||
{
|
{
|
||||||
cl_term->xpos = 0;
|
cl_term->pos.x = 0;
|
||||||
if (cl_term->ypos >= (unsigned) (cl_term->height - 1))
|
if (cl_term->pos.y >= (unsigned) (cl_term->height - 1))
|
||||||
cl_term->ystart--;
|
cl_term->ystart--;
|
||||||
else
|
else
|
||||||
cl_term->ypos++;
|
cl_term->pos.y++;
|
||||||
grub_putcode ('\n', cl_term->term);
|
grub_putcode ('\n', cl_term->term);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -335,9 +336,9 @@ grub_cmdline_get (const char *prompt_translated)
|
||||||
|
|
||||||
void init_clterm (struct cmdline_term *cl_term_cur)
|
void init_clterm (struct cmdline_term *cl_term_cur)
|
||||||
{
|
{
|
||||||
cl_term_cur->xpos = cl_term_cur->prompt_len;
|
cl_term_cur->pos.x = cl_term_cur->prompt_len;
|
||||||
cl_term_cur->ypos = (grub_term_getxy (cl_term_cur->term) & 0xFF);
|
cl_term_cur->pos.y = grub_term_getxy (cl_term_cur->term).y;
|
||||||
cl_term_cur->ystart = cl_term_cur->ypos;
|
cl_term_cur->ystart = cl_term_cur->pos.y;
|
||||||
cl_term_cur->width = grub_term_width (cl_term_cur->term);
|
cl_term_cur->width = grub_term_width (cl_term_cur->term);
|
||||||
cl_term_cur->height = grub_term_height (cl_term_cur->term);
|
cl_term_cur->height = grub_term_height (cl_term_cur->term);
|
||||||
}
|
}
|
||||||
|
@ -360,7 +361,7 @@ grub_cmdline_get (const char *prompt_translated)
|
||||||
grub_term_output_t term;
|
grub_term_output_t term;
|
||||||
|
|
||||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
FOR_ACTIVE_TERM_OUTPUTS(term)
|
||||||
if ((grub_term_getxy (term) >> 8) != 0)
|
if ((grub_term_getxy (term).x) != 0)
|
||||||
grub_putcode ('\n', term);
|
grub_putcode ('\n', term);
|
||||||
}
|
}
|
||||||
grub_xputs (prompt_translated);
|
grub_xputs (prompt_translated);
|
||||||
|
|
|
@ -264,7 +264,7 @@ grub_normal_init_page (struct grub_term_output *term,
|
||||||
posx = ((int) grub_term_width (term) - posx) / 2;
|
posx = ((int) grub_term_width (term) - posx) / 2;
|
||||||
if (posx < 0)
|
if (posx < 0)
|
||||||
posx = 0;
|
posx = 0;
|
||||||
grub_term_gotoxy (term, posx, y);
|
grub_term_gotoxy (term, (struct grub_term_coordinate) { posx, y });
|
||||||
|
|
||||||
grub_print_ucs4 (unicode_msg, last_position, 0, 0, term);
|
grub_print_ucs4 (unicode_msg, last_position, 0, 0, term);
|
||||||
grub_putcode ('\n', term);
|
grub_putcode ('\n', term);
|
||||||
|
|
|
@ -146,8 +146,8 @@ print_empty_line (int y, struct per_term_screen *term_screen)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
grub_term_gotoxy (term_screen->term,
|
grub_term_gotoxy (term_screen->term,
|
||||||
term_screen->geo.first_entry_x,
|
(struct grub_term_coordinate) { term_screen->geo.first_entry_x,
|
||||||
y + term_screen->geo.first_entry_y);
|
y + term_screen->geo.first_entry_y });
|
||||||
|
|
||||||
for (i = 0; i < term_screen->geo.entry_width + 1; i++)
|
for (i = 0; i < term_screen->geo.entry_width + 1; i++)
|
||||||
grub_putcode (' ', term_screen->term);
|
grub_putcode (' ', term_screen->term);
|
||||||
|
@ -156,10 +156,11 @@ print_empty_line (int y, struct per_term_screen *term_screen)
|
||||||
static void
|
static void
|
||||||
print_updown (int upflag, int downflag, struct per_term_screen *term_screen)
|
print_updown (int upflag, int downflag, struct per_term_screen *term_screen)
|
||||||
{
|
{
|
||||||
grub_term_gotoxy (term_screen->term, term_screen->geo.first_entry_x
|
grub_term_gotoxy (term_screen->term,
|
||||||
|
(struct grub_term_coordinate) { term_screen->geo.first_entry_x
|
||||||
+ term_screen->geo.entry_width + 1
|
+ term_screen->geo.entry_width + 1
|
||||||
+ term_screen->geo.border,
|
+ term_screen->geo.border,
|
||||||
term_screen->geo.first_entry_y);
|
term_screen->geo.first_entry_y });
|
||||||
|
|
||||||
if (upflag && downflag)
|
if (upflag && downflag)
|
||||||
grub_putcode (GRUB_UNICODE_UPDOWNARROW, term_screen->term);
|
grub_putcode (GRUB_UNICODE_UPDOWNARROW, term_screen->term);
|
||||||
|
@ -175,10 +176,11 @@ print_updown (int upflag, int downflag, struct per_term_screen *term_screen)
|
||||||
static void
|
static void
|
||||||
print_up (int flag, struct per_term_screen *term_screen)
|
print_up (int flag, struct per_term_screen *term_screen)
|
||||||
{
|
{
|
||||||
grub_term_gotoxy (term_screen->term, term_screen->geo.first_entry_x
|
grub_term_gotoxy (term_screen->term,
|
||||||
|
(struct grub_term_coordinate) { term_screen->geo.first_entry_x
|
||||||
+ term_screen->geo.entry_width + 1
|
+ term_screen->geo.entry_width + 1
|
||||||
+ term_screen->geo.border,
|
+ term_screen->geo.border,
|
||||||
term_screen->geo.first_entry_y);
|
term_screen->geo.first_entry_y });
|
||||||
|
|
||||||
if (flag)
|
if (flag)
|
||||||
grub_putcode (GRUB_UNICODE_UPARROW, term_screen->term);
|
grub_putcode (GRUB_UNICODE_UPARROW, term_screen->term);
|
||||||
|
@ -190,11 +192,12 @@ print_up (int flag, struct per_term_screen *term_screen)
|
||||||
static void
|
static void
|
||||||
print_down (int flag, struct per_term_screen *term_screen)
|
print_down (int flag, struct per_term_screen *term_screen)
|
||||||
{
|
{
|
||||||
grub_term_gotoxy (term_screen->term, term_screen->geo.first_entry_x
|
grub_term_gotoxy (term_screen->term,
|
||||||
|
(struct grub_term_coordinate) { term_screen->geo.first_entry_x
|
||||||
+ term_screen->geo.entry_width + 1
|
+ term_screen->geo.entry_width + 1
|
||||||
+ term_screen->geo.border,
|
+ term_screen->geo.border,
|
||||||
term_screen->geo.first_entry_y
|
term_screen->geo.first_entry_y
|
||||||
+ term_screen->geo.num_entries - 1);
|
+ term_screen->geo.num_entries - 1 });
|
||||||
|
|
||||||
if (flag)
|
if (flag)
|
||||||
grub_putcode (GRUB_UNICODE_DOWNARROW, term_screen->term);
|
grub_putcode (GRUB_UNICODE_DOWNARROW, term_screen->term);
|
||||||
|
@ -278,9 +281,10 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen,
|
||||||
if (i == region_start || linep == screen->lines + screen->line
|
if (i == region_start || linep == screen->lines + screen->line
|
||||||
|| (i > region_start && mode == ALL_LINES))
|
|| (i > region_start && mode == ALL_LINES))
|
||||||
{
|
{
|
||||||
grub_term_gotoxy (term_screen->term, term_screen->geo.first_entry_x,
|
grub_term_gotoxy (term_screen->term,
|
||||||
|
(struct grub_term_coordinate) { term_screen->geo.first_entry_x,
|
||||||
(y < 0 ? 0 : y)
|
(y < 0 ? 0 : y)
|
||||||
+ term_screen->geo.first_entry_y);
|
+ term_screen->geo.first_entry_y });
|
||||||
|
|
||||||
grub_print_ucs4_menu (linep->buf,
|
grub_print_ucs4_menu (linep->buf,
|
||||||
linep->buf + linep->len,
|
linep->buf + linep->len,
|
||||||
|
@ -338,13 +342,13 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen,
|
||||||
y += get_logical_num_lines (screen->lines + i, term_screen);
|
y += get_logical_num_lines (screen->lines + i, term_screen);
|
||||||
if (cpos >= &(screen->lines[screen->line].pos[term_screen - screen->terms])[0])
|
if (cpos >= &(screen->lines[screen->line].pos[term_screen - screen->terms])[0])
|
||||||
grub_term_gotoxy (term_screen->term,
|
grub_term_gotoxy (term_screen->term,
|
||||||
cpos->x + term_screen->geo.first_entry_x,
|
(struct grub_term_coordinate) { cpos->x + term_screen->geo.first_entry_x,
|
||||||
cpos->y + y
|
cpos->y + y
|
||||||
+ term_screen->geo.first_entry_y);
|
+ term_screen->geo.first_entry_y });
|
||||||
else
|
else
|
||||||
grub_term_gotoxy (term_screen->term,
|
grub_term_gotoxy (term_screen->term,
|
||||||
term_screen->geo.first_entry_x,
|
(struct grub_term_coordinate) { term_screen->geo.first_entry_x,
|
||||||
y + term_screen->geo.first_entry_y);
|
y + term_screen->geo.first_entry_y });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1028,15 +1032,16 @@ complete (struct screen *screen, int continuous, int update)
|
||||||
+ width - 1)
|
+ width - 1)
|
||||||
/ width);
|
/ width);
|
||||||
grub_uint32_t *endp;
|
grub_uint32_t *endp;
|
||||||
grub_uint16_t pos;
|
struct grub_term_coordinate pos;
|
||||||
grub_uint32_t *p = ucs4;
|
grub_uint32_t *p = ucs4;
|
||||||
|
|
||||||
pos = grub_term_getxy (screen->terms[i].term);
|
pos = grub_term_getxy (screen->terms[i].term);
|
||||||
|
|
||||||
screen->completion_shown = 1;
|
screen->completion_shown = 1;
|
||||||
|
|
||||||
grub_term_gotoxy (screen->terms[i].term, 0,
|
grub_term_gotoxy (screen->terms[i].term,
|
||||||
screen->terms[i].geo.timeout_y);
|
(struct grub_term_coordinate) { 0,
|
||||||
|
screen->terms[i].geo.timeout_y });
|
||||||
if (screen->terms[i].geo.timeout_lines >= 2)
|
if (screen->terms[i].geo.timeout_lines >= 2)
|
||||||
{
|
{
|
||||||
grub_puts_terminal (" ", screen->terms[i].term);
|
grub_puts_terminal (" ", screen->terms[i].term);
|
||||||
|
@ -1084,7 +1089,7 @@ complete (struct screen *screen, int continuous, int update)
|
||||||
|
|
||||||
if (ucs4 + ucs4len > endp)
|
if (ucs4 + ucs4len > endp)
|
||||||
grub_putcode (GRUB_UNICODE_RIGHTARROW, screen->terms[i].term);
|
grub_putcode (GRUB_UNICODE_RIGHTARROW, screen->terms[i].term);
|
||||||
grub_term_gotoxy (screen->terms[i].term, pos >> 8, pos & 0xFF);
|
grub_term_gotoxy (screen->terms[i].term, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1105,13 +1110,14 @@ complete (struct screen *screen, int continuous, int update)
|
||||||
static void
|
static void
|
||||||
clear_completions (struct per_term_screen *term_screen)
|
clear_completions (struct per_term_screen *term_screen)
|
||||||
{
|
{
|
||||||
grub_uint16_t pos;
|
struct grub_term_coordinate pos;
|
||||||
unsigned j;
|
unsigned j;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
pos = grub_term_getxy (term_screen->term);
|
pos = grub_term_getxy (term_screen->term);
|
||||||
grub_term_gotoxy (term_screen->term, 0,
|
grub_term_gotoxy (term_screen->term,
|
||||||
term_screen->geo.timeout_y);
|
(struct grub_term_coordinate) { 0,
|
||||||
|
term_screen->geo.timeout_y });
|
||||||
|
|
||||||
for (i = 0; i < term_screen->geo.timeout_lines; i++)
|
for (i = 0; i < term_screen->geo.timeout_lines; i++)
|
||||||
{
|
{
|
||||||
|
@ -1121,7 +1127,7 @@ clear_completions (struct per_term_screen *term_screen)
|
||||||
grub_putcode ('\n', term_screen->term);
|
grub_putcode ('\n', term_screen->term);
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_term_gotoxy (term_screen->term, pos >> 8, pos & 0xFF);
|
grub_term_gotoxy (term_screen->term, pos);
|
||||||
grub_term_refresh (term_screen->term);
|
grub_term_refresh (term_screen->term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,8 @@ draw_border (struct grub_term_output *term, const struct grub_term_screen_geomet
|
||||||
|
|
||||||
grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL);
|
grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL);
|
||||||
|
|
||||||
grub_term_gotoxy (term, geo->first_entry_x - 1, geo->first_entry_y - 1);
|
grub_term_gotoxy (term, (struct grub_term_coordinate) { geo->first_entry_x - 1,
|
||||||
|
geo->first_entry_y - 1 });
|
||||||
grub_putcode (GRUB_UNICODE_CORNER_UL, term);
|
grub_putcode (GRUB_UNICODE_CORNER_UL, term);
|
||||||
for (i = 0; i < geo->entry_width + 1; i++)
|
for (i = 0; i < geo->entry_width + 1; i++)
|
||||||
grub_putcode (GRUB_UNICODE_HLINE, term);
|
grub_putcode (GRUB_UNICODE_HLINE, term);
|
||||||
|
@ -123,15 +124,18 @@ draw_border (struct grub_term_output *term, const struct grub_term_screen_geomet
|
||||||
|
|
||||||
for (i = 0; i < geo->num_entries; i++)
|
for (i = 0; i < geo->num_entries; i++)
|
||||||
{
|
{
|
||||||
grub_term_gotoxy (term, geo->first_entry_x - 1, geo->first_entry_y + i);
|
grub_term_gotoxy (term, (struct grub_term_coordinate) { geo->first_entry_x - 1,
|
||||||
|
geo->first_entry_y + i });
|
||||||
grub_putcode (GRUB_UNICODE_VLINE, term);
|
grub_putcode (GRUB_UNICODE_VLINE, term);
|
||||||
grub_term_gotoxy (term, geo->first_entry_x + geo->entry_width + 1,
|
grub_term_gotoxy (term,
|
||||||
geo->first_entry_y + i);
|
(struct grub_term_coordinate) { geo->first_entry_x + geo->entry_width + 1,
|
||||||
|
geo->first_entry_y + i });
|
||||||
grub_putcode (GRUB_UNICODE_VLINE, term);
|
grub_putcode (GRUB_UNICODE_VLINE, term);
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_term_gotoxy (term, geo->first_entry_x - 1,
|
grub_term_gotoxy (term,
|
||||||
geo->first_entry_y - 1 + geo->num_entries + 1);
|
(struct grub_term_coordinate) { geo->first_entry_x - 1,
|
||||||
|
geo->first_entry_y - 1 + geo->num_entries + 1 });
|
||||||
grub_putcode (GRUB_UNICODE_CORNER_LL, term);
|
grub_putcode (GRUB_UNICODE_CORNER_LL, term);
|
||||||
for (i = 0; i < geo->entry_width + 1; i++)
|
for (i = 0; i < geo->entry_width + 1; i++)
|
||||||
grub_putcode (GRUB_UNICODE_HLINE, term);
|
grub_putcode (GRUB_UNICODE_HLINE, term);
|
||||||
|
@ -139,9 +143,10 @@ draw_border (struct grub_term_output *term, const struct grub_term_screen_geomet
|
||||||
|
|
||||||
grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL);
|
grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL);
|
||||||
|
|
||||||
grub_term_gotoxy (term, geo->first_entry_x - 1,
|
grub_term_gotoxy (term,
|
||||||
|
(struct grub_term_coordinate) { geo->first_entry_x - 1,
|
||||||
(geo->first_entry_y - 1 + geo->num_entries
|
(geo->first_entry_y - 1 + geo->num_entries
|
||||||
+ GRUB_TERM_MARGIN + 1));
|
+ GRUB_TERM_MARGIN + 1) });
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -228,7 +233,8 @@ print_entry (int y, int highlight, grub_menu_entry_t entry,
|
||||||
? GRUB_TERM_COLOR_HIGHLIGHT
|
? GRUB_TERM_COLOR_HIGHLIGHT
|
||||||
: GRUB_TERM_COLOR_NORMAL);
|
: GRUB_TERM_COLOR_NORMAL);
|
||||||
|
|
||||||
grub_term_gotoxy (data->term, data->geo.first_entry_x, y);
|
grub_term_gotoxy (data->term, (struct grub_term_coordinate) {
|
||||||
|
data->geo.first_entry_x, y });
|
||||||
|
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
if (unicode_title[i] == '\n' || unicode_title[i] == '\b'
|
if (unicode_title[i] == '\n' || unicode_title[i] == '\b'
|
||||||
|
@ -246,7 +252,9 @@ print_entry (int y, int highlight, grub_menu_entry_t entry,
|
||||||
GRUB_UNICODE_RIGHTARROW, 0);
|
GRUB_UNICODE_RIGHTARROW, 0);
|
||||||
|
|
||||||
grub_term_setcolorstate (data->term, GRUB_TERM_COLOR_NORMAL);
|
grub_term_setcolorstate (data->term, GRUB_TERM_COLOR_NORMAL);
|
||||||
grub_term_gotoxy (data->term, grub_term_cursor_x (&data->geo), y);
|
grub_term_gotoxy (data->term,
|
||||||
|
(struct grub_term_coordinate) {
|
||||||
|
grub_term_cursor_x (&data->geo), y });
|
||||||
|
|
||||||
grub_term_normal_color = old_color_normal;
|
grub_term_normal_color = old_color_normal;
|
||||||
grub_term_highlight_color = old_color_highlight;
|
grub_term_highlight_color = old_color_highlight;
|
||||||
|
@ -262,9 +270,10 @@ print_entries (grub_menu_t menu, const struct menu_viewer_data *data)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
grub_term_gotoxy (data->term,
|
grub_term_gotoxy (data->term,
|
||||||
|
(struct grub_term_coordinate) {
|
||||||
data->geo.first_entry_x + data->geo.entry_width
|
data->geo.first_entry_x + data->geo.entry_width
|
||||||
+ data->geo.border + 1,
|
+ data->geo.border + 1,
|
||||||
data->geo.first_entry_y);
|
data->geo.first_entry_y });
|
||||||
|
|
||||||
if (data->geo.num_entries != 1)
|
if (data->geo.num_entries != 1)
|
||||||
{
|
{
|
||||||
|
@ -283,9 +292,10 @@ print_entries (grub_menu_t menu, const struct menu_viewer_data *data)
|
||||||
e = e->next;
|
e = e->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_term_gotoxy (data->term, data->geo.first_entry_x + data->geo.entry_width
|
grub_term_gotoxy (data->term,
|
||||||
|
(struct grub_term_coordinate) { data->geo.first_entry_x + data->geo.entry_width
|
||||||
+ data->geo.border + 1,
|
+ data->geo.border + 1,
|
||||||
data->geo.first_entry_y + data->geo.num_entries - 1);
|
data->geo.first_entry_y + data->geo.num_entries - 1 });
|
||||||
if (data->geo.num_entries == 1)
|
if (data->geo.num_entries == 1)
|
||||||
{
|
{
|
||||||
if (data->first && e)
|
if (data->first && e)
|
||||||
|
@ -305,8 +315,9 @@ print_entries (grub_menu_t menu, const struct menu_viewer_data *data)
|
||||||
grub_putcode (' ', data->term);
|
grub_putcode (' ', data->term);
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_term_gotoxy (data->term, grub_term_cursor_x (&data->geo),
|
grub_term_gotoxy (data->term,
|
||||||
data->geo.first_entry_y + data->offset);
|
(struct grub_term_coordinate) { grub_term_cursor_x (&data->geo),
|
||||||
|
data->geo.first_entry_y + data->offset });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the screen. If NESTED is non-zero, assume that this menu
|
/* Initialize the screen. If NESTED is non-zero, assume that this menu
|
||||||
|
@ -404,8 +415,9 @@ grub_menu_init_page (int nested, int edit,
|
||||||
+ geo->border + empty_lines;
|
+ geo->border + empty_lines;
|
||||||
if (bottom_message)
|
if (bottom_message)
|
||||||
{
|
{
|
||||||
grub_term_gotoxy (term, GRUB_TERM_MARGIN,
|
grub_term_gotoxy (term,
|
||||||
geo->timeout_y);
|
(struct grub_term_coordinate) { GRUB_TERM_MARGIN,
|
||||||
|
geo->timeout_y });
|
||||||
|
|
||||||
print_message (nested, edit, term, 0);
|
print_message (nested, edit, term, 0);
|
||||||
geo->timeout_y += msg_num_lines;
|
geo->timeout_y += msg_num_lines;
|
||||||
|
@ -424,7 +436,8 @@ menu_text_print_timeout (int timeout, void *dataptr)
|
||||||
struct menu_viewer_data *data = dataptr;
|
struct menu_viewer_data *data = dataptr;
|
||||||
char *msg_translated = 0;
|
char *msg_translated = 0;
|
||||||
|
|
||||||
grub_term_gotoxy (data->term, 0, data->geo.timeout_y);
|
grub_term_gotoxy (data->term,
|
||||||
|
(struct grub_term_coordinate) { 0, data->geo.timeout_y });
|
||||||
|
|
||||||
if (data->timeout_msg == TIMEOUT_TERSE
|
if (data->timeout_msg == TIMEOUT_TERSE
|
||||||
|| data->timeout_msg == TIMEOUT_TERSE_NO_MARGIN)
|
|| data->timeout_msg == TIMEOUT_TERSE_NO_MARGIN)
|
||||||
|
@ -459,8 +472,9 @@ menu_text_print_timeout (int timeout, void *dataptr)
|
||||||
grub_free (msg_translated);
|
grub_free (msg_translated);
|
||||||
|
|
||||||
grub_term_gotoxy (data->term,
|
grub_term_gotoxy (data->term,
|
||||||
|
(struct grub_term_coordinate) {
|
||||||
grub_term_cursor_x (&data->geo),
|
grub_term_cursor_x (&data->geo),
|
||||||
data->geo.first_entry_y + data->offset);
|
data->geo.first_entry_y + data->offset });
|
||||||
grub_term_refresh (data->term);
|
grub_term_refresh (data->term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,22 +530,28 @@ menu_text_clear_timeout (void *dataptr)
|
||||||
|
|
||||||
for (i = 0; i < data->geo.timeout_lines;i++)
|
for (i = 0; i < data->geo.timeout_lines;i++)
|
||||||
{
|
{
|
||||||
grub_term_gotoxy (data->term, 0, data->geo.timeout_y + i);
|
grub_term_gotoxy (data->term, (struct grub_term_coordinate) {
|
||||||
|
0, data->geo.timeout_y + i });
|
||||||
grub_print_spaces (data->term, grub_term_width (data->term) - 1);
|
grub_print_spaces (data->term, grub_term_width (data->term) - 1);
|
||||||
}
|
}
|
||||||
if (data->geo.num_entries <= 5 && !data->geo.border)
|
if (data->geo.num_entries <= 5 && !data->geo.border)
|
||||||
{
|
{
|
||||||
grub_term_gotoxy (data->term, data->geo.first_entry_x + data->geo.entry_width
|
grub_term_gotoxy (data->term,
|
||||||
|
(struct grub_term_coordinate) {
|
||||||
|
data->geo.first_entry_x + data->geo.entry_width
|
||||||
+ data->geo.border + 1,
|
+ data->geo.border + 1,
|
||||||
data->geo.first_entry_y + data->geo.num_entries - 1);
|
data->geo.first_entry_y + data->geo.num_entries - 1
|
||||||
|
});
|
||||||
grub_putcode (' ', data->term);
|
grub_putcode (' ', data->term);
|
||||||
|
|
||||||
data->geo.timeout_lines = 0;
|
data->geo.timeout_lines = 0;
|
||||||
data->geo.num_entries++;
|
data->geo.num_entries++;
|
||||||
print_entries (data->menu, data);
|
print_entries (data->menu, data);
|
||||||
}
|
}
|
||||||
grub_term_gotoxy (data->term, grub_term_cursor_x (&data->geo),
|
grub_term_gotoxy (data->term,
|
||||||
data->geo.first_entry_y + data->offset);
|
(struct grub_term_coordinate) {
|
||||||
|
grub_term_cursor_x (&data->geo),
|
||||||
|
data->geo.first_entry_y + data->offset });
|
||||||
grub_term_refresh (data->term);
|
grub_term_refresh (data->term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ static void
|
||||||
print_more (void)
|
print_more (void)
|
||||||
{
|
{
|
||||||
char key;
|
char key;
|
||||||
grub_uint16_t *pos;
|
struct grub_term_coordinate *pos;
|
||||||
grub_term_output_t term;
|
grub_term_output_t term;
|
||||||
grub_uint32_t *unicode_str, *unicode_last_position;
|
grub_uint32_t *unicode_str, *unicode_last_position;
|
||||||
|
|
||||||
|
@ -257,12 +257,12 @@ grub_puts_terminal (const char *str, struct grub_term_output *term)
|
||||||
grub_free (unicode_str);
|
grub_free (unicode_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_uint16_t *
|
struct grub_term_coordinate *
|
||||||
grub_term_save_pos (void)
|
grub_term_save_pos (void)
|
||||||
{
|
{
|
||||||
struct grub_term_output *cur;
|
struct grub_term_output *cur;
|
||||||
unsigned cnt = 0;
|
unsigned cnt = 0;
|
||||||
grub_uint16_t *ret, *ptr;
|
struct grub_term_coordinate *ret, *ptr;
|
||||||
|
|
||||||
FOR_ACTIVE_TERM_OUTPUTS(cur)
|
FOR_ACTIVE_TERM_OUTPUTS(cur)
|
||||||
cnt++;
|
cnt++;
|
||||||
|
@ -279,17 +279,17 @@ grub_term_save_pos (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_term_restore_pos (grub_uint16_t *pos)
|
grub_term_restore_pos (struct grub_term_coordinate *pos)
|
||||||
{
|
{
|
||||||
struct grub_term_output *cur;
|
struct grub_term_output *cur;
|
||||||
grub_uint16_t *ptr = pos;
|
struct grub_term_coordinate *ptr = pos;
|
||||||
|
|
||||||
if (!pos)
|
if (!pos)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FOR_ACTIVE_TERM_OUTPUTS(cur)
|
FOR_ACTIVE_TERM_OUTPUTS(cur)
|
||||||
{
|
{
|
||||||
grub_term_gotoxy (cur, (*ptr & 0xff00) >> 8, *ptr & 0xff);
|
grub_term_gotoxy (cur, *ptr);
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -444,7 +444,7 @@ putglyph (const struct grub_unicode_glyph *c, struct grub_term_output *term,
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
n = GRUB_TERM_TAB_WIDTH - ((term->getxy (term) >> 8)
|
n = GRUB_TERM_TAB_WIDTH - ((term->getxy (term).x)
|
||||||
% GRUB_TERM_TAB_WIDTH);
|
% GRUB_TERM_TAB_WIDTH);
|
||||||
c2.base = ' ';
|
c2.base = ' ';
|
||||||
while (n--)
|
while (n--)
|
||||||
|
@ -545,14 +545,14 @@ static grub_ssize_t
|
||||||
get_startwidth (struct grub_term_output *term,
|
get_startwidth (struct grub_term_output *term,
|
||||||
int margin_left)
|
int margin_left)
|
||||||
{
|
{
|
||||||
return ((term->getxy (term) >> 8) & 0xff) - margin_left;
|
return (term->getxy (term).x) - margin_left;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fill_margin (struct grub_term_output *term, int r)
|
fill_margin (struct grub_term_output *term, int r)
|
||||||
{
|
{
|
||||||
int sp = (term->getwh (term) >> 8)
|
int sp = (term->getwh (term).x)
|
||||||
- (term->getxy (term) >> 8) - r;
|
- (term->getxy (term).x) - r;
|
||||||
if (sp > 0)
|
if (sp > 0)
|
||||||
grub_print_spaces (term, sp);
|
grub_print_spaces (term, sp);
|
||||||
}
|
}
|
||||||
|
@ -713,8 +713,8 @@ print_ucs4_terminal (const grub_uint32_t * str,
|
||||||
if (!contchar)
|
if (!contchar)
|
||||||
grub_print_spaces (term, margin_left);
|
grub_print_spaces (term, margin_left);
|
||||||
else
|
else
|
||||||
grub_term_gotoxy (term, margin_left,
|
grub_term_gotoxy (term, (struct grub_term_coordinate)
|
||||||
grub_term_getxy (term) & 0xff);
|
{ margin_left, grub_term_getxy (term).y });
|
||||||
for (i = 0; i < state->bidi_stack_depth; i++)
|
for (i = 0; i < state->bidi_stack_depth; i++)
|
||||||
putcode_real (state->bidi_stack[i] | (GRUB_UNICODE_LRE & ~0xff),
|
putcode_real (state->bidi_stack[i] | (GRUB_UNICODE_LRE & ~0xff),
|
||||||
term, fixed_tab);
|
term, fixed_tab);
|
||||||
|
@ -807,8 +807,9 @@ put_glyphs_terminal (struct grub_unicode_glyph *visual,
|
||||||
if (!contchar)
|
if (!contchar)
|
||||||
grub_print_spaces (term, margin_left);
|
grub_print_spaces (term, margin_left);
|
||||||
else
|
else
|
||||||
grub_term_gotoxy (term, margin_left,
|
grub_term_gotoxy (term,
|
||||||
grub_term_getxy (term) & 0xff);
|
(struct grub_term_coordinate)
|
||||||
|
{ margin_left, grub_term_getxy (term).y });
|
||||||
}
|
}
|
||||||
grub_unicode_destroy_glyph (visual_ptr);
|
grub_unicode_destroy_glyph (visual_ptr);
|
||||||
}
|
}
|
||||||
|
@ -885,19 +886,19 @@ print_ucs4_real (const grub_uint32_t * str,
|
||||||
|
|
||||||
if (!dry_run)
|
if (!dry_run)
|
||||||
{
|
{
|
||||||
int xy;
|
struct grub_term_coordinate xy;
|
||||||
if (backlog)
|
if (backlog)
|
||||||
state = find_term_state (term);
|
state = find_term_state (term);
|
||||||
|
|
||||||
xy = term->getxy (term);
|
xy = term->getxy (term);
|
||||||
|
|
||||||
if (((xy >> 8) & 0xff) < margin_left)
|
if (xy.x < margin_left)
|
||||||
{
|
{
|
||||||
if (!contchar)
|
if (!contchar)
|
||||||
grub_print_spaces (term, margin_left - ((xy >> 8) & 0xff));
|
grub_print_spaces (term, margin_left - xy.x);
|
||||||
else
|
else
|
||||||
grub_term_gotoxy (term, margin_left,
|
grub_term_gotoxy (term, (struct grub_term_coordinate) {margin_left,
|
||||||
xy & 0xff);
|
xy.y});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,13 +101,13 @@ grub_console_init_output (struct grub_term_output *term)
|
||||||
struct winsize size;
|
struct winsize size;
|
||||||
if (ioctl (STDOUT_FILENO, TIOCGWINSZ, &size) >= 0)
|
if (ioctl (STDOUT_FILENO, TIOCGWINSZ, &size) >= 0)
|
||||||
{
|
{
|
||||||
grub_console_terminfo_output.width = size.ws_col;
|
grub_console_terminfo_output.size.x = size.ws_col;
|
||||||
grub_console_terminfo_output.height = size.ws_row;
|
grub_console_terminfo_output.size.y = size.ws_row;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
grub_console_terminfo_output.width = 80;
|
grub_console_terminfo_output.size.x = 80;
|
||||||
grub_console_terminfo_output.height = 24;
|
grub_console_terminfo_output.size.y = 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_terminfo_output_init (term);
|
grub_terminfo_output_init (term);
|
||||||
|
@ -125,8 +125,7 @@ struct grub_terminfo_input_state grub_console_terminfo_input =
|
||||||
struct grub_terminfo_output_state grub_console_terminfo_output =
|
struct grub_terminfo_output_state grub_console_terminfo_output =
|
||||||
{
|
{
|
||||||
.put = put,
|
.put = put,
|
||||||
.width = 80,
|
.size = { 80, 24 }
|
||||||
.height = 24
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct grub_term_input grub_console_term_input =
|
static struct grub_term_input grub_console_term_input =
|
||||||
|
|
|
@ -129,7 +129,7 @@ grub_console_getkey (struct grub_term_input *term __attribute__ ((unused)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_uint16_t
|
static struct grub_term_coordinate
|
||||||
grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
|
grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
@ -139,24 +139,24 @@ grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
|
||||||
|
|
||||||
GetConsoleScreenBufferInfo (hStdout, &csbi);
|
GetConsoleScreenBufferInfo (hStdout, &csbi);
|
||||||
|
|
||||||
return ((csbi.dwSize.X << 8) | csbi.dwSize.Y);
|
return (struct grub_term_coordinate) { csbi.dwSize.X, csbi.dwSize.Y };
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_uint16_t
|
static struct grub_term_coordinate
|
||||||
grub_console_getxy (struct grub_term_output *term __attribute__ ((unused)))
|
grub_console_getxy (struct grub_term_output *term __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
|
||||||
GetConsoleScreenBufferInfo (hStdout, &csbi);
|
GetConsoleScreenBufferInfo (hStdout, &csbi);
|
||||||
|
|
||||||
return ((csbi.dwCursorPosition.X << 8) | csbi.dwCursorPosition.Y);
|
return (struct grub_term_coordinate) { csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y };
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
grub_console_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
|
grub_console_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
|
||||||
grub_uint8_t x, grub_uint8_t y)
|
struct grub_term_coordinate pos)
|
||||||
{
|
{
|
||||||
COORD coord = { x, y };
|
COORD coord = { pos.x, pos.y };
|
||||||
|
|
||||||
SetConsoleCursorPosition (hStdout, coord);
|
SetConsoleCursorPosition (hStdout, coord);
|
||||||
}
|
}
|
||||||
|
@ -179,13 +179,13 @@ grub_console_cls (struct grub_term_output *term)
|
||||||
GetConsoleScreenBufferInfo (hStdout, &csbi);
|
GetConsoleScreenBufferInfo (hStdout, &csbi);
|
||||||
|
|
||||||
SetConsoleTextAttribute (hStdout, 0);
|
SetConsoleTextAttribute (hStdout, 0);
|
||||||
grub_console_gotoxy (term, 0, 0);
|
grub_console_gotoxy (term, (struct grub_term_coordinate) { 0, 0 });
|
||||||
tsz = csbi.dwSize.X * csbi.dwSize.Y;
|
tsz = csbi.dwSize.X * csbi.dwSize.Y;
|
||||||
|
|
||||||
while (tsz--)
|
while (tsz--)
|
||||||
grub_console_putchar (term, &c);
|
grub_console_putchar (term, &c);
|
||||||
|
|
||||||
grub_console_gotoxy (term, 0, 0);
|
grub_console_gotoxy (term, (struct grub_term_coordinate) { 0, 0 });
|
||||||
SetConsoleTextAttribute (hStdout, csbi.wAttributes);
|
SetConsoleTextAttribute (hStdout, csbi.wAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,8 +130,8 @@ set_console_dimensions (void)
|
||||||
|
|
||||||
if (check_is_serial ())
|
if (check_is_serial ())
|
||||||
{
|
{
|
||||||
grub_console_terminfo_output.width = 80;
|
grub_console_terminfo_output.size.x = 80;
|
||||||
grub_console_terminfo_output.height = 24;
|
grub_console_terminfo_output.size.y = 24;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,8 +142,8 @@ set_console_dimensions (void)
|
||||||
info = GRUB_ARC_FIRMWARE_VECTOR->getdisplaystatus (GRUB_ARC_STDOUT);
|
info = GRUB_ARC_FIRMWARE_VECTOR->getdisplaystatus (GRUB_ARC_STDOUT);
|
||||||
if (info)
|
if (info)
|
||||||
{
|
{
|
||||||
grub_console_terminfo_output.width = info->w + 1;
|
grub_console_terminfo_output.size.x = info->w + 1;
|
||||||
grub_console_terminfo_output.height = info->h + 1;
|
grub_console_terminfo_output.size.y = info->h + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,8 +164,7 @@ static struct grub_terminfo_input_state grub_console_terminfo_input =
|
||||||
static struct grub_terminfo_output_state grub_console_terminfo_output =
|
static struct grub_terminfo_output_state grub_console_terminfo_output =
|
||||||
{
|
{
|
||||||
.put = put,
|
.put = put,
|
||||||
.width = 80,
|
.size = { 80, 20 }
|
||||||
.height = 20
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct grub_term_input grub_console_term_input =
|
static struct grub_term_input grub_console_term_input =
|
||||||
|
|
|
@ -142,7 +142,7 @@ grub_console_getkey (struct grub_term_input *term __attribute__ ((unused)))
|
||||||
return GRUB_TERM_NO_KEY;
|
return GRUB_TERM_NO_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_uint16_t
|
static struct grub_term_coordinate
|
||||||
grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
|
grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
grub_efi_simple_text_output_interface_t *o;
|
grub_efi_simple_text_output_interface_t *o;
|
||||||
|
@ -157,24 +157,24 @@ grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
|
||||||
rows = 25;
|
rows = 25;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((columns << 8) | rows);
|
return (struct grub_term_coordinate) { columns, rows };
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_uint16_t
|
static struct grub_term_coordinate
|
||||||
grub_console_getxy (struct grub_term_output *term __attribute__ ((unused)))
|
grub_console_getxy (struct grub_term_output *term __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
grub_efi_simple_text_output_interface_t *o;
|
grub_efi_simple_text_output_interface_t *o;
|
||||||
|
|
||||||
if (grub_efi_is_finished)
|
if (grub_efi_is_finished)
|
||||||
return 0;
|
return (struct grub_term_coordinate) { 0, 0 };
|
||||||
|
|
||||||
o = grub_efi_system_table->con_out;
|
o = grub_efi_system_table->con_out;
|
||||||
return ((o->mode->cursor_column << 8) | o->mode->cursor_row);
|
return (struct grub_term_coordinate) { o->mode->cursor_column, o->mode->cursor_row };
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
grub_console_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
|
grub_console_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
|
||||||
grub_uint8_t x, grub_uint8_t y)
|
struct grub_term_coordinate pos)
|
||||||
{
|
{
|
||||||
grub_efi_simple_text_output_interface_t *o;
|
grub_efi_simple_text_output_interface_t *o;
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ grub_console_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
|
||||||
return;
|
return;
|
||||||
|
|
||||||
o = grub_efi_system_table->con_out;
|
o = grub_efi_system_table->con_out;
|
||||||
efi_call_3 (o->set_cursor_position, o, x, y);
|
efi_call_3 (o->set_cursor_position, o, pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -970,34 +970,34 @@ grub_gfxterm_getcharwidth (struct grub_term_output *term __attribute__ ((unused)
|
||||||
/ virtual_screen.normal_char_width;
|
/ virtual_screen.normal_char_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_uint16_t
|
static struct grub_term_coordinate
|
||||||
grub_virtual_screen_getwh (struct grub_term_output *term __attribute__ ((unused)))
|
grub_virtual_screen_getwh (struct grub_term_output *term __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
return (virtual_screen.columns << 8) | virtual_screen.rows;
|
return (struct grub_term_coordinate) { virtual_screen.columns, virtual_screen.rows };
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_uint16_t
|
static struct grub_term_coordinate
|
||||||
grub_virtual_screen_getxy (struct grub_term_output *term __attribute__ ((unused)))
|
grub_virtual_screen_getxy (struct grub_term_output *term __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
return ((virtual_screen.cursor_x << 8) | virtual_screen.cursor_y);
|
return (struct grub_term_coordinate) { virtual_screen.cursor_x, virtual_screen.cursor_y };
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
grub_gfxterm_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
|
grub_gfxterm_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
|
||||||
grub_uint8_t x, grub_uint8_t y)
|
struct grub_term_coordinate pos)
|
||||||
{
|
{
|
||||||
if (x >= virtual_screen.columns)
|
if (pos.x >= virtual_screen.columns)
|
||||||
x = virtual_screen.columns - 1;
|
pos.x = virtual_screen.columns - 1;
|
||||||
|
|
||||||
if (y >= virtual_screen.rows)
|
if (pos.y >= virtual_screen.rows)
|
||||||
y = virtual_screen.rows - 1;
|
pos.y = virtual_screen.rows - 1;
|
||||||
|
|
||||||
/* Erase current cursor, if any. */
|
/* Erase current cursor, if any. */
|
||||||
if (virtual_screen.cursor_state)
|
if (virtual_screen.cursor_state)
|
||||||
draw_cursor (0);
|
draw_cursor (0);
|
||||||
|
|
||||||
virtual_screen.cursor_x = x;
|
virtual_screen.cursor_x = pos.x;
|
||||||
virtual_screen.cursor_y = y;
|
virtual_screen.cursor_y = pos.y;
|
||||||
|
|
||||||
/* Draw cursor if visible. */
|
/* Draw cursor if visible. */
|
||||||
if (virtual_screen.cursor_state)
|
if (virtual_screen.cursor_state)
|
||||||
|
|
|
@ -51,8 +51,7 @@ put (struct grub_term_output *term __attribute__ ((unused)), const int c)
|
||||||
struct grub_terminfo_output_state grub_cbmemc_terminfo_output =
|
struct grub_terminfo_output_state grub_cbmemc_terminfo_output =
|
||||||
{
|
{
|
||||||
.put = put,
|
.put = put,
|
||||||
.width = 80,
|
.size = { 80, 24 }
|
||||||
.height = 24
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct grub_term_output grub_cbmemc_term_output =
|
static struct grub_term_output grub_cbmemc_term_output =
|
||||||
|
|
|
@ -47,7 +47,7 @@ int10_9 (grub_uint8_t ch, grub_uint16_t n)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
static grub_uint16_t
|
static struct grub_term_coordinate
|
||||||
grub_console_getxy (struct grub_term_output *term __attribute__ ((unused)))
|
grub_console_getxy (struct grub_term_output *term __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
struct grub_bios_int_registers regs;
|
struct grub_bios_int_registers regs;
|
||||||
|
@ -57,7 +57,8 @@ grub_console_getxy (struct grub_term_output *term __attribute__ ((unused)))
|
||||||
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
|
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
|
||||||
grub_bios_interrupt (0x10, ®s);
|
grub_bios_interrupt (0x10, ®s);
|
||||||
|
|
||||||
return ((regs.edx & 0xff) << 8) | ((regs.edx & 0xff00) >> 8);
|
return (struct grub_term_coordinate) {
|
||||||
|
(regs.edx & 0xff), ((regs.edx & 0xff00) >> 8) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -69,14 +70,14 @@ grub_console_getxy (struct grub_term_output *term __attribute__ ((unused)))
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
grub_console_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
|
grub_console_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
|
||||||
grub_uint8_t x, grub_uint8_t y)
|
struct grub_term_coordinate pos)
|
||||||
{
|
{
|
||||||
struct grub_bios_int_registers regs;
|
struct grub_bios_int_registers regs;
|
||||||
|
|
||||||
/* set page to 0 */
|
/* set page to 0 */
|
||||||
regs.ebx = 0;
|
regs.ebx = 0;
|
||||||
regs.eax = 0x0200;
|
regs.eax = 0x0200;
|
||||||
regs.edx = (y << 8) | x;
|
regs.edx = (pos.y << 8) | pos.x;
|
||||||
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
|
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
|
||||||
grub_bios_interrupt (0x10, ®s);
|
grub_bios_interrupt (0x10, ®s);
|
||||||
}
|
}
|
||||||
|
@ -94,7 +95,7 @@ static void
|
||||||
grub_console_putchar_real (grub_uint8_t c)
|
grub_console_putchar_real (grub_uint8_t c)
|
||||||
{
|
{
|
||||||
struct grub_bios_int_registers regs;
|
struct grub_bios_int_registers regs;
|
||||||
grub_uint16_t pos;
|
struct grub_term_coordinate pos;
|
||||||
|
|
||||||
if (c == 7 || c == 8 || c == 0xa || c == 0xd)
|
if (c == 7 || c == 8 || c == 0xa || c == 0xd)
|
||||||
{
|
{
|
||||||
|
@ -112,14 +113,14 @@ grub_console_putchar_real (grub_uint8_t c)
|
||||||
int10_9 (c, 1);
|
int10_9 (c, 1);
|
||||||
|
|
||||||
/* check the column with the width */
|
/* check the column with the width */
|
||||||
if ((pos & 0xff00) >= (79 << 8))
|
if (pos.x >= 79)
|
||||||
{
|
{
|
||||||
grub_console_putchar_real (0x0d);
|
grub_console_putchar_real (0x0d);
|
||||||
grub_console_putchar_real (0x0a);
|
grub_console_putchar_real (0x0a);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
grub_console_gotoxy (NULL, ((pos & 0xff00) >> 8) + 1, (pos & 0xff));
|
grub_console_gotoxy (NULL, (struct grub_term_coordinate) { pos.x + 1,
|
||||||
|
pos.y });
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -141,13 +142,13 @@ static void
|
||||||
grub_console_cls (struct grub_term_output *term)
|
grub_console_cls (struct grub_term_output *term)
|
||||||
{
|
{
|
||||||
/* move the cursor to the beginning */
|
/* move the cursor to the beginning */
|
||||||
grub_console_gotoxy (term, 0, 0);
|
grub_console_gotoxy (term, (struct grub_term_coordinate) { 0, 0 });
|
||||||
|
|
||||||
/* write spaces to the entire screen */
|
/* write spaces to the entire screen */
|
||||||
int10_9 (' ', 80 * 25);
|
int10_9 (' ', 80 * 25);
|
||||||
|
|
||||||
/* move back the cursor */
|
/* move back the cursor */
|
||||||
grub_console_gotoxy (term, 0, 0);
|
grub_console_gotoxy (term, (struct grub_term_coordinate) { 0, 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -247,10 +248,10 @@ grub_console_getkeystatus (struct grub_term_input *term __attribute__ ((unused))
|
||||||
return bios_data_area->keyboard_flag_lower & ~0x80;
|
return bios_data_area->keyboard_flag_lower & ~0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_uint16_t
|
static struct grub_term_coordinate
|
||||||
grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
|
grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
return (80 << 8) | 25;
|
return (struct grub_term_coordinate) { 80, 25 };
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -42,7 +42,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
||||||
#define COLS 80
|
#define COLS 80
|
||||||
#define ROWS 25
|
#define ROWS 25
|
||||||
|
|
||||||
static int grub_curr_x, grub_curr_y;
|
static struct grub_term_coordinate grub_curr_pos;
|
||||||
|
|
||||||
#ifdef __mips__
|
#ifdef __mips__
|
||||||
#define VGA_TEXT_SCREEN ((grub_uint16_t *) 0xb00b8000)
|
#define VGA_TEXT_SCREEN ((grub_uint16_t *) 0xb00b8000)
|
||||||
|
@ -75,7 +75,7 @@ screen_read_char (int x, int y)
|
||||||
static void
|
static void
|
||||||
update_cursor (void)
|
update_cursor (void)
|
||||||
{
|
{
|
||||||
unsigned int pos = grub_curr_y * COLS + grub_curr_x;
|
unsigned int pos = grub_curr_pos.y * COLS + grub_curr_pos.x;
|
||||||
cr_write (pos >> 8, GRUB_VGA_CR_CURSOR_ADDR_HIGH);
|
cr_write (pos >> 8, GRUB_VGA_CR_CURSOR_ADDR_HIGH);
|
||||||
cr_write (pos & 0xFF, GRUB_VGA_CR_CURSOR_ADDR_LOW);
|
cr_write (pos & 0xFF, GRUB_VGA_CR_CURSOR_ADDR_LOW);
|
||||||
}
|
}
|
||||||
|
@ -83,9 +83,9 @@ update_cursor (void)
|
||||||
static void
|
static void
|
||||||
inc_y (void)
|
inc_y (void)
|
||||||
{
|
{
|
||||||
grub_curr_x = 0;
|
grub_curr_pos.x = 0;
|
||||||
if (grub_curr_y < ROWS - 1)
|
if (grub_curr_pos.y < ROWS - 1)
|
||||||
grub_curr_y++;
|
grub_curr_pos.y++;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
|
@ -100,10 +100,10 @@ inc_y (void)
|
||||||
static void
|
static void
|
||||||
inc_x (void)
|
inc_x (void)
|
||||||
{
|
{
|
||||||
if (grub_curr_x >= COLS - 1)
|
if (grub_curr_pos.x >= COLS - 1)
|
||||||
inc_y ();
|
inc_y ();
|
||||||
else
|
else
|
||||||
grub_curr_x++;
|
grub_curr_pos.x++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -113,17 +113,17 @@ grub_vga_text_putchar (struct grub_term_output *term __attribute__ ((unused)),
|
||||||
switch (c->base)
|
switch (c->base)
|
||||||
{
|
{
|
||||||
case '\b':
|
case '\b':
|
||||||
if (grub_curr_x != 0)
|
if (grub_curr_pos.x != 0)
|
||||||
screen_write_char (grub_curr_x--, grub_curr_y, ' ');
|
screen_write_char (grub_curr_pos.x--, grub_curr_pos.y, ' ');
|
||||||
break;
|
break;
|
||||||
case '\n':
|
case '\n':
|
||||||
inc_y ();
|
inc_y ();
|
||||||
break;
|
break;
|
||||||
case '\r':
|
case '\r':
|
||||||
grub_curr_x = 0;
|
grub_curr_pos.x = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
screen_write_char (grub_curr_x, grub_curr_y,
|
screen_write_char (grub_curr_pos.x, grub_curr_pos.y,
|
||||||
c->base | (cur_color << 8));
|
c->base | (cur_color << 8));
|
||||||
inc_x ();
|
inc_x ();
|
||||||
}
|
}
|
||||||
|
@ -131,18 +131,17 @@ grub_vga_text_putchar (struct grub_term_output *term __attribute__ ((unused)),
|
||||||
update_cursor ();
|
update_cursor ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_uint16_t
|
static struct grub_term_coordinate
|
||||||
grub_vga_text_getxy (struct grub_term_output *term __attribute__ ((unused)))
|
grub_vga_text_getxy (struct grub_term_output *term __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
return (grub_curr_x << 8) | grub_curr_y;
|
return grub_curr_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
grub_vga_text_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
|
grub_vga_text_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
|
||||||
grub_uint8_t x, grub_uint8_t y)
|
struct grub_term_coordinate pos)
|
||||||
{
|
{
|
||||||
grub_curr_x = x;
|
grub_curr_pos = pos;
|
||||||
grub_curr_y = y;
|
|
||||||
update_cursor ();
|
update_cursor ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +151,7 @@ grub_vga_text_cls (struct grub_term_output *term)
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < ROWS * COLS; i++)
|
for (i = 0; i < ROWS * COLS; i++)
|
||||||
VGA_TEXT_SCREEN[i] = grub_cpu_to_le16 (' ' | (cur_color << 8));
|
VGA_TEXT_SCREEN[i] = grub_cpu_to_le16 (' ' | (cur_color << 8));
|
||||||
grub_vga_text_gotoxy (term, 0, 0);
|
grub_vga_text_gotoxy (term, (struct grub_term_coordinate) { 0, 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -203,10 +202,10 @@ grub_vga_text_fini_real (struct grub_term_output *term)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_uint16_t
|
static struct grub_term_coordinate
|
||||||
grub_vga_text_getwh (struct grub_term_output *term __attribute__ ((unused)))
|
grub_vga_text_getwh (struct grub_term_output *term __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
return (80 << 8) | 25;
|
return (struct grub_term_coordinate) { 80, 25 };
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef MODE_MDA
|
#ifndef MODE_MDA
|
||||||
|
|
|
@ -97,8 +97,8 @@ grub_console_dimensions (void)
|
||||||
val[sizeof (val) - 1] = 0;
|
val[sizeof (val) - 1] = 0;
|
||||||
if (grub_strcmp (val, "serial") == 0)
|
if (grub_strcmp (val, "serial") == 0)
|
||||||
{
|
{
|
||||||
grub_console_terminfo_output.width = 80;
|
grub_console_terminfo_output.size.x = 80;
|
||||||
grub_console_terminfo_output.height = 24;
|
grub_console_terminfo_output.size.y = 24;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,31 +111,31 @@ grub_console_dimensions (void)
|
||||||
val, sizeof (val) - 1, 0))
|
val, sizeof (val) - 1, 0))
|
||||||
{
|
{
|
||||||
val[sizeof (val) - 1] = 0;
|
val[sizeof (val) - 1] = 0;
|
||||||
grub_console_terminfo_output.width
|
grub_console_terminfo_output.size.x
|
||||||
= (grub_uint8_t) grub_strtoul (val, 0, 10);
|
= (grub_uint8_t) grub_strtoul (val, 0, 10);
|
||||||
}
|
}
|
||||||
if (! grub_ieee1275_get_property (options, "screen-#rows",
|
if (! grub_ieee1275_get_property (options, "screen-#rows",
|
||||||
val, sizeof (val) - 1, 0))
|
val, sizeof (val) - 1, 0))
|
||||||
{
|
{
|
||||||
val[sizeof (val) - 1] = 0;
|
val[sizeof (val) - 1] = 0;
|
||||||
grub_console_terminfo_output.height
|
grub_console_terminfo_output.size.y
|
||||||
= (grub_uint8_t) grub_strtoul (val, 0, 10);
|
= (grub_uint8_t) grub_strtoul (val, 0, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Bogus default value on SLOF in QEMU. */
|
/* Bogus default value on SLOF in QEMU. */
|
||||||
if (grub_console_terminfo_output.width == 200
|
if (grub_console_terminfo_output.size.x == 200
|
||||||
&& grub_console_terminfo_output.height == 200)
|
&& grub_console_terminfo_output.size.y == 200)
|
||||||
{
|
{
|
||||||
grub_console_terminfo_output.width = 80;
|
grub_console_terminfo_output.size.x = 80;
|
||||||
grub_console_terminfo_output.height = 24;
|
grub_console_terminfo_output.size.y = 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use a small console by default. */
|
/* Use a small console by default. */
|
||||||
if (! grub_console_terminfo_output.width)
|
if (! grub_console_terminfo_output.size.x)
|
||||||
grub_console_terminfo_output.width = 80;
|
grub_console_terminfo_output.size.x = 80;
|
||||||
if (! grub_console_terminfo_output.height)
|
if (! grub_console_terminfo_output.size.y)
|
||||||
grub_console_terminfo_output.height = 24;
|
grub_console_terminfo_output.size.y = 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -212,8 +212,7 @@ struct grub_terminfo_input_state grub_console_terminfo_input =
|
||||||
struct grub_terminfo_output_state grub_console_terminfo_output =
|
struct grub_terminfo_output_state grub_console_terminfo_output =
|
||||||
{
|
{
|
||||||
.put = put,
|
.put = put,
|
||||||
.width = 80,
|
.size = { 80, 24 }
|
||||||
.height = 24
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct grub_term_input grub_console_term_input =
|
static struct grub_term_input grub_console_term_input =
|
||||||
|
|
|
@ -92,8 +92,7 @@ static const struct grub_serial_output_state grub_serial_terminfo_output_templat
|
||||||
.tinfo =
|
.tinfo =
|
||||||
{
|
{
|
||||||
.put = serial_put,
|
.put = serial_put,
|
||||||
.width = 80,
|
.size = { 80, 24 }
|
||||||
.height = 24
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -109,8 +109,7 @@ grub_spkmodem_fini_output (struct grub_term_output *term __attribute__ ((unused)
|
||||||
struct grub_terminfo_output_state grub_spkmodem_terminfo_output =
|
struct grub_terminfo_output_state grub_spkmodem_terminfo_output =
|
||||||
{
|
{
|
||||||
.put = put,
|
.put = put,
|
||||||
.width = 80,
|
.size = { 80, 24 }
|
||||||
.height = 24
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct grub_term_output grub_spkmodem_term_output =
|
static struct grub_term_output grub_spkmodem_term_output =
|
||||||
|
|
|
@ -230,38 +230,37 @@ putstr (struct grub_term_output *term, const char *str)
|
||||||
data->put (term, *str++);
|
data->put (term, *str++);
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_uint16_t
|
struct grub_term_coordinate
|
||||||
grub_terminfo_getxy (struct grub_term_output *term)
|
grub_terminfo_getxy (struct grub_term_output *term)
|
||||||
{
|
{
|
||||||
struct grub_terminfo_output_state *data
|
struct grub_terminfo_output_state *data
|
||||||
= (struct grub_terminfo_output_state *) term->data;
|
= (struct grub_terminfo_output_state *) term->data;
|
||||||
|
|
||||||
return ((data->xpos << 8) | data->ypos);
|
return data->pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_terminfo_gotoxy (struct grub_term_output *term,
|
grub_terminfo_gotoxy (struct grub_term_output *term,
|
||||||
grub_uint8_t x, grub_uint8_t y)
|
struct grub_term_coordinate pos)
|
||||||
{
|
{
|
||||||
struct grub_terminfo_output_state *data
|
struct grub_terminfo_output_state *data
|
||||||
= (struct grub_terminfo_output_state *) term->data;
|
= (struct grub_terminfo_output_state *) term->data;
|
||||||
|
|
||||||
if (x > grub_term_width (term) || y > grub_term_height (term))
|
if (pos.x > grub_term_width (term) || pos.y > grub_term_height (term))
|
||||||
{
|
{
|
||||||
grub_error (GRUB_ERR_BUG, "invalid point (%u,%u)", x, y);
|
grub_error (GRUB_ERR_BUG, "invalid point (%u,%u)", pos.x, pos.y);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->gotoxy)
|
if (data->gotoxy)
|
||||||
putstr (term, grub_terminfo_tparm (data->gotoxy, y, x));
|
putstr (term, grub_terminfo_tparm (data->gotoxy, pos.y, pos.x));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((y == data->ypos) && (x == data->xpos - 1))
|
if ((pos.y == data->pos.y) && (pos.x == data->pos.x - 1))
|
||||||
data->put (term, '\b');
|
data->put (term, '\b');
|
||||||
}
|
}
|
||||||
|
|
||||||
data->xpos = x;
|
data->pos = pos;
|
||||||
data->ypos = y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear the screen. */
|
/* Clear the screen. */
|
||||||
|
@ -272,7 +271,7 @@ grub_terminfo_cls (struct grub_term_output *term)
|
||||||
= (struct grub_terminfo_output_state *) term->data;
|
= (struct grub_terminfo_output_state *) term->data;
|
||||||
|
|
||||||
putstr (term, grub_terminfo_tparm (data->cls));
|
putstr (term, grub_terminfo_tparm (data->cls));
|
||||||
grub_terminfo_gotoxy (term, 0, 0);
|
grub_terminfo_gotoxy (term, (struct grub_term_coordinate) { 0, 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -360,42 +359,42 @@ grub_terminfo_putchar (struct grub_term_output *term,
|
||||||
|
|
||||||
case '\b':
|
case '\b':
|
||||||
case 127:
|
case 127:
|
||||||
if (data->xpos > 0)
|
if (data->pos.x > 0)
|
||||||
data->xpos--;
|
data->pos.x--;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\n':
|
case '\n':
|
||||||
if (data->ypos < grub_term_height (term) - 1)
|
if (data->pos.y < grub_term_height (term) - 1)
|
||||||
data->ypos++;
|
data->pos.y++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\r':
|
case '\r':
|
||||||
data->xpos = 0;
|
data->pos.x = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (data->xpos + c->estimated_width >= grub_term_width (term) + 1)
|
if ((int) data->pos.x + c->estimated_width >= (int) grub_term_width (term) + 1)
|
||||||
{
|
{
|
||||||
data->xpos = 0;
|
data->pos.x = 0;
|
||||||
if (data->ypos < grub_term_height (term) - 1)
|
if (data->pos.y < grub_term_height (term) - 1)
|
||||||
data->ypos++;
|
data->pos.y++;
|
||||||
data->put (term, '\r');
|
data->put (term, '\r');
|
||||||
data->put (term, '\n');
|
data->put (term, '\n');
|
||||||
}
|
}
|
||||||
data->xpos += c->estimated_width;
|
data->pos.x += c->estimated_width;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->put (term, c->base);
|
data->put (term, c->base);
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_uint16_t
|
struct grub_term_coordinate
|
||||||
grub_terminfo_getwh (struct grub_term_output *term)
|
grub_terminfo_getwh (struct grub_term_output *term)
|
||||||
{
|
{
|
||||||
struct grub_terminfo_output_state *data
|
struct grub_terminfo_output_state *data
|
||||||
= (struct grub_terminfo_output_state *) term->data;
|
= (struct grub_terminfo_output_state *) term->data;
|
||||||
|
|
||||||
return (data->width << 8) | data->height;
|
return data->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -673,8 +672,8 @@ print_terminfo (void)
|
||||||
grub_terminfo_get_current(cur),
|
grub_terminfo_get_current(cur),
|
||||||
encoding_names[(cur->flags & GRUB_TERM_CODE_TYPE_MASK)
|
encoding_names[(cur->flags & GRUB_TERM_CODE_TYPE_MASK)
|
||||||
>> GRUB_TERM_CODE_TYPE_SHIFT],
|
>> GRUB_TERM_CODE_TYPE_SHIFT],
|
||||||
((struct grub_terminfo_output_state *) cur->data)->width,
|
((struct grub_terminfo_output_state *) cur->data)->pos.x,
|
||||||
((struct grub_terminfo_output_state *) cur->data)->height);
|
((struct grub_terminfo_output_state *) cur->data)->pos.y);
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
@ -747,8 +746,8 @@ grub_cmd_terminfo (grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
{
|
{
|
||||||
struct grub_terminfo_output_state *data
|
struct grub_terminfo_output_state *data
|
||||||
= (struct grub_terminfo_output_state *) cur->data;
|
= (struct grub_terminfo_output_state *) cur->data;
|
||||||
data->width = w;
|
data->pos.x = w;
|
||||||
data->height = h;
|
data->pos.y = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
|
|
|
@ -56,21 +56,10 @@ uboot_console_init_input (struct grub_term_input *term)
|
||||||
|
|
||||||
extern struct grub_terminfo_output_state uboot_console_terminfo_output;
|
extern struct grub_terminfo_output_state uboot_console_terminfo_output;
|
||||||
|
|
||||||
static void
|
|
||||||
uboot_console_dimensions (void)
|
|
||||||
{
|
|
||||||
/* Use a small console by default. */
|
|
||||||
if (!uboot_console_terminfo_output.width)
|
|
||||||
uboot_console_terminfo_output.width = 80;
|
|
||||||
if (!uboot_console_terminfo_output.height)
|
|
||||||
uboot_console_terminfo_output.height = 24;
|
|
||||||
}
|
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
uboot_console_init_output (struct grub_term_output *term)
|
uboot_console_init_output (struct grub_term_output *term)
|
||||||
{
|
{
|
||||||
uboot_console_dimensions ();
|
|
||||||
|
|
||||||
grub_terminfo_output_init (term);
|
grub_terminfo_output_init (term);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -82,8 +71,9 @@ struct grub_terminfo_input_state uboot_console_terminfo_input = {
|
||||||
|
|
||||||
struct grub_terminfo_output_state uboot_console_terminfo_output = {
|
struct grub_terminfo_output_state uboot_console_terminfo_output = {
|
||||||
.put = put,
|
.put = put,
|
||||||
.width = 80,
|
/* FIXME: In rare cases when console isn't serial,
|
||||||
.height = 24
|
determine real width. */
|
||||||
|
.size = { 80, 24 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct grub_term_input uboot_console_term_input = {
|
static struct grub_term_input uboot_console_term_input = {
|
||||||
|
|
|
@ -155,6 +155,13 @@ struct grub_term_input
|
||||||
};
|
};
|
||||||
typedef struct grub_term_input *grub_term_input_t;
|
typedef struct grub_term_input *grub_term_input_t;
|
||||||
|
|
||||||
|
/* Made in a way to fit into uint32_t and so be passed in a register. */
|
||||||
|
struct grub_term_coordinate
|
||||||
|
{
|
||||||
|
grub_uint8_t x;
|
||||||
|
grub_uint8_t y;
|
||||||
|
};
|
||||||
|
|
||||||
struct grub_term_output
|
struct grub_term_output
|
||||||
{
|
{
|
||||||
/* The next terminal. */
|
/* The next terminal. */
|
||||||
|
@ -179,15 +186,15 @@ struct grub_term_output
|
||||||
grub_ssize_t (*getcharwidth) (struct grub_term_output *term,
|
grub_ssize_t (*getcharwidth) (struct grub_term_output *term,
|
||||||
const struct grub_unicode_glyph *c);
|
const struct grub_unicode_glyph *c);
|
||||||
|
|
||||||
/* Get the screen size. The return value is ((Width << 8) | Height). */
|
/* Get the screen size. */
|
||||||
grub_uint16_t (*getwh) (struct grub_term_output *term);
|
struct grub_term_coordinate (*getwh) (struct grub_term_output *term);
|
||||||
|
|
||||||
/* Get the cursor position. The return value is ((X << 8) | Y). */
|
/* Get the cursor position. The return value is ((X << 8) | Y). */
|
||||||
grub_uint16_t (*getxy) (struct grub_term_output *term);
|
struct grub_term_coordinate (*getxy) (struct grub_term_output *term);
|
||||||
|
|
||||||
/* Go to the position (X, Y). */
|
/* Go to the position (X, Y). */
|
||||||
void (*gotoxy) (struct grub_term_output *term,
|
void (*gotoxy) (struct grub_term_output *term,
|
||||||
grub_uint8_t x, grub_uint8_t y);
|
struct grub_term_coordinate pos);
|
||||||
|
|
||||||
/* Clear the screen. */
|
/* Clear the screen. */
|
||||||
void (*cls) (struct grub_term_output *term);
|
void (*cls) (struct grub_term_output *term);
|
||||||
|
@ -314,20 +321,20 @@ int EXPORT_FUNC(grub_getkey_noblock) (void);
|
||||||
void grub_cls (void);
|
void grub_cls (void);
|
||||||
void EXPORT_FUNC(grub_refresh) (void);
|
void EXPORT_FUNC(grub_refresh) (void);
|
||||||
void grub_puts_terminal (const char *str, struct grub_term_output *term);
|
void grub_puts_terminal (const char *str, struct grub_term_output *term);
|
||||||
grub_uint16_t *grub_term_save_pos (void);
|
struct grub_term_coordinate *grub_term_save_pos (void);
|
||||||
void grub_term_restore_pos (grub_uint16_t *pos);
|
void grub_term_restore_pos (struct grub_term_coordinate *pos);
|
||||||
|
|
||||||
static inline unsigned grub_term_width (struct grub_term_output *term)
|
static inline unsigned grub_term_width (struct grub_term_output *term)
|
||||||
{
|
{
|
||||||
return ((term->getwh(term)&0xFF00)>>8);
|
return term->getwh(term).x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned grub_term_height (struct grub_term_output *term)
|
static inline unsigned grub_term_height (struct grub_term_output *term)
|
||||||
{
|
{
|
||||||
return (term->getwh(term)&0xFF);
|
return term->getwh(term).y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline grub_uint16_t
|
static inline struct grub_term_coordinate
|
||||||
grub_term_getxy (struct grub_term_output *term)
|
grub_term_getxy (struct grub_term_output *term)
|
||||||
{
|
{
|
||||||
return term->getxy (term);
|
return term->getxy (term);
|
||||||
|
@ -341,9 +348,9 @@ grub_term_refresh (struct grub_term_output *term)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
grub_term_gotoxy (struct grub_term_output *term, grub_uint8_t x, grub_uint8_t y)
|
grub_term_gotoxy (struct grub_term_output *term, struct grub_term_coordinate pos)
|
||||||
{
|
{
|
||||||
term->gotoxy (term, x, y);
|
term->gotoxy (term, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
|
|
@ -53,18 +53,17 @@ struct grub_terminfo_output_state
|
||||||
char *cursor_off;
|
char *cursor_off;
|
||||||
char *setcolor;
|
char *setcolor;
|
||||||
|
|
||||||
unsigned int width, height;
|
struct grub_term_coordinate size;
|
||||||
|
struct grub_term_coordinate pos;
|
||||||
unsigned int xpos, ypos;
|
|
||||||
|
|
||||||
void (*put) (struct grub_term_output *term, const int c);
|
void (*put) (struct grub_term_output *term, const int c);
|
||||||
};
|
};
|
||||||
|
|
||||||
grub_err_t EXPORT_FUNC(grub_terminfo_output_init) (struct grub_term_output *term);
|
grub_err_t EXPORT_FUNC(grub_terminfo_output_init) (struct grub_term_output *term);
|
||||||
void EXPORT_FUNC(grub_terminfo_gotoxy) (grub_term_output_t term,
|
void EXPORT_FUNC(grub_terminfo_gotoxy) (grub_term_output_t term,
|
||||||
grub_uint8_t x, grub_uint8_t y);
|
struct grub_term_coordinate pos);
|
||||||
void EXPORT_FUNC(grub_terminfo_cls) (grub_term_output_t term);
|
void EXPORT_FUNC(grub_terminfo_cls) (grub_term_output_t term);
|
||||||
grub_uint16_t EXPORT_FUNC (grub_terminfo_getxy) (struct grub_term_output *term);
|
struct grub_term_coordinate EXPORT_FUNC (grub_terminfo_getxy) (struct grub_term_output *term);
|
||||||
void EXPORT_FUNC (grub_terminfo_setcursor) (struct grub_term_output *term,
|
void EXPORT_FUNC (grub_terminfo_setcursor) (struct grub_term_output *term,
|
||||||
const int on);
|
const int on);
|
||||||
void EXPORT_FUNC (grub_terminfo_setcolorstate) (struct grub_term_output *term,
|
void EXPORT_FUNC (grub_terminfo_setcolorstate) (struct grub_term_output *term,
|
||||||
|
@ -75,7 +74,7 @@ grub_err_t EXPORT_FUNC (grub_terminfo_input_init) (struct grub_term_input *term)
|
||||||
int EXPORT_FUNC (grub_terminfo_getkey) (struct grub_term_input *term);
|
int EXPORT_FUNC (grub_terminfo_getkey) (struct grub_term_input *term);
|
||||||
void EXPORT_FUNC (grub_terminfo_putchar) (struct grub_term_output *term,
|
void EXPORT_FUNC (grub_terminfo_putchar) (struct grub_term_output *term,
|
||||||
const struct grub_unicode_glyph *c);
|
const struct grub_unicode_glyph *c);
|
||||||
grub_uint16_t EXPORT_FUNC (grub_terminfo_getwh) (struct grub_term_output *term);
|
struct grub_term_coordinate EXPORT_FUNC (grub_terminfo_getwh) (struct grub_term_output *term);
|
||||||
|
|
||||||
|
|
||||||
grub_err_t EXPORT_FUNC (grub_terminfo_output_register) (struct grub_term_output *term,
|
grub_err_t EXPORT_FUNC (grub_terminfo_output_register) (struct grub_term_output *term,
|
||||||
|
|
Loading…
Reference in a new issue