grub2/0271-grub-core-normal-term.c-Few-more-fixes-for-menu-entr.patch
Peter Jones f74b50e380 Rebase to upstream, fix a pile of bugs. The usual.
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-06-12 15:37:08 -04:00

123 lines
3.9 KiB
Diff

From 6a5471c23274d40eec0226793a1dd09fd0a16b5b Mon Sep 17 00:00:00 2001
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Date: Mon, 8 Apr 2013 14:35:26 +0200
Subject: [PATCH 271/482] * grub-core/normal/term.c: Few more fixes for
menu entry editor rendering. Reported by: Andrey Borzenkov
<arvidjaar@gmail.com>
---
ChangeLog | 6 ++++++
grub-core/normal/menu_entry.c | 11 ++++++++++-
grub-core/normal/term.c | 13 ++++++++++---
include/grub/term.h | 8 --------
4 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8b90e7a..0c97d42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-04-08 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/normal/term.c: Few more fixes for menu entry editor
+ rendering.
+ Reported by: Andrey Borzenkov <arvidjaar@gmail.com>
+
2013-04-07 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/normal/term.c: Few more fixes for menu entry editor
diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c
index 80f9464..e0407aa 100644
--- a/grub-core/normal/menu_entry.c
+++ b/grub-core/normal/menu_entry.c
@@ -118,6 +118,15 @@ ensure_space (struct line *linep, int extra)
return 1;
}
+/* The max column number of an entry. The last "-1" is for a
+ continuation marker. */
+static inline int
+grub_term_entry_width (struct grub_term_output *term)
+{
+ return grub_term_border_width (term) - GRUB_TERM_MARGIN * 2 - 2;
+}
+
+
/* Return the number of lines occupied by this line on the screen. */
static int
get_logical_num_lines (struct line *linep, struct per_term_screen *term_screen)
@@ -150,7 +159,7 @@ print_empty_line (int y, struct per_term_screen *term_screen)
GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN + 1,
y + GRUB_TERM_FIRST_ENTRY_Y);
- for (i = 0; i < grub_term_entry_width (term_screen->term); i++)
+ for (i = 0; i < grub_term_entry_width (term_screen->term) + 1; i++)
grub_putcode (' ', term_screen->term);
}
diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c
index d73d29c..f9620f6 100644
--- a/grub-core/normal/term.c
+++ b/grub-core/normal/term.c
@@ -787,13 +787,17 @@ put_glyphs_terminal (const struct grub_unicode_glyph *visual,
grub_uint32_t contchar)
{
const struct grub_unicode_glyph *visual_ptr;
+ int since_last_nl = 1;
for (visual_ptr = visual; visual_ptr < visual + visual_len; visual_ptr++)
{
- if (visual_ptr->base == '\n')
- grub_print_spaces (term, margin_right);
+ if (visual_ptr->base == '\n' && contchar)
+ fill_margin (term, margin_right);
+
putglyph (visual_ptr, term, fixed_tab);
+ since_last_nl++;
if (visual_ptr->base == '\n')
{
+ since_last_nl = 0;
if (state && ++state->num_lines
>= (grub_ssize_t) grub_term_height (term) - 2)
{
@@ -811,6 +815,9 @@ put_glyphs_terminal (const struct grub_unicode_glyph *visual,
}
grub_free (visual_ptr->combining);
}
+ if (contchar && since_last_nl)
+ fill_margin (term, margin_right);
+
return 0;
}
@@ -950,7 +957,7 @@ print_ucs4_real (const grub_uint32_t * str,
else
{
ret = put_glyphs_terminal (visual_show, visual_len_show, margin_left,
- contchar ? 0 : margin_right,
+ margin_right,
term, state, fixed_tab, contchar);
if (!ret)
diff --git a/include/grub/term.h b/include/grub/term.h
index 655a5e3..565d14f 100644
--- a/include/grub/term.h
+++ b/include/grub/term.h
@@ -347,14 +347,6 @@ grub_term_border_width (struct grub_term_output *term)
return grub_term_width (term) - GRUB_TERM_MARGIN * 2;
}
-/* The max column number of an entry. The last "-1" is for a
- continuation marker. */
-static inline int
-grub_term_entry_width (struct grub_term_output *term)
-{
- return grub_term_border_width (term) - GRUB_TERM_MARGIN * 2 - 1;
-}
-
static inline grub_uint16_t
grub_term_getxy (struct grub_term_output *term)
{
--
1.8.2.1