@@ -9786,6 +9786,73 @@ gui_do_one_color(
97869786}
97879787#endif
97889788
9789+ #if defined(USER_HIGHLIGHT ) && defined(FEAT_STL_OPT )
9790+ /*
9791+ * Apply difference between User[1-9] and HLF_S to HLF_SNC or HLF_ST.
9792+ */
9793+ static void
9794+ combine_stl_hlt (
9795+ int id ,
9796+ int id_S ,
9797+ int id_alt ,
9798+ int hlcnt ,
9799+ int i ,
9800+ int hlf ,
9801+ int * table )
9802+ {
9803+ struct hl_group * hlt = HL_TABLE ();
9804+
9805+ if (id_alt == 0 )
9806+ {
9807+ vim_memset (& hlt [hlcnt + i ], 0 , sizeof (struct hl_group ));
9808+ hlt [hlcnt + i ].sg_term = highlight_attr [hlf ];
9809+ hlt [hlcnt + i ].sg_cterm = highlight_attr [hlf ];
9810+ # if defined(FEAT_GUI ) || defined(FEAT_EVAL )
9811+ hlt [hlcnt + i ].sg_gui = highlight_attr [hlf ];
9812+ # endif
9813+ }
9814+ else
9815+ mch_memmove (& hlt [hlcnt + i ],
9816+ & hlt [id_alt - 1 ],
9817+ sizeof (struct hl_group ));
9818+ hlt [hlcnt + i ].sg_link = 0 ;
9819+
9820+ hlt [hlcnt + i ].sg_term ^=
9821+ hlt [id - 1 ].sg_term ^ hlt [id_S - 1 ].sg_term ;
9822+ if (hlt [id - 1 ].sg_start != hlt [id_S - 1 ].sg_start )
9823+ hlt [hlcnt + i ].sg_start = hlt [id - 1 ].sg_start ;
9824+ if (hlt [id - 1 ].sg_stop != hlt [id_S - 1 ].sg_stop )
9825+ hlt [hlcnt + i ].sg_stop = hlt [id - 1 ].sg_stop ;
9826+ hlt [hlcnt + i ].sg_cterm ^=
9827+ hlt [id - 1 ].sg_cterm ^ hlt [id_S - 1 ].sg_cterm ;
9828+ if (hlt [id - 1 ].sg_cterm_fg != hlt [id_S - 1 ].sg_cterm_fg )
9829+ hlt [hlcnt + i ].sg_cterm_fg = hlt [id - 1 ].sg_cterm_fg ;
9830+ if (hlt [id - 1 ].sg_cterm_bg != hlt [id_S - 1 ].sg_cterm_bg )
9831+ hlt [hlcnt + i ].sg_cterm_bg = hlt [id - 1 ].sg_cterm_bg ;
9832+ # if defined(FEAT_GUI ) || defined(FEAT_EVAL )
9833+ hlt [hlcnt + i ].sg_gui ^=
9834+ hlt [id - 1 ].sg_gui ^ hlt [id_S - 1 ].sg_gui ;
9835+ # endif
9836+ # ifdef FEAT_GUI
9837+ if (hlt [id - 1 ].sg_gui_fg != hlt [id_S - 1 ].sg_gui_fg )
9838+ hlt [hlcnt + i ].sg_gui_fg = hlt [id - 1 ].sg_gui_fg ;
9839+ if (hlt [id - 1 ].sg_gui_bg != hlt [id_S - 1 ].sg_gui_bg )
9840+ hlt [hlcnt + i ].sg_gui_bg = hlt [id - 1 ].sg_gui_bg ;
9841+ if (hlt [id - 1 ].sg_gui_sp != hlt [id_S - 1 ].sg_gui_sp )
9842+ hlt [hlcnt + i ].sg_gui_sp = hlt [id - 1 ].sg_gui_sp ;
9843+ if (hlt [id - 1 ].sg_font != hlt [id_S - 1 ].sg_font )
9844+ hlt [hlcnt + i ].sg_font = hlt [id - 1 ].sg_font ;
9845+ # ifdef FEAT_XFONTSET
9846+ if (hlt [id - 1 ].sg_fontset != hlt [id_S - 1 ].sg_fontset )
9847+ hlt [hlcnt + i ].sg_fontset = hlt [id - 1 ].sg_fontset ;
9848+ # endif
9849+ # endif
9850+ highlight_ga .ga_len = hlcnt + i + 1 ;
9851+ set_hl_attr (hlcnt + i ); /* At long last we can apply */
9852+ table [i ] = syn_id2attr (hlcnt + i + 1 );
9853+ }
9854+ #endif
9855+
97899856/*
97909857 * Translate the 'highlight' option into attributes in highlight_attr[] and
97919858 * set up the user highlights User1..9. If FEAT_STL_OPT is in use, a set of
@@ -9808,6 +9875,9 @@ highlight_changed(void)
98089875# ifdef FEAT_STL_OPT
98099876 int id_SNC = -1 ;
98109877 int id_S = -1 ;
9878+ # ifdef FEAT_TERMINAL
9879+ int id_ST = -1 ;
9880+ # endif
98119881 int hlcnt ;
98129882# endif
98139883#endif
@@ -9887,6 +9957,10 @@ highlight_changed(void)
98879957#if defined(FEAT_STL_OPT ) && defined(USER_HIGHLIGHT )
98889958 if (hlf == (int )HLF_SNC )
98899959 id_SNC = syn_get_final_id (id );
9960+ # ifdef FEAT_TERMINAL
9961+ else if (hlf == (int )HLF_ST )
9962+ id_ST = syn_get_final_id (id );
9963+ # endif
98909964 else if (hlf == (int )HLF_S )
98919965 id_S = syn_get_final_id (id );
98929966#endif
@@ -9903,18 +9977,24 @@ highlight_changed(void)
99039977#ifdef USER_HIGHLIGHT
99049978 /* Setup the user highlights
99059979 *
9906- * Temporarily utilize 10 more hl entries. Have to be in there
9907- * simultaneously in case of table overflows in get_attr_entry()
9980+ * Temporarily utilize 19 more hl entries:
9981+ * 9 for User1-User9 combined with StatusLineNC
9982+ * 9 for User1-User9 combined with StatusLineTerm
9983+ * 1 for StatusLine default
9984+ * Have to be in there simultaneously in case of table overflows in
9985+ * get_attr_entry()
99089986 */
99099987# ifdef FEAT_STL_OPT
9910- if (ga_grow (& highlight_ga , 10 ) == FAIL )
9988+ if (ga_grow (& highlight_ga , 19 ) == FAIL )
99119989 return FAIL ;
99129990 hlcnt = highlight_ga .ga_len ;
99139991 if (id_S == 0 )
9914- { /* Make sure id_S is always valid to simplify code below */
9915- vim_memset (& HL_TABLE ()[hlcnt + 9 ], 0 , sizeof (struct hl_group ));
9916- HL_TABLE ()[hlcnt + 9 ].sg_term = highlight_attr [HLF_S ];
9917- id_S = hlcnt + 10 ;
9992+ {
9993+ /* Make sure id_S is always valid to simplify code below. Use the last
9994+ * entry. */
9995+ vim_memset (& HL_TABLE ()[hlcnt + 18 ], 0 , sizeof (struct hl_group ));
9996+ HL_TABLE ()[hlcnt + 18 ].sg_term = highlight_attr [HLF_S ];
9997+ id_S = hlcnt + 19 ;
99189998 }
99199999# endif
992010000 for (i = 0 ; i < 9 ; i ++ )
@@ -9926,65 +10006,21 @@ highlight_changed(void)
992610006 highlight_user [i ] = 0 ;
992710007# ifdef FEAT_STL_OPT
992810008 highlight_stlnc [i ] = 0 ;
10009+ # ifdef FEAT_TERMINAL
10010+ highlight_stlterm [i ] = 0 ;
10011+ # endif
992910012# endif
993010013 }
993110014 else
993210015 {
9933- # ifdef FEAT_STL_OPT
9934- struct hl_group * hlt = HL_TABLE ();
9935- # endif
9936-
993710016 highlight_user [i ] = syn_id2attr (id );
993810017# ifdef FEAT_STL_OPT
9939- if (id_SNC == 0 )
9940- {
9941- vim_memset (& hlt [hlcnt + i ], 0 , sizeof (struct hl_group ));
9942- hlt [hlcnt + i ].sg_term = highlight_attr [HLF_SNC ];
9943- hlt [hlcnt + i ].sg_cterm = highlight_attr [HLF_SNC ];
9944- # if defined(FEAT_GUI ) || defined(FEAT_EVAL )
9945- hlt [hlcnt + i ].sg_gui = highlight_attr [HLF_SNC ];
9946- # endif
9947- }
9948- else
9949- mch_memmove (& hlt [hlcnt + i ],
9950- & hlt [id_SNC - 1 ],
9951- sizeof (struct hl_group ));
9952- hlt [hlcnt + i ].sg_link = 0 ;
9953-
9954- /* Apply difference between UserX and HLF_S to HLF_SNC */
9955- hlt [hlcnt + i ].sg_term ^=
9956- hlt [id - 1 ].sg_term ^ hlt [id_S - 1 ].sg_term ;
9957- if (hlt [id - 1 ].sg_start != hlt [id_S - 1 ].sg_start )
9958- hlt [hlcnt + i ].sg_start = hlt [id - 1 ].sg_start ;
9959- if (hlt [id - 1 ].sg_stop != hlt [id_S - 1 ].sg_stop )
9960- hlt [hlcnt + i ].sg_stop = hlt [id - 1 ].sg_stop ;
9961- hlt [hlcnt + i ].sg_cterm ^=
9962- hlt [id - 1 ].sg_cterm ^ hlt [id_S - 1 ].sg_cterm ;
9963- if (hlt [id - 1 ].sg_cterm_fg != hlt [id_S - 1 ].sg_cterm_fg )
9964- hlt [hlcnt + i ].sg_cterm_fg = hlt [id - 1 ].sg_cterm_fg ;
9965- if (hlt [id - 1 ].sg_cterm_bg != hlt [id_S - 1 ].sg_cterm_bg )
9966- hlt [hlcnt + i ].sg_cterm_bg = hlt [id - 1 ].sg_cterm_bg ;
9967- # if defined(FEAT_GUI ) || defined(FEAT_EVAL )
9968- hlt [hlcnt + i ].sg_gui ^=
9969- hlt [id - 1 ].sg_gui ^ hlt [id_S - 1 ].sg_gui ;
9970- # endif
9971- # ifdef FEAT_GUI
9972- if (hlt [id - 1 ].sg_gui_fg != hlt [id_S - 1 ].sg_gui_fg )
9973- hlt [hlcnt + i ].sg_gui_fg = hlt [id - 1 ].sg_gui_fg ;
9974- if (hlt [id - 1 ].sg_gui_bg != hlt [id_S - 1 ].sg_gui_bg )
9975- hlt [hlcnt + i ].sg_gui_bg = hlt [id - 1 ].sg_gui_bg ;
9976- if (hlt [id - 1 ].sg_gui_sp != hlt [id_S - 1 ].sg_gui_sp )
9977- hlt [hlcnt + i ].sg_gui_sp = hlt [id - 1 ].sg_gui_sp ;
9978- if (hlt [id - 1 ].sg_font != hlt [id_S - 1 ].sg_font )
9979- hlt [hlcnt + i ].sg_font = hlt [id - 1 ].sg_font ;
9980- # ifdef FEAT_XFONTSET
9981- if (hlt [id - 1 ].sg_fontset != hlt [id_S - 1 ].sg_fontset )
9982- hlt [hlcnt + i ].sg_fontset = hlt [id - 1 ].sg_fontset ;
9983- # endif
10018+ combine_stl_hlt (id , id_S , id_SNC , hlcnt , i ,
10019+ HLF_SNC , highlight_stlnc );
10020+ # ifdef FEAT_TERMINAL
10021+ combine_stl_hlt (id , id_S , id_ST , hlcnt + 9 , i ,
10022+ HLF_ST , highlight_stlterm );
998410023# endif
9985- highlight_ga .ga_len = hlcnt + i + 1 ;
9986- set_hl_attr (hlcnt + i ); /* At long last we can apply */
9987- highlight_stlnc [i ] = syn_id2attr (hlcnt + i + 1 );
998810024# endif
998910025 }
999010026 }
0 commit comments