Tyru wrote:

> I have implemented wcwidth() function.
> Based commit was 7.2.444.
> 
> It is useful to get width of character,
> for e.g., when creating plugin which needs to
> align text not to exceed &columns,
> or which needs to concern character width like tetris game :)
> 
> I'm new to hack Vim source.
> So please tell me if I did it wrongly.

I can see it is a useful function.

The implementation isn't quite right, the input conversion should not be
part of the function that counts the cells.

I notice that this loop appears in multiple places, let's make a new
function mb_string2cells() for this.

The name wcwith() is a bit obscure.  How about strlencells()?
Or strwidth()?

We should also have a strchars() to count the number of characters.
Might as well add that now.

-- 
DENNIS:  Listen -- strange women lying in ponds distributing swords is no
         basis for a system of government.  Supreme executive power derives
         from a mandate from the masses, not from some farcical aquatic
         ceremony.
                                  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui