On 17-Jul-2010 20:40, 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.
Good idea, I had beforehand implemented something like this in Vimscript, and it
wasn't pretty :-)
I have only read, not tried your patch, but it looks like it doesn't account for
the (dynamic) width of the <Tab> character. You seem to be primarily motivated
by the East Asian double width use case, whereas I wanted to :echo fragments
from the buffer while not exceeding the terminal width so that no Hit-Enter
message would show up.
To be able to give correct answers for embedded <Tab> characters, the wcwidth()
function would need the start screen column of the text and the 'tabstop'
setting passed in. Calculating the amount of display cells for a given <Tab> is
then trivial, something along tabstop - (column - 1) % tabstop.
wcwidth({expr}, [{startcol}, [{tabstop}]])
{startcol} is the screen column where {expr} starts (default 1)
{tabstop} is the tabstop value, default 'tabstop'
Related: Does the function handle unprintable characters (e.g. ^F -> two cells,
<xxxx> for unprintable Unicode characters), cp. the 'isprint' setting?!
-- regards, ingo
--
-- Ingo Karkat -- /^-- /^-- /^-- /^-- /^-- /^-- http://ingo-karkat.de/ --
-- http://vim.sourceforge.net/account/profile.php?user_id=9713 --
--
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