grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix entry editor screen screen layout corruption in trunk
@ 2013-02-17 15:15 Andrey Borzenkov
  2013-04-03 13:22 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 5+ messages in thread
From: Andrey Borzenkov @ 2013-02-17 15:15 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 5254 bytes --]

See screenshot for what I get using current trunk.

I do not pretend to fully understand all this code so review is
appreciated. So far it does fix both gfxterm and console cases for me.

Patch follows.

---

From: Andrey Borzenkov <arvidjaar@gmail.com>
Subject: [PATCH] fix entry editor screen corruption

Fixes the following issues after rev 7137

1. right margines were erased on wrapped lines (with contibuation char)

2. left margines were erased on continuation lines

3. max_lines was effectively ignored by gfxterm, so last line was printed
outside of editor window, overwriting bottom border and probably beyond

4. menu_entry:update_screen() unconditionally padded last line with
spaces, but print_ucs4_menu() would move to next screen position if
line was wrapped. This caused bottom border to be partially overwritten
with spaces. The patch moves line padding to term.c. It also
makes behaviour consistent with print_ucs4_terminal which did padding
itself.

Signed-off-by: Andrey Borzenkov <arvidjaar@gmail.com>

---
 grub-core/normal/menu_entry.c |   10 ----------
 grub-core/normal/term.c       |   29 +++++++++++++++++++++++------
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c
index 7cd67f3..cc977b5 100644
--- a/grub-core/normal/menu_entry.c
+++ b/grub-core/normal/menu_entry.c
@@ -256,7 +256,6 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen,
 
 	  if (i == region_start || linep == screen->lines + screen->line)
 	    {
-	      int sp;
 	      grub_term_gotoxy (term_screen->term, GRUB_TERM_LEFT_BORDER_X
 				+ GRUB_TERM_MARGIN + 1, (y < 0 ? 0 : y)
 				+ GRUB_TERM_FIRST_ENTRY_Y);
@@ -271,14 +270,9 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen,
 				    term_screen->num_entries
 				    - ((y > 0) ? y : 0), '\\',
 				    *pos);
-	      sp = grub_term_entry_width (term_screen->term)
-		 - (*pos)[linep->len].x;
-	      if (sp > 0)
-		grub_print_spaces (term_screen->term, sp);
  	    }
 	  else if (i > region_start && mode == ALL_LINES)
 	    {
-	      int sp;
 	      grub_term_gotoxy (term_screen->term, GRUB_TERM_LEFT_BORDER_X
 				+ GRUB_TERM_MARGIN + 1, (y < 0 ? 0 : y)
 				+ GRUB_TERM_FIRST_ENTRY_Y);
@@ -293,10 +287,6 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen,
 				    term_screen->num_entries
 				    - ((y > 0) ? y : 0), '\\',
 				    *pos);
-	      sp = grub_term_entry_width (term_screen->term)
-		- (*pos)[linep->len].x;
-	      if (sp > 0)
-		grub_print_spaces (term_screen->term, sp);
 	    }
 	  y += get_logical_num_lines (linep, term_screen);
 	  if (y >= term_screen->num_entries)
diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c
index dc03268..0290968 100644
--- a/grub-core/normal/term.c
+++ b/grub-core/normal/term.c
@@ -736,6 +736,8 @@ print_ucs4_terminal (const grub_uint32_t * str,
 	    continue;
 	  putcode_real (*ptr2, term, fixed_tab);
 	}
+      if (contchar)
+	fill_margin (term, margin_right);
     }
   return dry_run ? lines : 0;
 }
@@ -767,13 +769,22 @@ put_glyphs_terminal (const struct grub_unicode_glyph *visual,
 		     grub_ssize_t visual_len,
 		     int margin_left, int margin_right,
 		     struct grub_term_output *term,
-		     struct term_state *state, int fixed_tab)
+		     struct term_state *state, int fixed_tab, grub_uint32_t contchar)
 {
   const struct grub_unicode_glyph *visual_ptr;
+  int wasn = 0;
+
   for (visual_ptr = visual; visual_ptr < visual + visual_len; visual_ptr++)
     {
       if (visual_ptr->base == '\n')
-	grub_print_spaces (term, margin_right);
+	{
+	  wasn = 1;
+	  if (contchar)
+	    fill_margin (term, margin_right);
+	}
+      else
+	wasn = 0;
+ 
       putglyph (visual_ptr, term, fixed_tab);
       if (visual_ptr->base == '\n')
 	{
@@ -786,10 +797,16 @@ put_glyphs_terminal (const struct grub_unicode_glyph *visual,
 	      return 1;
 	    }
 
-	  grub_print_spaces (term, margin_left);
+	  if (!contchar)
+	    grub_print_spaces (term, margin_left);
+	  else
+	    grub_term_gotoxy (term, margin_left,
+			      grub_term_getxy (term) & 0xff);
 	}
       grub_free (visual_ptr->combining);
     }
+    if (!wasn && contchar)
+      fill_margin (term, margin_right);
   return 0;
 }
 
@@ -826,7 +843,7 @@ print_backlog (struct grub_term_output *term,
       ret = put_glyphs_terminal (state->backlog_glyphs,
 				 state->backlog_len,
 				 margin_left, margin_right, term, state,
-				 state->backlog_fixed_tab);
+				 state->backlog_fixed_tab, 0);
       if (!ret)
 	{
 	  grub_free (state->free);
@@ -908,7 +925,7 @@ print_ucs4_real (const grub_uint32_t * str,
 	{
 	  for (vptr = visual_show;
 	       max_lines && vptr < visual + visual_len; vptr++)
-	    if (visual_show->base == '\n')
+	    if (vptr->base == '\n')
 	      max_lines--;
 
 	  visual_len_show = vptr - visual_show;	  
@@ -930,7 +947,7 @@ print_ucs4_real (const grub_uint32_t * str,
 	{
 	  ret = put_glyphs_terminal (visual_show, visual_len_show, margin_left,
 				     contchar ? margin_right : 1,
-				     term, state, fixed_tab);
+				     term, state, fixed_tab, contchar);
 
 	  if (!ret)
 	    grub_free (visual);
-- 
tg: (c235052..) u/fix-after-bidi (depends on: master)

[-- Attachment #2: QEMU_006.png --]
[-- Type: image/png, Size: 24296 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-04-08  2:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-17 15:15 [PATCH] fix entry editor screen screen layout corruption in trunk Andrey Borzenkov
2013-04-03 13:22 ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-04-07 12:26   ` Andrey Borzenkov
2013-04-07 15:49     ` Vladimir 'φ-coder/phcoder' Serbinenko
     [not found]       ` <20130407225029.79b6795e@opensuse.site>
2013-04-08  2:42         ` Andrey Borzenkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).