[PATCH] unicode: fix lineedit navigation over wide and combining characters

Denys Vlasenko vda.linux at googlemail.com
Sun May 16 18:49:18 UTC 2010


On Tuesday 11 May 2010 22:54, Tomas Heinrich wrote:
> On 05/11/2010 02:47 PM, Denys Vlasenko wrote:
> > On Wed, Apr 21, 2010 at 11:22 PM, Tomas Heinrich
> > <heinrich.tomas at gmail.com> wrote:
> >> Hi,
> >>
> >> this patch should make cursor movement (C-a, C-e, C-f, ...) over wide and
> >> combining unicode characters correct.
> >> It depends on the previous patch.
> > 
> > Please see attached.
> > 
> > 2.patch is a part which changes how cmdedit_set_out_char works.
> > It renames two badly names functions, uses "clear to end of screen"
> > to eliminate annoying problems with clearing wide chars, and such.
> > Run tested. I will apply it to git. Please review.
> > 
> > I renamed the function to put_cur_*glyph*_and_inc_cursor, not
> > put_cur_*char*_and_inc_cursor, because for combining chars,
> > it will print _more than one_ (unicode) char.
> > 
> > 3.patch is the remainder of your patch. Not reviewed yet.
> 
> The changes look good.
> I don't think that the function should work with glyphs, though.
> It is used at lineedit.c:2273 and processes a single combining char at a 
> time. Better places for handling glyphs may be in input_forward(), 
> input_delete(), input_backspace() etc, if for example the whole glyph 
> should be deleted instead of a single combining character.
> 
> I've rewritten the remainder of the patch into two parts:
> 
> p1.patch - removes the check for a null byte because the function is not 
> used this way anymore and probably shouldn't be.
> 
> p2.patch - adds changes to correctly redraw wide/combining utf-8 chars;
> moving over e.g. a base character with 10 combining chars following is 
> still a bit unintuitive, but the visualization should be correct.

Does not compile with unicode support off:

  CC      libbb/lineedit.o
cc1: warnings being treated as errors
libbb/lineedit.c: In function 'put_cur_glyph_and_inc_cursor':
libbb/lineedit.c:319: error: implicit declaration of function 'validate_wc'
libbb/lineedit.c:321: error: implicit declaration of function 'wcwidth'
make[1]: *** [libbb/lineedit.o] Error 1
make: *** [libbb] Error 2

Does not work correctly if we enter a wide char when we have just one
screen position left. Entered wide char appears on next line,
but then cursor jumps once more, creating another empty line:

|prompt: W W W W W W W W W W W W |
|W                               |
|_                               |

which is wrong, should be:

|prompt: W W W W W W W W W W W W |
|W _                             |

I fixed these things and applied the patch. However, going back
using left arrow to such not completely full line does not work
totally correctly.

-- 
vda


More information about the busybox mailing list