Fix tab and wide character handling in editor and menu.

* grub-core/normal/charset.c (grub_unicode_aglomerate_comb): Don't
	agglomerate control characters with combining marks.
	(bidi_line_wrap): Allow break on tab.
	(grub_unicode_get_comb_start): New function.
	* grub-core/normal/menu_entry.c: Restructure to handle wide characters
	and tab correctly.
	* grub-core/normal/menu_text.c (print_entry): Replace \n, \r, \b and \e
	with a space.
	* grub-core/normal/term.c (print_ucs4_terminal): New argument
	fixed_tab_size. All users updated.
	* include/grub/term.h (GRUB_TERM_TAB_WIDTH): New const.
	(grub_term_getcharwidth): Handle \t.
	* include/grub/unicode.h (grub_unicode_glyph_dup): Fix allocation
	and copy.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-03-27 17:07:26 +02:00
parent 22e6a774f9
commit e1bd676b4e
9 changed files with 320 additions and 189 deletions

View file

@ -293,4 +293,8 @@ grub_ssize_t
grub_encode_utf8_character (grub_uint8_t *dest, grub_uint8_t *destend,
grub_uint32_t code);
const grub_uint32_t *
grub_unicode_get_comb_start (const grub_uint32_t *str,
const grub_uint32_t *cur);
#endif

View file

@ -435,10 +435,15 @@ grub_unicode_estimate_width (const struct grub_unicode_glyph *c __attribute__ ((
#endif
#define GRUB_TERM_TAB_WIDTH 8
static inline grub_ssize_t
grub_term_getcharwidth (struct grub_term_output *term,
const struct grub_unicode_glyph *c)
{
if (c->base == '\t')
return GRUB_TERM_TAB_WIDTH;
if (term->getcharwidth)
return term->getcharwidth (term, c);
else if (((term->flags & GRUB_TERM_CODE_TYPE_MASK)

View file

@ -243,13 +243,14 @@ grub_unicode_glyph_dup (const struct grub_unicode_glyph *in)
grub_memcpy (out, in, sizeof (*in));
if (in->combining)
{
out->combining = grub_malloc (in->ncomb * sizeof (*in));
out->combining = grub_malloc (in->ncomb * sizeof (out->combining[0]));
if (!out->combining)
{
grub_free (out);
return NULL;
}
grub_memcpy (out->combining, in->combining, in->ncomb * sizeof (*in));
grub_memcpy (out->combining, in->combining,
in->ncomb * sizeof (out->combining[0]));
}
return out;
}