]> granicus.if.org Git - vim/commitdiff
Give each syntax item a sequence number, so that we know when it starts and
authorBram Moolenaar <Bram@vim.org>
Sat, 24 Jul 2010 15:29:03 +0000 (17:29 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 24 Jul 2010 15:29:03 +0000 (17:29 +0200)
can show the 'cchar' for each of them.

runtime/doc/todo.txt
src/proto/syntax.pro
src/screen.c
src/syntax.c

index adb714027418137bb4f57ca4a27658dfa87700b8..119ec99f7e3084d60b8a9b32694a2632a8dfc6e6 100644 (file)
@@ -42,9 +42,6 @@ Add documentation for Python 3 support.
 
 Check position in wrapped line with 'concealcursor' set.
 
-Trick with syntax ID works, but it's not nice.  Can we give a sequence nr to
-syntax item matches?  At least the ones with a replacement char.
-
 'undoreload' option: when fewer lines than these consider a reload as a change
 action and save the text before the reload, don't clear undo info.
 
index 12dc9dec3b945b4d196b38f82a65eb5440f4bbcd..7ae13e98eeb9d8ee61f05249e7090e8539261651 100644 (file)
@@ -15,7 +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 get_syntax_info __ARGS((int *seqnrp));
 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));
index 1756fc0b2b72f1b9b86f41e9cb8c6c9e0eb46f10..e7c3ad2663f9b34a28bc549e4f5dcb7bc5746f2b 100644 (file)
@@ -2816,7 +2816,7 @@ win_line(wp, lnum, startrow, endrow, nochange)
 
 #ifdef FEAT_CONCEAL
     int                syntax_flags    = 0;
-    int                syntax_id       = 0;
+    int                syntax_seqnr    = 0;
     int                prev_syntax_id  = 0;
     int                conceal_attr    = hl_attr(HLF_CONCEAL);
     int                is_concealing   = FALSE;
@@ -4099,7 +4099,7 @@ win_line(wp, lnum, startrow, endrow, nochange)
                    if (c == NUL)
                        syntax_flags = 0;
                    else
-                       syntax_flags = get_syntax_info(&syntax_id);
+                       syntax_flags = get_syntax_info(&syntax_seqnr);
 # endif
                }
 #endif
@@ -4430,7 +4430,7 @@ win_line(wp, lnum, startrow, endrow, nochange)
                && !lnum_in_visual_area)
            {
                char_attr = conceal_attr;
-               if (prev_syntax_id != syntax_id
+               if (prev_syntax_id != syntax_seqnr
                        && (syn_get_sub_char() != NUL || wp->w_p_cole == 1)
                        && wp->w_p_cole != 3)
                {
@@ -4443,7 +4443,7 @@ win_line(wp, lnum, startrow, endrow, nochange)
                    else
                        c = ' ';
 
-                   prev_syntax_id = syntax_id;
+                   prev_syntax_id = syntax_seqnr;
 
                    if (n_extra > 0)
                        vcol_off += n_extra;
index 5880803645ca52064220fdae932923e1f6d34c41..099e0a7c0d110e9023671d6a8bf9715ef9737e00 100644 (file)
@@ -196,6 +196,7 @@ static int current_id = 0;      /* ID of current char for syn_get_id() */
 static int current_trans_id = 0;    /* idem, transparency removed */
 #endif
 #ifdef FEAT_CONCEAL
+static int current_seqnr = 0;
 static int current_flags = 0;
 static int current_sub_char = 0;
 #endif
@@ -287,6 +288,7 @@ typedef struct state_item
                                         * HL_SKIP* for si_next_list */
 #ifdef FEAT_CONCEAL
     int                si_char;                /* substitution character for conceal */
+    int                si_seqnr;               /* sequence number */
 #endif
     short      *si_cont_list;          /* list of contained groups */
     short      *si_next_list;          /* nextgroup IDs after this item ends */
@@ -298,6 +300,10 @@ typedef struct state_item
 #define ID_LIST_ALL    (short *)-1 /* valid of si_cont_list for containing all
                                       but contained groups */
 
+#ifdef FEAT_CONCEAL
+static int next_seqnr = 0;             /* value to use for si_seqnr */
+#endif
+
 /*
  * Struct to reduce the number of arguments to get_syn_options(), it's used
  * very often.
@@ -1949,6 +1955,7 @@ syn_current_attr(syncing, displaying, can_spell, keep_state)
                        cur_si->si_end_idx = 0;
                        cur_si->si_flags = flags;
 #ifdef FEAT_CONCEAL
+                       cur_si->si_seqnr = next_seqnr++;
                        cur_si->si_char = cchar;
                        if (current_state.ga_len > 1)
                            cur_si->si_flags |=
@@ -2280,6 +2287,7 @@ syn_current_attr(syncing, displaying, can_spell, keep_state)
 #ifdef FEAT_CONCEAL
                current_flags = sip->si_flags;
                current_sub_char = sip->si_char;
+               current_seqnr = sip->si_seqnr;
 #endif
                break;
            }
@@ -2433,6 +2441,7 @@ push_next_match(cur_si)
        cur_si->si_m_lnum = current_lnum;
        cur_si->si_flags = spp->sp_flags;
 #ifdef FEAT_CONCEAL
+       cur_si->si_seqnr = next_seqnr++;
        cur_si->si_char = spp->sp_char;
        if (current_state.ga_len > 1)
            cur_si->si_flags |=
@@ -6336,14 +6345,14 @@ syn_get_id(wp, lnum, col, trans, spellp, keep_state)
 /*
  * Get extra information about the syntax item.  Must be called right after
  * get_syntax_attr().
- * Stores the current item ID in "*idp".
+ * Stores the current item sequence nr in "*seqnrp".
  * Returns the current flags.
  */
     int
-get_syntax_info(idp)
-    int                *idp;
+get_syntax_info(seqnrp)
+    int                *seqnrp;
 {
-    *idp = current_id;
+    *seqnrp = current_seqnr;
     return current_flags;
 }