Blame SOURCES/0247-Fix-screen-corruption-in-menu-entry-editor-and-simpl.patch

f96e0b
From f51e0c966f51523abcc5856a5667537d1dcf62ca Mon Sep 17 00:00:00 2001
f96e0b
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
f96e0b
Date: Wed, 3 Apr 2013 15:19:34 +0200
f96e0b
Subject: [PATCH 247/482] 	Fix screen corruption in menu entry editor and
f96e0b
 simplify the code 	flow while on it.
f96e0b
f96e0b
---
f96e0b
 ChangeLog                     |  5 +++++
f96e0b
 grub-core/normal/menu_entry.c | 35 +++++------------------------------
f96e0b
 grub-core/normal/term.c       | 15 ++++++++++++++-
f96e0b
 3 files changed, 24 insertions(+), 31 deletions(-)
f96e0b
f96e0b
diff --git a/ChangeLog b/ChangeLog
f96e0b
index 7cda161..0592cac 100644
f96e0b
--- a/ChangeLog
f96e0b
+++ b/ChangeLog
f96e0b
@@ -1,3 +1,8 @@
f96e0b
+2013-04-03  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
+
f96e0b
+	Fix screen corruption in menu entry editor and simplify the code
f96e0b
+	flow while on it.
f96e0b
+
f96e0b
 2013-04-03  Andrey Borzenkov <arvidjaar@gmail.com>
f96e0b
 
f96e0b
 	* util/grub-mount.c (fuse_init): Return error if fuse_main
f96e0b
diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c
f96e0b
index f4c8afd..80f9464 100644
f96e0b
--- a/grub-core/normal/menu_entry.c
f96e0b
+++ b/grub-core/normal/menu_entry.c
f96e0b
@@ -253,49 +253,24 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen,
f96e0b
 	  if (!*pos)
f96e0b
 	    *pos = grub_zalloc ((linep->len + 1) * sizeof (**pos));
f96e0b
 
f96e0b
-	  if (i == region_start || linep == screen->lines + screen->line)
f96e0b
+	  if (i == region_start || linep == screen->lines + screen->line
f96e0b
+	      || (i > region_start && mode == ALL_LINES))
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
-	      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
+
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 + 1,
f96e0b
 				    GRUB_TERM_MARGIN
f96e0b
-				    + GRUB_TERM_SCROLL_WIDTH + 2,
f96e0b
+				    + GRUB_TERM_SCROLL_WIDTH,
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
 	  y += get_logical_num_lines (linep, term_screen);
f96e0b
 	  if (y >= term_screen->num_entries)
f96e0b
diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c
f96e0b
index 32deba3..f05184b 100644
f96e0b
--- a/grub-core/normal/term.c
f96e0b
+++ b/grub-core/normal/term.c
f96e0b
@@ -690,6 +690,13 @@ print_ucs4_terminal (const grub_uint32_t * str,
f96e0b
 	  line_width -= lastspacewidth;
f96e0b
 	  if (ptr == last_space || *ptr == '\n')
f96e0b
 	    ptr++;
f96e0b
+	  else if (pos)
f96e0b
+	      {
f96e0b
+		pos[ptr - str].x = line_width - last_width;
f96e0b
+		pos[ptr - str].y = lines;
f96e0b
+		pos[ptr - str].valid = 1;
f96e0b
+	      }
f96e0b
+
f96e0b
 	  line_start = ptr;
f96e0b
 
f96e0b
 	  if (skip_lines)
f96e0b
@@ -726,6 +733,8 @@ print_ucs4_terminal (const grub_uint32_t * str,
f96e0b
   if (!dry_run && !skip_lines && max_lines)
f96e0b
     {
f96e0b
       const grub_uint32_t *ptr2;
f96e0b
+      int sp;
f96e0b
+
f96e0b
       for (ptr2 = line_start; ptr2 < last_position; ptr2++)
f96e0b
 	{
f96e0b
 	  /* Skip combining characters on non-UTF8 terminals.  */
f96e0b
@@ -736,6 +745,10 @@ print_ucs4_terminal (const grub_uint32_t * str,
f96e0b
 	    continue;
f96e0b
 	  putcode_real (*ptr2, term, fixed_tab);
f96e0b
 	}
f96e0b
+
f96e0b
+      sp = max_width - pos[last_position - str].x + 1;
f96e0b
+      if (sp > 0)
f96e0b
+	grub_print_spaces (term, sp);
f96e0b
     }
f96e0b
   return dry_run ? lines : 0;
f96e0b
 }
f96e0b
@@ -908,7 +921,7 @@ print_ucs4_real (const grub_uint32_t * str,
f96e0b
 	{
f96e0b
 	  for (vptr = visual_show;
f96e0b
 	       max_lines && vptr < visual + visual_len; vptr++)
f96e0b
-	    if (visual_show->base == '\n')
f96e0b
+	    if (vptr->base == '\n')
f96e0b
 	      max_lines--;
f96e0b
 
f96e0b
 	  visual_len_show = vptr - visual_show;	  
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b