comparison src/syntax.c @ 12385:972732a27d7c v8.0.1072

patch 8.0.1072: :highlight command causes a redraw even when nothing changed commit https://github.com/vim/vim/commit/99433291b135094d9592c41f96d3ccd60073e2c1 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Sep 8 12:37:47 2017 +0200 patch 8.0.1072: :highlight command causes a redraw even when nothing changed Problem: The :highlight command causes a redraw even when nothing changed. Solution: Only set "need_highlight_changed" when an attribute changed.
author Christian Brabandt <cb@256bit.org>
date Fri, 08 Sep 2017 12:45:04 +0200
parents 2a8890b80923
children 2bac51746e2b
comparison
equal deleted inserted replaced
12384:a9cf1e51c795 12385:972732a27d7c
7362 int off; 7362 int off;
7363 int len; 7363 int len;
7364 int attr; 7364 int attr;
7365 int id; 7365 int id;
7366 int idx; 7366 int idx;
7367 struct hl_group *item;
7368 struct hl_group item_before;
7367 int dodefault = FALSE; 7369 int dodefault = FALSE;
7368 int doclear = FALSE; 7370 int doclear = FALSE;
7369 int dolink = FALSE; 7371 int dolink = FALSE;
7370 int error = FALSE; 7372 int error = FALSE;
7371 int color; 7373 int color;
7457 EMSG2(_("E413: Too many arguments: \":highlight link %s\""), from_start); 7459 EMSG2(_("E413: Too many arguments: \":highlight link %s\""), from_start);
7458 return; 7460 return;
7459 } 7461 }
7460 7462
7461 from_id = syn_check_group(from_start, (int)(from_end - from_start)); 7463 from_id = syn_check_group(from_start, (int)(from_end - from_start));
7464 item = &HL_TABLE()[from_id - 1];
7462 if (STRNCMP(to_start, "NONE", 4) == 0) 7465 if (STRNCMP(to_start, "NONE", 4) == 0)
7463 to_id = 0; 7466 to_id = 0;
7464 else 7467 else
7465 to_id = syn_check_group(to_start, (int)(to_end - to_start)); 7468 to_id = syn_check_group(to_start, (int)(to_end - to_start));
7466 7469
7467 if (from_id > 0 && (!init || HL_TABLE()[from_id - 1].sg_set == 0)) 7470 if (from_id > 0 && (!init || item->sg_set == 0))
7468 { 7471 {
7469 /* 7472 /*
7470 * Don't allow a link when there already is some highlighting 7473 * Don't allow a link when there already is some highlighting
7471 * for the group, unless '!' is used 7474 * for the group, unless '!' is used
7472 */ 7475 */
7474 && hl_has_settings(from_id - 1, dodefault)) 7477 && hl_has_settings(from_id - 1, dodefault))
7475 { 7478 {
7476 if (sourcing_name == NULL && !dodefault) 7479 if (sourcing_name == NULL && !dodefault)
7477 EMSG(_("E414: group has settings, highlight link ignored")); 7480 EMSG(_("E414: group has settings, highlight link ignored"));
7478 } 7481 }
7479 else 7482 else if (item->sg_link != to_id
7483 #ifdef FEAT_EVAL
7484 || item->sg_scriptID != current_SID
7485 #endif
7486 || item->sg_cleared)
7480 { 7487 {
7481 if (!init) 7488 if (!init)
7482 HL_TABLE()[from_id - 1].sg_set |= SG_LINK; 7489 item->sg_set |= SG_LINK;
7483 HL_TABLE()[from_id - 1].sg_link = to_id; 7490 item->sg_link = to_id;
7484 #ifdef FEAT_EVAL 7491 #ifdef FEAT_EVAL
7485 HL_TABLE()[from_id - 1].sg_scriptID = current_SID; 7492 item->sg_scriptID = current_SID;
7486 #endif 7493 #endif
7487 HL_TABLE()[from_id - 1].sg_cleared = FALSE; 7494 item->sg_cleared = FALSE;
7488 redraw_all_later(SOME_VALID); 7495 redraw_all_later(SOME_VALID);
7489 } 7496
7490 } 7497 /* Only call highlight_changed() once after multiple changes. */
7491 7498 need_highlight_changed = TRUE;
7492 /* Only call highlight_changed() once, after sourcing a syntax file */ 7499 }
7493 need_highlight_changed = TRUE; 7500 }
7494 7501
7495 return; 7502 return;
7496 } 7503 }
7497 7504
7498 if (doclear) 7505 if (doclear)
7575 */ 7582 */
7576 id = syn_check_group(line, (int)(name_end - line)); 7583 id = syn_check_group(line, (int)(name_end - line));
7577 if (id == 0) /* failed (out of memory) */ 7584 if (id == 0) /* failed (out of memory) */
7578 return; 7585 return;
7579 idx = id - 1; /* index is ID minus one */ 7586 idx = id - 1; /* index is ID minus one */
7587 item = &HL_TABLE()[idx];
7580 7588
7581 /* Return if "default" was used and the group already has settings. */ 7589 /* Return if "default" was used and the group already has settings. */
7582 if (dodefault && hl_has_settings(idx, TRUE)) 7590 if (dodefault && hl_has_settings(idx, TRUE))
7583 return; 7591 return;
7584 7592
7585 if (STRCMP(HL_TABLE()[idx].sg_name_u, "NORMAL") == 0) 7593 /* Make a copy so we can check if any attribute actually changed. */
7594 item_before = *item;
7595
7596 if (STRCMP(item->sg_name_u, "NORMAL") == 0)
7586 is_normal_group = TRUE; 7597 is_normal_group = TRUE;
7587 #ifdef FEAT_GUI_X11 7598 #ifdef FEAT_GUI_X11
7588 else if (STRCMP(HL_TABLE()[idx].sg_name_u, "MENU") == 0) 7599 else if (STRCMP(item->sg_name_u, "MENU") == 0)
7589 is_menu_group = TRUE; 7600 is_menu_group = TRUE;
7590 else if (STRCMP(HL_TABLE()[idx].sg_name_u, "SCROLLBAR") == 0) 7601 else if (STRCMP(item->sg_name_u, "SCROLLBAR") == 0)
7591 is_scrollbar_group = TRUE; 7602 is_scrollbar_group = TRUE;
7592 else if (STRCMP(HL_TABLE()[idx].sg_name_u, "TOOLTIP") == 0) 7603 else if (STRCMP(item->sg_name_u, "TOOLTIP") == 0)
7593 is_tooltip_group = TRUE; 7604 is_tooltip_group = TRUE;
7594 #endif 7605 #endif
7595 7606
7596 /* Clear the highlighting for ":hi clear {group}" and ":hi clear". */ 7607 /* Clear the highlighting for ":hi clear {group}" and ":hi clear". */
7597 if (doclear || (forceit && init)) 7608 if (doclear || (forceit && init))
7598 { 7609 {
7599 highlight_clear(idx); 7610 highlight_clear(idx);
7600 if (!doclear) 7611 if (!doclear)
7601 HL_TABLE()[idx].sg_set = 0; 7612 item->sg_set = 0;
7602 } 7613 }
7603 7614
7604 if (!doclear) 7615 if (!doclear)
7605 while (!ends_excmd(*linep)) 7616 while (!ends_excmd(*linep))
7606 { 7617 {
7627 } 7638 }
7628 linep = skipwhite(linep); 7639 linep = skipwhite(linep);
7629 7640
7630 if (STRCMP(key, "NONE") == 0) 7641 if (STRCMP(key, "NONE") == 0)
7631 { 7642 {
7632 if (!init || HL_TABLE()[idx].sg_set == 0) 7643 if (!init || item->sg_set == 0)
7633 { 7644 {
7634 if (!init) 7645 if (!init)
7635 HL_TABLE()[idx].sg_set |= SG_TERM+SG_CTERM+SG_GUI; 7646 item->sg_set |= SG_TERM+SG_CTERM+SG_GUI;
7636 highlight_clear(idx); 7647 highlight_clear(idx);
7637 } 7648 }
7638 continue; 7649 continue;
7639 } 7650 }
7640 7651
7717 } 7728 }
7718 if (error) 7729 if (error)
7719 break; 7730 break;
7720 if (*key == 'T') 7731 if (*key == 'T')
7721 { 7732 {
7722 if (!init || !(HL_TABLE()[idx].sg_set & SG_TERM)) 7733 if (!init || !(item->sg_set & SG_TERM))
7723 { 7734 {
7724 if (!init) 7735 if (!init)
7725 HL_TABLE()[idx].sg_set |= SG_TERM; 7736 item->sg_set |= SG_TERM;
7726 HL_TABLE()[idx].sg_term = attr; 7737 item->sg_term = attr;
7727 } 7738 }
7728 } 7739 }
7729 else if (*key == 'C') 7740 else if (*key == 'C')
7730 { 7741 {
7731 if (!init || !(HL_TABLE()[idx].sg_set & SG_CTERM)) 7742 if (!init || !(item->sg_set & SG_CTERM))
7732 { 7743 {
7733 if (!init) 7744 if (!init)
7734 HL_TABLE()[idx].sg_set |= SG_CTERM; 7745 item->sg_set |= SG_CTERM;
7735 HL_TABLE()[idx].sg_cterm = attr; 7746 item->sg_cterm = attr;
7736 HL_TABLE()[idx].sg_cterm_bold = FALSE; 7747 item->sg_cterm_bold = FALSE;
7737 } 7748 }
7738 } 7749 }
7739 #if defined(FEAT_GUI) || defined(FEAT_EVAL) 7750 #if defined(FEAT_GUI) || defined(FEAT_EVAL)
7740 else 7751 else
7741 { 7752 {
7742 if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) 7753 if (!init || !(item->sg_set & SG_GUI))
7743 { 7754 {
7744 if (!init) 7755 if (!init)
7745 HL_TABLE()[idx].sg_set |= SG_GUI; 7756 item->sg_set |= SG_GUI;
7746 HL_TABLE()[idx].sg_gui = attr; 7757 item->sg_gui = attr;
7747 } 7758 }
7748 } 7759 }
7749 #endif 7760 #endif
7750 } 7761 }
7751 else if (STRCMP(key, "FONT") == 0) 7762 else if (STRCMP(key, "FONT") == 0)
7752 { 7763 {
7753 /* in non-GUI fonts are simply ignored */ 7764 /* in non-GUI fonts are simply ignored */
7754 #ifdef FEAT_GUI 7765 #ifdef FEAT_GUI
7755 if (!gui.shell_created) 7766 if (item->sg_font_name != NULL
7767 && STRCMP(item->sg_font_name, arg) == 0)
7768 {
7769 /* Font name didn't change, ignore. */
7770 }
7771 else if (!gui.shell_created)
7756 { 7772 {
7757 /* GUI not started yet, always accept the name. */ 7773 /* GUI not started yet, always accept the name. */
7758 vim_free(HL_TABLE()[idx].sg_font_name); 7774 vim_free(item->sg_font_name);
7759 HL_TABLE()[idx].sg_font_name = vim_strsave(arg); 7775 item->sg_font_name = vim_strsave(arg);
7760 } 7776 }
7761 else 7777 else
7762 { 7778 {
7763 GuiFont temp_sg_font = HL_TABLE()[idx].sg_font; 7779 GuiFont temp_sg_font = item->sg_font;
7764 # ifdef FEAT_XFONTSET 7780 # ifdef FEAT_XFONTSET
7765 GuiFontset temp_sg_fontset = HL_TABLE()[idx].sg_fontset; 7781 GuiFontset temp_sg_fontset = item->sg_fontset;
7766 # endif 7782 # endif
7767 /* First, save the current font/fontset. 7783 /* First, save the current font/fontset.
7768 * Then try to allocate the font/fontset. 7784 * Then try to allocate the font/fontset.
7769 * If the allocation fails, HL_TABLE()[idx].sg_font OR 7785 * If the allocation fails, item->sg_font OR
7770 * sg_fontset will be set to NOFONT or NOFONTSET respectively. 7786 * sg_fontset will be set to NOFONT or NOFONTSET respectively.
7771 */ 7787 */
7772 7788
7773 HL_TABLE()[idx].sg_font = NOFONT; 7789 item->sg_font = NOFONT;
7774 # ifdef FEAT_XFONTSET 7790 # ifdef FEAT_XFONTSET
7775 HL_TABLE()[idx].sg_fontset = NOFONTSET; 7791 item->sg_fontset = NOFONTSET;
7776 # endif 7792 # endif
7777 hl_do_font(idx, arg, is_normal_group, is_menu_group, 7793 hl_do_font(idx, arg, is_normal_group, is_menu_group,
7778 is_tooltip_group, FALSE); 7794 is_tooltip_group, FALSE);
7779 7795
7780 # ifdef FEAT_XFONTSET 7796 # ifdef FEAT_XFONTSET
7781 if (HL_TABLE()[idx].sg_fontset != NOFONTSET) 7797 if (item->sg_fontset != NOFONTSET)
7782 { 7798 {
7783 /* New fontset was accepted. Free the old one, if there 7799 /* New fontset was accepted. Free the old one, if there
7784 * was one. */ 7800 * was one. */
7785 gui_mch_free_fontset(temp_sg_fontset); 7801 gui_mch_free_fontset(temp_sg_fontset);
7786 vim_free(HL_TABLE()[idx].sg_font_name); 7802 vim_free(item->sg_font_name);
7787 HL_TABLE()[idx].sg_font_name = vim_strsave(arg); 7803 item->sg_font_name = vim_strsave(arg);
7788 } 7804 }
7789 else 7805 else
7790 HL_TABLE()[idx].sg_fontset = temp_sg_fontset; 7806 item->sg_fontset = temp_sg_fontset;
7791 # endif 7807 # endif
7792 if (HL_TABLE()[idx].sg_font != NOFONT) 7808 if (item->sg_font != NOFONT)
7793 { 7809 {
7794 /* New font was accepted. Free the old one, if there was 7810 /* New font was accepted. Free the old one, if there was
7795 * one. */ 7811 * one. */
7796 gui_mch_free_font(temp_sg_font); 7812 gui_mch_free_font(temp_sg_font);
7797 vim_free(HL_TABLE()[idx].sg_font_name); 7813 vim_free(item->sg_font_name);
7798 HL_TABLE()[idx].sg_font_name = vim_strsave(arg); 7814 item->sg_font_name = vim_strsave(arg);
7799 } 7815 }
7800 else 7816 else
7801 HL_TABLE()[idx].sg_font = temp_sg_font; 7817 item->sg_font = temp_sg_font;
7802 } 7818 }
7803 #endif 7819 #endif
7804 } 7820 }
7805 else if (STRCMP(key, "CTERMFG") == 0 || STRCMP(key, "CTERMBG") == 0) 7821 else if (STRCMP(key, "CTERMFG") == 0 || STRCMP(key, "CTERMBG") == 0)
7806 { 7822 {
7807 if (!init || !(HL_TABLE()[idx].sg_set & SG_CTERM)) 7823 if (!init || !(item->sg_set & SG_CTERM))
7808 { 7824 {
7809 if (!init) 7825 if (!init)
7810 HL_TABLE()[idx].sg_set |= SG_CTERM; 7826 item->sg_set |= SG_CTERM;
7811 7827
7812 /* When setting the foreground color, and previously the "bold" 7828 /* When setting the foreground color, and previously the "bold"
7813 * flag was set for a light color, reset it now */ 7829 * flag was set for a light color, reset it now */
7814 if (key[5] == 'F' && HL_TABLE()[idx].sg_cterm_bold) 7830 if (key[5] == 'F' && item->sg_cterm_bold)
7815 { 7831 {
7816 HL_TABLE()[idx].sg_cterm &= ~HL_BOLD; 7832 item->sg_cterm &= ~HL_BOLD;
7817 HL_TABLE()[idx].sg_cterm_bold = FALSE; 7833 item->sg_cterm_bold = FALSE;
7818 } 7834 }
7819 7835
7820 if (VIM_ISDIGIT(*arg)) 7836 if (VIM_ISDIGIT(*arg))
7821 color = atoi((char *)arg); 7837 color = atoi((char *)arg);
7822 else if (STRICMP(arg, "fg") == 0) 7838 else if (STRICMP(arg, "fg") == 0)
7869 7885
7870 /* set/reset bold attribute to get light foreground 7886 /* set/reset bold attribute to get light foreground
7871 * colors (on some terminals, e.g. "linux") */ 7887 * colors (on some terminals, e.g. "linux") */
7872 if (bold == TRUE) 7888 if (bold == TRUE)
7873 { 7889 {
7874 HL_TABLE()[idx].sg_cterm |= HL_BOLD; 7890 item->sg_cterm |= HL_BOLD;
7875 HL_TABLE()[idx].sg_cterm_bold = TRUE; 7891 item->sg_cterm_bold = TRUE;
7876 } 7892 }
7877 else if (bold == FALSE) 7893 else if (bold == FALSE)
7878 HL_TABLE()[idx].sg_cterm &= ~HL_BOLD; 7894 item->sg_cterm &= ~HL_BOLD;
7879 } 7895 }
7880 7896
7881 /* Add one to the argument, to avoid zero. Zero is used for 7897 /* Add one to the argument, to avoid zero. Zero is used for
7882 * "NONE", then "color" is -1. */ 7898 * "NONE", then "color" is -1. */
7883 if (key[5] == 'F') 7899 if (key[5] == 'F')
7884 { 7900 {
7885 HL_TABLE()[idx].sg_cterm_fg = color + 1; 7901 item->sg_cterm_fg = color + 1;
7886 if (is_normal_group) 7902 if (is_normal_group)
7887 { 7903 {
7888 cterm_normal_fg_color = color + 1; 7904 cterm_normal_fg_color = color + 1;
7889 cterm_normal_fg_bold = (HL_TABLE()[idx].sg_cterm & HL_BOLD); 7905 cterm_normal_fg_bold = (item->sg_cterm & HL_BOLD);
7890 #ifdef FEAT_GUI 7906 #ifdef FEAT_GUI
7891 /* Don't do this if the GUI is used. */ 7907 /* Don't do this if the GUI is used. */
7892 if (!gui.in_use && !gui.starting) 7908 if (!gui.in_use && !gui.starting)
7893 #endif 7909 #endif
7894 { 7910 {
7898 } 7914 }
7899 } 7915 }
7900 } 7916 }
7901 else 7917 else
7902 { 7918 {
7903 HL_TABLE()[idx].sg_cterm_bg = color + 1; 7919 item->sg_cterm_bg = color + 1;
7904 if (is_normal_group) 7920 if (is_normal_group)
7905 { 7921 {
7906 cterm_normal_bg_color = color + 1; 7922 cterm_normal_bg_color = color + 1;
7907 #ifdef FEAT_GUI 7923 #ifdef FEAT_GUI
7908 /* Don't mess with 'background' if the GUI is used. */ 7924 /* Don't mess with 'background' if the GUI is used. */
7938 } 7954 }
7939 } 7955 }
7940 else if (STRCMP(key, "GUIFG") == 0) 7956 else if (STRCMP(key, "GUIFG") == 0)
7941 { 7957 {
7942 #if defined(FEAT_GUI) || defined(FEAT_EVAL) 7958 #if defined(FEAT_GUI) || defined(FEAT_EVAL)
7943 if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) 7959 if (!init || !(item->sg_set & SG_GUI))
7944 { 7960 {
7945 if (!init) 7961 if (!init)
7946 HL_TABLE()[idx].sg_set |= SG_GUI; 7962 item->sg_set |= SG_GUI;
7947 7963
7948 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) 7964 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
7949 /* In GUI guifg colors are only used when recognized */ 7965 /* In GUI guifg colors are only used when recognized */
7950 i = color_name2handle(arg); 7966 i = color_name2handle(arg);
7951 if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !USE_24BIT) 7967 if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !USE_24BIT)
7952 { 7968 {
7953 HL_TABLE()[idx].sg_gui_fg = i; 7969 item->sg_gui_fg = i;
7954 # endif 7970 # endif
7955 vim_free(HL_TABLE()[idx].sg_gui_fg_name); 7971 vim_free(item->sg_gui_fg_name);
7956 if (STRCMP(arg, "NONE") != 0) 7972 if (STRCMP(arg, "NONE") != 0)
7957 HL_TABLE()[idx].sg_gui_fg_name = vim_strsave(arg); 7973 item->sg_gui_fg_name = vim_strsave(arg);
7958 else 7974 else
7959 HL_TABLE()[idx].sg_gui_fg_name = NULL; 7975 item->sg_gui_fg_name = NULL;
7960 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) 7976 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
7961 # ifdef FEAT_GUI_X11 7977 # ifdef FEAT_GUI_X11
7962 if (is_menu_group) 7978 if (is_menu_group)
7963 gui.menu_fg_pixel = i; 7979 gui.menu_fg_pixel = i;
7964 if (is_scrollbar_group) 7980 if (is_scrollbar_group)
7975 #endif 7991 #endif
7976 } 7992 }
7977 else if (STRCMP(key, "GUIBG") == 0) 7993 else if (STRCMP(key, "GUIBG") == 0)
7978 { 7994 {
7979 #if defined(FEAT_GUI) || defined(FEAT_EVAL) 7995 #if defined(FEAT_GUI) || defined(FEAT_EVAL)
7980 if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) 7996 if (!init || !(item->sg_set & SG_GUI))
7981 { 7997 {
7982 if (!init) 7998 if (!init)
7983 HL_TABLE()[idx].sg_set |= SG_GUI; 7999 item->sg_set |= SG_GUI;
7984 8000
7985 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) 8001 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
7986 /* In GUI guifg colors are only used when recognized */ 8002 /* In GUI guifg colors are only used when recognized */
7987 i = color_name2handle(arg); 8003 i = color_name2handle(arg);
7988 if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !USE_24BIT) 8004 if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !USE_24BIT)
7989 { 8005 {
7990 HL_TABLE()[idx].sg_gui_bg = i; 8006 item->sg_gui_bg = i;
7991 # endif 8007 # endif
7992 vim_free(HL_TABLE()[idx].sg_gui_bg_name); 8008 vim_free(item->sg_gui_bg_name);
7993 if (STRCMP(arg, "NONE") != 0) 8009 if (STRCMP(arg, "NONE") != 0)
7994 HL_TABLE()[idx].sg_gui_bg_name = vim_strsave(arg); 8010 item->sg_gui_bg_name = vim_strsave(arg);
7995 else 8011 else
7996 HL_TABLE()[idx].sg_gui_bg_name = NULL; 8012 item->sg_gui_bg_name = NULL;
7997 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) 8013 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
7998 # ifdef FEAT_GUI_X11 8014 # ifdef FEAT_GUI_X11
7999 if (is_menu_group) 8015 if (is_menu_group)
8000 gui.menu_bg_pixel = i; 8016 gui.menu_bg_pixel = i;
8001 if (is_scrollbar_group) 8017 if (is_scrollbar_group)
8012 #endif 8028 #endif
8013 } 8029 }
8014 else if (STRCMP(key, "GUISP") == 0) 8030 else if (STRCMP(key, "GUISP") == 0)
8015 { 8031 {
8016 #if defined(FEAT_GUI) || defined(FEAT_EVAL) 8032 #if defined(FEAT_GUI) || defined(FEAT_EVAL)
8017 if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) 8033 if (!init || !(item->sg_set & SG_GUI))
8018 { 8034 {
8019 if (!init) 8035 if (!init)
8020 HL_TABLE()[idx].sg_set |= SG_GUI; 8036 item->sg_set |= SG_GUI;
8021 8037
8022 # ifdef FEAT_GUI 8038 # ifdef FEAT_GUI
8023 i = color_name2handle(arg); 8039 i = color_name2handle(arg);
8024 if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !gui.in_use) 8040 if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !gui.in_use)
8025 { 8041 {
8026 HL_TABLE()[idx].sg_gui_sp = i; 8042 item->sg_gui_sp = i;
8027 # endif 8043 # endif
8028 vim_free(HL_TABLE()[idx].sg_gui_sp_name); 8044 vim_free(item->sg_gui_sp_name);
8029 if (STRCMP(arg, "NONE") != 0) 8045 if (STRCMP(arg, "NONE") != 0)
8030 HL_TABLE()[idx].sg_gui_sp_name = vim_strsave(arg); 8046 item->sg_gui_sp_name = vim_strsave(arg);
8031 else 8047 else
8032 HL_TABLE()[idx].sg_gui_sp_name = NULL; 8048 item->sg_gui_sp_name = NULL;
8033 # ifdef FEAT_GUI 8049 # ifdef FEAT_GUI
8034 } 8050 }
8035 # endif 8051 # endif
8036 } 8052 }
8037 #endif 8053 #endif
8040 { 8056 {
8041 char_u buf[100]; 8057 char_u buf[100];
8042 char_u *tname; 8058 char_u *tname;
8043 8059
8044 if (!init) 8060 if (!init)
8045 HL_TABLE()[idx].sg_set |= SG_TERM; 8061 item->sg_set |= SG_TERM;
8046 8062
8047 /* 8063 /*
8048 * The "start" and "stop" arguments can be a literal escape 8064 * The "start" and "stop" arguments can be a literal escape
8049 * sequence, or a comma separated list of terminal codes. 8065 * sequence, or a comma separated list of terminal codes.
8050 */ 8066 */
8107 p = NULL; 8123 p = NULL;
8108 else 8124 else
8109 p = vim_strsave(buf); 8125 p = vim_strsave(buf);
8110 if (key[2] == 'A') 8126 if (key[2] == 'A')
8111 { 8127 {
8112 vim_free(HL_TABLE()[idx].sg_start); 8128 vim_free(item->sg_start);
8113 HL_TABLE()[idx].sg_start = p; 8129 item->sg_start = p;
8114 } 8130 }
8115 else 8131 else
8116 { 8132 {
8117 vim_free(HL_TABLE()[idx].sg_stop); 8133 vim_free(item->sg_stop);
8118 HL_TABLE()[idx].sg_stop = p; 8134 item->sg_stop = p;
8119 } 8135 }
8120 } 8136 }
8121 else 8137 else
8122 { 8138 {
8123 EMSG2(_("E423: Illegal argument: %s"), key_start); 8139 EMSG2(_("E423: Illegal argument: %s"), key_start);
8124 error = TRUE; 8140 error = TRUE;
8125 break; 8141 break;
8126 } 8142 }
8127 HL_TABLE()[idx].sg_cleared = FALSE; 8143 item->sg_cleared = FALSE;
8128 8144
8129 /* 8145 /*
8130 * When highlighting has been given for a group, don't link it. 8146 * When highlighting has been given for a group, don't link it.
8131 */ 8147 */
8132 if (!init || !(HL_TABLE()[idx].sg_set & SG_LINK)) 8148 if (!init || !(item->sg_set & SG_LINK))
8133 HL_TABLE()[idx].sg_link = 0; 8149 item->sg_link = 0;
8134 8150
8135 /* 8151 /*
8136 * Continue with next argument. 8152 * Continue with next argument.
8137 */ 8153 */
8138 linep = skipwhite(linep); 8154 linep = skipwhite(linep);
8145 syn_unadd_group(); 8161 syn_unadd_group();
8146 else 8162 else
8147 { 8163 {
8148 if (is_normal_group) 8164 if (is_normal_group)
8149 { 8165 {
8150 HL_TABLE()[idx].sg_term_attr = 0; 8166 item->sg_term_attr = 0;
8151 HL_TABLE()[idx].sg_cterm_attr = 0; 8167 item->sg_cterm_attr = 0;
8152 #ifdef FEAT_GUI 8168 #ifdef FEAT_GUI
8153 HL_TABLE()[idx].sg_gui_attr = 0; 8169 item->sg_gui_attr = 0;
8154 /* 8170 /*
8155 * Need to update all groups, because they might be using "bg" 8171 * Need to update all groups, because they might be using "bg"
8156 * and/or "fg", which have been changed now. 8172 * and/or "fg", which have been changed now.
8157 */ 8173 */
8158 #endif 8174 #endif
8183 # endif 8199 # endif
8184 #endif 8200 #endif
8185 else 8201 else
8186 set_hl_attr(idx); 8202 set_hl_attr(idx);
8187 #ifdef FEAT_EVAL 8203 #ifdef FEAT_EVAL
8188 HL_TABLE()[idx].sg_scriptID = current_SID; 8204 item->sg_scriptID = current_SID;
8189 #endif 8205 #endif
8190 redraw_all_later(NOT_VALID); 8206 }
8191 } 8207
8192 vim_free(key); 8208 vim_free(key);
8193 vim_free(arg); 8209 vim_free(arg);
8194 8210
8195 /* Only call highlight_changed() once, after sourcing a syntax file */ 8211 /* Only call highlight_changed() once, after a sequence of highlight
8196 need_highlight_changed = TRUE; 8212 * commands, and only if an attribute actually changed. */
8213 if (memcmp(item, &item_before, sizeof(item_before)) != 0)
8214 {
8215 redraw_all_later(NOT_VALID);
8216 need_highlight_changed = TRUE;
8217 }
8197 } 8218 }
8198 8219
8199 #if defined(EXITFREE) || defined(PROTO) 8220 #if defined(EXITFREE) || defined(PROTO)
8200 void 8221 void
8201 free_highlight(void) 8222 free_highlight(void)