|
|
f96e0b |
From 1ce5f411b75c2bcd899e1a838d1d6292d6c76972 Mon Sep 17 00:00:00 2001
|
|
|
f96e0b |
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
Date: Wed, 16 Jan 2013 13:41:16 +0100
|
|
|
f96e0b |
Subject: [PATCH 110/482] Improve bidi handling in entry editor.
|
|
|
f96e0b |
|
|
|
f96e0b |
---
|
|
|
f96e0b |
ChangeLog | 4 +
|
|
|
f96e0b |
grub-core/gfxmenu/font.c | 2 +-
|
|
|
f96e0b |
grub-core/normal/charset.c | 98 ++++++++++-
|
|
|
f96e0b |
grub-core/normal/menu_entry.c | 394 ++++++++++++++++++------------------------
|
|
|
f96e0b |
grub-core/normal/term.c | 186 +++++++++++++++++---
|
|
|
f96e0b |
include/grub/normal.h | 8 +
|
|
|
f96e0b |
include/grub/term.h | 6 +-
|
|
|
f96e0b |
include/grub/unicode.h | 22 ++-
|
|
|
f96e0b |
8 files changed, 453 insertions(+), 267 deletions(-)
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/ChangeLog b/ChangeLog
|
|
|
f96e0b |
index 76a9f68..96aca66 100644
|
|
|
f96e0b |
--- a/ChangeLog
|
|
|
f96e0b |
+++ b/ChangeLog
|
|
|
f96e0b |
@@ -1,5 +1,9 @@
|
|
|
f96e0b |
2013-01-16 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
|
|
|
f96e0b |
+ Improve bidi handling in entry editor.
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+2013-01-16 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
+
|
|
|
f96e0b |
* grub-core/script/lexer.c (grub_script_lexer_init): Rename getline
|
|
|
f96e0b |
argument to prevent name collision.
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/grub-core/gfxmenu/font.c b/grub-core/gfxmenu/font.c
|
|
|
f96e0b |
index 3c15e19..81a689d 100644
|
|
|
f96e0b |
--- a/grub-core/gfxmenu/font.c
|
|
|
f96e0b |
+++ b/grub-core/gfxmenu/font.c
|
|
|
f96e0b |
@@ -52,7 +52,7 @@ grub_font_draw_string (const char *str, grub_font_t font,
|
|
|
f96e0b |
return grub_errno;
|
|
|
f96e0b |
|
|
|
f96e0b |
visual_len = grub_bidi_logical_to_visual (logical, logical_len, &visual,
|
|
|
f96e0b |
- 0, 0, 0);
|
|
|
f96e0b |
+ 0, 0, 0, 0, 0, 0);
|
|
|
f96e0b |
grub_free (logical);
|
|
|
f96e0b |
if (visual_len < 0)
|
|
|
f96e0b |
return grub_errno;
|
|
|
f96e0b |
diff --git a/grub-core/normal/charset.c b/grub-core/normal/charset.c
|
|
|
f96e0b |
index 25593ce..bd9fbf4 100644
|
|
|
f96e0b |
--- a/grub-core/normal/charset.c
|
|
|
f96e0b |
+++ b/grub-core/normal/charset.c
|
|
|
f96e0b |
@@ -513,7 +513,10 @@ bidi_line_wrap (struct grub_unicode_glyph *visual_out,
|
|
|
f96e0b |
struct grub_unicode_glyph *visual,
|
|
|
f96e0b |
grub_size_t visual_len, unsigned *levels,
|
|
|
f96e0b |
grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual),
|
|
|
f96e0b |
- grub_size_t maxwidth, grub_size_t startwidth)
|
|
|
f96e0b |
+ grub_size_t maxwidth, grub_size_t startwidth,
|
|
|
f96e0b |
+ grub_uint32_t contchar,
|
|
|
f96e0b |
+ struct grub_term_pos *pos, int primitive_wrap,
|
|
|
f96e0b |
+ grub_size_t log_end)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
struct grub_unicode_glyph *outptr = visual_out;
|
|
|
f96e0b |
unsigned line_start = 0;
|
|
|
f96e0b |
@@ -521,17 +524,30 @@ bidi_line_wrap (struct grub_unicode_glyph *visual_out,
|
|
|
f96e0b |
unsigned k;
|
|
|
f96e0b |
grub_ssize_t last_space = -1;
|
|
|
f96e0b |
grub_ssize_t last_space_width = 0;
|
|
|
f96e0b |
+ int lines = 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
auto void revert (unsigned start, unsigned end);
|
|
|
f96e0b |
void revert (unsigned start, unsigned end)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
struct grub_unicode_glyph t;
|
|
|
f96e0b |
unsigned i, tl;
|
|
|
f96e0b |
+ int a, b;
|
|
|
f96e0b |
+ if (pos)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ a = pos[visual[start].orig_pos].x;
|
|
|
f96e0b |
+ b = pos[visual[end].orig_pos].x;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
for (i = 0; i < (end - start) / 2 + 1; i++)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
t = visual[start + i];
|
|
|
f96e0b |
visual[start + i] = visual[end - i];
|
|
|
f96e0b |
visual[end - i] = t;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (pos)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ pos[visual[start + i].orig_pos].x = a + b - pos[visual[start + i].orig_pos].x;
|
|
|
f96e0b |
+ pos[visual[end - i].orig_pos].x = a + b - pos[visual[end - i].orig_pos].x;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
tl = levels[start + i];
|
|
|
f96e0b |
levels[start + i] = levels[end - i];
|
|
|
f96e0b |
levels[end - i] = tl;
|
|
|
f96e0b |
@@ -545,11 +561,27 @@ bidi_line_wrap (struct grub_unicode_glyph *visual_out,
|
|
|
f96e0b |
{
|
|
|
f96e0b |
grub_ssize_t last_width = 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (pos && k != visual_len)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ pos[visual[k].orig_pos].x = line_width;
|
|
|
f96e0b |
+ pos[visual[k].orig_pos].y = lines;
|
|
|
f96e0b |
+ pos[visual[k].orig_pos].valid = 1;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (k == visual_len && pos)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ pos[log_end].x = line_width;
|
|
|
f96e0b |
+ pos[log_end].y = lines;
|
|
|
f96e0b |
+ pos[log_end].valid = 1;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+
|
|
|
f96e0b |
if (getcharwidth && k != visual_len)
|
|
|
f96e0b |
line_width += last_width = getcharwidth (&visual[k]);
|
|
|
f96e0b |
|
|
|
f96e0b |
if (k != visual_len && (visual[k].base == ' '
|
|
|
f96e0b |
- || visual[k].base == '\t'))
|
|
|
f96e0b |
+ || visual[k].base == '\t')
|
|
|
f96e0b |
+ && !primitive_wrap)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
last_space = k;
|
|
|
f96e0b |
last_space_width = line_width;
|
|
|
f96e0b |
@@ -561,9 +593,12 @@ bidi_line_wrap (struct grub_unicode_glyph *visual_out,
|
|
|
f96e0b |
unsigned min_odd_level = 0xffffffff;
|
|
|
f96e0b |
unsigned max_level = 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
+ lines++;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
if (k != visual_len && last_space > (signed) line_start)
|
|
|
f96e0b |
k = last_space;
|
|
|
f96e0b |
- else if (k != visual_len && line_start == 0 && startwidth != 0)
|
|
|
f96e0b |
+ else if (k != visual_len && line_start == 0 && startwidth != 0
|
|
|
f96e0b |
+ && !primitive_wrap)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
k = 0;
|
|
|
f96e0b |
last_space_width = startwidth;
|
|
|
f96e0b |
@@ -685,6 +720,12 @@ bidi_line_wrap (struct grub_unicode_glyph *visual_out,
|
|
|
f96e0b |
outptr += k - line_start;
|
|
|
f96e0b |
if (k != visual_len)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
+ if (contchar)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_memset (outptr, 0, sizeof (visual[0]));
|
|
|
f96e0b |
+ outptr->base = contchar;
|
|
|
f96e0b |
+ outptr++;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
grub_memset (outptr, 0, sizeof (visual[0]));
|
|
|
f96e0b |
outptr->base = '\n';
|
|
|
f96e0b |
outptr++;
|
|
|
f96e0b |
@@ -695,6 +736,11 @@ bidi_line_wrap (struct grub_unicode_glyph *visual_out,
|
|
|
f96e0b |
|
|
|
f96e0b |
line_start = k;
|
|
|
f96e0b |
line_width -= last_space_width;
|
|
|
f96e0b |
+ if (pos && k != visual_len)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ pos[visual[k].orig_pos].x = 0;
|
|
|
f96e0b |
+ pos[visual[k].orig_pos].y = lines;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
}
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -707,7 +753,11 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,
|
|
|
f96e0b |
grub_size_t logical_len,
|
|
|
f96e0b |
struct grub_unicode_glyph *visual_out,
|
|
|
f96e0b |
grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual),
|
|
|
f96e0b |
- grub_size_t maxwidth, grub_size_t startwidth)
|
|
|
f96e0b |
+ grub_size_t maxwidth, grub_size_t startwidth,
|
|
|
f96e0b |
+ grub_uint32_t contchar,
|
|
|
f96e0b |
+ struct grub_term_pos *pos,
|
|
|
f96e0b |
+ int primitive_wrap,
|
|
|
f96e0b |
+ grub_size_t log_end)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
enum grub_bidi_type type = GRUB_BIDI_TYPE_L;
|
|
|
f96e0b |
enum override_status {OVERRIDE_NEUTRAL = 0, OVERRIDE_R, OVERRIDE_L};
|
|
|
f96e0b |
@@ -832,7 +882,7 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,
|
|
|
f96e0b |
|
|
|
f96e0b |
p = grub_unicode_aglomerate_comb (lptr, logical + logical_len - lptr,
|
|
|
f96e0b |
&visual[visual_len]);
|
|
|
f96e0b |
-
|
|
|
f96e0b |
+ visual[visual_len].orig_pos = lptr - logical;
|
|
|
f96e0b |
type = get_bidi_type (visual[visual_len].base);
|
|
|
f96e0b |
switch (type)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
@@ -1066,7 +1116,8 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,
|
|
|
f96e0b |
{
|
|
|
f96e0b |
grub_ssize_t ret;
|
|
|
f96e0b |
ret = bidi_line_wrap (visual_out, visual, visual_len, levels,
|
|
|
f96e0b |
- getcharwidth, maxwidth, startwidth);
|
|
|
f96e0b |
+ getcharwidth, maxwidth, startwidth, contchar,
|
|
|
f96e0b |
+ pos, primitive_wrap, log_end);
|
|
|
f96e0b |
grub_free (levels);
|
|
|
f96e0b |
grub_free (visual);
|
|
|
f96e0b |
return ret;
|
|
|
f96e0b |
@@ -1078,11 +1129,12 @@ grub_bidi_logical_to_visual (const grub_uint32_t *logical,
|
|
|
f96e0b |
grub_size_t logical_len,
|
|
|
f96e0b |
struct grub_unicode_glyph **visual_out,
|
|
|
f96e0b |
grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual),
|
|
|
f96e0b |
- grub_size_t max_length, grub_size_t startwidth)
|
|
|
f96e0b |
+ grub_size_t max_length, grub_size_t startwidth,
|
|
|
f96e0b |
+ grub_uint32_t contchar, struct grub_term_pos *pos, int primitive_wrap)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
const grub_uint32_t *line_start = logical, *ptr;
|
|
|
f96e0b |
struct grub_unicode_glyph *visual_ptr;
|
|
|
f96e0b |
- *visual_out = visual_ptr = grub_malloc (2 * sizeof (visual_ptr[0])
|
|
|
f96e0b |
+ *visual_out = visual_ptr = grub_malloc (3 * sizeof (visual_ptr[0])
|
|
|
f96e0b |
* logical_len);
|
|
|
f96e0b |
if (!visual_ptr)
|
|
|
f96e0b |
return -1;
|
|
|
f96e0b |
@@ -1096,7 +1148,11 @@ grub_bidi_logical_to_visual (const grub_uint32_t *logical,
|
|
|
f96e0b |
visual_ptr,
|
|
|
f96e0b |
getcharwidth,
|
|
|
f96e0b |
max_length,
|
|
|
f96e0b |
- startwidth);
|
|
|
f96e0b |
+ startwidth,
|
|
|
f96e0b |
+ contchar,
|
|
|
f96e0b |
+ pos,
|
|
|
f96e0b |
+ primitive_wrap,
|
|
|
f96e0b |
+ logical_len);
|
|
|
f96e0b |
startwidth = 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
if (ret < 0)
|
|
|
f96e0b |
@@ -1188,3 +1244,27 @@ grub_unicode_get_comb_start (const grub_uint32_t *str,
|
|
|
f96e0b |
return str;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
+const grub_uint32_t *
|
|
|
f96e0b |
+grub_unicode_get_comb_end (const grub_uint32_t *end,
|
|
|
f96e0b |
+ const grub_uint32_t *cur)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ const grub_uint32_t *ptr;
|
|
|
f96e0b |
+ for (ptr = cur; ptr < end; ptr++)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ if (*ptr >= GRUB_UNICODE_VARIATION_SELECTOR_1
|
|
|
f96e0b |
+ && *ptr <= GRUB_UNICODE_VARIATION_SELECTOR_16)
|
|
|
f96e0b |
+ continue;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (*ptr >= GRUB_UNICODE_VARIATION_SELECTOR_17
|
|
|
f96e0b |
+ && *ptr <= GRUB_UNICODE_VARIATION_SELECTOR_256)
|
|
|
f96e0b |
+ continue;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ enum grub_comb_type comb_type;
|
|
|
f96e0b |
+ comb_type = grub_unicode_get_comb_type (*ptr);
|
|
|
f96e0b |
+ if (comb_type)
|
|
|
f96e0b |
+ continue;
|
|
|
f96e0b |
+ return ptr;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+ return end;
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
+
|
|
|
f96e0b |
diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c
|
|
|
f96e0b |
index 33b644b..7cd67f3 100644
|
|
|
f96e0b |
--- a/grub-core/normal/menu_entry.c
|
|
|
f96e0b |
+++ b/grub-core/normal/menu_entry.c
|
|
|
f96e0b |
@@ -43,15 +43,12 @@ struct line
|
|
|
f96e0b |
int len;
|
|
|
f96e0b |
/* The maximum length of the line. */
|
|
|
f96e0b |
int max_len;
|
|
|
f96e0b |
+ struct grub_term_pos **pos;
|
|
|
f96e0b |
};
|
|
|
f96e0b |
|
|
|
f96e0b |
struct per_term_screen
|
|
|
f96e0b |
{
|
|
|
f96e0b |
struct grub_term_output *term;
|
|
|
f96e0b |
- /* The X coordinate. */
|
|
|
f96e0b |
- int x;
|
|
|
f96e0b |
- /* The Y coordinate. */
|
|
|
f96e0b |
- int y;
|
|
|
f96e0b |
int y_line_start;
|
|
|
f96e0b |
/* Number of entries. */
|
|
|
f96e0b |
int num_entries;
|
|
|
f96e0b |
@@ -90,13 +87,18 @@ static int completion_type;
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Initialize a line. */
|
|
|
f96e0b |
static int
|
|
|
f96e0b |
-init_line (struct line *linep)
|
|
|
f96e0b |
+init_line (struct screen *screen, struct line *linep)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
linep->len = 0;
|
|
|
f96e0b |
linep->max_len = 80;
|
|
|
f96e0b |
linep->buf = grub_malloc ((linep->max_len + 1) * sizeof (linep->buf[0]));
|
|
|
f96e0b |
- if (! linep->buf)
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
+ linep->pos = grub_zalloc (screen->nterms * sizeof (linep->pos[0]));
|
|
|
f96e0b |
+ if (! linep->buf || !linep->pos)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_free (linep->buf);
|
|
|
f96e0b |
+ grub_free (linep->pos);
|
|
|
f96e0b |
+ return 0;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
|
|
|
f96e0b |
return 1;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
@@ -126,93 +128,16 @@ get_logical_num_lines (struct line *linep, struct per_term_screen *term_screen)
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
static void
|
|
|
f96e0b |
-advance (struct screen *screen)
|
|
|
f96e0b |
-{
|
|
|
f96e0b |
- unsigned i;
|
|
|
f96e0b |
- struct grub_unicode_glyph glyph;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- screen->column += grub_unicode_aglomerate_comb (screen->lines[screen->line].buf + screen->column,
|
|
|
f96e0b |
- screen->lines[screen->line].len - screen->column,
|
|
|
f96e0b |
- &glyph);
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- for (i = 0; i < screen->nterms; i++)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- grub_ssize_t width;
|
|
|
f96e0b |
- width = grub_term_getcharwidth (screen->terms[i].term, &glyph);
|
|
|
f96e0b |
- screen->terms[i].x += width;
|
|
|
f96e0b |
- if (screen->terms[i].x
|
|
|
f96e0b |
- == grub_term_entry_width (screen->terms[i].term))
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- screen->terms[i].x = 0;
|
|
|
f96e0b |
- screen->terms[i].y++;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
- if (screen->terms[i].x
|
|
|
f96e0b |
- > grub_term_entry_width (screen->terms[i].term))
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- screen->terms[i].x = width;
|
|
|
f96e0b |
- screen->terms[i].y++;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
- grub_free (glyph.combining);
|
|
|
f96e0b |
-}
|
|
|
f96e0b |
-
|
|
|
f96e0b |
-static void
|
|
|
f96e0b |
advance_to (struct screen *screen, int c)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
if (c > screen->lines[screen->line].len)
|
|
|
f96e0b |
c = screen->lines[screen->line].len;
|
|
|
f96e0b |
|
|
|
f96e0b |
- while (screen->column < c)
|
|
|
f96e0b |
- advance (screen);
|
|
|
f96e0b |
-}
|
|
|
f96e0b |
-
|
|
|
f96e0b |
-/* Print a line. */
|
|
|
f96e0b |
-static int
|
|
|
f96e0b |
-print_line (struct line *linep, int offset, int y,
|
|
|
f96e0b |
- struct per_term_screen *term_screen, int dry_run)
|
|
|
f96e0b |
-{
|
|
|
f96e0b |
- int x;
|
|
|
f96e0b |
- int i;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- grub_term_gotoxy (term_screen->term,
|
|
|
f96e0b |
- GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN + 1,
|
|
|
f96e0b |
- y + GRUB_TERM_FIRST_ENTRY_Y);
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- x = 0;
|
|
|
f96e0b |
- for (i = 0; i + offset < (int) linep->len;)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- grub_ssize_t width;
|
|
|
f96e0b |
- grub_size_t delta = 0;
|
|
|
f96e0b |
- struct grub_unicode_glyph glyph;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- delta = grub_unicode_aglomerate_comb (linep->buf + offset + i,
|
|
|
f96e0b |
- linep->len - offset - i,
|
|
|
f96e0b |
- &glyph);
|
|
|
f96e0b |
- width = grub_term_getcharwidth (term_screen->term, &glyph);
|
|
|
f96e0b |
- grub_free (glyph.combining);
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- if (x + width > grub_term_entry_width (term_screen->term) && x != 0)
|
|
|
f96e0b |
- break;
|
|
|
f96e0b |
- x += width;
|
|
|
f96e0b |
- i += delta;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- if (dry_run)
|
|
|
f96e0b |
- return i;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- grub_print_ucs4 (linep->buf + offset,
|
|
|
f96e0b |
- linep->buf + offset + i, 0, 0, term_screen->term);
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- if (i + offset != linep->len)
|
|
|
f96e0b |
- grub_putcode ('\\', term_screen->term);
|
|
|
f96e0b |
- else
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- for (;
|
|
|
f96e0b |
- x <= (int) grub_term_entry_width (term_screen->term);
|
|
|
f96e0b |
- x++)
|
|
|
f96e0b |
- grub_putcode (' ', term_screen->term);
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
- return i;
|
|
|
f96e0b |
+ screen->column = grub_unicode_get_comb_end (screen->lines[screen->line].buf
|
|
|
f96e0b |
+ + screen->lines[screen->line].len,
|
|
|
f96e0b |
+ screen->lines[screen->line].buf
|
|
|
f96e0b |
+ + c)
|
|
|
f96e0b |
+ - screen->lines[screen->line].buf;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Print an empty line. */
|
|
|
f96e0b |
@@ -225,7 +150,7 @@ print_empty_line (int y, struct per_term_screen *term_screen)
|
|
|
f96e0b |
GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN + 1,
|
|
|
f96e0b |
y + GRUB_TERM_FIRST_ENTRY_Y);
|
|
|
f96e0b |
|
|
|
f96e0b |
- for (i = 0; i < grub_term_entry_width (term_screen->term) + 1; i++)
|
|
|
f96e0b |
+ for (i = 0; i < grub_term_entry_width (term_screen->term); i++)
|
|
|
f96e0b |
grub_putcode (' ', term_screen->term);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -261,7 +186,7 @@ print_down (int flag, struct per_term_screen *term_screen)
|
|
|
f96e0b |
/* Draw the lines of the screen SCREEN. */
|
|
|
f96e0b |
static void
|
|
|
f96e0b |
update_screen (struct screen *screen, struct per_term_screen *term_screen,
|
|
|
f96e0b |
- int region_start, int region_column,
|
|
|
f96e0b |
+ int region_start, int region_column __attribute__ ((unused)),
|
|
|
f96e0b |
int up, int down, enum update_mode mode)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
int up_flag = 0;
|
|
|
f96e0b |
@@ -270,19 +195,26 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen,
|
|
|
f96e0b |
int i;
|
|
|
f96e0b |
struct line *linep;
|
|
|
f96e0b |
|
|
|
f96e0b |
+ y = term_screen->y_line_start;
|
|
|
f96e0b |
+ linep = screen->lines;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ for (i = 0; i < screen->line; i++, linep++)
|
|
|
f96e0b |
+ y += get_logical_num_lines (linep, term_screen);
|
|
|
f96e0b |
+ linep = screen->lines + screen->line;
|
|
|
f96e0b |
+ y += grub_getstringwidth (linep->buf, linep->buf + screen->column,
|
|
|
f96e0b |
+ term_screen->term) / grub_term_entry_width (term_screen->term);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
/* Check if scrolling is necessary. */
|
|
|
f96e0b |
- if (term_screen->y < 0 || term_screen->y >= term_screen->num_entries)
|
|
|
f96e0b |
+ if (y < 0 || y >= term_screen->num_entries)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
int delta;
|
|
|
f96e0b |
- if (term_screen->y < 0)
|
|
|
f96e0b |
- delta = -term_screen->y;
|
|
|
f96e0b |
+ if (y < 0)
|
|
|
f96e0b |
+ delta = -y;
|
|
|
f96e0b |
else
|
|
|
f96e0b |
- delta = term_screen->num_entries - 1 - term_screen->y;
|
|
|
f96e0b |
- term_screen->y += delta;
|
|
|
f96e0b |
+ delta = term_screen->num_entries - 1 - y;
|
|
|
f96e0b |
term_screen->y_line_start += delta;
|
|
|
f96e0b |
|
|
|
f96e0b |
region_start = 0;
|
|
|
f96e0b |
- region_column = 0;
|
|
|
f96e0b |
up = 1;
|
|
|
f96e0b |
down = 1;
|
|
|
f96e0b |
mode = ALL_LINES;
|
|
|
f96e0b |
@@ -293,58 +225,81 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen,
|
|
|
f96e0b |
/* Draw lines. This code is tricky, because this must calculate logical
|
|
|
f96e0b |
positions. */
|
|
|
f96e0b |
y = term_screen->y_line_start;
|
|
|
f96e0b |
- i = screen->line;
|
|
|
f96e0b |
- linep = screen->lines + i;
|
|
|
f96e0b |
- while (y > 0)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- i--;
|
|
|
f96e0b |
- linep--;
|
|
|
f96e0b |
- y -= get_logical_num_lines (linep, term_screen);
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
+ i = 0;
|
|
|
f96e0b |
+ linep = screen->lines;
|
|
|
f96e0b |
+ while (1)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ int add;
|
|
|
f96e0b |
+ add = get_logical_num_lines (linep, term_screen);
|
|
|
f96e0b |
+ if (y + add > 0)
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
+ i++;
|
|
|
f96e0b |
+ linep++;
|
|
|
f96e0b |
+ y += add;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
|
|
|
f96e0b |
if (y < 0 || i > 0)
|
|
|
f96e0b |
up_flag = 1;
|
|
|
f96e0b |
|
|
|
f96e0b |
do
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- int column;
|
|
|
f96e0b |
int off = 0;
|
|
|
f96e0b |
- int full_len;
|
|
|
f96e0b |
+ struct grub_term_pos **pos;
|
|
|
f96e0b |
|
|
|
f96e0b |
if (linep >= screen->lines + screen->num_lines)
|
|
|
f96e0b |
break;
|
|
|
f96e0b |
|
|
|
f96e0b |
- full_len = grub_getstringwidth (linep->buf, linep->buf + linep->len,
|
|
|
f96e0b |
- term_screen->term);
|
|
|
f96e0b |
+ pos = linep->pos + (term_screen - screen->terms);
|
|
|
f96e0b |
|
|
|
f96e0b |
- for (column = 0;
|
|
|
f96e0b |
- column <= full_len
|
|
|
f96e0b |
- && y < term_screen->num_entries;
|
|
|
f96e0b |
- column += grub_term_entry_width (term_screen->term), y++)
|
|
|
f96e0b |
+ if (!*pos)
|
|
|
f96e0b |
+ *pos = grub_zalloc ((linep->len + 1) * sizeof (**pos));
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (i == region_start || linep == screen->lines + screen->line)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ int sp;
|
|
|
f96e0b |
+ grub_term_gotoxy (term_screen->term, GRUB_TERM_LEFT_BORDER_X
|
|
|
f96e0b |
+ + GRUB_TERM_MARGIN + 1, (y < 0 ? 0 : y)
|
|
|
f96e0b |
+ + GRUB_TERM_FIRST_ENTRY_Y);
|
|
|
f96e0b |
+ grub_print_ucs4_menu (linep->buf,
|
|
|
f96e0b |
+ linep->buf + linep->len,
|
|
|
f96e0b |
+ GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN
|
|
|
f96e0b |
+ + 1,
|
|
|
f96e0b |
+ GRUB_TERM_MARGIN
|
|
|
f96e0b |
+ + GRUB_TERM_SCROLL_WIDTH + 2,
|
|
|
f96e0b |
+ term_screen->term,
|
|
|
f96e0b |
+ (y < 0) ? -y : 0,
|
|
|
f96e0b |
+ term_screen->num_entries
|
|
|
f96e0b |
+ - ((y > 0) ? y : 0), '\\',
|
|
|
f96e0b |
+ *pos);
|
|
|
f96e0b |
+ sp = grub_term_entry_width (term_screen->term)
|
|
|
f96e0b |
+ - (*pos)[linep->len].x;
|
|
|
f96e0b |
+ if (sp > 0)
|
|
|
f96e0b |
+ grub_print_spaces (term_screen->term, sp);
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+ else if (i > region_start && mode == ALL_LINES)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- if (y < 0)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- off += print_line (linep, off, y, term_screen, 1);
|
|
|
f96e0b |
- continue;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- if (i == region_start)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- if (region_column >= column
|
|
|
f96e0b |
- && region_column
|
|
|
f96e0b |
- < (column
|
|
|
f96e0b |
- + grub_term_entry_width (term_screen->term)))
|
|
|
f96e0b |
- off += print_line (linep, off, y, term_screen, 0);
|
|
|
f96e0b |
- else if (region_column < column)
|
|
|
f96e0b |
- off += print_line (linep, off, y, term_screen, 0);
|
|
|
f96e0b |
- else
|
|
|
f96e0b |
- off += print_line (linep, off, y, term_screen, 1);
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
- else if (i > region_start && mode == ALL_LINES)
|
|
|
f96e0b |
- off += print_line (linep, off, y, term_screen, 0);
|
|
|
f96e0b |
+ int sp;
|
|
|
f96e0b |
+ grub_term_gotoxy (term_screen->term, GRUB_TERM_LEFT_BORDER_X
|
|
|
f96e0b |
+ + GRUB_TERM_MARGIN + 1, (y < 0 ? 0 : y)
|
|
|
f96e0b |
+ + GRUB_TERM_FIRST_ENTRY_Y);
|
|
|
f96e0b |
+ grub_print_ucs4_menu (linep->buf,
|
|
|
f96e0b |
+ linep->buf + linep->len,
|
|
|
f96e0b |
+ GRUB_TERM_LEFT_BORDER_X
|
|
|
f96e0b |
+ + GRUB_TERM_MARGIN + 1,
|
|
|
f96e0b |
+ GRUB_TERM_MARGIN
|
|
|
f96e0b |
+ + GRUB_TERM_SCROLL_WIDTH + 2,
|
|
|
f96e0b |
+ term_screen->term,
|
|
|
f96e0b |
+ (y < 0) ? -y : 0,
|
|
|
f96e0b |
+ term_screen->num_entries
|
|
|
f96e0b |
+ - ((y > 0) ? y : 0), '\\',
|
|
|
f96e0b |
+ *pos);
|
|
|
f96e0b |
+ sp = grub_term_entry_width (term_screen->term)
|
|
|
f96e0b |
+ - (*pos)[linep->len].x;
|
|
|
f96e0b |
+ if (sp > 0)
|
|
|
f96e0b |
+ grub_print_spaces (term_screen->term, sp);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- if (y == term_screen->num_entries)
|
|
|
f96e0b |
+ y += get_logical_num_lines (linep, term_screen);
|
|
|
f96e0b |
+ if (y >= term_screen->num_entries)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
if (off <= linep->len || i + 1 < screen->num_lines)
|
|
|
f96e0b |
down_flag = 1;
|
|
|
f96e0b |
@@ -367,10 +322,30 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen,
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Place the cursor. */
|
|
|
f96e0b |
- grub_term_gotoxy (term_screen->term,
|
|
|
f96e0b |
- GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN + 1
|
|
|
f96e0b |
- + term_screen->x,
|
|
|
f96e0b |
- GRUB_TERM_FIRST_ENTRY_Y + term_screen->y);
|
|
|
f96e0b |
+ if (screen->lines[screen->line].pos[term_screen - screen->terms])
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ const struct grub_term_pos *cpos;
|
|
|
f96e0b |
+ for (cpos = &(screen->lines[screen->line].pos[term_screen - screen->terms])[screen->column];
|
|
|
f96e0b |
+ cpos >= &(screen->lines[screen->line].pos[term_screen - screen->terms])[0];
|
|
|
f96e0b |
+ cpos--)
|
|
|
f96e0b |
+ if (cpos->valid)
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
+ y = term_screen->y_line_start;
|
|
|
f96e0b |
+ for (i = 0; i < screen->line; i++)
|
|
|
f96e0b |
+ y += get_logical_num_lines (screen->lines + i, term_screen);
|
|
|
f96e0b |
+ if (cpos >= &(screen->lines[screen->line].pos[term_screen - screen->terms])[0])
|
|
|
f96e0b |
+ grub_term_gotoxy (term_screen->term,
|
|
|
f96e0b |
+ cpos->x + GRUB_TERM_LEFT_BORDER_X
|
|
|
f96e0b |
+ + GRUB_TERM_MARGIN + 1,
|
|
|
f96e0b |
+ cpos->y + y
|
|
|
f96e0b |
+ + GRUB_TERM_FIRST_ENTRY_Y);
|
|
|
f96e0b |
+ else
|
|
|
f96e0b |
+ grub_term_gotoxy (term_screen->term,
|
|
|
f96e0b |
+ GRUB_TERM_LEFT_BORDER_X
|
|
|
f96e0b |
+ + GRUB_TERM_MARGIN + 1,
|
|
|
f96e0b |
+ y + GRUB_TERM_FIRST_ENTRY_Y);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
|
|
|
f96e0b |
grub_term_refresh (term_screen->term);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
@@ -424,7 +399,7 @@ insert_string (struct screen *screen, const char *s, int update)
|
|
|
f96e0b |
((screen->num_lines - screen->line - 2)
|
|
|
f96e0b |
* sizeof (struct line)));
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (! init_line (screen->lines + screen->line + 1))
|
|
|
f96e0b |
+ if (! init_line (screen, screen->lines + screen->line + 1))
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Fold the line. */
|
|
|
f96e0b |
@@ -439,6 +414,11 @@ insert_string (struct screen *screen, const char *s, int update)
|
|
|
f96e0b |
current_linep->buf + screen->column,
|
|
|
f96e0b |
size * sizeof (next_linep->buf[0]));
|
|
|
f96e0b |
current_linep->len = screen->column;
|
|
|
f96e0b |
+ for (i = 0; i < screen->nterms; i++)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_free (current_linep->pos[i]);
|
|
|
f96e0b |
+ current_linep->pos[i] = 0;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
next_linep->len = size;
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Update a dirty region. */
|
|
|
f96e0b |
@@ -457,12 +437,6 @@ insert_string (struct screen *screen, const char *s, int update)
|
|
|
f96e0b |
/* Move the cursor. */
|
|
|
f96e0b |
screen->column = screen->real_column = 0;
|
|
|
f96e0b |
screen->line++;
|
|
|
f96e0b |
- for (i = 0; i < screen->nterms; i++)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- screen->terms[i].x = 0;
|
|
|
f96e0b |
- screen->terms[i].y++;
|
|
|
f96e0b |
- screen->terms[i].y_line_start = screen->terms[i].y;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
s++;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
else
|
|
|
f96e0b |
@@ -502,6 +476,12 @@ insert_string (struct screen *screen, const char *s, int update)
|
|
|
f96e0b |
grub_free (unicode_msg);
|
|
|
f96e0b |
|
|
|
f96e0b |
for (i = 0; i < screen->nterms; i++)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_free (current_linep->pos[i]);
|
|
|
f96e0b |
+ current_linep->pos[i] = 0;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ for (i = 0; i < screen->nterms; i++)
|
|
|
f96e0b |
orig_num[i] = get_logical_num_lines (current_linep,
|
|
|
f96e0b |
&screen->terms[i]);
|
|
|
f96e0b |
current_linep->len += size;
|
|
|
f96e0b |
@@ -582,7 +562,7 @@ make_screen (grub_menu_entry_t entry)
|
|
|
f96e0b |
goto fail;
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Initialize the first line which must be always present. */
|
|
|
f96e0b |
- if (! init_line (screen->lines))
|
|
|
f96e0b |
+ if (! init_line (screen, screen->lines))
|
|
|
f96e0b |
goto fail;
|
|
|
f96e0b |
|
|
|
f96e0b |
insert_string (screen, (char *) entry->sourcecode, 0);
|
|
|
f96e0b |
@@ -593,9 +573,7 @@ make_screen (grub_menu_entry_t entry)
|
|
|
f96e0b |
screen->line = 0;
|
|
|
f96e0b |
for (i = 0; i < screen->nterms; i++)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- screen->terms[i].x = 0;
|
|
|
f96e0b |
- screen->terms[i].y = 0;
|
|
|
f96e0b |
- screen->terms[i].y_line_start = screen->terms[i].y;
|
|
|
f96e0b |
+ screen->terms[i].y_line_start = 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
return screen;
|
|
|
f96e0b |
@@ -609,21 +587,20 @@ static int
|
|
|
f96e0b |
forward_char (struct screen *screen, int update)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
struct line *linep;
|
|
|
f96e0b |
- unsigned i;
|
|
|
f96e0b |
|
|
|
f96e0b |
linep = screen->lines + screen->line;
|
|
|
f96e0b |
if (screen->column < linep->len)
|
|
|
f96e0b |
- advance (screen);
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ screen->column = grub_unicode_get_comb_end (screen->lines[screen->line].buf
|
|
|
f96e0b |
+ + screen->lines[screen->line].len,
|
|
|
f96e0b |
+ screen->lines[screen->line].buf
|
|
|
f96e0b |
+ + screen->column + 1)
|
|
|
f96e0b |
+ - screen->lines[screen->line].buf;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
else if (screen->num_lines > screen->line + 1)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
screen->column = 0;
|
|
|
f96e0b |
screen->line++;
|
|
|
f96e0b |
- for (i = 0; i < screen->nterms; i++)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- screen->terms[i].x = 0;
|
|
|
f96e0b |
- screen->terms[i].y++;
|
|
|
f96e0b |
- screen->terms[i].y_line_start = screen->terms[i].y;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
screen->real_column = screen->column;
|
|
|
f96e0b |
@@ -636,8 +613,6 @@ forward_char (struct screen *screen, int update)
|
|
|
f96e0b |
static int
|
|
|
f96e0b |
backward_char (struct screen *screen, int update)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- unsigned i;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
if (screen->column > 0)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
struct grub_unicode_glyph glyph;
|
|
|
f96e0b |
@@ -653,36 +628,16 @@ backward_char (struct screen *screen, int update)
|
|
|
f96e0b |
grub_unicode_aglomerate_comb (screen->lines[screen->line].buf + screen->column,
|
|
|
f96e0b |
screen->lines[screen->line].len - screen->column,
|
|
|
f96e0b |
&glyph);
|
|
|
f96e0b |
+ screen->column = grub_unicode_get_comb_start (linep->buf,
|
|
|
f96e0b |
+ linep->buf + screen->column)
|
|
|
f96e0b |
+ - linep->buf;
|
|
|
f96e0b |
|
|
|
f96e0b |
- for (i = 0; i < screen->nterms; i++)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- grub_ssize_t width;
|
|
|
f96e0b |
- width = grub_term_getcharwidth (screen->terms[i].term, &glyph);
|
|
|
f96e0b |
- screen->terms[i].x -= width;
|
|
|
f96e0b |
- if (screen->terms[i].x < 0)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- screen->terms[i].x
|
|
|
f96e0b |
- = grub_term_entry_width (screen->terms[i].term) - 1;
|
|
|
f96e0b |
- screen->terms[i].y--;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
grub_free (glyph.combining);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
else if (screen->line > 0)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- struct line *linep;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- screen->column = 0;
|
|
|
f96e0b |
screen->line--;
|
|
|
f96e0b |
- linep = screen->lines + screen->line;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- for (i = 0; i < screen->nterms; i++)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- screen->terms[i].y_line_start -= get_logical_num_lines (linep, &screen->terms[i]);
|
|
|
f96e0b |
- screen->terms[i].y = screen->terms[i].y_line_start;
|
|
|
f96e0b |
- screen->terms[i].x = 0;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
- advance_to (screen, screen->lines[screen->line].len);
|
|
|
f96e0b |
+ screen->column = screen->lines[screen->line].len;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
screen->real_column = screen->column;
|
|
|
f96e0b |
@@ -696,8 +651,6 @@ backward_char (struct screen *screen, int update)
|
|
|
f96e0b |
static int
|
|
|
f96e0b |
previous_line (struct screen *screen, int update)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- unsigned i;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
if (screen->line > 0)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
struct line *linep;
|
|
|
f96e0b |
@@ -712,22 +665,10 @@ previous_line (struct screen *screen, int update)
|
|
|
f96e0b |
col = screen->real_column;
|
|
|
f96e0b |
|
|
|
f96e0b |
screen->column = 0;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- for (i = 0; i < screen->nterms; i++)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- screen->terms[i].y_line_start -= get_logical_num_lines (linep, &screen->terms[i]);
|
|
|
f96e0b |
- screen->terms[i].y = screen->terms[i].y_line_start;
|
|
|
f96e0b |
- screen->terms[i].x = 0;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
advance_to (screen, col);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
else
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- for (i = 0; i < screen->nterms; i++)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- screen->terms[i].y = screen->terms[i].y_line_start;
|
|
|
f96e0b |
- screen->terms[i].x = 0;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
screen->column = 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -740,8 +681,6 @@ previous_line (struct screen *screen, int update)
|
|
|
f96e0b |
static int
|
|
|
f96e0b |
next_line (struct screen *screen, int update)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- unsigned i;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
if (screen->line < screen->num_lines - 1)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
struct line *linep;
|
|
|
f96e0b |
@@ -758,12 +697,6 @@ next_line (struct screen *screen, int update)
|
|
|
f96e0b |
c = screen->real_column;
|
|
|
f96e0b |
screen->column = 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
- for (i = 0; i < screen->nterms; i++)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- screen->terms[i].y_line_start += get_logical_num_lines (linep, &screen->terms[i]);
|
|
|
f96e0b |
- screen->terms[i].x = 0;
|
|
|
f96e0b |
- screen->terms[i].y = screen->terms[i].y_line_start;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
advance_to (screen, c);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
else
|
|
|
f96e0b |
@@ -778,14 +711,7 @@ next_line (struct screen *screen, int update)
|
|
|
f96e0b |
static int
|
|
|
f96e0b |
beginning_of_line (struct screen *screen, int update)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- unsigned i;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
screen->column = screen->real_column = 0;
|
|
|
f96e0b |
- for (i = 0; i < screen->nterms; i++)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- screen->terms[i].x = 0;
|
|
|
f96e0b |
- screen->terms[i].y = screen->terms[i].y_line_start;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
|
|
|
f96e0b |
if (update)
|
|
|
f96e0b |
update_screen_all (screen, screen->num_lines, 0, 0, 0, NO_LINE);
|
|
|
f96e0b |
@@ -826,6 +752,11 @@ delete_char (struct screen *screen, int update)
|
|
|
f96e0b |
* sizeof (linep->buf[0]));
|
|
|
f96e0b |
linep->len--;
|
|
|
f96e0b |
|
|
|
f96e0b |
+ for (i = 0; i < screen->nterms; i++)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_free (linep->pos[i]);
|
|
|
f96e0b |
+ linep->pos[i] = 0;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
start = screen->line;
|
|
|
f96e0b |
column = screen->column;
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -848,6 +779,7 @@ delete_char (struct screen *screen, int update)
|
|
|
f96e0b |
else if (screen->num_lines > screen->line + 1)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
struct line *next_linep;
|
|
|
f96e0b |
+ unsigned i;
|
|
|
f96e0b |
|
|
|
f96e0b |
next_linep = linep + 1;
|
|
|
f96e0b |
if (! ensure_space (linep, next_linep->len))
|
|
|
f96e0b |
@@ -856,6 +788,11 @@ delete_char (struct screen *screen, int update)
|
|
|
f96e0b |
grub_memmove (linep->buf + linep->len, next_linep->buf,
|
|
|
f96e0b |
next_linep->len * sizeof (linep->buf[0]));
|
|
|
f96e0b |
linep->len += next_linep->len;
|
|
|
f96e0b |
+ for (i = 0; i < screen->nterms; i++)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_free (linep->pos[i]);
|
|
|
f96e0b |
+ linep->pos[i] = 0;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
|
|
|
f96e0b |
grub_free (next_linep->buf);
|
|
|
f96e0b |
grub_memmove (next_linep,
|
|
|
f96e0b |
@@ -975,24 +912,12 @@ yank (struct screen *screen, int update)
|
|
|
f96e0b |
static int
|
|
|
f96e0b |
open_line (struct screen *screen, int update)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- int saved_y[screen->nterms];
|
|
|
f96e0b |
- unsigned i;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- for (i = 0; i < screen->nterms; i++)
|
|
|
f96e0b |
- saved_y[i] = screen->terms[i].y;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
if (! insert_string (screen, "\n", 0))
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
if (! backward_char (screen, 0))
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
- for (i = 0; i < screen->nterms; i++)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- screen->terms[i].y = saved_y[i];
|
|
|
f96e0b |
- screen->terms[i].y_line_start = screen->terms[i].y;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
-
|
|
|
f96e0b |
if (update)
|
|
|
f96e0b |
update_screen_all (screen, screen->line, screen->column, 0, 1, ALL_LINES);
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -1303,7 +1228,20 @@ grub_menu_entry_run (grub_menu_entry_t entry)
|
|
|
f96e0b |
screen->nterms = 0;
|
|
|
f96e0b |
FOR_ACTIVE_TERM_OUTPUTS(term)
|
|
|
f96e0b |
screen->nterms++;
|
|
|
f96e0b |
- screen->terms = grub_malloc (screen->nterms * sizeof (screen->terms[0]));
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ for (i = 0; i < (unsigned) screen->num_lines; i++)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_free (screen->lines[i].pos);
|
|
|
f96e0b |
+ screen->lines[i].pos = grub_zalloc (screen->nterms * sizeof (screen->lines[i].pos[0]));
|
|
|
f96e0b |
+ if (! screen->lines[i].pos)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_print_error ();
|
|
|
f96e0b |
+ grub_errno = GRUB_ERR_NONE;
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ screen->terms = grub_zalloc (screen->nterms * sizeof (screen->terms[0]));
|
|
|
f96e0b |
if (!screen->terms)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
grub_print_error ();
|
|
|
f96e0b |
@@ -1314,9 +1252,7 @@ grub_menu_entry_run (grub_menu_entry_t entry)
|
|
|
f96e0b |
FOR_ACTIVE_TERM_OUTPUTS(term)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
screen->terms[i].term = term;
|
|
|
f96e0b |
- screen->terms[i].x = 0;
|
|
|
f96e0b |
- screen->terms[i].y = 0;
|
|
|
f96e0b |
- screen->terms[i].y_line_start = screen->terms[i].y;
|
|
|
f96e0b |
+ screen->terms[i].y_line_start = 0;
|
|
|
f96e0b |
i++;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
/* Draw the screen. */
|
|
|
f96e0b |
diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c
|
|
|
f96e0b |
index dc5fdcb..43622be 100644
|
|
|
f96e0b |
--- a/grub-core/normal/term.c
|
|
|
f96e0b |
+++ b/grub-core/normal/term.c
|
|
|
f96e0b |
@@ -34,6 +34,10 @@ struct term_state
|
|
|
f96e0b |
int backlog_fixed_tab;
|
|
|
f96e0b |
grub_size_t backlog_len;
|
|
|
f96e0b |
|
|
|
f96e0b |
+ int bidi_stack_depth;
|
|
|
f96e0b |
+ grub_uint8_t bidi_stack[GRUB_BIDI_MAX_EXPLICIT_LEVEL];
|
|
|
f96e0b |
+ int invalid_pushes;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
void *free;
|
|
|
f96e0b |
int num_lines;
|
|
|
f96e0b |
char *term_name;
|
|
|
f96e0b |
@@ -44,7 +48,9 @@ print_ucs4_real (const grub_uint32_t * str,
|
|
|
f96e0b |
const grub_uint32_t * last_position,
|
|
|
f96e0b |
int margin_left, int margin_right,
|
|
|
f96e0b |
struct grub_term_output *term, int backlog,
|
|
|
f96e0b |
- int dry_run, int fixed_tab);
|
|
|
f96e0b |
+ int dry_run, int fixed_tab, unsigned skip_lines,
|
|
|
f96e0b |
+ unsigned max_lines,
|
|
|
f96e0b |
+ grub_uint32_t contchar, struct grub_term_pos *pos);
|
|
|
f96e0b |
|
|
|
f96e0b |
static struct term_state *term_states = NULL;
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -243,7 +249,8 @@ grub_puts_terminal (const char *str, struct grub_term_output *term)
|
|
|
f96e0b |
return;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
- print_ucs4_real (unicode_str, unicode_last_position, 0, 0, term, 0, 0, 0);
|
|
|
f96e0b |
+ print_ucs4_real (unicode_str, unicode_last_position, 0, 0, term,
|
|
|
f96e0b |
+ 0, 0, 0, 0, -1, 0, 0);
|
|
|
f96e0b |
grub_free (unicode_str);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -541,13 +548,25 @@ get_startwidth (struct grub_term_output *term,
|
|
|
f96e0b |
return ((term->getxy (term) >> 8) & 0xff) - margin_left;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
+static void
|
|
|
f96e0b |
+fill_margin (struct grub_term_output *term, int r)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ int sp = (term->getwh (term) >> 8)
|
|
|
f96e0b |
+ - (term->getxy (term) >> 8) - r;
|
|
|
f96e0b |
+ if (sp > 0)
|
|
|
f96e0b |
+ grub_print_spaces (term, sp);
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
+
|
|
|
f96e0b |
static int
|
|
|
f96e0b |
print_ucs4_terminal (const grub_uint32_t * str,
|
|
|
f96e0b |
const grub_uint32_t * last_position,
|
|
|
f96e0b |
int margin_left, int margin_right,
|
|
|
f96e0b |
struct grub_term_output *term,
|
|
|
f96e0b |
struct term_state *state,
|
|
|
f96e0b |
- int dry_run, int fixed_tab)
|
|
|
f96e0b |
+ int dry_run, int fixed_tab, unsigned skip_lines,
|
|
|
f96e0b |
+ unsigned max_lines,
|
|
|
f96e0b |
+ grub_uint32_t contchar,
|
|
|
f96e0b |
+ int primitive_wrap, struct grub_term_pos *pos)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
const grub_uint32_t *ptr;
|
|
|
f96e0b |
grub_ssize_t startwidth = dry_run ? 0 : get_startwidth (term, margin_left);
|
|
|
f96e0b |
@@ -556,10 +575,40 @@ print_ucs4_terminal (const grub_uint32_t * str,
|
|
|
f96e0b |
grub_ssize_t max_width = get_maxwidth (term, margin_left, margin_right);
|
|
|
f96e0b |
const grub_uint32_t *line_start = str, *last_space = str - 1;
|
|
|
f96e0b |
int lines = 0;
|
|
|
f96e0b |
+ int i;
|
|
|
f96e0b |
+ struct term_state local_state;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (!state)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_memset (&local_state, 0, sizeof (local_state));
|
|
|
f96e0b |
+ state = &local_state;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ for (i = 0; i < state->bidi_stack_depth; i++)
|
|
|
f96e0b |
+ putcode_real (state->bidi_stack[i] | (GRUB_UNICODE_LRE & ~0xff),
|
|
|
f96e0b |
+ term, fixed_tab);
|
|
|
f96e0b |
|
|
|
f96e0b |
for (ptr = str; ptr < last_position; ptr++)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
grub_ssize_t last_width = 0;
|
|
|
f96e0b |
+ switch (*ptr)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ case GRUB_UNICODE_LRE:
|
|
|
f96e0b |
+ case GRUB_UNICODE_RLE:
|
|
|
f96e0b |
+ case GRUB_UNICODE_LRO:
|
|
|
f96e0b |
+ case GRUB_UNICODE_RLO:
|
|
|
f96e0b |
+ if (state->bidi_stack_depth >= (int) ARRAY_SIZE (state->bidi_stack))
|
|
|
f96e0b |
+ state->invalid_pushes++;
|
|
|
f96e0b |
+ else
|
|
|
f96e0b |
+ state->bidi_stack[state->bidi_stack_depth++] = *ptr;
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
+ case GRUB_UNICODE_PDF:
|
|
|
f96e0b |
+ if (state->invalid_pushes)
|
|
|
f96e0b |
+ state->invalid_pushes--;
|
|
|
f96e0b |
+ else if (state->bidi_stack_depth)
|
|
|
f96e0b |
+ state->bidi_stack_depth--;
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
if (grub_unicode_get_comb_type (*ptr) == GRUB_UNICODE_COMB_NONE)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
struct grub_unicode_glyph c = {
|
|
|
f96e0b |
@@ -569,10 +618,16 @@ print_ucs4_terminal (const grub_uint32_t * str,
|
|
|
f96e0b |
.combining = 0
|
|
|
f96e0b |
};
|
|
|
f96e0b |
c.base = *ptr;
|
|
|
f96e0b |
+ if (pos)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ pos[ptr - str].x = line_width;
|
|
|
f96e0b |
+ pos[ptr - str].y = lines;
|
|
|
f96e0b |
+ pos[ptr - str].valid = 1;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
line_width += last_width = grub_term_getcharwidth (term, &c);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (*ptr == ' ')
|
|
|
f96e0b |
+ if (*ptr == ' ' && !primitive_wrap)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
lastspacewidth = line_width;
|
|
|
f96e0b |
last_space = ptr;
|
|
|
f96e0b |
@@ -581,6 +636,13 @@ print_ucs4_terminal (const grub_uint32_t * str,
|
|
|
f96e0b |
if (line_width > max_width || *ptr == '\n')
|
|
|
f96e0b |
{
|
|
|
f96e0b |
const grub_uint32_t *ptr2;
|
|
|
f96e0b |
+ int wasn = (*ptr == '\n');
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (wasn)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ state->bidi_stack_depth = 0;
|
|
|
f96e0b |
+ state->invalid_pushes = 0;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
|
|
|
f96e0b |
if (line_width > max_width && last_space > line_start)
|
|
|
f96e0b |
ptr = last_space;
|
|
|
f96e0b |
@@ -595,7 +657,7 @@ print_ucs4_terminal (const grub_uint32_t * str,
|
|
|
f96e0b |
|
|
|
f96e0b |
lines++;
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (!dry_run)
|
|
|
f96e0b |
+ if (!skip_lines && !dry_run)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
for (ptr2 = line_start; ptr2 < ptr; ptr2++)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
@@ -608,9 +670,12 @@ print_ucs4_terminal (const grub_uint32_t * str,
|
|
|
f96e0b |
putcode_real (*ptr2, term, fixed_tab);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
- grub_print_spaces (term, margin_right);
|
|
|
f96e0b |
+ if (!wasn && contchar)
|
|
|
f96e0b |
+ putcode_real (contchar, term, fixed_tab);
|
|
|
f96e0b |
+ fill_margin (term, contchar ? margin_right : 1);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
grub_putcode ('\n', term);
|
|
|
f96e0b |
- if (state && ++state->num_lines
|
|
|
f96e0b |
+ if (state != &local_state && ++state->num_lines
|
|
|
f96e0b |
>= (grub_ssize_t) grub_term_height (term) - 2)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
state->backlog_ucs4 = (ptr == last_space || *ptr == '\n')
|
|
|
f96e0b |
@@ -622,17 +687,42 @@ print_ucs4_terminal (const grub_uint32_t * str,
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
line_width -= lastspacewidth;
|
|
|
f96e0b |
- if (!dry_run)
|
|
|
f96e0b |
- grub_print_spaces (term, margin_left);
|
|
|
f96e0b |
if (ptr == last_space || *ptr == '\n')
|
|
|
f96e0b |
ptr++;
|
|
|
f96e0b |
line_start = ptr;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (skip_lines)
|
|
|
f96e0b |
+ skip_lines--;
|
|
|
f96e0b |
+ else if (max_lines != (unsigned) -1)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ max_lines--;
|
|
|
f96e0b |
+ if (!max_lines)
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+ if (!skip_lines && !dry_run)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ if (!contchar)
|
|
|
f96e0b |
+ grub_print_spaces (term, margin_left);
|
|
|
f96e0b |
+ else
|
|
|
f96e0b |
+ grub_term_gotoxy (term, margin_left,
|
|
|
f96e0b |
+ grub_term_getxy (term) & 0xff);
|
|
|
f96e0b |
+ for (i = 0; i < state->bidi_stack_depth; i++)
|
|
|
f96e0b |
+ putcode_real (state->bidi_stack[i] | (GRUB_UNICODE_LRE & ~0xff),
|
|
|
f96e0b |
+ term, fixed_tab);
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
}
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
+ if (pos)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ pos[ptr - str].x = line_width;
|
|
|
f96e0b |
+ pos[ptr - str].y = lines;
|
|
|
f96e0b |
+ pos[ptr - str].valid = 1;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+
|
|
|
f96e0b |
if (line_start < last_position)
|
|
|
f96e0b |
lines++;
|
|
|
f96e0b |
- if (!dry_run)
|
|
|
f96e0b |
+ if (!dry_run && !skip_lines && max_lines)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
const grub_uint32_t *ptr2;
|
|
|
f96e0b |
for (ptr2 = line_start; ptr2 < last_position; ptr2++)
|
|
|
f96e0b |
@@ -717,7 +807,8 @@ print_backlog (struct grub_term_output *term,
|
|
|
f96e0b |
ret = print_ucs4_terminal (state->backlog_ucs4,
|
|
|
f96e0b |
state->backlog_ucs4 + state->backlog_len,
|
|
|
f96e0b |
margin_left, margin_right, term, state, 0,
|
|
|
f96e0b |
- state->backlog_fixed_tab);
|
|
|
f96e0b |
+ state->backlog_fixed_tab, 0, -1, 0, 0,
|
|
|
f96e0b |
+ 0);
|
|
|
f96e0b |
if (!ret)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
grub_free (state->free);
|
|
|
f96e0b |
@@ -753,17 +844,28 @@ print_ucs4_real (const grub_uint32_t * str,
|
|
|
f96e0b |
const grub_uint32_t * last_position,
|
|
|
f96e0b |
int margin_left, int margin_right,
|
|
|
f96e0b |
struct grub_term_output *term, int backlog,
|
|
|
f96e0b |
- int dry_run, int fixed_tab)
|
|
|
f96e0b |
+ int dry_run, int fixed_tab, unsigned skip_lines,
|
|
|
f96e0b |
+ unsigned max_lines,
|
|
|
f96e0b |
+ grub_uint32_t contchar, struct grub_term_pos *pos)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
struct term_state *state = NULL;
|
|
|
f96e0b |
|
|
|
f96e0b |
if (!dry_run)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
+ int xy;
|
|
|
f96e0b |
if (backlog)
|
|
|
f96e0b |
state = find_term_state (term);
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (((term->getxy (term) >> 8) & 0xff) < margin_left)
|
|
|
f96e0b |
- grub_print_spaces (term, margin_left - ((term->getxy (term) >> 8) & 0xff));
|
|
|
f96e0b |
+ xy = term->getxy (term);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (((xy >> 8) & 0xff) < margin_left)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ if (!contchar)
|
|
|
f96e0b |
+ grub_print_spaces (term, margin_left - ((xy >> 8) & 0xff));
|
|
|
f96e0b |
+ else
|
|
|
f96e0b |
+ grub_term_gotoxy (term, margin_left,
|
|
|
f96e0b |
+ xy & 0xff);
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
if ((term->flags & GRUB_TERM_CODE_TYPE_MASK)
|
|
|
f96e0b |
@@ -773,7 +875,10 @@ print_ucs4_real (const grub_uint32_t * str,
|
|
|
f96e0b |
{
|
|
|
f96e0b |
grub_ssize_t visual_len;
|
|
|
f96e0b |
struct grub_unicode_glyph *visual;
|
|
|
f96e0b |
+ grub_ssize_t visual_len_show;
|
|
|
f96e0b |
+ struct grub_unicode_glyph *visual_show;
|
|
|
f96e0b |
int ret;
|
|
|
f96e0b |
+ struct grub_unicode_glyph *vptr;
|
|
|
f96e0b |
|
|
|
f96e0b |
auto grub_ssize_t getcharwidth (const struct grub_unicode_glyph *c);
|
|
|
f96e0b |
grub_ssize_t getcharwidth (const struct grub_unicode_glyph *c)
|
|
|
f96e0b |
@@ -787,27 +892,45 @@ print_ucs4_real (const grub_uint32_t * str,
|
|
|
f96e0b |
margin_left,
|
|
|
f96e0b |
margin_right),
|
|
|
f96e0b |
get_startwidth (term,
|
|
|
f96e0b |
- margin_left));
|
|
|
f96e0b |
+ margin_left),
|
|
|
f96e0b |
+ contchar, pos, !!contchar);
|
|
|
f96e0b |
if (visual_len < 0)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
grub_print_error ();
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
+ visual_show = visual;
|
|
|
f96e0b |
+ for (; skip_lines && visual_show < visual + visual_len; visual_show++)
|
|
|
f96e0b |
+ if (visual_show->base == '\n')
|
|
|
f96e0b |
+ skip_lines--;
|
|
|
f96e0b |
+ if (max_lines != (unsigned) -1)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ for (vptr = visual_show;
|
|
|
f96e0b |
+ max_lines && vptr < visual + visual_len; vptr++)
|
|
|
f96e0b |
+ if (visual_show->base == '\n')
|
|
|
f96e0b |
+ max_lines--;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ visual_len_show = vptr - visual_show;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+ else
|
|
|
f96e0b |
+ visual_len_show = visual + visual_len - visual_show;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
if (dry_run)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- struct grub_unicode_glyph *vptr;
|
|
|
f96e0b |
ret = 0;
|
|
|
f96e0b |
- for (vptr = visual; vptr < visual + visual_len; vptr++)
|
|
|
f96e0b |
+ for (vptr = visual_show; vptr < visual_show + visual_len_show; vptr++)
|
|
|
f96e0b |
if (vptr->base == '\n')
|
|
|
f96e0b |
ret++;
|
|
|
f96e0b |
- if (visual_len && visual[visual_len - 1].base != '\n')
|
|
|
f96e0b |
+ if (visual_len_show && visual[visual_len_show - 1].base != '\n')
|
|
|
f96e0b |
ret++;
|
|
|
f96e0b |
grub_free (visual);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
else
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- ret = put_glyphs_terminal (visual, visual_len, margin_left,
|
|
|
f96e0b |
- margin_right, term, state, fixed_tab);
|
|
|
f96e0b |
+ ret = put_glyphs_terminal (visual_show, visual_len_show, margin_left,
|
|
|
f96e0b |
+ contchar ? margin_right : 1,
|
|
|
f96e0b |
+ term, state, fixed_tab);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
if (!ret)
|
|
|
f96e0b |
grub_free (visual);
|
|
|
f96e0b |
else
|
|
|
f96e0b |
@@ -816,7 +939,22 @@ print_ucs4_real (const grub_uint32_t * str,
|
|
|
f96e0b |
return ret;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
return print_ucs4_terminal (str, last_position, margin_left, margin_right,
|
|
|
f96e0b |
- term, state, dry_run, fixed_tab);
|
|
|
f96e0b |
+ term, state, dry_run, fixed_tab, skip_lines,
|
|
|
f96e0b |
+ max_lines, contchar, !!contchar, pos);
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+void
|
|
|
f96e0b |
+grub_print_ucs4_menu (const grub_uint32_t * str,
|
|
|
f96e0b |
+ const grub_uint32_t * last_position,
|
|
|
f96e0b |
+ int margin_left, int margin_right,
|
|
|
f96e0b |
+ struct grub_term_output *term,
|
|
|
f96e0b |
+ int skip_lines, int max_lines,
|
|
|
f96e0b |
+ grub_uint32_t contchar,
|
|
|
f96e0b |
+ struct grub_term_pos *pos)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ print_ucs4_real (str, last_position, margin_left, margin_right,
|
|
|
f96e0b |
+ term, 0, 0, 1, skip_lines, max_lines,
|
|
|
f96e0b |
+ contchar, pos);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
void
|
|
|
f96e0b |
@@ -826,7 +964,7 @@ grub_print_ucs4 (const grub_uint32_t * str,
|
|
|
f96e0b |
struct grub_term_output *term)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
print_ucs4_real (str, last_position, margin_left, margin_right,
|
|
|
f96e0b |
- term, 0, 0, 1);
|
|
|
f96e0b |
+ term, 0, 0, 1, 0, -1, 0, 0);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
int
|
|
|
f96e0b |
@@ -836,7 +974,7 @@ grub_ucs4_count_lines (const grub_uint32_t * str,
|
|
|
f96e0b |
struct grub_term_output *term)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
return print_ucs4_real (str, last_position, margin_left, margin_right,
|
|
|
f96e0b |
- term, 0, 1, 1);
|
|
|
f96e0b |
+ term, 0, 1, 1, 0, -1, 0, 0);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
void
|
|
|
f96e0b |
@@ -886,7 +1024,7 @@ grub_xputs_normal (const char *str)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
int cur;
|
|
|
f96e0b |
cur = print_ucs4_real (unicode_str, unicode_last_position, 0, 0,
|
|
|
f96e0b |
- term, grub_more, 0, 0);
|
|
|
f96e0b |
+ term, grub_more, 0, 0, 0, -1, 0, 0);
|
|
|
f96e0b |
if (cur)
|
|
|
f96e0b |
backlog = 1;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
diff --git a/include/grub/normal.h b/include/grub/normal.h
|
|
|
f96e0b |
index e88cd26..416faa4 100644
|
|
|
f96e0b |
--- a/include/grub/normal.h
|
|
|
f96e0b |
+++ b/include/grub/normal.h
|
|
|
f96e0b |
@@ -77,6 +77,14 @@ grub_print_ucs4 (const grub_uint32_t * str,
|
|
|
f96e0b |
const grub_uint32_t * last_position,
|
|
|
f96e0b |
int margin_left, int margin_right,
|
|
|
f96e0b |
struct grub_term_output *term);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+void
|
|
|
f96e0b |
+grub_print_ucs4_menu (const grub_uint32_t * str,
|
|
|
f96e0b |
+ const grub_uint32_t * last_position,
|
|
|
f96e0b |
+ int margin_left, int margin_right,
|
|
|
f96e0b |
+ struct grub_term_output *term,
|
|
|
f96e0b |
+ int skip_lines, int max_lines, grub_uint32_t contchar,
|
|
|
f96e0b |
+ struct grub_term_pos *pos);
|
|
|
f96e0b |
int
|
|
|
f96e0b |
grub_ucs4_count_lines (const grub_uint32_t * str,
|
|
|
f96e0b |
const grub_uint32_t * last_position,
|
|
|
f96e0b |
diff --git a/include/grub/term.h b/include/grub/term.h
|
|
|
f96e0b |
index bf4dcb4..39c3d5a 100644
|
|
|
f96e0b |
--- a/include/grub/term.h
|
|
|
f96e0b |
+++ b/include/grub/term.h
|
|
|
f96e0b |
@@ -104,7 +104,7 @@ grub_term_color_state;
|
|
|
f96e0b |
#define GRUB_TERM_CODE_TYPE_CP437 (1 << GRUB_TERM_CODE_TYPE_SHIFT)
|
|
|
f96e0b |
/* UTF-8 stream in logical order. Usually used for terminals
|
|
|
f96e0b |
which just forward the stream to another computer. */
|
|
|
f96e0b |
-#define GRUB_TERM_CODE_TYPE_UTF8_LOGICAL (2 << GRUB_TERM_CODE_TYPE_SHIFT)
|
|
|
f96e0b |
+#define GRUB_TERM_CODE_TYPE_UTF8_LOGICAL (2 << GRUB_TERM_CODE_TYPE_SHIFT)
|
|
|
f96e0b |
/* UTF-8 in visual order. Like UTF-8 logical but for buggy endpoints. */
|
|
|
f96e0b |
#define GRUB_TERM_CODE_TYPE_UTF8_VISUAL (3 << GRUB_TERM_CODE_TYPE_SHIFT)
|
|
|
f96e0b |
/* Glyph description in visual order. */
|
|
|
f96e0b |
@@ -344,7 +344,7 @@ static inline unsigned grub_term_height (struct grub_term_output *term)
|
|
|
f96e0b |
static inline unsigned
|
|
|
f96e0b |
grub_term_border_width (struct grub_term_output *term)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- return grub_term_width (term) - GRUB_TERM_MARGIN * 3 - GRUB_TERM_SCROLL_WIDTH;
|
|
|
f96e0b |
+ return grub_term_width (term) - GRUB_TERM_MARGIN * 2;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
/* The max column number of an entry. The last "-1" is for a
|
|
|
f96e0b |
@@ -352,7 +352,7 @@ grub_term_border_width (struct grub_term_output *term)
|
|
|
f96e0b |
static inline int
|
|
|
f96e0b |
grub_term_entry_width (struct grub_term_output *term)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- return grub_term_border_width (term) - 2 - GRUB_TERM_MARGIN * 2 - 1;
|
|
|
f96e0b |
+ return grub_term_border_width (term) - GRUB_TERM_MARGIN * 2 - 1;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
static inline grub_uint16_t
|
|
|
f96e0b |
diff --git a/include/grub/unicode.h b/include/grub/unicode.h
|
|
|
f96e0b |
index 763e25e..eb5051a 100644
|
|
|
f96e0b |
--- a/include/grub/unicode.h
|
|
|
f96e0b |
+++ b/include/grub/unicode.h
|
|
|
f96e0b |
@@ -139,6 +139,7 @@ struct grub_unicode_glyph
|
|
|
f96e0b |
grub_uint16_t variant:9;
|
|
|
f96e0b |
grub_uint8_t attributes:5;
|
|
|
f96e0b |
grub_size_t ncomb;
|
|
|
f96e0b |
+ grub_size_t orig_pos;
|
|
|
f96e0b |
struct grub_unicode_combining {
|
|
|
f96e0b |
grub_uint32_t code;
|
|
|
f96e0b |
enum grub_comb_type type;
|
|
|
f96e0b |
@@ -186,6 +187,13 @@ enum
|
|
|
f96e0b |
GRUB_UNICODE_THAANA_SUKUN = 0x07b0,
|
|
|
f96e0b |
GRUB_UNICODE_ZWNJ = 0x200c,
|
|
|
f96e0b |
GRUB_UNICODE_ZWJ = 0x200d,
|
|
|
f96e0b |
+ GRUB_UNICODE_LRM = 0x200e,
|
|
|
f96e0b |
+ GRUB_UNICODE_RLM = 0x200f,
|
|
|
f96e0b |
+ GRUB_UNICODE_LRE = 0x202a,
|
|
|
f96e0b |
+ GRUB_UNICODE_RLE = 0x202b,
|
|
|
f96e0b |
+ GRUB_UNICODE_PDF = 0x202c,
|
|
|
f96e0b |
+ GRUB_UNICODE_LRO = 0x202d,
|
|
|
f96e0b |
+ GRUB_UNICODE_RLO = 0x202e,
|
|
|
f96e0b |
GRUB_UNICODE_LEFTARROW = 0x2190,
|
|
|
f96e0b |
GRUB_UNICODE_UPARROW = 0x2191,
|
|
|
f96e0b |
GRUB_UNICODE_RIGHTARROW = 0x2192,
|
|
|
f96e0b |
@@ -222,13 +230,21 @@ extern struct grub_unicode_bidi_pair grub_unicode_bidi_pairs[];
|
|
|
f96e0b |
/* Unicode mandates an arbitrary limit. */
|
|
|
f96e0b |
#define GRUB_BIDI_MAX_EXPLICIT_LEVEL 61
|
|
|
f96e0b |
|
|
|
f96e0b |
+struct grub_term_pos
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ unsigned valid:1;
|
|
|
f96e0b |
+ unsigned x:15, y:16;
|
|
|
f96e0b |
+};
|
|
|
f96e0b |
+
|
|
|
f96e0b |
grub_ssize_t
|
|
|
f96e0b |
grub_bidi_logical_to_visual (const grub_uint32_t *logical,
|
|
|
f96e0b |
grub_size_t logical_len,
|
|
|
f96e0b |
struct grub_unicode_glyph **visual_out,
|
|
|
f96e0b |
grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual),
|
|
|
f96e0b |
grub_size_t max_width,
|
|
|
f96e0b |
- grub_size_t start_width);
|
|
|
f96e0b |
+ grub_size_t start_width, grub_uint32_t codechar,
|
|
|
f96e0b |
+ struct grub_term_pos *pos,
|
|
|
f96e0b |
+ int primitive_wrap);
|
|
|
f96e0b |
|
|
|
f96e0b |
enum grub_comb_type
|
|
|
f96e0b |
grub_unicode_get_comb_type (grub_uint32_t c);
|
|
|
f96e0b |
@@ -275,4 +291,8 @@ grub_unicode_mirror_code (grub_uint32_t in);
|
|
|
f96e0b |
grub_uint32_t
|
|
|
f96e0b |
grub_unicode_shape_code (grub_uint32_t in, grub_uint8_t attr);
|
|
|
f96e0b |
|
|
|
f96e0b |
+const grub_uint32_t *
|
|
|
f96e0b |
+grub_unicode_get_comb_end (const grub_uint32_t *end,
|
|
|
f96e0b |
+ const grub_uint32_t *cur);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
#endif
|
|
|
f96e0b |
--
|
|
|
f96e0b |
1.8.2.1
|
|
|
f96e0b |
|