]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Fix screen corruption in menu entry editor and simplify the code
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 3 Apr 2013 13:19:34 +0000 (15:19 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 3 Apr 2013 13:19:34 +0000 (15:19 +0200)
flow while on it.

ChangeLog
grub-core/normal/menu_entry.c
grub-core/normal/term.c

index 7cda161059716a9f2d9b53be13453936e036a0cc..0592caced2eb36a7c2787329d2fa9d1cce08e84c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-04-03  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Fix screen corruption in menu entry editor and simplify the code
+       flow while on it.
+
 2013-04-03  Andrey Borzenkov <arvidjaar@gmail.com>
 
        * util/grub-mount.c (fuse_init): Return error if fuse_main
index f4c8afdde31d7e4b859288ee4cba1da3eec6309b..80f9464851588005590434857031a4535c70fd90 100644 (file)
@@ -253,49 +253,24 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen,
          if (!*pos)
            *pos = grub_zalloc ((linep->len + 1) * sizeof (**pos));
 
-         if (i == region_start || linep == screen->lines + screen->line)
+         if (i == region_start || linep == screen->lines + screen->line
+             || (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);
-             grub_print_ucs4_menu (linep->buf,
-                                   linep->buf + linep->len,
-                                   GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN
-                                   + 1,
-                                   GRUB_TERM_MARGIN
-                                   + GRUB_TERM_SCROLL_WIDTH + 2,
-                                   term_screen->term,
-                                   (y < 0) ? -y : 0,
-                                   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);
+
              grub_print_ucs4_menu (linep->buf,
                                    linep->buf + linep->len,
                                    GRUB_TERM_LEFT_BORDER_X
-                           + GRUB_TERM_MARGIN + 1,
+                                   + GRUB_TERM_MARGIN + 1,
                                    GRUB_TERM_MARGIN
-                                   + GRUB_TERM_SCROLL_WIDTH + 2,
+                                   + GRUB_TERM_SCROLL_WIDTH,
                                    term_screen->term,
                                    (y < 0) ? -y : 0,
                                    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)
index 32deba37527b232969d1a9a1400d8f601eabf549..f05184b46dbee8274295ed73c884890681474645 100644 (file)
@@ -690,6 +690,13 @@ print_ucs4_terminal (const grub_uint32_t * str,
          line_width -= lastspacewidth;
          if (ptr == last_space || *ptr == '\n')
            ptr++;
+         else if (pos)
+             {
+               pos[ptr - str].x = line_width - last_width;
+               pos[ptr - str].y = lines;
+               pos[ptr - str].valid = 1;
+             }
+
          line_start = ptr;
 
          if (skip_lines)
@@ -726,6 +733,8 @@ print_ucs4_terminal (const grub_uint32_t * str,
   if (!dry_run && !skip_lines && max_lines)
     {
       const grub_uint32_t *ptr2;
+      int sp;
+
       for (ptr2 = line_start; ptr2 < last_position; ptr2++)
        {
          /* Skip combining characters on non-UTF8 terminals.  */
@@ -736,6 +745,10 @@ print_ucs4_terminal (const grub_uint32_t * str,
            continue;
          putcode_real (*ptr2, term, fixed_tab);
        }
+
+      sp = max_width - pos[last_position - str].x + 1;
+      if (sp > 0)
+       grub_print_spaces (term, sp);
     }
   return dry_run ? lines : 0;
 }
@@ -908,7 +921,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;