To: vim_dev@googlegroups.com Subject: Patch 8.0.0937 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.0937 Problem: User highlight groups are not adjusted for StatusLineTerm. Solution: Combine attributes like for StatusLineNC. Files: src/syntax.c, src/globals.h, src/screen.c *** ../vim-8.0.0936/src/syntax.c 2017-08-12 22:55:54.221280883 +0200 --- src/syntax.c 2017-08-13 21:36:37.026338294 +0200 *************** *** 9786,9791 **** --- 9786,9858 ---- } #endif + #if defined(USER_HIGHLIGHT) && defined(FEAT_STL_OPT) + /* + * Apply difference between User[1-9] and HLF_S to HLF_SNC or HLF_ST. + */ + static void + combine_stl_hlt( + int id, + int id_S, + int id_alt, + int hlcnt, + int i, + int hlf, + int *table) + { + struct hl_group *hlt = HL_TABLE(); + + if (id_alt == 0) + { + vim_memset(&hlt[hlcnt + i], 0, sizeof(struct hl_group)); + hlt[hlcnt + i].sg_term = highlight_attr[hlf]; + hlt[hlcnt + i].sg_cterm = highlight_attr[hlf]; + # if defined(FEAT_GUI) || defined(FEAT_EVAL) + hlt[hlcnt + i].sg_gui = highlight_attr[hlf]; + # endif + } + else + mch_memmove(&hlt[hlcnt + i], + &hlt[id_alt - 1], + sizeof(struct hl_group)); + hlt[hlcnt + i].sg_link = 0; + + hlt[hlcnt + i].sg_term ^= + hlt[id - 1].sg_term ^ hlt[id_S - 1].sg_term; + if (hlt[id - 1].sg_start != hlt[id_S - 1].sg_start) + hlt[hlcnt + i].sg_start = hlt[id - 1].sg_start; + if (hlt[id - 1].sg_stop != hlt[id_S - 1].sg_stop) + hlt[hlcnt + i].sg_stop = hlt[id - 1].sg_stop; + hlt[hlcnt + i].sg_cterm ^= + hlt[id - 1].sg_cterm ^ hlt[id_S - 1].sg_cterm; + if (hlt[id - 1].sg_cterm_fg != hlt[id_S - 1].sg_cterm_fg) + hlt[hlcnt + i].sg_cterm_fg = hlt[id - 1].sg_cterm_fg; + if (hlt[id - 1].sg_cterm_bg != hlt[id_S - 1].sg_cterm_bg) + hlt[hlcnt + i].sg_cterm_bg = hlt[id - 1].sg_cterm_bg; + # if defined(FEAT_GUI) || defined(FEAT_EVAL) + hlt[hlcnt + i].sg_gui ^= + hlt[id - 1].sg_gui ^ hlt[id_S - 1].sg_gui; + # endif + # ifdef FEAT_GUI + if (hlt[id - 1].sg_gui_fg != hlt[id_S - 1].sg_gui_fg) + hlt[hlcnt + i].sg_gui_fg = hlt[id - 1].sg_gui_fg; + if (hlt[id - 1].sg_gui_bg != hlt[id_S - 1].sg_gui_bg) + hlt[hlcnt + i].sg_gui_bg = hlt[id - 1].sg_gui_bg; + if (hlt[id - 1].sg_gui_sp != hlt[id_S - 1].sg_gui_sp) + hlt[hlcnt + i].sg_gui_sp = hlt[id - 1].sg_gui_sp; + if (hlt[id - 1].sg_font != hlt[id_S - 1].sg_font) + hlt[hlcnt + i].sg_font = hlt[id - 1].sg_font; + # ifdef FEAT_XFONTSET + if (hlt[id - 1].sg_fontset != hlt[id_S - 1].sg_fontset) + hlt[hlcnt + i].sg_fontset = hlt[id - 1].sg_fontset; + # endif + # endif + highlight_ga.ga_len = hlcnt + i + 1; + set_hl_attr(hlcnt + i); /* At long last we can apply */ + table[i] = syn_id2attr(hlcnt + i + 1); + } + #endif + /* * Translate the 'highlight' option into attributes in highlight_attr[] and * set up the user highlights User1..9. If FEAT_STL_OPT is in use, a set of *************** *** 9808,9813 **** --- 9875,9883 ---- # ifdef FEAT_STL_OPT int id_SNC = -1; int id_S = -1; + # ifdef FEAT_TERMINAL + int id_ST = -1; + # endif int hlcnt; # endif #endif *************** *** 9887,9892 **** --- 9957,9966 ---- #if defined(FEAT_STL_OPT) && defined(USER_HIGHLIGHT) if (hlf == (int)HLF_SNC) id_SNC = syn_get_final_id(id); + # ifdef FEAT_TERMINAL + else if (hlf == (int)HLF_ST) + id_ST = syn_get_final_id(id); + # endif else if (hlf == (int)HLF_S) id_S = syn_get_final_id(id); #endif *************** *** 9903,9920 **** #ifdef USER_HIGHLIGHT /* Setup the user highlights * ! * Temporarily utilize 10 more hl entries. Have to be in there ! * simultaneously in case of table overflows in get_attr_entry() */ # ifdef FEAT_STL_OPT ! if (ga_grow(&highlight_ga, 10) == FAIL) return FAIL; hlcnt = highlight_ga.ga_len; if (id_S == 0) ! { /* Make sure id_S is always valid to simplify code below */ ! vim_memset(&HL_TABLE()[hlcnt + 9], 0, sizeof(struct hl_group)); ! HL_TABLE()[hlcnt + 9].sg_term = highlight_attr[HLF_S]; ! id_S = hlcnt + 10; } # endif for (i = 0; i < 9; i++) --- 9977,10000 ---- #ifdef USER_HIGHLIGHT /* Setup the user highlights * ! * Temporarily utilize 19 more hl entries: ! * 9 for User1-User9 combined with StatusLineNC ! * 9 for User1-User9 combined with StatusLineTerm ! * 1 for StatusLine default ! * Have to be in there simultaneously in case of table overflows in ! * get_attr_entry() */ # ifdef FEAT_STL_OPT ! if (ga_grow(&highlight_ga, 19) == FAIL) return FAIL; hlcnt = highlight_ga.ga_len; if (id_S == 0) ! { ! /* Make sure id_S is always valid to simplify code below. Use the last ! * entry. */ ! vim_memset(&HL_TABLE()[hlcnt + 18], 0, sizeof(struct hl_group)); ! HL_TABLE()[hlcnt + 18].sg_term = highlight_attr[HLF_S]; ! id_S = hlcnt + 19; } # endif for (i = 0; i < 9; i++) *************** *** 9926,9990 **** highlight_user[i] = 0; # ifdef FEAT_STL_OPT highlight_stlnc[i] = 0; # endif } else { - # ifdef FEAT_STL_OPT - struct hl_group *hlt = HL_TABLE(); - # endif - highlight_user[i] = syn_id2attr(id); # ifdef FEAT_STL_OPT ! if (id_SNC == 0) ! { ! vim_memset(&hlt[hlcnt + i], 0, sizeof(struct hl_group)); ! hlt[hlcnt + i].sg_term = highlight_attr[HLF_SNC]; ! hlt[hlcnt + i].sg_cterm = highlight_attr[HLF_SNC]; ! # if defined(FEAT_GUI) || defined(FEAT_EVAL) ! hlt[hlcnt + i].sg_gui = highlight_attr[HLF_SNC]; ! # endif ! } ! else ! mch_memmove(&hlt[hlcnt + i], ! &hlt[id_SNC - 1], ! sizeof(struct hl_group)); ! hlt[hlcnt + i].sg_link = 0; ! ! /* Apply difference between UserX and HLF_S to HLF_SNC */ ! hlt[hlcnt + i].sg_term ^= ! hlt[id - 1].sg_term ^ hlt[id_S - 1].sg_term; ! if (hlt[id - 1].sg_start != hlt[id_S - 1].sg_start) ! hlt[hlcnt + i].sg_start = hlt[id - 1].sg_start; ! if (hlt[id - 1].sg_stop != hlt[id_S - 1].sg_stop) ! hlt[hlcnt + i].sg_stop = hlt[id - 1].sg_stop; ! hlt[hlcnt + i].sg_cterm ^= ! hlt[id - 1].sg_cterm ^ hlt[id_S - 1].sg_cterm; ! if (hlt[id - 1].sg_cterm_fg != hlt[id_S - 1].sg_cterm_fg) ! hlt[hlcnt + i].sg_cterm_fg = hlt[id - 1].sg_cterm_fg; ! if (hlt[id - 1].sg_cterm_bg != hlt[id_S - 1].sg_cterm_bg) ! hlt[hlcnt + i].sg_cterm_bg = hlt[id - 1].sg_cterm_bg; ! # if defined(FEAT_GUI) || defined(FEAT_EVAL) ! hlt[hlcnt + i].sg_gui ^= ! hlt[id - 1].sg_gui ^ hlt[id_S - 1].sg_gui; ! # endif ! # ifdef FEAT_GUI ! if (hlt[id - 1].sg_gui_fg != hlt[id_S - 1].sg_gui_fg) ! hlt[hlcnt + i].sg_gui_fg = hlt[id - 1].sg_gui_fg; ! if (hlt[id - 1].sg_gui_bg != hlt[id_S - 1].sg_gui_bg) ! hlt[hlcnt + i].sg_gui_bg = hlt[id - 1].sg_gui_bg; ! if (hlt[id - 1].sg_gui_sp != hlt[id_S - 1].sg_gui_sp) ! hlt[hlcnt + i].sg_gui_sp = hlt[id - 1].sg_gui_sp; ! if (hlt[id - 1].sg_font != hlt[id_S - 1].sg_font) ! hlt[hlcnt + i].sg_font = hlt[id - 1].sg_font; ! # ifdef FEAT_XFONTSET ! if (hlt[id - 1].sg_fontset != hlt[id_S - 1].sg_fontset) ! hlt[hlcnt + i].sg_fontset = hlt[id - 1].sg_fontset; ! # endif # endif - highlight_ga.ga_len = hlcnt + i + 1; - set_hl_attr(hlcnt + i); /* At long last we can apply */ - highlight_stlnc[i] = syn_id2attr(hlcnt + i + 1); # endif } } --- 10006,10026 ---- highlight_user[i] = 0; # ifdef FEAT_STL_OPT highlight_stlnc[i] = 0; + # ifdef FEAT_TERMINAL + highlight_stlterm[i] = 0; + # endif # endif } else { highlight_user[i] = syn_id2attr(id); # ifdef FEAT_STL_OPT ! combine_stl_hlt(id, id_S, id_SNC, hlcnt, i, ! HLF_SNC, highlight_stlnc); ! # ifdef FEAT_TERMINAL ! combine_stl_hlt(id, id_S, id_ST, hlcnt + 9, i, ! HLF_ST, highlight_stlterm); # endif # endif } } *** ../vim-8.0.0936/src/globals.h 2017-08-12 15:15:29.570927422 +0200 --- src/globals.h 2017-08-13 21:02:23.575023185 +0200 *************** *** 362,367 **** --- 362,370 ---- EXTERN int highlight_user[9]; /* User[1-9] attributes */ # ifdef FEAT_STL_OPT EXTERN int highlight_stlnc[9]; /* On top of user */ + # ifdef FEAT_TERMINAL + EXTERN int highlight_stlterm[9]; /* On top of user */ + # endif # endif #endif #ifdef FEAT_GUI *** ../vim-8.0.0936/src/screen.c 2017-08-05 18:19:51.050143054 +0200 --- src/screen.c 2017-08-13 21:05:36.241843377 +0200 *************** *** 7257,7262 **** --- 7257,7267 ---- else if (hltab[n].userhl < 0) curattr = syn_id2attr(-hltab[n].userhl); #ifdef FEAT_WINDOWS + # ifdef FEAT_TERMINAL + else if (wp != NULL && bt_terminal(wp->w_buffer) + && wp->w_status_height != 0) + curattr = highlight_stlterm[hltab[n].userhl - 1]; + # endif else if (wp != NULL && wp != curwin && wp->w_status_height != 0) curattr = highlight_stlnc[hltab[n].userhl - 1]; #endif *** ../vim-8.0.0936/src/version.c 2017-08-13 20:58:29.280457584 +0200 --- src/version.c 2017-08-13 21:01:44.599261879 +0200 *************** *** 771,772 **** --- 771,774 ---- { /* Add new patch number below this line */ + /**/ + 937, /**/ -- NEIL INNES PLAYED: THE FIRST SELF-DESTRUCTIVE MONK, ROBIN'S LEAST FAVORITE MINSTREL, THE PAGE CRUSHED BY A RABBIT, THE OWNER OF A DUCK "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///