On Tue, February 1, 2011 2:14 pm, Bram Moolenaar wrote:
> Christian Brabandt wrote:
>> Here is a patch, that adds nbsp support to :list command. I leave out
>> conceal, as I don't think this makes sense here:
> That only works when 'enc' is a multi-byte encoding. It should also
> work for latin1.
>
Upps forgotten. I somehow thought, this is only relevant for multibyte
encodings. Here is an updated patch.
> Please insert spaces around "=".
Done.
> You don't actually need the "ll" variable.
I don't? But I need the width of the lcs_nbsp char for the output buffer
and the width of the non-breaking char in the line to advance the pointer
in the line.
regards,
Christian
--
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
diff --git a/src/message.c b/src/message.c
--- a/src/message.c
+++ b/src/message.c
@@ -1637,8 +1637,18 @@
else if (has_mbyte && (l = (*mb_ptr2len)(s)) > 1)
{
col += (*mb_ptr2cells)(s);
- mch_memmove(buf, s, (size_t)l);
- buf[l] = NUL;
+ if (mb_ptr2char(s) == 160 && list && lcs_nbsp != NUL)
+ {
+ int ll = 0;
+ mb_char2bytes(lcs_nbsp, buf);
+ ll = (*mb_ptr2len)(buf);
+ buf[ll] = NUL;
+ }
+ else
+ {
+ mch_memmove(buf, s, (size_t)l);
+ buf[l] = NUL;
+ }
msg_puts(buf);
s += l;
continue;
@@ -1664,6 +1674,11 @@
attr = hl_attr(HLF_8);
}
}
+ else if (c == 160 && list && lcs_nbsp != NUL)
+ {
+ c = lcs_nbsp;
+ attr = hl_attr(HLF_8);
+ }
else if (c == NUL && list && lcs_eol != NUL)
{
p_extra = (char_u *)"";