Ingo Karkat wrote:
> 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?!
I think the most useful is to do exactly what is used for displayed
text. I'll add a function for that.
--
I'm sure that I asked CBuilder to do a "full" install. Looks like I got
a "fool" install, instead. Charles E Campbell, Jr, PhD
/// 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