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:
Vladimir 'phcoder' Serbinenko 2013-10-19 23:59:32 +02:00
parent 7abdac8e13
commit e89c2d48a9
24 changed files with 266 additions and 244 deletions

View file

@ -206,7 +206,8 @@ print_completion (const char *item, grub_completion_type_t type, int count)
struct cmdline_term
{
unsigned xpos, ypos, ystart, width, height;
struct grub_term_coordinate pos;
unsigned ystart, width, height;
unsigned prompt_len;
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)
{
cl_term->xpos = (cl_term->prompt_len + lpos) % cl_term->width;
cl_term->ypos = cl_term->ystart
cl_term->pos.x = (cl_term->prompt_len + lpos) % cl_term->width;
cl_term->pos.y = cl_term->ystart
+ (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)
@ -260,14 +261,14 @@ grub_cmdline_get (const char *prompt_translated)
grub_putcode (c, cl_term->term);
else
grub_putcode (*p, cl_term->term);
cl_term->xpos++;
if (cl_term->xpos >= cl_term->width - 1)
cl_term->pos.x++;
if (cl_term->pos.x >= cl_term->width - 1)
{
cl_term->xpos = 0;
if (cl_term->ypos >= (unsigned) (cl_term->height - 1))
cl_term->pos.x = 0;
if (cl_term->pos.y >= (unsigned) (cl_term->height - 1))
cl_term->ystart--;
else
cl_term->ypos++;
cl_term->pos.y++;
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)
{
cl_term_cur->xpos = cl_term_cur->prompt_len;
cl_term_cur->ypos = (grub_term_getxy (cl_term_cur->term) & 0xFF);
cl_term_cur->ystart = cl_term_cur->ypos;
cl_term_cur->pos.x = cl_term_cur->prompt_len;
cl_term_cur->pos.y = grub_term_getxy (cl_term_cur->term).y;
cl_term_cur->ystart = cl_term_cur->pos.y;
cl_term_cur->width = grub_term_width (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;
FOR_ACTIVE_TERM_OUTPUTS(term)
if ((grub_term_getxy (term) >> 8) != 0)
if ((grub_term_getxy (term).x) != 0)
grub_putcode ('\n', term);
}
grub_xputs (prompt_translated);

View file

@ -264,7 +264,7 @@ grub_normal_init_page (struct grub_term_output *term,
posx = ((int) grub_term_width (term) - posx) / 2;
if (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_putcode ('\n', term);

View file

@ -146,8 +146,8 @@ print_empty_line (int y, struct per_term_screen *term_screen)
int i;
grub_term_gotoxy (term_screen->term,
term_screen->geo.first_entry_x,
y + term_screen->geo.first_entry_y);
(struct grub_term_coordinate) { term_screen->geo.first_entry_x,
y + term_screen->geo.first_entry_y });
for (i = 0; i < term_screen->geo.entry_width + 1; i++)
grub_putcode (' ', term_screen->term);
@ -156,10 +156,11 @@ print_empty_line (int y, struct per_term_screen *term_screen)
static void
print_updown (int upflag, int downflag, struct per_term_screen *term_screen)
{
grub_term_gotoxy (term_screen->term, term_screen->geo.first_entry_x
+ term_screen->geo.entry_width + 1
+ term_screen->geo.border,
term_screen->geo.first_entry_y);
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.border,
term_screen->geo.first_entry_y });
if (upflag && downflag)
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
print_up (int flag, struct per_term_screen *term_screen)
{
grub_term_gotoxy (term_screen->term, term_screen->geo.first_entry_x
+ term_screen->geo.entry_width + 1
+ term_screen->geo.border,
term_screen->geo.first_entry_y);
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.border,
term_screen->geo.first_entry_y });
if (flag)
grub_putcode (GRUB_UNICODE_UPARROW, term_screen->term);
@ -190,11 +192,12 @@ print_up (int flag, struct per_term_screen *term_screen)
static void
print_down (int flag, struct per_term_screen *term_screen)
{
grub_term_gotoxy (term_screen->term, term_screen->geo.first_entry_x
+ term_screen->geo.entry_width + 1
+ term_screen->geo.border,
term_screen->geo.first_entry_y
+ term_screen->geo.num_entries - 1);
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.border,
term_screen->geo.first_entry_y
+ term_screen->geo.num_entries - 1 });
if (flag)
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
|| (i > region_start && mode == ALL_LINES))
{
grub_term_gotoxy (term_screen->term, term_screen->geo.first_entry_x,
(y < 0 ? 0 : y)
+ term_screen->geo.first_entry_y);
grub_term_gotoxy (term_screen->term,
(struct grub_term_coordinate) { term_screen->geo.first_entry_x,
(y < 0 ? 0 : y)
+ term_screen->geo.first_entry_y });
grub_print_ucs4_menu (linep->buf,
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);
if (cpos >= &(screen->lines[screen->line].pos[term_screen - screen->terms])[0])
grub_term_gotoxy (term_screen->term,
cpos->x + term_screen->geo.first_entry_x,
cpos->y + y
+ term_screen->geo.first_entry_y);
(struct grub_term_coordinate) { cpos->x + term_screen->geo.first_entry_x,
cpos->y + y
+ term_screen->geo.first_entry_y });
else
grub_term_gotoxy (term_screen->term,
term_screen->geo.first_entry_x,
y + term_screen->geo.first_entry_y);
(struct grub_term_coordinate) { term_screen->geo.first_entry_x,
y + term_screen->geo.first_entry_y });
}
@ -1028,15 +1032,16 @@ complete (struct screen *screen, int continuous, int update)
+ width - 1)
/ width);
grub_uint32_t *endp;
grub_uint16_t pos;
struct grub_term_coordinate pos;
grub_uint32_t *p = ucs4;
pos = grub_term_getxy (screen->terms[i].term);
screen->completion_shown = 1;
grub_term_gotoxy (screen->terms[i].term, 0,
screen->terms[i].geo.timeout_y);
grub_term_gotoxy (screen->terms[i].term,
(struct grub_term_coordinate) { 0,
screen->terms[i].geo.timeout_y });
if (screen->terms[i].geo.timeout_lines >= 2)
{
grub_puts_terminal (" ", screen->terms[i].term);
@ -1084,7 +1089,7 @@ complete (struct screen *screen, int continuous, int update)
if (ucs4 + ucs4len > endp)
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
clear_completions (struct per_term_screen *term_screen)
{
grub_uint16_t pos;
struct grub_term_coordinate pos;
unsigned j;
int i;
pos = grub_term_getxy (term_screen->term);
grub_term_gotoxy (term_screen->term, 0,
term_screen->geo.timeout_y);
grub_term_gotoxy (term_screen->term,
(struct grub_term_coordinate) { 0,
term_screen->geo.timeout_y });
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_term_gotoxy (term_screen->term, pos >> 8, pos & 0xFF);
grub_term_gotoxy (term_screen->term, pos);
grub_term_refresh (term_screen->term);
}

View file

@ -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_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);
for (i = 0; i < geo->entry_width + 1; i++)
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++)
{
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_term_gotoxy (term, geo->first_entry_x + geo->entry_width + 1,
geo->first_entry_y + i);
grub_term_gotoxy (term,
(struct grub_term_coordinate) { geo->first_entry_x + geo->entry_width + 1,
geo->first_entry_y + i });
grub_putcode (GRUB_UNICODE_VLINE, term);
}
grub_term_gotoxy (term, geo->first_entry_x - 1,
geo->first_entry_y - 1 + geo->num_entries + 1);
grub_term_gotoxy (term,
(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);
for (i = 0; i < geo->entry_width + 1; i++)
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_gotoxy (term, geo->first_entry_x - 1,
(geo->first_entry_y - 1 + geo->num_entries
+ GRUB_TERM_MARGIN + 1));
grub_term_gotoxy (term,
(struct grub_term_coordinate) { geo->first_entry_x - 1,
(geo->first_entry_y - 1 + geo->num_entries
+ GRUB_TERM_MARGIN + 1) });
}
static int
@ -228,7 +233,8 @@ print_entry (int y, int highlight, grub_menu_entry_t entry,
? GRUB_TERM_COLOR_HIGHLIGHT
: 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++)
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_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_highlight_color = old_color_highlight;
@ -262,9 +270,10 @@ print_entries (grub_menu_t menu, const struct menu_viewer_data *data)
int i;
grub_term_gotoxy (data->term,
data->geo.first_entry_x + data->geo.entry_width
+ data->geo.border + 1,
data->geo.first_entry_y);
(struct grub_term_coordinate) {
data->geo.first_entry_x + data->geo.entry_width
+ data->geo.border + 1,
data->geo.first_entry_y });
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;
}
grub_term_gotoxy (data->term, data->geo.first_entry_x + data->geo.entry_width
+ data->geo.border + 1,
data->geo.first_entry_y + data->geo.num_entries - 1);
grub_term_gotoxy (data->term,
(struct grub_term_coordinate) { data->geo.first_entry_x + data->geo.entry_width
+ data->geo.border + 1,
data->geo.first_entry_y + data->geo.num_entries - 1 });
if (data->geo.num_entries == 1)
{
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_term_gotoxy (data->term, grub_term_cursor_x (&data->geo),
data->geo.first_entry_y + data->offset);
grub_term_gotoxy (data->term,
(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
@ -404,8 +415,9 @@ grub_menu_init_page (int nested, int edit,
+ geo->border + empty_lines;
if (bottom_message)
{
grub_term_gotoxy (term, GRUB_TERM_MARGIN,
geo->timeout_y);
grub_term_gotoxy (term,
(struct grub_term_coordinate) { GRUB_TERM_MARGIN,
geo->timeout_y });
print_message (nested, edit, term, 0);
geo->timeout_y += msg_num_lines;
@ -424,7 +436,8 @@ menu_text_print_timeout (int timeout, void *dataptr)
struct menu_viewer_data *data = dataptr;
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
|| data->timeout_msg == TIMEOUT_TERSE_NO_MARGIN)
@ -459,8 +472,9 @@ menu_text_print_timeout (int timeout, void *dataptr)
grub_free (msg_translated);
grub_term_gotoxy (data->term,
grub_term_cursor_x (&data->geo),
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);
}
@ -516,22 +530,28 @@ menu_text_clear_timeout (void *dataptr)
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);
}
if (data->geo.num_entries <= 5 && !data->geo.border)
{
grub_term_gotoxy (data->term, data->geo.first_entry_x + data->geo.entry_width
+ data->geo.border + 1,
data->geo.first_entry_y + data->geo.num_entries - 1);
grub_term_gotoxy (data->term,
(struct grub_term_coordinate) {
data->geo.first_entry_x + data->geo.entry_width
+ data->geo.border + 1,
data->geo.first_entry_y + data->geo.num_entries - 1
});
grub_putcode (' ', data->term);
data->geo.timeout_lines = 0;
data->geo.num_entries++;
print_entries (data->menu, data);
}
grub_term_gotoxy (data->term, grub_term_cursor_x (&data->geo),
data->geo.first_entry_y + data->offset);
grub_term_gotoxy (data->term,
(struct grub_term_coordinate) {
grub_term_cursor_x (&data->geo),
data->geo.first_entry_y + data->offset });
grub_term_refresh (data->term);
}

View file

@ -73,7 +73,7 @@ static void
print_more (void)
{
char key;
grub_uint16_t *pos;
struct grub_term_coordinate *pos;
grub_term_output_t term;
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_uint16_t *
struct grub_term_coordinate *
grub_term_save_pos (void)
{
struct grub_term_output *cur;
unsigned cnt = 0;
grub_uint16_t *ret, *ptr;
struct grub_term_coordinate *ret, *ptr;
FOR_ACTIVE_TERM_OUTPUTS(cur)
cnt++;
@ -279,17 +279,17 @@ grub_term_save_pos (void)
}
void
grub_term_restore_pos (grub_uint16_t *pos)
grub_term_restore_pos (struct grub_term_coordinate *pos)
{
struct grub_term_output *cur;
grub_uint16_t *ptr = pos;
struct grub_term_coordinate *ptr = pos;
if (!pos)
return;
FOR_ACTIVE_TERM_OUTPUTS(cur)
{
grub_term_gotoxy (cur, (*ptr & 0xff00) >> 8, *ptr & 0xff);
grub_term_gotoxy (cur, *ptr);
ptr++;
}
}
@ -444,7 +444,7 @@ putglyph (const struct grub_unicode_glyph *c, struct grub_term_output *term,
{
int n;
n = GRUB_TERM_TAB_WIDTH - ((term->getxy (term) >> 8)
n = GRUB_TERM_TAB_WIDTH - ((term->getxy (term).x)
% GRUB_TERM_TAB_WIDTH);
c2.base = ' ';
while (n--)
@ -545,14 +545,14 @@ static grub_ssize_t
get_startwidth (struct grub_term_output *term,
int margin_left)
{
return ((term->getxy (term) >> 8) & 0xff) - margin_left;
return (term->getxy (term).x) - margin_left;
}
static void
fill_margin (struct grub_term_output *term, int r)
{
int sp = (term->getwh (term) >> 8)
- (term->getxy (term) >> 8) - r;
int sp = (term->getwh (term).x)
- (term->getxy (term).x) - r;
if (sp > 0)
grub_print_spaces (term, sp);
}
@ -713,8 +713,8 @@ print_ucs4_terminal (const grub_uint32_t * str,
if (!contchar)
grub_print_spaces (term, margin_left);
else
grub_term_gotoxy (term, margin_left,
grub_term_getxy (term) & 0xff);
grub_term_gotoxy (term, (struct grub_term_coordinate)
{ margin_left, grub_term_getxy (term).y });
for (i = 0; i < state->bidi_stack_depth; i++)
putcode_real (state->bidi_stack[i] | (GRUB_UNICODE_LRE & ~0xff),
term, fixed_tab);
@ -807,8 +807,9 @@ put_glyphs_terminal (struct grub_unicode_glyph *visual,
if (!contchar)
grub_print_spaces (term, margin_left);
else
grub_term_gotoxy (term, margin_left,
grub_term_getxy (term) & 0xff);
grub_term_gotoxy (term,
(struct grub_term_coordinate)
{ margin_left, grub_term_getxy (term).y });
}
grub_unicode_destroy_glyph (visual_ptr);
}
@ -885,19 +886,19 @@ print_ucs4_real (const grub_uint32_t * str,
if (!dry_run)
{
int xy;
struct grub_term_coordinate xy;
if (backlog)
state = find_term_state (term);
xy = term->getxy (term);
if (((xy >> 8) & 0xff) < margin_left)
if (xy.x < margin_left)
{
if (!contchar)
grub_print_spaces (term, margin_left - ((xy >> 8) & 0xff));
grub_print_spaces (term, margin_left - xy.x);
else
grub_term_gotoxy (term, margin_left,
xy & 0xff);
grub_term_gotoxy (term, (struct grub_term_coordinate) {margin_left,
xy.y});
}
}