comparison src/syntax.c @ 12114:f306e6decaf9 v8.0.0937

patch 8.0.0937: user highlight groups not adjusted for terminal commit https://github.com/vim/vim/commit/bce4f62d3043f04fe29f3fef2b927b2268b15255 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 13 21:37:43 2017 +0200 patch 8.0.0937: user highlight groups not adjusted for terminal Problem: User highlight groups are not adjusted for StatusLineTerm. Solution: Combine attributes like for StatusLineNC.
author Christian Brabandt <cb@256bit.org>
date Sun, 13 Aug 2017 21:45:04 +0200
parents 504df4aa84c6
children 68c593f649d1
comparison
equal deleted inserted replaced
12113:e058a485a027 12114:f306e6decaf9
9784 if (didit) /* need to get a new attr number */ 9784 if (didit) /* need to get a new attr number */
9785 set_hl_attr(idx); 9785 set_hl_attr(idx);
9786 } 9786 }
9787 #endif 9787 #endif
9788 9788
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
9789 /* 9856 /*
9790 * Translate the 'highlight' option into attributes in highlight_attr[] and 9857 * Translate the 'highlight' option into attributes in highlight_attr[] and
9791 * set up the user highlights User1..9. If FEAT_STL_OPT is in use, a set of 9858 * set up the user highlights User1..9. If FEAT_STL_OPT is in use, a set of
9792 * corresponding highlights to use on top of HLF_SNC is computed. 9859 * corresponding highlights to use on top of HLF_SNC is computed.
9793 * Called only when the 'highlight' option has been changed and upon first 9860 * Called only when the 'highlight' option has been changed and upon first
9806 #ifdef USER_HIGHLIGHT 9873 #ifdef USER_HIGHLIGHT
9807 char_u userhl[10]; 9874 char_u userhl[10];
9808 # ifdef FEAT_STL_OPT 9875 # ifdef FEAT_STL_OPT
9809 int id_SNC = -1; 9876 int id_SNC = -1;
9810 int id_S = -1; 9877 int id_S = -1;
9878 # ifdef FEAT_TERMINAL
9879 int id_ST = -1;
9880 # endif
9811 int hlcnt; 9881 int hlcnt;
9812 # endif 9882 # endif
9813 #endif 9883 #endif
9814 static int hl_flags[HLF_COUNT] = HL_FLAGS; 9884 static int hl_flags[HLF_COUNT] = HL_FLAGS;
9815 9885
9885 attr = syn_id2attr(id); 9955 attr = syn_id2attr(id);
9886 p = end - 1; 9956 p = end - 1;
9887 #if defined(FEAT_STL_OPT) && defined(USER_HIGHLIGHT) 9957 #if defined(FEAT_STL_OPT) && defined(USER_HIGHLIGHT)
9888 if (hlf == (int)HLF_SNC) 9958 if (hlf == (int)HLF_SNC)
9889 id_SNC = syn_get_final_id(id); 9959 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
9890 else if (hlf == (int)HLF_S) 9964 else if (hlf == (int)HLF_S)
9891 id_S = syn_get_final_id(id); 9965 id_S = syn_get_final_id(id);
9892 #endif 9966 #endif
9893 break; 9967 break;
9894 default: return FAIL; 9968 default: return FAIL;
9901 } 9975 }
9902 9976
9903 #ifdef USER_HIGHLIGHT 9977 #ifdef USER_HIGHLIGHT
9904 /* Setup the user highlights 9978 /* Setup the user highlights
9905 * 9979 *
9906 * Temporarily utilize 10 more hl entries. Have to be in there 9980 * Temporarily utilize 19 more hl entries:
9907 * simultaneously in case of table overflows in get_attr_entry() 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()
9908 */ 9986 */
9909 # ifdef FEAT_STL_OPT 9987 # ifdef FEAT_STL_OPT
9910 if (ga_grow(&highlight_ga, 10) == FAIL) 9988 if (ga_grow(&highlight_ga, 19) == FAIL)
9911 return FAIL; 9989 return FAIL;
9912 hlcnt = highlight_ga.ga_len; 9990 hlcnt = highlight_ga.ga_len;
9913 if (id_S == 0) 9991 if (id_S == 0)
9914 { /* Make sure id_S is always valid to simplify code below */ 9992 {
9915 vim_memset(&HL_TABLE()[hlcnt + 9], 0, sizeof(struct hl_group)); 9993 /* Make sure id_S is always valid to simplify code below. Use the last
9916 HL_TABLE()[hlcnt + 9].sg_term = highlight_attr[HLF_S]; 9994 * entry. */
9917 id_S = hlcnt + 10; 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;
9918 } 9998 }
9919 # endif 9999 # endif
9920 for (i = 0; i < 9; i++) 10000 for (i = 0; i < 9; i++)
9921 { 10001 {
9922 sprintf((char *)userhl, "User%d", i + 1); 10002 sprintf((char *)userhl, "User%d", i + 1);
9924 if (id == 0) 10004 if (id == 0)
9925 { 10005 {
9926 highlight_user[i] = 0; 10006 highlight_user[i] = 0;
9927 # ifdef FEAT_STL_OPT 10007 # ifdef FEAT_STL_OPT
9928 highlight_stlnc[i] = 0; 10008 highlight_stlnc[i] = 0;
10009 # ifdef FEAT_TERMINAL
10010 highlight_stlterm[i] = 0;
10011 # endif
9929 # endif 10012 # endif
9930 } 10013 }
9931 else 10014 else
9932 { 10015 {
9933 # ifdef FEAT_STL_OPT
9934 struct hl_group *hlt = HL_TABLE();
9935 # endif
9936
9937 highlight_user[i] = syn_id2attr(id); 10016 highlight_user[i] = syn_id2attr(id);
9938 # ifdef FEAT_STL_OPT 10017 # ifdef FEAT_STL_OPT
9939 if (id_SNC == 0) 10018 combine_stl_hlt(id, id_S, id_SNC, hlcnt, i,
9940 { 10019 HLF_SNC, highlight_stlnc);
9941 vim_memset(&hlt[hlcnt + i], 0, sizeof(struct hl_group)); 10020 # ifdef FEAT_TERMINAL
9942 hlt[hlcnt + i].sg_term = highlight_attr[HLF_SNC]; 10021 combine_stl_hlt(id, id_S, id_ST, hlcnt + 9, i,
9943 hlt[hlcnt + i].sg_cterm = highlight_attr[HLF_SNC]; 10022 HLF_ST, highlight_stlterm);
9944 # if defined(FEAT_GUI) || defined(FEAT_EVAL)
9945 hlt[hlcnt + i].sg_gui = highlight_attr[HLF_SNC];
9946 # endif 10023 # 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
9984 # 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);
9988 # endif 10024 # endif
9989 } 10025 }
9990 } 10026 }
9991 # ifdef FEAT_STL_OPT 10027 # ifdef FEAT_STL_OPT
9992 highlight_ga.ga_len = hlcnt; 10028 highlight_ga.ga_len = hlcnt;