Bram Moolenaar wrote:
> Yukihiro Nakadaira wrote:
>
>> Bram Moolenaar wrote:
>>> Patch 7.2.119
>>> Problem: Status line is redrawn too often.
>>> Solution: Check ScreeenLinesUC[] properly. (Yukihiro Nakadaira)
>>> Files: src/screen.c
>> Sorry, one more patch related to this.
>>
>> When bold character is overwritten, all of rest characters are redrawn.
>>
>> See following code in the screen_puts_len() function. At line 6402
>> "attr + 1" is assigned to next cell. And "n > HL_ALL" is always true
>> when syntax highlighting is used. So once character is drawn, all of
>> rest characters are redrawn.
>>
>> Please check attached patch.
>
> So, this patch avoids drawing more than needed, when there is a bold
> character and following characters have some highlighting attribute?
> I wonder how one can be 100% sure that the redraw isn't needed.
>
> This code has already been changed mutiple times to fix problems.
> We should try to take it towards a more reliable, and thus easier to
> understand implementation.
>
> Your other message didn't have an attachment...
I'm sorry. File is attached.
Actually, I didn't have serious problem with current code.
So perhaps it would be better to keep the current code...
--
Yukihiro Nakadaira - [email protected]
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Index: src/screen.c
===================================================================
RCS file: /cvsroot/vim/vim7/src/screen.c,v
retrieving revision 1.113
diff -u -r1.113 screen.c
--- src/screen.c 22 Feb 2009 00:14:54 -0000 1.113
+++ src/screen.c 22 Feb 2009 18:12:40 -0000
@@ -6275,6 +6275,11 @@
int pcc[MAX_MCO];
# endif
#endif
+#if defined(FEAT_MBYTE) || defined(FEAT_GUI) || defined(UNIX)
+ int redraw_this;
+ int redraw_next = FALSE;
+#endif
+ int overwrite;
if (ScreenLines == NULL || row >= screen_Rows) /* safety check */
return;
@@ -6287,7 +6292,25 @@
&& !gui.in_use
# endif
&& mb_fix_col(col, row) != col)
- screen_puts_len((char_u *)" ", 1, row, col - 1, 0);
+ {
+ int i;
+
+ off = LineOffset[row] + col;
+ for (i = 0; i < 2; ++i)
+ {
+ ScreenLines[off - i] = ' ';
+ ScreenAttrs[off - i] = 0;
+ if (enc_utf8)
+ {
+ ScreenLinesUC[off - i] = 0;
+ ScreenLinesC[0][off - i] = 0;
+ }
+ }
+ /* redraw only previous cell */
+ screen_char(off - 1, row, col - 1);
+ /* force the first cell be redrawn */
+ redraw_next = TRUE;
+ }
#endif
off = LineOffset[row] + col;
@@ -6354,7 +6377,12 @@
}
#endif
- if (ScreenLines[off] != c
+#if defined(FEAT_MBYTE) || defined(FEAT_GUI) || defined(UNIX)
+ redraw_this = redraw_next;
+ redraw_next = FALSE;
+#endif
+
+ overwrite = ScreenLines[off] != c
#ifdef FEAT_MBYTE
|| (mbyte_cells == 2
&& ScreenLines[off + 1] != (enc_dbcs ? ptr[1] : 0))
@@ -6366,20 +6394,20 @@
|| screen_comp_differs(off, u8cc)))
#endif
|| ScreenAttrs[off] != attr
- || exmode_active
+ || exmode_active;
+
+ if (overwrite
+#if defined(FEAT_MBYTE) || defined(FEAT_GUI) || defined(UNIX)
+ || redraw_this
+#endif
)
{
#if defined(FEAT_GUI) || defined(UNIX)
/* The bold trick makes a single row of pixels appear in the next
* character. When a bold character is removed, the next
* character should be redrawn too. This happens for our own GUI
- * and for some xterms.
- * Force the redraw by setting the attribute to a different value
- * than "attr", the contents of ScreenLines[] may be needed by
- * mb_off2cells() further on.
- * Don't do this for the last drawn character, because the next
- * character may not be redrawn. */
- if (
+ * and for some xterms. */
+ if (overwrite && (
# ifdef FEAT_GUI
gui.in_use
# endif
@@ -6389,23 +6417,16 @@
# ifdef UNIX
term_is_xterm
# endif
+ )
)
{
int n;
n = ScreenAttrs[off];
-# ifdef FEAT_MBYTE
- if (col + mbyte_cells < screen_Columns
- && (n > HL_ALL || (n & HL_BOLD))
- && (len < 0 ? ptr[mbyte_blen] != NUL
- : ptr + mbyte_blen < text + len))
- ScreenAttrs[off + mbyte_cells] = attr + 1;
-# else
- if (col + 1 < screen_Columns
- && (n > HL_ALL || (n & HL_BOLD))
- && (len < 0 ? ptr[1] != NUL : ptr + 1 < text + len))
- ScreenLines[off + 1] = 0;
-# endif
+ if (n > HL_ALL)
+ n = syn_attr2attr(n);
+ if (n & HL_BOLD)
+ redraw_next = TRUE;
}
#endif
#ifdef FEAT_MBYTE
@@ -6492,6 +6513,17 @@
++ptr;
}
}
+#if defined(FEAT_MBYTE) || defined(FEAT_GUI) || defined(UNIX)
+ if (redraw_next && col < screen_Columns)
+ {
+# if defined(FEAT_MBYTE)
+ if (enc_dbcs != 0 && dbcs_off2cells(off, max_off) > 1)
+ screen_char_2(off, row, col);
+ else
+# endif
+ screen_char(off, row, col);
+ }
+#endif
}
#ifdef FEAT_SEARCH_EXTRA