diff options
author | Bram Moolenaar <Bram@vim.org> | 2010-07-22 22:16:29 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2010-07-22 22:16:29 +0200 |
commit | 27c735b2f87770a59940a15e44a052bd9eaf99e4 (patch) | |
tree | 70ed59b15394c97bce854fcf906d2a152bb769c7 /src | |
parent | fa5d1e63c73cfb8b85fb94a9bd073eb34d143742 (diff) | |
download | vim-git-27c735b2f87770a59940a15e44a052bd9eaf99e4.tar.gz |
For conceal mode: when two different syntax items follow each other, show the
replacement character for both.
Diffstat (limited to 'src')
-rw-r--r-- | src/proto/syntax.pro | 3 | ||||
-rw-r--r-- | src/screen.c | 21 | ||||
-rw-r--r-- | src/syntax.c | 23 |
3 files changed, 29 insertions, 18 deletions
diff --git a/src/proto/syntax.pro b/src/proto/syntax.pro index b2d63fdd7..12dc9dec3 100644 --- a/src/proto/syntax.pro +++ b/src/proto/syntax.pro @@ -4,7 +4,7 @@ void syn_stack_free_all __ARGS((synblock_T *block)); void syn_stack_apply_changes __ARGS((buf_T *buf)); void syntax_end_parsing __ARGS((linenr_T lnum)); int syntax_check_changed __ARGS((linenr_T lnum)); -int get_syntax_attr __ARGS((colnr_T col, int *p_flags, int *can_spell, int keep_state)); +int get_syntax_attr __ARGS((colnr_T col, int *can_spell, int keep_state)); void syntax_clear __ARGS((synblock_T *block)); void reset_synblock __ARGS((win_T *wp)); void ex_syntax __ARGS((exarg_T *eap)); @@ -15,6 +15,7 @@ void set_context_in_echohl_cmd __ARGS((expand_T *xp, char_u *arg)); void set_context_in_syntax_cmd __ARGS((expand_T *xp, char_u *arg)); char_u *get_syntax_name __ARGS((expand_T *xp, int idx)); int syn_get_id __ARGS((win_T *wp, long lnum, colnr_T col, int trans, int *spellp, int keep_state)); +int get_syntax_info __ARGS((int *idp)); int syn_get_sub_char __ARGS((void)); int syn_get_stack_item __ARGS((int i)); int syn_get_foldlevel __ARGS((win_T *wp, long lnum)); diff --git a/src/screen.c b/src/screen.c index 69df0b2cd..71eb16fca 100644 --- a/src/screen.c +++ b/src/screen.c @@ -2775,8 +2775,9 @@ win_line(wp, lnum, startrow, endrow, nochange) #ifdef FEAT_CONCEAL int syntax_flags = 0; + int syntax_id = 0; + int prev_syntax_id = 0; int conceal_attr = hl_attr(HLF_CONCEAL); - int first_conceal = (wp->w_p_conc != 3); int is_concealing = FALSE; int boguscols = 0; /* nonexistent columns added to force wrapping */ @@ -4028,11 +4029,6 @@ win_line(wp, lnum, startrow, endrow, nochange) did_emsg = FALSE; syntax_attr = get_syntax_attr((colnr_T)v - 1, -# ifdef FEAT_CONCEAL - &syntax_flags, -# else - NULL, -# endif # ifdef FEAT_SPELL has_spell ? &can_spell : # endif @@ -4060,6 +4056,8 @@ win_line(wp, lnum, startrow, endrow, nochange) * with line highlighting */ if (c == NUL) syntax_flags = 0; + else + syntax_flags = get_syntax_info(&syntax_id); # endif } #endif @@ -4388,9 +4386,12 @@ win_line(wp, lnum, startrow, endrow, nochange) && (syntax_flags & HL_CONCEAL) != 0) { char_attr = conceal_attr; - if (first_conceal - && (syn_get_sub_char() != NUL || wp->w_p_conc == 1)) + if (prev_syntax_id != syntax_id + && (syn_get_sub_char() != NUL || wp->w_p_conc == 1) + && wp->w_p_conc != 3) { + /* First time at this concealed item: display one + * character. */ if (syn_get_sub_char() != NUL) c = syn_get_sub_char(); else if (lcs_conceal != NUL) @@ -4398,7 +4399,7 @@ win_line(wp, lnum, startrow, endrow, nochange) else c = ' '; - first_conceal = FALSE; + prev_syntax_id = syntax_id; if (n_extra > 0) vcol_off += n_extra; @@ -4440,7 +4441,7 @@ win_line(wp, lnum, startrow, endrow, nochange) } else { - first_conceal = (wp->w_p_conc != 3); + prev_syntax_id = 0; is_concealing = FALSE; } #endif /* FEAT_CONCEAL */ diff --git a/src/syntax.c b/src/syntax.c index c54984c97..588080364 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -1755,9 +1755,8 @@ syn_finish_line(syncing) * done. */ int -get_syntax_attr(col, p_flags, can_spell, keep_state) +get_syntax_attr(col, can_spell, keep_state) colnr_T col; - int *p_flags UNUSED; int *can_spell; int keep_state; /* keep state of char at "col" */ { @@ -1799,10 +1798,6 @@ get_syntax_attr(col, p_flags, can_spell, keep_state) ++current_col; } -#ifdef FEAT_CONCEAL - if (p_flags != NULL) - *p_flags = current_flags; -#endif return attr; } @@ -6332,13 +6327,27 @@ syn_get_id(wp, lnum, col, trans, spellp, keep_state) || col < current_col) syntax_start(wp, lnum); - (void)get_syntax_attr(col, NULL, spellp, keep_state); + (void)get_syntax_attr(col, spellp, keep_state); return (trans ? current_trans_id : current_id); } #if defined(FEAT_CONCEAL) || defined(PROTO) /* + * Get extra information about the syntax item. Must be called right after + * get_syntax_attr(). + * Stores the current item ID in "*idp". + * Returns the current flags. + */ + int +get_syntax_info(idp) + int *idp; +{ + *idp = current_id; + return current_flags; +} + +/* * Return conceal substitution character */ int |