fix entry editor screen screen layout corruption in trunk
PATCH 1/1 fix entry editor screen screen layout corruption in trunk
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 <[email protected]>
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.
--- grub-core/normal/menu_entry.c | 10 ---------- grub-core/normal/term.c | 29 +++++++++++++++++++++++------ 2 files changed, 23 insertions(+), 16 deletions(-)
grub-core/normal/menu_entry.c +0 -10
@@ -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)
grub-core/normal/term.c +23 -6
@@ -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);
Signature · 1 line
tg: (c235052..) u/fix-after-bidi (depends on: master)
Quoted 4 lines · Andrey Borzenkov
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.
I've fixed the same problem by much smaller logic change
Quoted 159 lines
Patch follows.
---
From: Andrey Borzenkov <[email protected]>
Subject: [PATCH] fix entry editor screen corruptionFixes 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_lineswas effectively ignored by gfxterm, so last line was printed outside of editor window, overwriting bottom border and probably beyond4. 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 toterm.c. It also makes behaviour consistent withprint_ucs4_terminalwhich did padding itself.Signed-off-by Andrey Borzenkov <[email protected]>--- grub-core/normal/menu_entry.c | 10 ---------- grub-core/normal/term.c | 29 +++++++++++++++++++++++------ 2 files changed, 23 insertions(+), 16 deletions(-)grub-core/normal/menu_entry.c +0
-10@@ -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)grub-core/normal/term.c +23
-6@@ -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);_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
В Wed, 03 Apr 2013 15:22:31 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:
Quoted 9 lines · Andrey Borzenkov
Quoted 5 lines
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.
I've fixed the same problem by much smaller logic change
Unfortunately now gfxterm case it completely broken. IIRC with my patch it worked right in both cases ...
Quoted 7 lines · Andrey Borzenkov
В Wed, 03 Apr 2013 15:22:31 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:Quoted 4 lines · Andrey Borzenkov
Quoted 3 lines
See screenshot for what I get using current trunk.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
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.
I've fixed the same problem by much smaller logic change
Unfortunately now gfxterm case it completely broken. IIRC with my patch it worked right in both cases ...
Thank you for reporting this. Fixed.
A message that is not in the archive (sent off-list or not yet received): [email protected]
В Sun, 7 Apr 2013 22:50:29 +0400
Andrey Borzenkov <[email protected]> пишет:
Quoted 22 lines
В Sun, 07 Apr 2013 17:49:09 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:Quoted 19 lines · Andrey Borzenkov
Quoted 17 lines
В Wed, 03 Apr 2013 15:22:31 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:Quoted 9 lines · Andrey Borzenkov
Quoted 5 lines
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.
I've fixed the same problem by much smaller logic change
Unfortunately now gfxterm case it completely broken. IIRC with my patch it worked right in both cases ...
Quoted 6 lines
Quoted 3 lines
Thank you for reporting this. Fixed.
Not quite. Better, but ...
Mail was rejected due to size so here link to screenshot: