Skip to content

Instantly share code, notes, and snippets.

@DeaR
Last active December 16, 2015 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DeaR/5467343 to your computer and use it in GitHub Desktop.
Save DeaR/5467343 to your computer and use it in GitHub Desktop.
diff -r c61da758a9a2 src/screen.c
--- a/src/screen.c Wed Apr 24 18:34:45 2013 +0200
+++ b/src/screen.c Fri May 03 16:46:51 2013 +0900
@@ -2844,7 +2844,7 @@
int syntax_flags = 0;
int syntax_seqnr = 0;
int prev_syntax_id = 0;
- int conceal_attr = hl_attr(HLF_CONCEAL);
+ int conceal_attr = 0;
int is_concealing = FALSE;
int boguscols = 0; /* nonexistent columns added to force
wrapping */
@@ -3941,12 +3941,9 @@
mb_utf8 = (c >= 0x80);
n_extra = (int)STRLEN(p_extra);
c_extra = NUL;
- if (area_attr == 0 && search_attr == 0)
- {
- n_attr = n_extra + 1;
- extra_attr = hl_attr(HLF_8);
- saved_attr2 = char_attr; /* save current attr */
- }
+ n_attr = n_extra + 1;
+ extra_attr = hl_attr(HLF_8);
+ saved_attr2 = char_attr; /* save current attr */
}
else if (mb_l == 0) /* at the NUL at end-of-line */
mb_l = 1;
@@ -4073,12 +4070,9 @@
) && lcs_nbsp)
{
c = lcs_nbsp;
- if (area_attr == 0 && search_attr == 0)
- {
- n_attr = 1;
- extra_attr = hl_attr(HLF_8);
- saved_attr2 = char_attr; /* save current attr */
- }
+ n_attr = 1;
+ extra_attr = hl_attr(HLF_8);
+ saved_attr2 = char_attr; /* save current attr */
#ifdef FEAT_MBYTE
mb_c = c;
if (enc_utf8 && (*mb_char2len)(c) > 1)
@@ -4123,15 +4117,6 @@
else
did_emsg = save_did_emsg;
- /* Need to get the line again, a multi-line regexp may
- * have made it invalid. */
- line = ml_get_buf(wp->w_buffer, lnum, FALSE);
- ptr = line + v;
-
- if (!attr_pri)
- char_attr = syntax_attr;
- else
- char_attr = hl_combine_attr(syntax_attr, char_attr);
# ifdef FEAT_CONCEAL
/* no concealing past the end of the line, it interferes
* with line highlighting */
@@ -4257,12 +4242,9 @@
if (trailcol != MAXCOL && ptr > line + trailcol && c == ' ')
{
c = lcs_trail;
- if (!attr_pri)
- {
- n_attr = 1;
- extra_attr = hl_attr(HLF_8);
- saved_attr2 = char_attr; /* save current attr */
- }
+ n_attr = 1;
+ extra_attr = hl_attr(HLF_8);
+ saved_attr2 = char_attr; /* save current attr */
#ifdef FEAT_MBYTE
mb_c = c;
if (enc_utf8 && (*mb_char2len)(c) > 1)
@@ -4386,11 +4368,8 @@
c = ' ';
lcs_eol_one = -1;
--ptr; /* put it back at the NUL */
- if (!attr_pri)
- {
- extra_attr = hl_attr(HLF_AT);
- n_attr = 1;
- }
+ extra_attr = hl_attr(HLF_AT);
+ n_attr = 1;
#ifdef FEAT_MBYTE
mb_c = c;
if (enc_utf8 && (*mb_char2len)(c) > 1)
@@ -4413,12 +4392,9 @@
n_extra = byte2cells(c) - 1;
c_extra = NUL;
c = *p_extra++;
- if (!attr_pri)
- {
- n_attr = n_extra + 1;
- extra_attr = hl_attr(HLF_8);
- saved_attr2 = char_attr; /* save current attr */
- }
+ n_attr = n_extra + 1;
+ extra_attr = hl_attr(HLF_8);
+ saved_attr2 = char_attr; /* save current attr */
#ifdef FEAT_MBYTE
mb_utf8 = FALSE; /* don't draw as UTF-8 */
#endif
@@ -4486,7 +4462,7 @@
&& !(lnum_in_visual_area
&& vim_strchr(wp->w_p_cocu, 'v') == NULL))
{
- char_attr = conceal_attr;
+ conceal_attr = hl_attr(HLF_CONCEAL);
if (prev_syntax_id != syntax_seqnr
&& (syn_get_sub_char() != NUL || wp->w_p_cole == 1)
&& wp->w_p_cole != 3)
@@ -4544,6 +4520,7 @@
{
prev_syntax_id = 0;
is_concealing = FALSE;
+ conceal_attr = 0;
}
#endif /* FEAT_CONCEAL */
}
@@ -4564,9 +4541,42 @@
/* Don't override visual selection highlighting. */
if (n_attr > 0
- && draw_state == WL_LINE
- && !attr_pri)
- char_attr = extra_attr;
+ && draw_state == WL_LINE)
+ {
+ if (!attr_pri)
+ char_attr = extra_attr;
+ else
+ char_attr = hl_combine_attr(extra_attr, char_attr);
+ }
+#ifdef FEAT_CONCEAL
+ else if (conceal_attr > 0)
+ {
+ if (!attr_pri)
+ char_attr = conceal_attr;
+ else
+ char_attr = hl_combine_attr(conceal_attr, char_attr);
+ }
+#endif
+ else if (extra_check)
+ {
+#ifdef FEAT_SYN_HL
+ /* Get syntax attribute, unless still at the start of the line
+ * (double-wide char that doesn't fit). */
+ v = (long)(ptr - line);
+ if (has_syntax && v > 0)
+ {
+ /* Need to get the line again, a multi-line regexp may
+ * have made it invalid. */
+ line = ml_get_buf(wp->w_buffer, lnum, FALSE);
+ ptr = line + v;
+
+ if (!attr_pri)
+ char_attr = syntax_attr;
+ else
+ char_attr = hl_combine_attr(syntax_attr, char_attr);
+ }
+#endif
+ }
#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
/* XIM don't send preedit_start and preedit_end, but they send
diff -r c61da758a9a2 src/screen.c
--- a/src/screen.c Wed Apr 24 18:34:45 2013 +0200
+++ b/src/screen.c Fri May 03 16:47:04 2013 +0900
@@ -2844,7 +2844,7 @@
int syntax_flags = 0;
int syntax_seqnr = 0;
int prev_syntax_id = 0;
- int conceal_attr = hl_attr(HLF_CONCEAL);
+ int conceal_attr = 0;
int is_concealing = FALSE;
int boguscols = 0; /* nonexistent columns added to force
wrapping */
@@ -3941,12 +3941,9 @@
mb_utf8 = (c >= 0x80);
n_extra = (int)STRLEN(p_extra);
c_extra = NUL;
- if (area_attr == 0 && search_attr == 0)
- {
- n_attr = n_extra + 1;
- extra_attr = hl_attr(HLF_8);
- saved_attr2 = char_attr; /* save current attr */
- }
+ n_attr = n_extra + 1;
+ extra_attr = hl_attr(HLF_8);
+ saved_attr2 = char_attr; /* save current attr */
}
else if (mb_l == 0) /* at the NUL at end-of-line */
mb_l = 1;
@@ -4073,12 +4070,9 @@
) && lcs_nbsp)
{
c = lcs_nbsp;
- if (area_attr == 0 && search_attr == 0)
- {
- n_attr = 1;
- extra_attr = hl_attr(HLF_8);
- saved_attr2 = char_attr; /* save current attr */
- }
+ n_attr = 1;
+ extra_attr = hl_attr(HLF_8);
+ saved_attr2 = char_attr; /* save current attr */
#ifdef FEAT_MBYTE
mb_c = c;
if (enc_utf8 && (*mb_char2len)(c) > 1)
@@ -4123,15 +4117,6 @@
else
did_emsg = save_did_emsg;
- /* Need to get the line again, a multi-line regexp may
- * have made it invalid. */
- line = ml_get_buf(wp->w_buffer, lnum, FALSE);
- ptr = line + v;
-
- if (!attr_pri)
- char_attr = syntax_attr;
- else
- char_attr = hl_combine_attr(syntax_attr, char_attr);
# ifdef FEAT_CONCEAL
/* no concealing past the end of the line, it interferes
* with line highlighting */
@@ -4257,12 +4242,9 @@
if (trailcol != MAXCOL && ptr > line + trailcol && c == ' ')
{
c = lcs_trail;
- if (!attr_pri)
- {
- n_attr = 1;
- extra_attr = hl_attr(HLF_8);
- saved_attr2 = char_attr; /* save current attr */
- }
+ n_attr = 1;
+ extra_attr = hl_attr(HLF_8);
+ saved_attr2 = char_attr; /* save current attr */
#ifdef FEAT_MBYTE
mb_c = c;
if (enc_utf8 && (*mb_char2len)(c) > 1)
@@ -4386,11 +4368,8 @@
c = ' ';
lcs_eol_one = -1;
--ptr; /* put it back at the NUL */
- if (!attr_pri)
- {
- extra_attr = hl_attr(HLF_AT);
- n_attr = 1;
- }
+ extra_attr = hl_attr(HLF_AT);
+ n_attr = 1;
#ifdef FEAT_MBYTE
mb_c = c;
if (enc_utf8 && (*mb_char2len)(c) > 1)
@@ -4413,12 +4392,9 @@
n_extra = byte2cells(c) - 1;
c_extra = NUL;
c = *p_extra++;
- if (!attr_pri)
- {
- n_attr = n_extra + 1;
- extra_attr = hl_attr(HLF_8);
- saved_attr2 = char_attr; /* save current attr */
- }
+ n_attr = n_extra + 1;
+ extra_attr = hl_attr(HLF_8);
+ saved_attr2 = char_attr; /* save current attr */
#ifdef FEAT_MBYTE
mb_utf8 = FALSE; /* don't draw as UTF-8 */
#endif
@@ -4486,7 +4462,7 @@
&& !(lnum_in_visual_area
&& vim_strchr(wp->w_p_cocu, 'v') == NULL))
{
- char_attr = conceal_attr;
+ conceal_attr = hl_attr(HLF_CONCEAL);
if (prev_syntax_id != syntax_seqnr
&& (syn_get_sub_char() != NUL || wp->w_p_cole == 1)
&& wp->w_p_cole != 3)
@@ -4544,6 +4520,7 @@
{
prev_syntax_id = 0;
is_concealing = FALSE;
+ conceal_attr = 0;
}
#endif /* FEAT_CONCEAL */
}
@@ -4564,9 +4541,39 @@
/* Don't override visual selection highlighting. */
if (n_attr > 0
- && draw_state == WL_LINE
- && !attr_pri)
- char_attr = extra_attr;
+ && draw_state == WL_LINE)
+ {
+ if (!attr_pri)
+ char_attr = extra_attr;
+ else
+ char_attr = hl_combine_attr(char_attr, extra_attr);
+ }
+#ifdef FEAT_CONCEAL
+ else if (conceal_attr > 0)
+ {
+ char_attr = conceal_attr;
+ }
+#endif
+ else if (extra_check)
+ {
+#ifdef FEAT_SYN_HL
+ /* Get syntax attribute, unless still at the start of the line
+ * (double-wide char that doesn't fit). */
+ v = (long)(ptr - line);
+ if (has_syntax && v > 0)
+ {
+ /* Need to get the line again, a multi-line regexp may
+ * have made it invalid. */
+ line = ml_get_buf(wp->w_buffer, lnum, FALSE);
+ ptr = line + v;
+
+ if (!attr_pri)
+ char_attr = syntax_attr;
+ else
+ char_attr = hl_combine_attr(syntax_attr, char_attr);
+ }
+#endif
+ }
#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
/* XIM don't send preedit_start and preedit_end, but they send
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment