138 lines
5.3 KiB
Diff
138 lines
5.3 KiB
Diff
From 46992a68784aedc4e53ce749a88b6034209af87e Mon Sep 17 00:00:00 2001
|
|
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
|
|
Date: Sat, 2 Mar 2013 11:47:59 +0100
|
|
Subject: [PATCH 181/364] * grub-core/normal/charset.c
|
|
(grub_bidi_logical_to_visual): Add hook pass-through parameter. All users
|
|
updated and unnested.
|
|
|
|
---
|
|
grub-core/gfxmenu/font.c | 2 +-
|
|
grub-core/normal/charset.c | 14 +++++++++-----
|
|
grub-core/normal/term.c | 14 +++++++-------
|
|
include/grub/unicode.h | 3 ++-
|
|
4 files changed, 19 insertions(+), 14 deletions(-)
|
|
|
|
diff --git a/grub-core/gfxmenu/font.c b/grub-core/gfxmenu/font.c
|
|
index 81a689d..7174837 100644
|
|
--- a/grub-core/gfxmenu/font.c
|
|
+++ b/grub-core/gfxmenu/font.c
|
|
@@ -52,7 +52,7 @@ grub_font_draw_string (const char *str, grub_font_t font,
|
|
return grub_errno;
|
|
|
|
visual_len = grub_bidi_logical_to_visual (logical, logical_len, &visual,
|
|
- 0, 0, 0, 0, 0, 0);
|
|
+ 0, 0, 0, 0, 0, 0, 0);
|
|
grub_free (logical);
|
|
if (visual_len < 0)
|
|
return grub_errno;
|
|
diff --git a/grub-core/normal/charset.c b/grub-core/normal/charset.c
|
|
index bd9fbf4..ab3101b 100644
|
|
--- a/grub-core/normal/charset.c
|
|
+++ b/grub-core/normal/charset.c
|
|
@@ -512,7 +512,8 @@ static grub_ssize_t
|
|
bidi_line_wrap (struct grub_unicode_glyph *visual_out,
|
|
struct grub_unicode_glyph *visual,
|
|
grub_size_t visual_len, unsigned *levels,
|
|
- grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual),
|
|
+ grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual, void *getcharwidth_arg),
|
|
+ void *getcharwidth_arg,
|
|
grub_size_t maxwidth, grub_size_t startwidth,
|
|
grub_uint32_t contchar,
|
|
struct grub_term_pos *pos, int primitive_wrap,
|
|
@@ -577,7 +578,7 @@ bidi_line_wrap (struct grub_unicode_glyph *visual_out,
|
|
}
|
|
|
|
if (getcharwidth && k != visual_len)
|
|
- line_width += last_width = getcharwidth (&visual[k]);
|
|
+ line_width += last_width = getcharwidth (&visual[k], getcharwidth_arg);
|
|
|
|
if (k != visual_len && (visual[k].base == ' '
|
|
|| visual[k].base == '\t')
|
|
@@ -752,7 +753,8 @@ static grub_ssize_t
|
|
grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,
|
|
grub_size_t logical_len,
|
|
struct grub_unicode_glyph *visual_out,
|
|
- grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual),
|
|
+ grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual, void *getcharwidth_arg),
|
|
+ void *getcharwidth_arg,
|
|
grub_size_t maxwidth, grub_size_t startwidth,
|
|
grub_uint32_t contchar,
|
|
struct grub_term_pos *pos,
|
|
@@ -1116,7 +1118,7 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,
|
|
{
|
|
grub_ssize_t ret;
|
|
ret = bidi_line_wrap (visual_out, visual, visual_len, levels,
|
|
- getcharwidth, maxwidth, startwidth, contchar,
|
|
+ getcharwidth, getcharwidth_arg, maxwidth, startwidth, contchar,
|
|
pos, primitive_wrap, log_end);
|
|
grub_free (levels);
|
|
grub_free (visual);
|
|
@@ -1128,7 +1130,8 @@ grub_ssize_t
|
|
grub_bidi_logical_to_visual (const grub_uint32_t *logical,
|
|
grub_size_t logical_len,
|
|
struct grub_unicode_glyph **visual_out,
|
|
- grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual),
|
|
+ grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual, void *getcharwidth_arg),
|
|
+ void *getcharwidth_arg,
|
|
grub_size_t max_length, grub_size_t startwidth,
|
|
grub_uint32_t contchar, struct grub_term_pos *pos, int primitive_wrap)
|
|
{
|
|
@@ -1147,6 +1150,7 @@ grub_bidi_logical_to_visual (const grub_uint32_t *logical,
|
|
ptr - line_start,
|
|
visual_ptr,
|
|
getcharwidth,
|
|
+ getcharwidth_arg,
|
|
max_length,
|
|
startwidth,
|
|
contchar,
|
|
diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c
|
|
index dc03268..ae91071 100644
|
|
--- a/grub-core/normal/term.c
|
|
+++ b/grub-core/normal/term.c
|
|
@@ -840,6 +840,12 @@ print_backlog (struct grub_term_output *term,
|
|
return 0;
|
|
}
|
|
|
|
+static grub_ssize_t
|
|
+getcharwidth (const struct grub_unicode_glyph *c, void *term)
|
|
+{
|
|
+ return grub_term_getcharwidth (term, c);
|
|
+}
|
|
+
|
|
static int
|
|
print_ucs4_real (const grub_uint32_t * str,
|
|
const grub_uint32_t * last_position,
|
|
@@ -881,14 +887,8 @@ print_ucs4_real (const grub_uint32_t * str,
|
|
int ret;
|
|
struct grub_unicode_glyph *vptr;
|
|
|
|
- auto grub_ssize_t getcharwidth (const struct grub_unicode_glyph *c);
|
|
- grub_ssize_t getcharwidth (const struct grub_unicode_glyph *c)
|
|
- {
|
|
- return grub_term_getcharwidth (term, c);
|
|
- }
|
|
-
|
|
visual_len = grub_bidi_logical_to_visual (str, last_position - str,
|
|
- &visual, getcharwidth,
|
|
+ &visual, getcharwidth, term,
|
|
get_maxwidth (term,
|
|
margin_left,
|
|
margin_right),
|
|
diff --git a/include/grub/unicode.h b/include/grub/unicode.h
|
|
index eb5051a..5a96a19 100644
|
|
--- a/include/grub/unicode.h
|
|
+++ b/include/grub/unicode.h
|
|
@@ -240,7 +240,8 @@ grub_ssize_t
|
|
grub_bidi_logical_to_visual (const grub_uint32_t *logical,
|
|
grub_size_t logical_len,
|
|
struct grub_unicode_glyph **visual_out,
|
|
- grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual),
|
|
+ grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual, void *getcharwidth_arg),
|
|
+ void *getcharwidth_arg,
|
|
grub_size_t max_width,
|
|
grub_size_t start_width, grub_uint32_t codechar,
|
|
struct grub_term_pos *pos,
|
|
--
|
|
1.8.1.4
|
|
|