grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] normal: fix get_logical_num_lines


From: Michael Chang
Subject: Re: [PATCH] normal: fix get_logical_num_lines
Date: Mon, 28 Dec 2015 12:09:58 +0800
User-agent: Mutt/1.5.21 (2010-09-15)

On Thu, Dec 24, 2015 at 02:48:34PM +0300, Andrei Borzenkov wrote:
> On Wed, Dec 23, 2015 at 7:45 AM, Michael Chang <address@hidden> wrote:
> > In menu editing mode, grub2 shows bogus line if the character being
> > edited is at last column of entry. This patch fixes the problem by
> > having the get_logical_num_lines function to calculate correct number of
> > lines.
> >
> > ---
> >  grub-core/normal/menu_entry.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c
> > index 62c7e16..1d4b0c6 100644
> > --- a/grub-core/normal/menu_entry.c
> > +++ b/grub-core/normal/menu_entry.c
> > @@ -128,7 +128,7 @@ get_logical_num_lines (struct line *linep, struct 
> > per_term_screen *term_screen)
> >  {
> >    return (grub_getstringwidth (linep->buf, linep->buf + linep->len,
> >                                term_screen->term)
> > -         / (unsigned) term_screen->geo.entry_width) + 1;
> > +         / ((unsigned) term_screen->geo.entry_width + 1)) + 1;
> 
> No, that's wrong. Consider entry_width = 10 and grub_getstringwidth =
> 21. It needs 3 lines but your change gives only 2.

Alas! Indeed I am mistaken here. We should minus the numerator by one
but not adding one to denominator. Thanks for your check. :)

> 
> It sounds like we need
> 
> string_width = grub_getstringwidth (linep->buf, linep->buf +
> linep->len, term_screen->term);
> if (!string_width)
>   return 1;
> return (string_width + (unsigned) term_screen->geo.entry_width - 1) /
> (unsigned) term_screen->geo.entry_width;
> 
> Could you test if it works for you?

Yes. It works great.

Thanks,
Michael



reply via email to

[Prev in Thread] Current Thread [Next in Thread]