Hi vim_dev,
I recently noticed the following inconsistency regarding the 'fillchars' and
'statusline options:
- multi-byte 'fillchars' work with default 'statusline':
vim -u NONE -c "set ls=2 fcs=stl:●"
[No Name] [+]●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
- single-byte 'fillchars' work with custom 'statusline':
vim -u NONE -c "set ls=2 fcs=stl:x stl=a%=b"
axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxb
- multi-byte 'fillchars' with custom 'statusline' fall back to '-':
vim -u NONE -c "set ls=2 fcs=stl:● stl=a%=b"
a---------------------------------------------b
I attached a patch that yields the following statusline for the last invocation:
a●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●b
This is my first vim contribution. Some questions I asked myself in the process:
1. Is it ok to introduce a local variable here or should it be inlined instead?
2. Would on big #if-#else-block be preferable to those two smaller ones?
3. Should I check `has_mbyte` in the #if-#else-blocks?
Thank you,
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
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff -r bd242921603e src/buffer.c
--- a/src/buffer.c Sun Jun 02 22:37:42 2013 +0200
+++ b/src/buffer.c Mon Jun 03 00:05:17 2013 +0200
@@ -3567,11 +3567,6 @@
if (fillchar == 0)
fillchar = ' ';
-#ifdef FEAT_MBYTE
- /* Can't handle a multi-byte fill character yet. */
- else if (mb_char2len(fillchar) > 1)
- fillchar = '-';
-#endif
/* Get line & check if empty (cursorpos will show "0-1"). Note that
* p will become invalid when getting another buffer line. */
@@ -4278,12 +4273,20 @@
break;
if (l < itemcnt)
{
- p = item[l].start + maxwidth - width;
+ int middlelength = maxwidth - width;
+#ifdef FEAT_MBYTE
+ middlelength *= mb_char2len(fillchar);
+#endif
+ p = item[l].start + middlelength;
STRMOVE(p, item[l].start);
- for (s = item[l].start; s < p; s++)
- *s = fillchar;
+ for (s = item[l].start; s < p;)
+#ifdef FEAT_MBYTE
+ s += (*mb_char2bytes)(fillchar, s);
+#else
+ *s++ = fillchar;
+#endif
for (l++; l < itemcnt; l++)
- item[l].start += maxwidth - width;
+ item[l].start += middlelength;
width = maxwidth;
}
}