annotate src/highlight.c @ 17389:635d7f5010b8 v8.1.1693

patch 8.1.1693: syntax coloring and highlighting is in one big file commit https://github.com/vim/vim/commit/f9cc9f209ede9f15959e4c2351e970477c139614 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 14 21:29:22 2019 +0200 patch 8.1.1693: syntax coloring and highlighting is in one big file Problem: Syntax coloring and highlighting is in one big file. Solution: Move the highlighting to a separate file. (Yegappan Lakshmanan, closes #4674)
author Bram Moolenaar <Bram@vim.org>
date Sun, 14 Jul 2019 21:30:04 +0200
parents
children 5462bb963075
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17389
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 *
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 *
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 * Highlighting stuff
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 #include "vim.h"
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 #define SG_TERM 1 // term has been set
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 #define SG_CTERM 2 // cterm has been set
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 #define SG_GUI 4 // gui has been set
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 #define SG_LINK 8 // link has been set
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 * The "term", "cterm" and "gui" arguments can be any combination of the
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 * following names, separated by commas (but no spaces!).
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 static char *(hl_name_table[]) =
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 {"bold", "standout", "underline", "undercurl",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 "italic", "reverse", "inverse", "nocombine", "strikethrough", "NONE"};
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 static int hl_attr_table[] =
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 {HL_BOLD, HL_STANDOUT, HL_UNDERLINE, HL_UNDERCURL, HL_ITALIC, HL_INVERSE, HL_INVERSE, HL_NOCOMBINE, HL_STRIKETHROUGH, 0};
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 #define ATTR_COMBINE(attr_a, attr_b) ((((attr_b) & HL_NOCOMBINE) ? attr_b : (attr_a)) | (attr_b))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 static void syn_unadd_group(void);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 static void set_hl_attr(int idx);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 static void highlight_list_one(int id);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 static int highlight_list_arg(int id, int didh, int type, int iarg, char_u *sarg, char *name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 static int syn_add_group(char_u *name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 static int hl_has_settings(int idx, int check_link);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 static void highlight_clear(int idx);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 static void gui_do_one_color(int idx, int do_menu, int do_tooltip);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 static int set_group_colors(char_u *name, guicolor_T *fgp, guicolor_T *bgp, int do_menu, int use_norm, int do_tooltip);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 static void hl_do_font(int idx, char_u *arg, int do_normal, int do_menu, int do_tooltip, int free_font);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 * An attribute number is the index in attr_table plus ATTR_OFF.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 #define ATTR_OFF (HL_ALL + 1)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 * The default highlight groups. These are compiled-in for fast startup and
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 * they still work when the runtime files can't be found.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 * When making changes here, also change runtime/colors/default.vim!
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 * The #ifdefs are needed to reduce the amount of static data. Helps to make
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 * the 16 bit DOS (museum) version compile.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 #if defined(FEAT_GUI) || defined(FEAT_EVAL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 # define CENT(a, b) b
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 #else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 # define CENT(a, b) a
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 static char *(highlight_init_both[]) = {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 CENT("ErrorMsg term=standout ctermbg=DarkRed ctermfg=White",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 "ErrorMsg term=standout ctermbg=DarkRed ctermfg=White guibg=Red guifg=White"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 CENT("IncSearch term=reverse cterm=reverse",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 "IncSearch term=reverse cterm=reverse gui=reverse"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 CENT("ModeMsg term=bold cterm=bold",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 "ModeMsg term=bold cterm=bold gui=bold"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 CENT("NonText term=bold ctermfg=Blue",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 "NonText term=bold ctermfg=Blue gui=bold guifg=Blue"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 CENT("StatusLine term=reverse,bold cterm=reverse,bold",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 "StatusLine term=reverse,bold cterm=reverse,bold gui=reverse,bold"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 CENT("StatusLineNC term=reverse cterm=reverse",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 "StatusLineNC term=reverse cterm=reverse gui=reverse"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 "default link EndOfBuffer NonText",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 CENT("VertSplit term=reverse cterm=reverse",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 "VertSplit term=reverse cterm=reverse gui=reverse"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 #ifdef FEAT_CLIPBOARD
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 CENT("VisualNOS term=underline,bold cterm=underline,bold",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 "VisualNOS term=underline,bold cterm=underline,bold gui=underline,bold"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 #ifdef FEAT_DIFF
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 CENT("DiffText term=reverse cterm=bold ctermbg=Red",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 "DiffText term=reverse cterm=bold ctermbg=Red gui=bold guibg=Red"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 #ifdef FEAT_INS_EXPAND
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 CENT("PmenuSbar ctermbg=Grey",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 "PmenuSbar ctermbg=Grey guibg=Grey"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 CENT("TabLineSel term=bold cterm=bold",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 "TabLineSel term=bold cterm=bold gui=bold"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 CENT("TabLineFill term=reverse cterm=reverse",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 "TabLineFill term=reverse cterm=reverse gui=reverse"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 "Cursor guibg=fg guifg=bg",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 "lCursor guibg=fg guifg=bg", // should be different, but what?
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 "default link QuickFixLine Search",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 CENT("Normal cterm=NONE", "Normal gui=NONE"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 NULL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 };
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 /* Default colors only used with a light background. */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 static char *(highlight_init_light[]) = {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 CENT("Directory term=bold ctermfg=DarkBlue",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 "Directory term=bold ctermfg=DarkBlue guifg=Blue"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 CENT("LineNr term=underline ctermfg=Brown",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 "LineNr term=underline ctermfg=Brown guifg=Brown"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 CENT("CursorLineNr term=bold ctermfg=Brown",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 "CursorLineNr term=bold ctermfg=Brown gui=bold guifg=Brown"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 CENT("MoreMsg term=bold ctermfg=DarkGreen",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 "MoreMsg term=bold ctermfg=DarkGreen gui=bold guifg=SeaGreen"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 CENT("Question term=standout ctermfg=DarkGreen",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 "Question term=standout ctermfg=DarkGreen gui=bold guifg=SeaGreen"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 CENT("Search term=reverse ctermbg=Yellow ctermfg=NONE",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 "Search term=reverse ctermbg=Yellow ctermfg=NONE guibg=Yellow guifg=NONE"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 #ifdef FEAT_SPELL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 CENT("SpellBad term=reverse ctermbg=LightRed",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 "SpellBad term=reverse ctermbg=LightRed guisp=Red gui=undercurl"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 CENT("SpellCap term=reverse ctermbg=LightBlue",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 "SpellCap term=reverse ctermbg=LightBlue guisp=Blue gui=undercurl"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125 CENT("SpellRare term=reverse ctermbg=LightMagenta",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 "SpellRare term=reverse ctermbg=LightMagenta guisp=Magenta gui=undercurl"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 CENT("SpellLocal term=underline ctermbg=Cyan",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 "SpellLocal term=underline ctermbg=Cyan guisp=DarkCyan gui=undercurl"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 #ifdef FEAT_INS_EXPAND
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 CENT("PmenuThumb ctermbg=Black",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 "PmenuThumb ctermbg=Black guibg=Black"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 CENT("Pmenu ctermbg=LightMagenta ctermfg=Black",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 "Pmenu ctermbg=LightMagenta ctermfg=Black guibg=LightMagenta"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 CENT("PmenuSel ctermbg=LightGrey ctermfg=Black",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 "PmenuSel ctermbg=LightGrey ctermfg=Black guibg=Grey"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 CENT("SpecialKey term=bold ctermfg=DarkBlue",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 "SpecialKey term=bold ctermfg=DarkBlue guifg=Blue"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 CENT("Title term=bold ctermfg=DarkMagenta",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 "Title term=bold ctermfg=DarkMagenta gui=bold guifg=Magenta"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 CENT("WarningMsg term=standout ctermfg=DarkRed",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 "WarningMsg term=standout ctermfg=DarkRed guifg=Red"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 #ifdef FEAT_WILDMENU
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 CENT("WildMenu term=standout ctermbg=Yellow ctermfg=Black",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 "WildMenu term=standout ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 #ifdef FEAT_FOLDING
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 CENT("Folded term=standout ctermbg=Grey ctermfg=DarkBlue",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 "Folded term=standout ctermbg=Grey ctermfg=DarkBlue guibg=LightGrey guifg=DarkBlue"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 CENT("FoldColumn term=standout ctermbg=Grey ctermfg=DarkBlue",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 "FoldColumn term=standout ctermbg=Grey ctermfg=DarkBlue guibg=Grey guifg=DarkBlue"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 #ifdef FEAT_SIGNS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 CENT("SignColumn term=standout ctermbg=Grey ctermfg=DarkBlue",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 "SignColumn term=standout ctermbg=Grey ctermfg=DarkBlue guibg=Grey guifg=DarkBlue"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 CENT("Visual term=reverse",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 "Visual term=reverse guibg=LightGrey"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 #ifdef FEAT_DIFF
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 CENT("DiffAdd term=bold ctermbg=LightBlue",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 "DiffAdd term=bold ctermbg=LightBlue guibg=LightBlue"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163 CENT("DiffChange term=bold ctermbg=LightMagenta",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164 "DiffChange term=bold ctermbg=LightMagenta guibg=LightMagenta"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 CENT("DiffDelete term=bold ctermfg=Blue ctermbg=LightCyan",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 "DiffDelete term=bold ctermfg=Blue ctermbg=LightCyan gui=bold guifg=Blue guibg=LightCyan"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 CENT("TabLine term=underline cterm=underline ctermfg=black ctermbg=LightGrey",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 "TabLine term=underline cterm=underline ctermfg=black ctermbg=LightGrey gui=underline guibg=LightGrey"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 #ifdef FEAT_SYN_HL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 CENT("CursorColumn term=reverse ctermbg=LightGrey",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172 "CursorColumn term=reverse ctermbg=LightGrey guibg=Grey90"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 CENT("CursorLine term=underline cterm=underline",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 "CursorLine term=underline cterm=underline guibg=Grey90"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 CENT("ColorColumn term=reverse ctermbg=LightRed",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 "ColorColumn term=reverse ctermbg=LightRed guibg=LightRed"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 #ifdef FEAT_CONCEAL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 CENT("Conceal ctermbg=DarkGrey ctermfg=LightGrey",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180 "Conceal ctermbg=DarkGrey ctermfg=LightGrey guibg=DarkGrey guifg=LightGrey"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 CENT("MatchParen term=reverse ctermbg=Cyan",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
183 "MatchParen term=reverse ctermbg=Cyan guibg=Cyan"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184 #ifdef FEAT_TERMINAL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 CENT("StatusLineTerm term=reverse,bold cterm=bold ctermfg=White ctermbg=DarkGreen",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 "StatusLineTerm term=reverse,bold cterm=bold ctermfg=White ctermbg=DarkGreen gui=bold guifg=bg guibg=DarkGreen"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 CENT("StatusLineTermNC term=reverse ctermfg=White ctermbg=DarkGreen",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188 "StatusLineTermNC term=reverse ctermfg=White ctermbg=DarkGreen guifg=bg guibg=DarkGreen"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 #ifdef FEAT_MENU
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 CENT("ToolbarLine term=underline ctermbg=LightGrey",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 "ToolbarLine term=underline ctermbg=LightGrey guibg=LightGrey"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 CENT("ToolbarButton cterm=bold ctermfg=White ctermbg=DarkGrey",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194 "ToolbarButton cterm=bold ctermfg=White ctermbg=DarkGrey gui=bold guifg=White guibg=Grey40"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196 NULL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 };
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199 /* Default colors only used with a dark background. */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 static char *(highlight_init_dark[]) = {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 CENT("Directory term=bold ctermfg=LightCyan",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 "Directory term=bold ctermfg=LightCyan guifg=Cyan"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203 CENT("LineNr term=underline ctermfg=Yellow",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204 "LineNr term=underline ctermfg=Yellow guifg=Yellow"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 CENT("CursorLineNr term=bold ctermfg=Yellow",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 "CursorLineNr term=bold ctermfg=Yellow gui=bold guifg=Yellow"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 CENT("MoreMsg term=bold ctermfg=LightGreen",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208 "MoreMsg term=bold ctermfg=LightGreen gui=bold guifg=SeaGreen"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 CENT("Question term=standout ctermfg=LightGreen",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 "Question term=standout ctermfg=LightGreen gui=bold guifg=Green"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211 CENT("Search term=reverse ctermbg=Yellow ctermfg=Black",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212 "Search term=reverse ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 CENT("SpecialKey term=bold ctermfg=LightBlue",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 "SpecialKey term=bold ctermfg=LightBlue guifg=Cyan"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 #ifdef FEAT_SPELL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 CENT("SpellBad term=reverse ctermbg=Red",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 "SpellBad term=reverse ctermbg=Red guisp=Red gui=undercurl"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218 CENT("SpellCap term=reverse ctermbg=Blue",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 "SpellCap term=reverse ctermbg=Blue guisp=Blue gui=undercurl"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 CENT("SpellRare term=reverse ctermbg=Magenta",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221 "SpellRare term=reverse ctermbg=Magenta guisp=Magenta gui=undercurl"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 CENT("SpellLocal term=underline ctermbg=Cyan",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 "SpellLocal term=underline ctermbg=Cyan guisp=Cyan gui=undercurl"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225 #ifdef FEAT_INS_EXPAND
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226 CENT("PmenuThumb ctermbg=White",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 "PmenuThumb ctermbg=White guibg=White"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228 CENT("Pmenu ctermbg=Magenta ctermfg=Black",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 "Pmenu ctermbg=Magenta ctermfg=Black guibg=Magenta"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 CENT("PmenuSel ctermbg=Black ctermfg=DarkGrey",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 "PmenuSel ctermbg=Black ctermfg=DarkGrey guibg=DarkGrey"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233 CENT("Title term=bold ctermfg=LightMagenta",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 "Title term=bold ctermfg=LightMagenta gui=bold guifg=Magenta"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 CENT("WarningMsg term=standout ctermfg=LightRed",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 "WarningMsg term=standout ctermfg=LightRed guifg=Red"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 #ifdef FEAT_WILDMENU
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238 CENT("WildMenu term=standout ctermbg=Yellow ctermfg=Black",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 "WildMenu term=standout ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241 #ifdef FEAT_FOLDING
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242 CENT("Folded term=standout ctermbg=DarkGrey ctermfg=Cyan",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243 "Folded term=standout ctermbg=DarkGrey ctermfg=Cyan guibg=DarkGrey guifg=Cyan"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244 CENT("FoldColumn term=standout ctermbg=DarkGrey ctermfg=Cyan",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 "FoldColumn term=standout ctermbg=DarkGrey ctermfg=Cyan guibg=Grey guifg=Cyan"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247 #ifdef FEAT_SIGNS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 CENT("SignColumn term=standout ctermbg=DarkGrey ctermfg=Cyan",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249 "SignColumn term=standout ctermbg=DarkGrey ctermfg=Cyan guibg=Grey guifg=Cyan"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 CENT("Visual term=reverse",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 "Visual term=reverse guibg=DarkGrey"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253 #ifdef FEAT_DIFF
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254 CENT("DiffAdd term=bold ctermbg=DarkBlue",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 "DiffAdd term=bold ctermbg=DarkBlue guibg=DarkBlue"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256 CENT("DiffChange term=bold ctermbg=DarkMagenta",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 "DiffChange term=bold ctermbg=DarkMagenta guibg=DarkMagenta"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258 CENT("DiffDelete term=bold ctermfg=Blue ctermbg=DarkCyan",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259 "DiffDelete term=bold ctermfg=Blue ctermbg=DarkCyan gui=bold guifg=Blue guibg=DarkCyan"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 CENT("TabLine term=underline cterm=underline ctermfg=white ctermbg=DarkGrey",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262 "TabLine term=underline cterm=underline ctermfg=white ctermbg=DarkGrey gui=underline guibg=DarkGrey"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 #ifdef FEAT_SYN_HL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 CENT("CursorColumn term=reverse ctermbg=DarkGrey",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265 "CursorColumn term=reverse ctermbg=DarkGrey guibg=Grey40"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 CENT("CursorLine term=underline cterm=underline",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267 "CursorLine term=underline cterm=underline guibg=Grey40"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 CENT("ColorColumn term=reverse ctermbg=DarkRed",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 "ColorColumn term=reverse ctermbg=DarkRed guibg=DarkRed"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
270 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 CENT("MatchParen term=reverse ctermbg=DarkCyan",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272 "MatchParen term=reverse ctermbg=DarkCyan guibg=DarkCyan"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 #ifdef FEAT_CONCEAL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274 CENT("Conceal ctermbg=DarkGrey ctermfg=LightGrey",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 "Conceal ctermbg=DarkGrey ctermfg=LightGrey guibg=DarkGrey guifg=LightGrey"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
276 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277 #ifdef FEAT_TERMINAL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278 CENT("StatusLineTerm term=reverse,bold cterm=bold ctermfg=Black ctermbg=LightGreen",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 "StatusLineTerm term=reverse,bold cterm=bold ctermfg=Black ctermbg=LightGreen gui=bold guifg=bg guibg=LightGreen"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280 CENT("StatusLineTermNC term=reverse ctermfg=Black ctermbg=LightGreen",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 "StatusLineTermNC term=reverse ctermfg=Black ctermbg=LightGreen guifg=bg guibg=LightGreen"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283 #ifdef FEAT_MENU
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284 CENT("ToolbarLine term=underline ctermbg=DarkGrey",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285 "ToolbarLine term=underline ctermbg=DarkGrey guibg=Grey50"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286 CENT("ToolbarButton cterm=bold ctermfg=Black ctermbg=LightGrey",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 "ToolbarButton cterm=bold ctermfg=Black ctermbg=LightGrey gui=bold guifg=Black guibg=LightGrey"),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
289 NULL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290 };
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292 void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
293 init_highlight(
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
294 int both, // include groups where 'bg' doesn't matter
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
295 int reset) // clear group first
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
296 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
297 int i;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
298 char **pp;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
299 static int had_both = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300 #ifdef FEAT_EVAL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
301 char_u *p;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
302
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
303 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
304 * Try finding the color scheme file. Used when a color file was loaded
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305 * and 'background' or 't_Co' is changed.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307 p = get_var_value((char_u *)"g:colors_name");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 if (p != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 // The value of g:colors_name could be freed when sourcing the script,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311 // making "p" invalid, so copy it.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312 char_u *copy_p = vim_strsave(p);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
313 int r;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
314
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315 if (copy_p != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317 r = load_colors(copy_p);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
318 vim_free(copy_p);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319 if (r == OK)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320 return;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
321 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
323
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
327 * Didn't use a color file, use the compiled-in colors.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
328 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
329 if (both)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
330 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
331 had_both = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
332 pp = highlight_init_both;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
333 for (i = 0; pp[i] != NULL; ++i)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
334 do_highlight((char_u *)pp[i], reset, TRUE);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
335 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
336 else if (!had_both)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
337 // Don't do anything before the call with both == TRUE from main().
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
338 // Not everything has been setup then, and that call will overrule
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339 // everything anyway.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
340 return;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
342 if (*p_bg == 'l')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343 pp = highlight_init_light;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
345 pp = highlight_init_dark;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346 for (i = 0; pp[i] != NULL; ++i)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
347 do_highlight((char_u *)pp[i], reset, TRUE);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349 // Reverse looks ugly, but grey may not work for 8 colors. Thus let it
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
350 // depend on the number of colors available.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
351 // With 8 colors brown is equal to yellow, need to use black for Search fg
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
352 // to avoid Statement highlighted text disappears.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
353 // Clear the attributes, needed when changing the t_Co value.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
354 if (t_colors > 8)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
355 do_highlight((char_u *)(*p_bg == 'l'
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
356 ? "Visual cterm=NONE ctermbg=LightGrey"
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
357 : "Visual cterm=NONE ctermbg=DarkGrey"), FALSE, TRUE);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
358 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
359 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
360 do_highlight((char_u *)"Visual cterm=reverse ctermbg=NONE",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
361 FALSE, TRUE);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
362 if (*p_bg == 'l')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
363 do_highlight((char_u *)"Search ctermfg=black", FALSE, TRUE);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
364 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
366 #ifdef FEAT_SYN_HL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
367 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368 * If syntax highlighting is enabled load the highlighting for it.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
370 if (get_var_value((char_u *)"g:syntax_on") != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
371 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372 static int recursive = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
373
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
374 if (recursive >= 5)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375 emsg(_("E679: recursive loop loading syncolor.vim"));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
376 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
377 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
378 ++recursive;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
379 (void)source_runtime((char_u *)"syntax/syncolor.vim", DIP_ALL);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
380 --recursive;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
381 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387 * Load color file "name".
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 * Return OK for success, FAIL for failure.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391 load_colors(char_u *name)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 char_u *buf;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 int retval = FAIL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 static int recursive = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
397 // When being called recursively, this is probably because setting
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398 // 'background' caused the highlighting to be reloaded. This means it is
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399 // working, thus we should return OK.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
400 if (recursive)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401 return OK;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
402
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
403 recursive = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404 buf = alloc(STRLEN(name) + 12);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
405 if (buf != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407 apply_autocmds(EVENT_COLORSCHEMEPRE, name,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
408 curbuf->b_fname, FALSE, curbuf);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
409 sprintf((char *)buf, "colors/%s.vim", name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410 retval = source_runtime(buf, DIP_START + DIP_OPT);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
411 vim_free(buf);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412 apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, FALSE, curbuf);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
413 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 recursive = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 return retval;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419 static char *(color_names[28]) = {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 "Black", "DarkBlue", "DarkGreen", "DarkCyan",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 "DarkRed", "DarkMagenta", "Brown", "DarkYellow",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
422 "Gray", "Grey", "LightGray", "LightGrey",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 "DarkGray", "DarkGrey",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424 "Blue", "LightBlue", "Green", "LightGreen",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425 "Cyan", "LightCyan", "Red", "LightRed", "Magenta",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426 "LightMagenta", "Yellow", "LightYellow", "White", "NONE"};
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427 // indices:
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 // 0, 1, 2, 3,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 // 4, 5, 6, 7,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
430 // 8, 9, 10, 11,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
431 // 12, 13,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
432 // 14, 15, 16, 17,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
433 // 18, 19, 20, 21, 22,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
434 // 23, 24, 25, 26, 27
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
435 static int color_numbers_16[28] = {0, 1, 2, 3,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
436 4, 5, 6, 6,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
437 7, 7, 7, 7,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
438 8, 8,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
439 9, 9, 10, 10,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
440 11, 11, 12, 12, 13,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
441 13, 14, 14, 15, -1};
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
442 // for xterm with 88 colors...
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
443 static int color_numbers_88[28] = {0, 4, 2, 6,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444 1, 5, 32, 72,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
445 84, 84, 7, 7,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446 82, 82,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
447 12, 43, 10, 61,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
448 14, 63, 9, 74, 13,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
449 75, 11, 78, 15, -1};
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
450 // for xterm with 256 colors...
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
451 static int color_numbers_256[28] = {0, 4, 2, 6,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
452 1, 5, 130, 130,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453 248, 248, 7, 7,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454 242, 242,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
455 12, 81, 10, 121,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456 14, 159, 9, 224, 13,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
457 225, 11, 229, 15, -1};
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
458 // for terminals with less than 16 colors...
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
459 static int color_numbers_8[28] = {0, 4, 2, 6,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
460 1, 5, 3, 3,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 7, 7, 7, 7,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
462 0+8, 0+8,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463 4+8, 4+8, 2+8, 2+8,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464 6+8, 6+8, 1+8, 1+8, 5+8,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 5+8, 3+8, 3+8, 7+8, -1};
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
466
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
468 * Lookup the "cterm" value to be used for color with index "idx" in
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
469 * color_names[].
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470 * "boldp" will be set to TRUE or FALSE for a foreground color when using 8
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
471 * colors, otherwise it will be unchanged.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
473 int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
474 lookup_color(int idx, int foreground, int *boldp)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
476 int color = color_numbers_16[idx];
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 char_u *p;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
479 // Use the _16 table to check if it's a valid color name.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480 if (color < 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481 return -1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
483 if (t_colors == 8)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
484 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
485 // t_Co is 8: use the 8 colors table
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
486 #if defined(__QNXNTO__)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487 color = color_numbers_8_qansi[idx];
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488 #else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 color = color_numbers_8[idx];
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
491 if (foreground)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 // set/reset bold attribute to get light foreground
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
494 // colors (on some terminals, e.g. "linux")
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
495 if (color & 8)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
496 *boldp = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
497 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
498 *boldp = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
500 color &= 7; // truncate to 8 colors
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
502 else if (t_colors == 16 || t_colors == 88
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
503 || t_colors >= 256)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
504 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
505 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
506 * Guess: if the termcap entry ends in 'm', it is
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
507 * probably an xterm-like terminal. Use the changed
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
508 * order for colors.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
509 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
510 if (*T_CAF != NUL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511 p = T_CAF;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
512 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
513 p = T_CSF;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
514 if (*p != NUL && (t_colors > 256
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
515 || *(p + STRLEN(p) - 1) == 'm'))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
517 if (t_colors == 88)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
518 color = color_numbers_88[idx];
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
519 else if (t_colors >= 256)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
520 color = color_numbers_256[idx];
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
521 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
522 color = color_numbers_8[idx];
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
523 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
524 #ifdef FEAT_TERMRESPONSE
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
525 if (t_colors >= 256 && color == 15 && is_mac_terminal)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
526 // Terminal.app has a bug: 15 is light grey. Use white
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
527 // from the color cube instead.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
528 color = 231;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
529 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
530 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
531 return color;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
532 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
533
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
534 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
535 * Handle the ":highlight .." command.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
536 * When using ":hi clear" this is called recursively for each group with
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
537 * "forceit" and "init" both TRUE.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
538 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
539 void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
540 do_highlight(
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
541 char_u *line,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
542 int forceit,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
543 int init) // TRUE when called for initializing
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
544 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
545 char_u *name_end;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
546 char_u *p;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
547 char_u *linep;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
548 char_u *key_start;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
549 char_u *arg_start;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
550 char_u *key = NULL, *arg = NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
551 long i;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
552 int off;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
553 int len;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
554 int attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
555 int id;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
556 int idx;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
557 hl_group_T item_before;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
558 int did_change = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
559 int dodefault = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
560 int doclear = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
561 int dolink = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
562 int error = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
563 int color;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
564 int is_normal_group = FALSE; // "Normal" group
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
565 #ifdef FEAT_TERMINAL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
566 int is_terminal_group = FALSE; // "Terminal" group
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
567 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
568 #ifdef FEAT_GUI_X11
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
569 int is_menu_group = FALSE; // "Menu" group
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
570 int is_scrollbar_group = FALSE; // "Scrollbar" group
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
571 int is_tooltip_group = FALSE; // "Tooltip" group
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
572 int do_colors = FALSE; // need to update colors?
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
573 #else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
574 # define is_menu_group 0
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
575 # define is_tooltip_group 0
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
576 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
577 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
578 int did_highlight_changed = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
579 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
580
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
581 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
582 * If no argument, list current highlighting.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
583 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
584 if (ends_excmd(*line))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
585 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
586 for (i = 1; i <= highlight_ga.ga_len && !got_int; ++i)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
587 // TODO: only call when the group has attributes set
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
588 highlight_list_one((int)i);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
589 return;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
590 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
591
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
592 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
593 * Isolate the name.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
594 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
595 name_end = skiptowhite(line);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
596 linep = skipwhite(name_end);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
597
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
598 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
599 * Check for "default" argument.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
600 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
601 if (STRNCMP(line, "default", name_end - line) == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
602 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
603 dodefault = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
604 line = linep;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
605 name_end = skiptowhite(line);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
606 linep = skipwhite(name_end);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
607 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
608
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
609 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
610 * Check for "clear" or "link" argument.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
611 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
612 if (STRNCMP(line, "clear", name_end - line) == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
613 doclear = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
614 if (STRNCMP(line, "link", name_end - line) == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
615 dolink = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
616
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
617 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
618 * ":highlight {group-name}": list highlighting for one group.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
619 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
620 if (!doclear && !dolink && ends_excmd(*linep))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
621 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
622 id = syn_namen2id(line, (int)(name_end - line));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
623 if (id == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
624 semsg(_("E411: highlight group not found: %s"), line);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
625 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
626 highlight_list_one(id);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
627 return;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
628 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
629
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
630 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
631 * Handle ":highlight link {from} {to}" command.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
632 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
633 if (dolink)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
634 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
635 char_u *from_start = linep;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
636 char_u *from_end;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
637 char_u *to_start;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
638 char_u *to_end;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
639 int from_id;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
640 int to_id;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
641
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
642 from_end = skiptowhite(from_start);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
643 to_start = skipwhite(from_end);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
644 to_end = skiptowhite(to_start);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
645
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
646 if (ends_excmd(*from_start) || ends_excmd(*to_start))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
647 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
648 semsg(_("E412: Not enough arguments: \":highlight link %s\""),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
649 from_start);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
650 return;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
651 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
652
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
653 if (!ends_excmd(*skipwhite(to_end)))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
654 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
655 semsg(_("E413: Too many arguments: \":highlight link %s\""), from_start);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
656 return;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
657 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
658
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
659 from_id = syn_check_group(from_start, (int)(from_end - from_start));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
660 if (STRNCMP(to_start, "NONE", 4) == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
661 to_id = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
662 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
663 to_id = syn_check_group(to_start, (int)(to_end - to_start));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
664
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
665 if (from_id > 0 && (!init || HL_TABLE()[from_id - 1].sg_set == 0))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
666 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
667 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
668 * Don't allow a link when there already is some highlighting
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
669 * for the group, unless '!' is used
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
670 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
671 if (to_id > 0 && !forceit && !init
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
672 && hl_has_settings(from_id - 1, dodefault))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
673 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
674 if (sourcing_name == NULL && !dodefault)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
675 emsg(_("E414: group has settings, highlight link ignored"));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
676 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
677 else if (HL_TABLE()[from_id - 1].sg_link != to_id
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
678 #ifdef FEAT_EVAL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
679 || HL_TABLE()[from_id - 1].sg_script_ctx.sc_sid
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
680 != current_sctx.sc_sid
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
681 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
682 || HL_TABLE()[from_id - 1].sg_cleared)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
683 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
684 if (!init)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
685 HL_TABLE()[from_id - 1].sg_set |= SG_LINK;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
686 HL_TABLE()[from_id - 1].sg_link = to_id;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
687 #ifdef FEAT_EVAL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
688 HL_TABLE()[from_id - 1].sg_script_ctx = current_sctx;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
689 HL_TABLE()[from_id - 1].sg_script_ctx.sc_lnum += sourcing_lnum;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
690 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
691 HL_TABLE()[from_id - 1].sg_cleared = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
692 redraw_all_later(SOME_VALID);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
693
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
694 // Only call highlight_changed() once after multiple changes.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
695 need_highlight_changed = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
696 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
697 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
698
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
699 return;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
700 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
701
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
702 if (doclear)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
703 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
704 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
705 * ":highlight clear [group]" command.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
706 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
707 line = linep;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
708 if (ends_excmd(*line))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
709 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
710 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
711 // First, we do not destroy the old values, but allocate the new
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
712 // ones and update the display. THEN we destroy the old values.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
713 // If we destroy the old values first, then the old values
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
714 // (such as GuiFont's or GuiFontset's) will still be displayed but
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
715 // invalid because they were free'd.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
716 if (gui.in_use)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
717 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
718 # ifdef FEAT_BEVAL_TIP
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
719 gui_init_tooltip_font();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
720 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
721 # if defined(FEAT_MENU) && (defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MOTIF))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
722 gui_init_menu_font();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
723 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
724 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
725 # if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_X11)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
726 gui_mch_def_colors();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
727 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
728 # ifdef FEAT_GUI_X11
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
729 # ifdef FEAT_MENU
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
730
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
731 // This only needs to be done when there is no Menu highlight
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
732 // group defined by default, which IS currently the case.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
733 gui_mch_new_menu_colors();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
734 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
735 if (gui.in_use)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
736 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
737 gui_new_scrollbar_colors();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
738 # ifdef FEAT_BEVAL_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
739 gui_mch_new_tooltip_colors();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
740 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
741 # ifdef FEAT_MENU
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
742 gui_mch_new_menu_font();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
743 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
744 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
745 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
746
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
747 // Ok, we're done allocating the new default graphics items.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
748 // The screen should already be refreshed at this point.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
749 // It is now Ok to clear out the old data.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
750 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
751 #ifdef FEAT_EVAL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
752 do_unlet((char_u *)"colors_name", TRUE);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
753 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
754 restore_cterm_colors();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
755
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
756 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
757 * Clear all default highlight groups and load the defaults.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
758 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
759 for (idx = 0; idx < highlight_ga.ga_len; ++idx)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
760 highlight_clear(idx);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
761 init_highlight(TRUE, TRUE);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
762 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
763 if (USE_24BIT)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
764 highlight_gui_started();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
765 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
766 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
767 highlight_changed();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
768 redraw_later_clear();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
769 return;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
770 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
771 name_end = skiptowhite(line);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
772 linep = skipwhite(name_end);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
773 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
774
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
775 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
776 * Find the group name in the table. If it does not exist yet, add it.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
777 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
778 id = syn_check_group(line, (int)(name_end - line));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
779 if (id == 0) // failed (out of memory)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
780 return;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
781 idx = id - 1; // index is ID minus one
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
782
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
783 // Return if "default" was used and the group already has settings.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
784 if (dodefault && hl_has_settings(idx, TRUE))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
785 return;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
786
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
787 // Make a copy so we can check if any attribute actually changed.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
788 item_before = HL_TABLE()[idx];
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
789
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
790 if (STRCMP(HL_TABLE()[idx].sg_name_u, "NORMAL") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
791 is_normal_group = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
792 #ifdef FEAT_TERMINAL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
793 else if (STRCMP(HL_TABLE()[idx].sg_name_u, "TERMINAL") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
794 is_terminal_group = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
795 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
796 #ifdef FEAT_GUI_X11
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
797 else if (STRCMP(HL_TABLE()[idx].sg_name_u, "MENU") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
798 is_menu_group = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
799 else if (STRCMP(HL_TABLE()[idx].sg_name_u, "SCROLLBAR") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
800 is_scrollbar_group = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
801 else if (STRCMP(HL_TABLE()[idx].sg_name_u, "TOOLTIP") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
802 is_tooltip_group = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
803 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
804
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
805 // Clear the highlighting for ":hi clear {group}" and ":hi clear".
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
806 if (doclear || (forceit && init))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
807 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
808 highlight_clear(idx);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
809 if (!doclear)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
810 HL_TABLE()[idx].sg_set = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
811 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
812
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
813 if (!doclear)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
814 while (!ends_excmd(*linep))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
815 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
816 key_start = linep;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
817 if (*linep == '=')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
818 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
819 semsg(_("E415: unexpected equal sign: %s"), key_start);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
820 error = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
821 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
822 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
823
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
824 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
825 * Isolate the key ("term", "ctermfg", "ctermbg", "font", "guifg" or
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
826 * "guibg").
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
827 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
828 while (*linep && !VIM_ISWHITE(*linep) && *linep != '=')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
829 ++linep;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
830 vim_free(key);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
831 key = vim_strnsave_up(key_start, (int)(linep - key_start));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
832 if (key == NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
833 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
834 error = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
835 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
836 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
837 linep = skipwhite(linep);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
838
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
839 if (STRCMP(key, "NONE") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
840 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
841 if (!init || HL_TABLE()[idx].sg_set == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
842 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
843 if (!init)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
844 HL_TABLE()[idx].sg_set |= SG_TERM+SG_CTERM+SG_GUI;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
845 highlight_clear(idx);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
846 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
847 continue;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
848 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
849
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
850 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
851 * Check for the equal sign.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
852 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
853 if (*linep != '=')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
854 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
855 semsg(_("E416: missing equal sign: %s"), key_start);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
856 error = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
857 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
858 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
859 ++linep;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
860
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
861 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
862 * Isolate the argument.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
863 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
864 linep = skipwhite(linep);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
865 if (*linep == '\'') // guifg='color name'
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
866 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
867 arg_start = ++linep;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
868 linep = vim_strchr(linep, '\'');
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
869 if (linep == NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
870 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
871 semsg(_(e_invarg2), key_start);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
872 error = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
873 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
874 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
875 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
876 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
877 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
878 arg_start = linep;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
879 linep = skiptowhite(linep);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
880 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
881 if (linep == arg_start)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
882 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
883 semsg(_("E417: missing argument: %s"), key_start);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
884 error = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
885 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
886 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
887 vim_free(arg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
888 arg = vim_strnsave(arg_start, (int)(linep - arg_start));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
889 if (arg == NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
890 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
891 error = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
892 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
893 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
894 if (*linep == '\'')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
895 ++linep;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
896
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
897 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
898 * Store the argument.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
899 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
900 if ( STRCMP(key, "TERM") == 0
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
901 || STRCMP(key, "CTERM") == 0
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
902 || STRCMP(key, "GUI") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
903 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
904 attr = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
905 off = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
906 while (arg[off] != NUL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
907 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
908 for (i = sizeof(hl_attr_table) / sizeof(int); --i >= 0; )
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
909 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
910 len = (int)STRLEN(hl_name_table[i]);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
911 if (STRNICMP(arg + off, hl_name_table[i], len) == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
912 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
913 attr |= hl_attr_table[i];
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
914 off += len;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
915 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
916 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
917 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
918 if (i < 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
919 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
920 semsg(_("E418: Illegal value: %s"), arg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
921 error = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
922 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
923 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
924 if (arg[off] == ',') // another one follows
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
925 ++off;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
926 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
927 if (error)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
928 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
929 if (*key == 'T')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
930 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
931 if (!init || !(HL_TABLE()[idx].sg_set & SG_TERM))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
932 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
933 if (!init)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
934 HL_TABLE()[idx].sg_set |= SG_TERM;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
935 HL_TABLE()[idx].sg_term = attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
936 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
937 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
938 else if (*key == 'C')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
939 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
940 if (!init || !(HL_TABLE()[idx].sg_set & SG_CTERM))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
941 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
942 if (!init)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
943 HL_TABLE()[idx].sg_set |= SG_CTERM;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
944 HL_TABLE()[idx].sg_cterm = attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
945 HL_TABLE()[idx].sg_cterm_bold = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
946 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
947 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
948 #if defined(FEAT_GUI) || defined(FEAT_EVAL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
949 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
950 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
951 if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
952 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
953 if (!init)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
954 HL_TABLE()[idx].sg_set |= SG_GUI;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
955 HL_TABLE()[idx].sg_gui = attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
956 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
957 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
958 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
959 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
960 else if (STRCMP(key, "FONT") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
961 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
962 // in non-GUI fonts are simply ignored
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
963 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
964 if (HL_TABLE()[idx].sg_font_name != NULL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
965 && STRCMP(HL_TABLE()[idx].sg_font_name, arg) == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
966 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
967 // Font name didn't change, ignore.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
968 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
969 else if (!gui.shell_created)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
970 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
971 // GUI not started yet, always accept the name.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
972 vim_free(HL_TABLE()[idx].sg_font_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
973 HL_TABLE()[idx].sg_font_name = vim_strsave(arg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
974 did_change = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
975 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
976 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
977 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
978 GuiFont temp_sg_font = HL_TABLE()[idx].sg_font;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
979 # ifdef FEAT_XFONTSET
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
980 GuiFontset temp_sg_fontset = HL_TABLE()[idx].sg_fontset;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
981 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
982 // First, save the current font/fontset.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
983 // Then try to allocate the font/fontset.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
984 // If the allocation fails, HL_TABLE()[idx].sg_font OR
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
985 // sg_fontset will be set to NOFONT or NOFONTSET respectively.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
986
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
987 HL_TABLE()[idx].sg_font = NOFONT;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
988 # ifdef FEAT_XFONTSET
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
989 HL_TABLE()[idx].sg_fontset = NOFONTSET;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
990 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
991 hl_do_font(idx, arg, is_normal_group, is_menu_group,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
992 is_tooltip_group, FALSE);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
993
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
994 # ifdef FEAT_XFONTSET
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
995 if (HL_TABLE()[idx].sg_fontset != NOFONTSET)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
996 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
997 // New fontset was accepted. Free the old one, if there
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
998 // was one.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
999 gui_mch_free_fontset(temp_sg_fontset);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1000 vim_free(HL_TABLE()[idx].sg_font_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1001 HL_TABLE()[idx].sg_font_name = vim_strsave(arg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1002 did_change = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1003 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1004 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1005 HL_TABLE()[idx].sg_fontset = temp_sg_fontset;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1006 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1007 if (HL_TABLE()[idx].sg_font != NOFONT)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1008 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1009 // New font was accepted. Free the old one, if there was
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1010 // one.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1011 gui_mch_free_font(temp_sg_font);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1012 vim_free(HL_TABLE()[idx].sg_font_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1013 HL_TABLE()[idx].sg_font_name = vim_strsave(arg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1014 did_change = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1015 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1016 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1017 HL_TABLE()[idx].sg_font = temp_sg_font;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1018 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1019 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1020 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1021 else if (STRCMP(key, "CTERMFG") == 0 || STRCMP(key, "CTERMBG") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1022 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1023 if (!init || !(HL_TABLE()[idx].sg_set & SG_CTERM))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1024 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1025 if (!init)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1026 HL_TABLE()[idx].sg_set |= SG_CTERM;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1027
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1028 // When setting the foreground color, and previously the "bold"
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1029 // flag was set for a light color, reset it now
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1030 if (key[5] == 'F' && HL_TABLE()[idx].sg_cterm_bold)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1031 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1032 HL_TABLE()[idx].sg_cterm &= ~HL_BOLD;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1033 HL_TABLE()[idx].sg_cterm_bold = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1034 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1035
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1036 if (VIM_ISDIGIT(*arg))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1037 color = atoi((char *)arg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1038 else if (STRICMP(arg, "fg") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1039 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1040 if (cterm_normal_fg_color)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1041 color = cterm_normal_fg_color - 1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1042 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1043 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1044 emsg(_("E419: FG color unknown"));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1045 error = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1046 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1047 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1048 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1049 else if (STRICMP(arg, "bg") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1050 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1051 if (cterm_normal_bg_color > 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1052 color = cterm_normal_bg_color - 1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1053 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1054 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1055 emsg(_("E420: BG color unknown"));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1056 error = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1057 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1058 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1059 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1060 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1061 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1062 int bold = MAYBE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1063
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1064 #if defined(__QNXNTO__)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1065 static int *color_numbers_8_qansi = color_numbers_8;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1066 // On qnx, the 8 & 16 color arrays are the same
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1067 if (STRNCMP(T_NAME, "qansi", 5) == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1068 color_numbers_8_qansi = color_numbers_16;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1069 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1070
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1071 // reduce calls to STRICMP a bit, it can be slow
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1072 off = TOUPPER_ASC(*arg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1073 for (i = (sizeof(color_names) / sizeof(char *)); --i >= 0; )
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1074 if (off == color_names[i][0]
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1075 && STRICMP(arg + 1, color_names[i] + 1) == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1076 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1077 if (i < 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1078 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1079 semsg(_("E421: Color name or number not recognized: %s"), key_start);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1080 error = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1081 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1082 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1083
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1084 color = lookup_color(i, key[5] == 'F', &bold);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1085
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1086 // set/reset bold attribute to get light foreground
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1087 // colors (on some terminals, e.g. "linux")
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1088 if (bold == TRUE)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1089 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1090 HL_TABLE()[idx].sg_cterm |= HL_BOLD;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1091 HL_TABLE()[idx].sg_cterm_bold = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1092 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1093 else if (bold == FALSE)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1094 HL_TABLE()[idx].sg_cterm &= ~HL_BOLD;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1095 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1096
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1097 // Add one to the argument, to avoid zero. Zero is used for
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1098 // "NONE", then "color" is -1.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1099 if (key[5] == 'F')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1100 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1101 HL_TABLE()[idx].sg_cterm_fg = color + 1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1102 if (is_normal_group)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1103 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1104 cterm_normal_fg_color = color + 1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1105 cterm_normal_fg_bold = (HL_TABLE()[idx].sg_cterm & HL_BOLD);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1106 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1107 // Don't do this if the GUI is used.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1108 if (!gui.in_use && !gui.starting)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1109 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1110 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1111 must_redraw = CLEAR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1112 if (termcap_active && color >= 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1113 term_fg_color(color);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1114 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1115 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1116 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1117 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1118 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1119 HL_TABLE()[idx].sg_cterm_bg = color + 1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1120 if (is_normal_group)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1121 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1122 cterm_normal_bg_color = color + 1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1123 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1124 // Don't mess with 'background' if the GUI is used.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1125 if (!gui.in_use && !gui.starting)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1126 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1127 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1128 must_redraw = CLEAR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1129 if (color >= 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1130 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1131 int dark = -1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1132
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1133 if (termcap_active)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1134 term_bg_color(color);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1135 if (t_colors < 16)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1136 dark = (color == 0 || color == 4);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1137 // Limit the heuristic to the standard 16 colors
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1138 else if (color < 16)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1139 dark = (color < 7 || color == 8);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1140 // Set the 'background' option if the value is
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1141 // wrong.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1142 if (dark != -1
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1143 && dark != (*p_bg == 'd')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1144 && !option_was_set((char_u *)"bg"))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1145 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1146 set_option_value((char_u *)"bg", 0L,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1147 (char_u *)(dark ? "dark" : "light"), 0);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1148 reset_option_was_set((char_u *)"bg");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1149 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1150 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1151 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1152 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1153 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1154 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1155 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1156 else if (STRCMP(key, "GUIFG") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1157 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1158 #if defined(FEAT_GUI) || defined(FEAT_EVAL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1159 char_u **namep = &HL_TABLE()[idx].sg_gui_fg_name;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1160
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1161 if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1162 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1163 if (!init)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1164 HL_TABLE()[idx].sg_set |= SG_GUI;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1165
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1166 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1167 // In GUI guifg colors are only used when recognized
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1168 i = color_name2handle(arg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1169 if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !USE_24BIT)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1170 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1171 HL_TABLE()[idx].sg_gui_fg = i;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1172 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1173 if (*namep == NULL || STRCMP(*namep, arg) != 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1174 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1175 vim_free(*namep);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1176 if (STRCMP(arg, "NONE") != 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1177 *namep = vim_strsave(arg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1178 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1179 *namep = NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1180 did_change = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1181 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1182 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1183 # ifdef FEAT_GUI_X11
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1184 if (is_menu_group && gui.menu_fg_pixel != i)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1185 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1186 gui.menu_fg_pixel = i;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1187 do_colors = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1188 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1189 if (is_scrollbar_group && gui.scroll_fg_pixel != i)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1190 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1191 gui.scroll_fg_pixel = i;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1192 do_colors = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1193 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1194 # ifdef FEAT_BEVAL_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1195 if (is_tooltip_group && gui.tooltip_fg_pixel != i)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1196 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1197 gui.tooltip_fg_pixel = i;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1198 do_colors = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1199 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1200 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1201 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1202 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1203 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1204 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1205 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1206 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1207 else if (STRCMP(key, "GUIBG") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1208 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1209 #if defined(FEAT_GUI) || defined(FEAT_EVAL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1210 char_u **namep = &HL_TABLE()[idx].sg_gui_bg_name;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1211
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1212 if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1213 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1214 if (!init)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1215 HL_TABLE()[idx].sg_set |= SG_GUI;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1216
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1217 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1218 // In GUI guifg colors are only used when recognized
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1219 i = color_name2handle(arg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1220 if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !USE_24BIT)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1221 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1222 HL_TABLE()[idx].sg_gui_bg = i;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1223 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1224 if (*namep == NULL || STRCMP(*namep, arg) != 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1225 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1226 vim_free(*namep);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1227 if (STRCMP(arg, "NONE") != 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1228 *namep = vim_strsave(arg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1229 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1230 *namep = NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1231 did_change = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1232 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1233 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1234 # ifdef FEAT_GUI_X11
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1235 if (is_menu_group && gui.menu_bg_pixel != i)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1236 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1237 gui.menu_bg_pixel = i;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1238 do_colors = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1239 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1240 if (is_scrollbar_group && gui.scroll_bg_pixel != i)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1241 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1242 gui.scroll_bg_pixel = i;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1243 do_colors = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1244 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1245 # ifdef FEAT_BEVAL_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1246 if (is_tooltip_group && gui.tooltip_bg_pixel != i)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1247 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1248 gui.tooltip_bg_pixel = i;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1249 do_colors = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1250 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1251 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1252 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1253 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1254 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1255 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1256 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1257 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1258 else if (STRCMP(key, "GUISP") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1259 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1260 #if defined(FEAT_GUI) || defined(FEAT_EVAL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1261 char_u **namep = &HL_TABLE()[idx].sg_gui_sp_name;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1262
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1263 if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1264 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1265 if (!init)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1266 HL_TABLE()[idx].sg_set |= SG_GUI;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1267
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1268 # ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1269 i = color_name2handle(arg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1270 if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !gui.in_use)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1271 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1272 HL_TABLE()[idx].sg_gui_sp = i;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1273 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1274 if (*namep == NULL || STRCMP(*namep, arg) != 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1275 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1276 vim_free(*namep);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1277 if (STRCMP(arg, "NONE") != 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1278 *namep = vim_strsave(arg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1279 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1280 *namep = NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1281 did_change = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1282 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1283 # ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1284 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1285 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1286 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1287 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1288 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1289 else if (STRCMP(key, "START") == 0 || STRCMP(key, "STOP") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1290 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1291 char_u buf[100];
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1292 char_u *tname;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1293
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1294 if (!init)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1295 HL_TABLE()[idx].sg_set |= SG_TERM;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1296
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1297 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1298 * The "start" and "stop" arguments can be a literal escape
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1299 * sequence, or a comma separated list of terminal codes.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1300 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1301 if (STRNCMP(arg, "t_", 2) == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1302 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1303 off = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1304 buf[0] = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1305 while (arg[off] != NUL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1306 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1307 // Isolate one termcap name
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1308 for (len = 0; arg[off + len] &&
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1309 arg[off + len] != ','; ++len)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1310 ;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1311 tname = vim_strnsave(arg + off, len);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1312 if (tname == NULL) // out of memory
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1313 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1314 error = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1315 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1316 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1317 // lookup the escape sequence for the item
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1318 p = get_term_code(tname);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1319 vim_free(tname);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1320 if (p == NULL) // ignore non-existing things
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1321 p = (char_u *)"";
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1322
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1323 // Append it to the already found stuff
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1324 if ((int)(STRLEN(buf) + STRLEN(p)) >= 99)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1325 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1326 semsg(_("E422: terminal code too long: %s"), arg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1327 error = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1328 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1329 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1330 STRCAT(buf, p);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1331
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1332 // Advance to the next item
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1333 off += len;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1334 if (arg[off] == ',') // another one follows
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1335 ++off;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1336 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1337 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1338 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1339 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1340 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1341 * Copy characters from arg[] to buf[], translating <> codes.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1342 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1343 for (p = arg, off = 0; off < 100 - 6 && *p; )
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1344 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1345 len = trans_special(&p, buf + off, FALSE, FALSE);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1346 if (len > 0) // recognized special char
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1347 off += len;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1348 else // copy as normal char
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1349 buf[off++] = *p++;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1350 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1351 buf[off] = NUL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1352 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1353 if (error)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1354 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1355
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1356 if (STRCMP(buf, "NONE") == 0) // resetting the value
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1357 p = NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1358 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1359 p = vim_strsave(buf);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1360 if (key[2] == 'A')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1361 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1362 vim_free(HL_TABLE()[idx].sg_start);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1363 HL_TABLE()[idx].sg_start = p;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1364 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1365 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1366 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1367 vim_free(HL_TABLE()[idx].sg_stop);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1368 HL_TABLE()[idx].sg_stop = p;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1369 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1370 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1371 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1372 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1373 semsg(_("E423: Illegal argument: %s"), key_start);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1374 error = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1375 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1376 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1377 HL_TABLE()[idx].sg_cleared = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1378
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1379 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1380 * When highlighting has been given for a group, don't link it.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1381 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1382 if (!init || !(HL_TABLE()[idx].sg_set & SG_LINK))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1383 HL_TABLE()[idx].sg_link = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1384
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1385 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1386 * Continue with next argument.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1387 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1388 linep = skipwhite(linep);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1389 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1390
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1391 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1392 * If there is an error, and it's a new entry, remove it from the table.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1393 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1394 if (error && idx == highlight_ga.ga_len)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1395 syn_unadd_group();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1396 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1397 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1398 if (is_normal_group)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1399 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1400 HL_TABLE()[idx].sg_term_attr = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1401 HL_TABLE()[idx].sg_cterm_attr = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1402 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1403 HL_TABLE()[idx].sg_gui_attr = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1404 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1405 * Need to update all groups, because they might be using "bg"
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1406 * and/or "fg", which have been changed now.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1407 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1408 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1409 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1410 if (USE_24BIT)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1411 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1412 highlight_gui_started();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1413 did_highlight_changed = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1414 redraw_all_later(NOT_VALID);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1415 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1416 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1417 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1418 #ifdef FEAT_TERMINAL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1419 else if (is_terminal_group)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1420 set_terminal_default_colors(
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1421 HL_TABLE()[idx].sg_cterm_fg, HL_TABLE()[idx].sg_cterm_bg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1422 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1423 #ifdef FEAT_GUI_X11
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1424 # ifdef FEAT_MENU
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1425 else if (is_menu_group)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1426 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1427 if (gui.in_use && do_colors)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1428 gui_mch_new_menu_colors();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1429 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1430 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1431 else if (is_scrollbar_group)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1432 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1433 if (gui.in_use && do_colors)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1434 gui_new_scrollbar_colors();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1435 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1436 set_hl_attr(idx);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1437 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1438 # ifdef FEAT_BEVAL_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1439 else if (is_tooltip_group)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1440 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1441 if (gui.in_use && do_colors)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1442 gui_mch_new_tooltip_colors();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1443 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1444 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1445 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1446 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1447 set_hl_attr(idx);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1448 #ifdef FEAT_EVAL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1449 HL_TABLE()[idx].sg_script_ctx = current_sctx;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1450 HL_TABLE()[idx].sg_script_ctx.sc_lnum += sourcing_lnum;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1451 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1452 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1453
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1454 vim_free(key);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1455 vim_free(arg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1456
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1457 // Only call highlight_changed() once, after a sequence of highlight
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1458 // commands, and only if an attribute actually changed.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1459 if ((did_change
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1460 || memcmp(&HL_TABLE()[idx], &item_before, sizeof(item_before)) != 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1461 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1462 && !did_highlight_changed
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1463 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1464 )
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1465 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1466 // Do not trigger a redraw when highlighting is changed while
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1467 // redrawing. This may happen when evaluating 'statusline' changes the
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1468 // StatusLine group.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1469 if (!updating_screen)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1470 redraw_all_later(NOT_VALID);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1471 need_highlight_changed = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1472 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1473 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1474
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1475 #if defined(EXITFREE) || defined(PROTO)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1476 void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1477 free_highlight(void)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1478 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1479 int i;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1480
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1481 for (i = 0; i < highlight_ga.ga_len; ++i)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1482 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1483 highlight_clear(i);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1484 vim_free(HL_TABLE()[i].sg_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1485 vim_free(HL_TABLE()[i].sg_name_u);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1486 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1487 ga_clear(&highlight_ga);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1488 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1489 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1490
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1491 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1492 * Reset the cterm colors to what they were before Vim was started, if
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1493 * possible. Otherwise reset them to zero.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1494 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1495 void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1496 restore_cterm_colors(void)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1497 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1498 #if defined(MSWIN) && !defined(FEAT_GUI_MSWIN)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1499 // Since t_me has been set, this probably means that the user
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1500 // wants to use this as default colors. Need to reset default
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1501 // background/foreground colors.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1502 mch_set_normal_colors();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1503 #else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1504 # ifdef VIMDLL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1505 if (!gui.in_use)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1506 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1507 mch_set_normal_colors();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1508 return;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1509 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1510 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1511 cterm_normal_fg_color = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1512 cterm_normal_fg_bold = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1513 cterm_normal_bg_color = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1514 # ifdef FEAT_TERMGUICOLORS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1515 cterm_normal_fg_gui_color = INVALCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1516 cterm_normal_bg_gui_color = INVALCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1517 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1518 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1519 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1520
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1521 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1522 * Return TRUE if highlight group "idx" has any settings.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1523 * When "check_link" is TRUE also check for an existing link.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1524 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1525 static int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1526 hl_has_settings(int idx, int check_link)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1527 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1528 return ( HL_TABLE()[idx].sg_term_attr != 0
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1529 || HL_TABLE()[idx].sg_cterm_attr != 0
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1530 || HL_TABLE()[idx].sg_cterm_fg != 0
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1531 || HL_TABLE()[idx].sg_cterm_bg != 0
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1532 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1533 || HL_TABLE()[idx].sg_gui_attr != 0
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1534 || HL_TABLE()[idx].sg_gui_fg_name != NULL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1535 || HL_TABLE()[idx].sg_gui_bg_name != NULL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1536 || HL_TABLE()[idx].sg_gui_sp_name != NULL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1537 || HL_TABLE()[idx].sg_font_name != NULL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1538 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1539 || (check_link && (HL_TABLE()[idx].sg_set & SG_LINK)));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1540 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1541
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1542 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1543 * Clear highlighting for one group.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1544 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1545 static void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1546 highlight_clear(int idx)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1547 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1548 HL_TABLE()[idx].sg_cleared = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1549
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1550 HL_TABLE()[idx].sg_term = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1551 VIM_CLEAR(HL_TABLE()[idx].sg_start);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1552 VIM_CLEAR(HL_TABLE()[idx].sg_stop);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1553 HL_TABLE()[idx].sg_term_attr = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1554 HL_TABLE()[idx].sg_cterm = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1555 HL_TABLE()[idx].sg_cterm_bold = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1556 HL_TABLE()[idx].sg_cterm_fg = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1557 HL_TABLE()[idx].sg_cterm_bg = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1558 HL_TABLE()[idx].sg_cterm_attr = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1559 #if defined(FEAT_GUI) || defined(FEAT_EVAL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1560 HL_TABLE()[idx].sg_gui = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1561 VIM_CLEAR(HL_TABLE()[idx].sg_gui_fg_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1562 VIM_CLEAR(HL_TABLE()[idx].sg_gui_bg_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1563 VIM_CLEAR(HL_TABLE()[idx].sg_gui_sp_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1564 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1565 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1566 HL_TABLE()[idx].sg_gui_fg = INVALCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1567 HL_TABLE()[idx].sg_gui_bg = INVALCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1568 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1569 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1570 HL_TABLE()[idx].sg_gui_sp = INVALCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1571 gui_mch_free_font(HL_TABLE()[idx].sg_font);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1572 HL_TABLE()[idx].sg_font = NOFONT;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1573 # ifdef FEAT_XFONTSET
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1574 gui_mch_free_fontset(HL_TABLE()[idx].sg_fontset);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1575 HL_TABLE()[idx].sg_fontset = NOFONTSET;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1576 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1577 VIM_CLEAR(HL_TABLE()[idx].sg_font_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1578 HL_TABLE()[idx].sg_gui_attr = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1579 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1580 #ifdef FEAT_EVAL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1581 // Clear the script ID only when there is no link, since that is not
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1582 // cleared.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1583 if (HL_TABLE()[idx].sg_link == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1584 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1585 HL_TABLE()[idx].sg_script_ctx.sc_sid = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1586 HL_TABLE()[idx].sg_script_ctx.sc_lnum = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1587 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1588 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1589 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1590
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1591 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) || defined(PROTO)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1592 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1593 * Set the normal foreground and background colors according to the "Normal"
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1594 * highlighting group. For X11 also set "Menu", "Scrollbar", and
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1595 * "Tooltip" colors.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1596 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1597 void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1598 set_normal_colors(void)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1599 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1600 # ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1601 # ifdef FEAT_TERMGUICOLORS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1602 if (gui.in_use)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1603 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1604 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1605 if (set_group_colors((char_u *)"Normal",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1606 &gui.norm_pixel, &gui.back_pixel,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1607 FALSE, TRUE, FALSE))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1608 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1609 gui_mch_new_colors();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1610 must_redraw = CLEAR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1611 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1612 # ifdef FEAT_GUI_X11
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1613 if (set_group_colors((char_u *)"Menu",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1614 &gui.menu_fg_pixel, &gui.menu_bg_pixel,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1615 TRUE, FALSE, FALSE))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1616 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1617 # ifdef FEAT_MENU
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1618 gui_mch_new_menu_colors();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1619 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1620 must_redraw = CLEAR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1621 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1622 # ifdef FEAT_BEVAL_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1623 if (set_group_colors((char_u *)"Tooltip",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1624 &gui.tooltip_fg_pixel, &gui.tooltip_bg_pixel,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1625 FALSE, FALSE, TRUE))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1626 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1627 # ifdef FEAT_TOOLBAR
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1628 gui_mch_new_tooltip_colors();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1629 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1630 must_redraw = CLEAR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1631 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1632 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1633 if (set_group_colors((char_u *)"Scrollbar",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1634 &gui.scroll_fg_pixel, &gui.scroll_bg_pixel,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1635 FALSE, FALSE, FALSE))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1636 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1637 gui_new_scrollbar_colors();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1638 must_redraw = CLEAR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1639 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1640 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1641 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1642 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1643 # ifdef FEAT_TERMGUICOLORS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1644 # ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1645 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1646 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1647 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1648 int idx;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1649
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1650 idx = syn_name2id((char_u *)"Normal") - 1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1651 if (idx >= 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1652 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1653 gui_do_one_color(idx, FALSE, FALSE);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1654
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1655 // If the normal fg or bg color changed a complete redraw is
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1656 // required.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1657 if (cterm_normal_fg_gui_color != HL_TABLE()[idx].sg_gui_fg
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1658 || cterm_normal_bg_gui_color != HL_TABLE()[idx].sg_gui_bg)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1659 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1660 // if the GUI color is INVALCOLOR then we use the default cterm
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1661 // color
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1662 cterm_normal_fg_gui_color = HL_TABLE()[idx].sg_gui_fg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1663 cterm_normal_bg_gui_color = HL_TABLE()[idx].sg_gui_bg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1664 must_redraw = CLEAR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1665 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1666 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1667 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1668 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1669 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1670 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1671
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1672 #if defined(FEAT_GUI) || defined(PROTO)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1673 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1674 * Set the colors for "Normal", "Menu", "Tooltip" or "Scrollbar".
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1675 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1676 static int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1677 set_group_colors(
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1678 char_u *name,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1679 guicolor_T *fgp,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1680 guicolor_T *bgp,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1681 int do_menu,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1682 int use_norm,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1683 int do_tooltip)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1684 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1685 int idx;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1686
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1687 idx = syn_name2id(name) - 1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1688 if (idx >= 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1689 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1690 gui_do_one_color(idx, do_menu, do_tooltip);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1691
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1692 if (HL_TABLE()[idx].sg_gui_fg != INVALCOLOR)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1693 *fgp = HL_TABLE()[idx].sg_gui_fg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1694 else if (use_norm)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1695 *fgp = gui.def_norm_pixel;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1696 if (HL_TABLE()[idx].sg_gui_bg != INVALCOLOR)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1697 *bgp = HL_TABLE()[idx].sg_gui_bg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1698 else if (use_norm)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1699 *bgp = gui.def_back_pixel;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1700 return TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1701 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1702 return FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1703 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1704
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1705 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1706 * Get the font of the "Normal" group.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1707 * Returns "" when it's not found or not set.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1708 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1709 char_u *
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1710 hl_get_font_name(void)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1711 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1712 int id;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1713 char_u *s;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1714
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1715 id = syn_name2id((char_u *)"Normal");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1716 if (id > 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1717 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1718 s = HL_TABLE()[id - 1].sg_font_name;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1719 if (s != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1720 return s;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1721 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1722 return (char_u *)"";
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1723 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1724
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1725 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1726 * Set font for "Normal" group. Called by gui_mch_init_font() when a font has
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1727 * actually chosen to be used.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1728 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1729 void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1730 hl_set_font_name(char_u *font_name)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1731 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1732 int id;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1733
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1734 id = syn_name2id((char_u *)"Normal");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1735 if (id > 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1736 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1737 vim_free(HL_TABLE()[id - 1].sg_font_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1738 HL_TABLE()[id - 1].sg_font_name = vim_strsave(font_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1739 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1740 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1741
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1742 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1743 * Set background color for "Normal" group. Called by gui_set_bg_color()
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1744 * when the color is known.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1745 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1746 void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1747 hl_set_bg_color_name(
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1748 char_u *name) // must have been allocated
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1749 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1750 int id;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1751
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1752 if (name != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1753 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1754 id = syn_name2id((char_u *)"Normal");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1755 if (id > 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1756 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1757 vim_free(HL_TABLE()[id - 1].sg_gui_bg_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1758 HL_TABLE()[id - 1].sg_gui_bg_name = name;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1759 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1760 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1761 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1762
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1763 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1764 * Set foreground color for "Normal" group. Called by gui_set_fg_color()
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1765 * when the color is known.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1766 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1767 void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1768 hl_set_fg_color_name(
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1769 char_u *name) // must have been allocated
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1770 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1771 int id;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1772
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1773 if (name != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1774 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1775 id = syn_name2id((char_u *)"Normal");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1776 if (id > 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1777 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1778 vim_free(HL_TABLE()[id - 1].sg_gui_fg_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1779 HL_TABLE()[id - 1].sg_gui_fg_name = name;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1780 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1781 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1782 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1783
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1784 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1785 * Return the handle for a font name.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1786 * Returns NOFONT when failed.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1787 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1788 static GuiFont
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1789 font_name2handle(char_u *name)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1790 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1791 if (STRCMP(name, "NONE") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1792 return NOFONT;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1793
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1794 return gui_mch_get_font(name, TRUE);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1795 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1796
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1797 # ifdef FEAT_XFONTSET
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1798 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1799 * Return the handle for a fontset name.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1800 * Returns NOFONTSET when failed.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1801 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1802 static GuiFontset
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1803 fontset_name2handle(char_u *name, int fixed_width)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1804 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1805 if (STRCMP(name, "NONE") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1806 return NOFONTSET;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1807
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1808 return gui_mch_get_fontset(name, TRUE, fixed_width);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1809 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1810 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1811
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1812 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1813 * Get the font or fontset for one highlight group.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1814 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1815 static void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1816 hl_do_font(
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1817 int idx,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1818 char_u *arg,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1819 int do_normal, // set normal font
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1820 int do_menu UNUSED, // set menu font
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1821 int do_tooltip UNUSED, // set tooltip font
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1822 int free_font) // free current font/fontset
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1823 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1824 # ifdef FEAT_XFONTSET
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1825 // If 'guifontset' is not empty, first try using the name as a
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1826 // fontset. If that doesn't work, use it as a font name.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1827 if (*p_guifontset != NUL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1828 # ifdef FONTSET_ALWAYS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1829 || do_menu
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1830 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1831 # ifdef FEAT_BEVAL_TIP
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1832 // In Athena & Motif, the Tooltip highlight group is always a fontset
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1833 || do_tooltip
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1834 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1835 )
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1836 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1837 if (free_font)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1838 gui_mch_free_fontset(HL_TABLE()[idx].sg_fontset);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1839 HL_TABLE()[idx].sg_fontset = fontset_name2handle(arg, 0
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1840 # ifdef FONTSET_ALWAYS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1841 || do_menu
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1842 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1843 # ifdef FEAT_BEVAL_TIP
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1844 || do_tooltip
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1845 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1846 );
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1847 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1848 if (HL_TABLE()[idx].sg_fontset != NOFONTSET)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1849 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1850 // If it worked and it's the Normal group, use it as the normal
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1851 // fontset. Same for the Menu group.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1852 if (do_normal)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1853 gui_init_font(arg, TRUE);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1854 # if (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) && defined(FEAT_MENU)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1855 if (do_menu)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1856 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1857 # ifdef FONTSET_ALWAYS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1858 gui.menu_fontset = HL_TABLE()[idx].sg_fontset;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1859 # else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1860 // YIKES! This is a bug waiting to crash the program
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1861 gui.menu_font = HL_TABLE()[idx].sg_fontset;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1862 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1863 gui_mch_new_menu_font();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1864 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1865 # ifdef FEAT_BEVAL_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1866 if (do_tooltip)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1867 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1868 // The Athena widget set cannot currently handle switching between
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1869 // displaying a single font and a fontset.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1870 // If the XtNinternational resource is set to True at widget
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1871 // creation, then a fontset is always used, otherwise an
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1872 // XFontStruct is used.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1873 gui.tooltip_fontset = (XFontSet)HL_TABLE()[idx].sg_fontset;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1874 gui_mch_new_tooltip_font();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1875 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1876 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1877 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1878 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1879 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1880 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1881 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1882 if (free_font)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1883 gui_mch_free_font(HL_TABLE()[idx].sg_font);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1884 HL_TABLE()[idx].sg_font = font_name2handle(arg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1885 // If it worked and it's the Normal group, use it as the
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1886 // normal font. Same for the Menu group.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1887 if (HL_TABLE()[idx].sg_font != NOFONT)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1888 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1889 if (do_normal)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1890 gui_init_font(arg, FALSE);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1891 #ifndef FONTSET_ALWAYS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1892 # if (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) && defined(FEAT_MENU)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1893 if (do_menu)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1894 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1895 gui.menu_font = HL_TABLE()[idx].sg_font;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1896 gui_mch_new_menu_font();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1897 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1898 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1899 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1900 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1901 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1902 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1903
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1904 #endif // FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1905
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1906 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) || defined(PROTO)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1907 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1908 * Return the handle for a color name.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1909 * Returns INVALCOLOR when failed.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1910 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1911 guicolor_T
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1912 color_name2handle(char_u *name)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1913 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1914 if (STRCMP(name, "NONE") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1915 return INVALCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1916
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1917 if (STRICMP(name, "fg") == 0 || STRICMP(name, "foreground") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1918 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1919 #if defined(FEAT_TERMGUICOLORS) && defined(FEAT_GUI)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1920 if (gui.in_use)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1921 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1922 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1923 return gui.norm_pixel;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1924 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1925 #ifdef FEAT_TERMGUICOLORS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1926 if (cterm_normal_fg_gui_color != INVALCOLOR)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1927 return cterm_normal_fg_gui_color;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1928 // Guess that the foreground is black or white.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1929 return GUI_GET_COLOR((char_u *)(*p_bg == 'l' ? "black" : "white"));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1930 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1931 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1932 if (STRICMP(name, "bg") == 0 || STRICMP(name, "background") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1933 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1934 #if defined(FEAT_TERMGUICOLORS) && defined(FEAT_GUI)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1935 if (gui.in_use)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1936 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1937 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1938 return gui.back_pixel;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1939 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1940 #ifdef FEAT_TERMGUICOLORS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1941 if (cterm_normal_bg_gui_color != INVALCOLOR)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1942 return cterm_normal_bg_gui_color;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1943 // Guess that the background is white or black.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1944 return GUI_GET_COLOR((char_u *)(*p_bg == 'l' ? "white" : "black"));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1945 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1946 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1947
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1948 return GUI_GET_COLOR(name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1949 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1950 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1951
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1952 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1953 * Table with the specifications for an attribute number.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1954 * Note that this table is used by ALL buffers. This is required because the
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1955 * GUI can redraw at any time for any buffer.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1956 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1957 static garray_T term_attr_table = {0, 0, 0, 0, NULL};
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1958
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1959 #define TERM_ATTR_ENTRY(idx) ((attrentry_T *)term_attr_table.ga_data)[idx]
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1960
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1961 static garray_T cterm_attr_table = {0, 0, 0, 0, NULL};
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1962
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1963 #define CTERM_ATTR_ENTRY(idx) ((attrentry_T *)cterm_attr_table.ga_data)[idx]
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1964
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1965 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1966 static garray_T gui_attr_table = {0, 0, 0, 0, NULL};
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1967
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1968 #define GUI_ATTR_ENTRY(idx) ((attrentry_T *)gui_attr_table.ga_data)[idx]
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1969 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1970
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1971 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1972 * Return the attr number for a set of colors and font.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1973 * Add a new entry to the term_attr_table, cterm_attr_table or gui_attr_table
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1974 * if the combination is new.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1975 * Return 0 for error (no more room).
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1976 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1977 static int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1978 get_attr_entry(garray_T *table, attrentry_T *aep)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1979 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1980 int i;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1981 attrentry_T *taep;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1982 static int recursive = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1983
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1984 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1985 * Init the table, in case it wasn't done yet.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1986 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1987 table->ga_itemsize = sizeof(attrentry_T);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1988 table->ga_growsize = 7;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1989
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1990 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1991 * Try to find an entry with the same specifications.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1992 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1993 for (i = 0; i < table->ga_len; ++i)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1994 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1995 taep = &(((attrentry_T *)table->ga_data)[i]);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1996 if ( aep->ae_attr == taep->ae_attr
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1997 && (
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1998 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1999 (table == &gui_attr_table
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2000 && (aep->ae_u.gui.fg_color == taep->ae_u.gui.fg_color
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2001 && aep->ae_u.gui.bg_color
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2002 == taep->ae_u.gui.bg_color
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2003 && aep->ae_u.gui.sp_color
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2004 == taep->ae_u.gui.sp_color
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2005 && aep->ae_u.gui.font == taep->ae_u.gui.font
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2006 # ifdef FEAT_XFONTSET
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2007 && aep->ae_u.gui.fontset == taep->ae_u.gui.fontset
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2008 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2009 ))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2010 ||
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2011 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2012 (table == &term_attr_table
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2013 && (aep->ae_u.term.start == NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2014 == (taep->ae_u.term.start == NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2015 && (aep->ae_u.term.start == NULL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2016 || STRCMP(aep->ae_u.term.start,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2017 taep->ae_u.term.start) == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2018 && (aep->ae_u.term.stop == NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2019 == (taep->ae_u.term.stop == NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2020 && (aep->ae_u.term.stop == NULL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2021 || STRCMP(aep->ae_u.term.stop,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2022 taep->ae_u.term.stop) == 0))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2023 || (table == &cterm_attr_table
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2024 && aep->ae_u.cterm.fg_color
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2025 == taep->ae_u.cterm.fg_color
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2026 && aep->ae_u.cterm.bg_color
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2027 == taep->ae_u.cterm.bg_color
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2028 #ifdef FEAT_TERMGUICOLORS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2029 && aep->ae_u.cterm.fg_rgb
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2030 == taep->ae_u.cterm.fg_rgb
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2031 && aep->ae_u.cterm.bg_rgb
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2032 == taep->ae_u.cterm.bg_rgb
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2033 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2034 )))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2035
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2036 return i + ATTR_OFF;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2037 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2038
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2039 if (table->ga_len + ATTR_OFF > MAX_TYPENR)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2040 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2041 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2042 * Running out of attribute entries! remove all attributes, and
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2043 * compute new ones for all groups.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2044 * When called recursively, we are really out of numbers.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2045 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2046 if (recursive)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2047 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2048 emsg(_("E424: Too many different highlighting attributes in use"));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2049 return 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2050 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2051 recursive = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2052
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2053 clear_hl_tables();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2054
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2055 must_redraw = CLEAR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2056
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2057 for (i = 0; i < highlight_ga.ga_len; ++i)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2058 set_hl_attr(i);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2059
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2060 recursive = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2061 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2062
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2063 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2064 * This is a new combination of colors and font, add an entry.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2065 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2066 if (ga_grow(table, 1) == FAIL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2067 return 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2068
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2069 taep = &(((attrentry_T *)table->ga_data)[table->ga_len]);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2070 vim_memset(taep, 0, sizeof(attrentry_T));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2071 taep->ae_attr = aep->ae_attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2072 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2073 if (table == &gui_attr_table)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2074 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2075 taep->ae_u.gui.fg_color = aep->ae_u.gui.fg_color;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2076 taep->ae_u.gui.bg_color = aep->ae_u.gui.bg_color;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2077 taep->ae_u.gui.sp_color = aep->ae_u.gui.sp_color;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2078 taep->ae_u.gui.font = aep->ae_u.gui.font;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2079 # ifdef FEAT_XFONTSET
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2080 taep->ae_u.gui.fontset = aep->ae_u.gui.fontset;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2081 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2082 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2083 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2084 if (table == &term_attr_table)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2085 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2086 if (aep->ae_u.term.start == NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2087 taep->ae_u.term.start = NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2088 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2089 taep->ae_u.term.start = vim_strsave(aep->ae_u.term.start);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2090 if (aep->ae_u.term.stop == NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2091 taep->ae_u.term.stop = NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2092 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2093 taep->ae_u.term.stop = vim_strsave(aep->ae_u.term.stop);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2094 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2095 else if (table == &cterm_attr_table)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2096 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2097 taep->ae_u.cterm.fg_color = aep->ae_u.cterm.fg_color;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2098 taep->ae_u.cterm.bg_color = aep->ae_u.cterm.bg_color;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2099 #ifdef FEAT_TERMGUICOLORS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2100 taep->ae_u.cterm.fg_rgb = aep->ae_u.cterm.fg_rgb;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2101 taep->ae_u.cterm.bg_rgb = aep->ae_u.cterm.bg_rgb;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2102 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2103 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2104 ++table->ga_len;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2105 return (table->ga_len - 1 + ATTR_OFF);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2106 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2107
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2108 #if defined(FEAT_TERMINAL) || defined(PROTO)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2109 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2110 * Get an attribute index for a cterm entry.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2111 * Uses an existing entry when possible or adds one when needed.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2112 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2113 int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2114 get_cterm_attr_idx(int attr, int fg, int bg)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2115 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2116 attrentry_T at_en;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2117
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2118 vim_memset(&at_en, 0, sizeof(attrentry_T));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2119 #ifdef FEAT_TERMGUICOLORS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2120 at_en.ae_u.cterm.fg_rgb = INVALCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2121 at_en.ae_u.cterm.bg_rgb = INVALCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2122 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2123 at_en.ae_attr = attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2124 at_en.ae_u.cterm.fg_color = fg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2125 at_en.ae_u.cterm.bg_color = bg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2126 return get_attr_entry(&cterm_attr_table, &at_en);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2127 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2128 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2129
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2130 #if (defined(FEAT_TERMINAL) && defined(FEAT_TERMGUICOLORS)) || defined(PROTO)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2131 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2132 * Get an attribute index for a 'termguicolors' entry.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2133 * Uses an existing entry when possible or adds one when needed.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2134 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2135 int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2136 get_tgc_attr_idx(int attr, guicolor_T fg, guicolor_T bg)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2137 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2138 attrentry_T at_en;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2139
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2140 vim_memset(&at_en, 0, sizeof(attrentry_T));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2141 at_en.ae_attr = attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2142 if (fg == INVALCOLOR && bg == INVALCOLOR)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2143 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2144 // If both GUI colors are not set fall back to the cterm colors. Helps
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2145 // if the GUI only has an attribute, such as undercurl.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2146 at_en.ae_u.cterm.fg_rgb = CTERMCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2147 at_en.ae_u.cterm.bg_rgb = CTERMCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2148 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2149 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2150 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2151 at_en.ae_u.cterm.fg_rgb = fg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2152 at_en.ae_u.cterm.bg_rgb = bg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2153 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2154 return get_attr_entry(&cterm_attr_table, &at_en);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2155 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2156 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2157
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2158 #if (defined(FEAT_TERMINAL) && defined(FEAT_GUI)) || defined(PROTO)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2159 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2160 * Get an attribute index for a cterm entry.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2161 * Uses an existing entry when possible or adds one when needed.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2162 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2163 int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2164 get_gui_attr_idx(int attr, guicolor_T fg, guicolor_T bg)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2165 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2166 attrentry_T at_en;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2167
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2168 vim_memset(&at_en, 0, sizeof(attrentry_T));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2169 at_en.ae_attr = attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2170 at_en.ae_u.gui.fg_color = fg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2171 at_en.ae_u.gui.bg_color = bg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2172 return get_attr_entry(&gui_attr_table, &at_en);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2173 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2174 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2175
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2176 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2177 * Clear all highlight tables.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2178 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2179 void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2180 clear_hl_tables(void)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2181 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2182 int i;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2183 attrentry_T *taep;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2184
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2185 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2186 ga_clear(&gui_attr_table);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2187 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2188 for (i = 0; i < term_attr_table.ga_len; ++i)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2189 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2190 taep = &(((attrentry_T *)term_attr_table.ga_data)[i]);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2191 vim_free(taep->ae_u.term.start);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2192 vim_free(taep->ae_u.term.stop);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2193 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2194 ga_clear(&term_attr_table);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2195 ga_clear(&cterm_attr_table);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2196 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2197
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2198 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2199 * Combine special attributes (e.g., for spelling) with other attributes
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2200 * (e.g., for syntax highlighting).
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2201 * "prim_attr" overrules "char_attr".
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2202 * This creates a new group when required.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2203 * Since we expect there to be few spelling mistakes we don't cache the
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2204 * result.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2205 * Return the resulting attributes.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2206 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2207 int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2208 hl_combine_attr(int char_attr, int prim_attr)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2209 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2210 attrentry_T *char_aep = NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2211 attrentry_T *spell_aep;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2212 attrentry_T new_en;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2213
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2214 if (char_attr == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2215 return prim_attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2216 if (char_attr <= HL_ALL && prim_attr <= HL_ALL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2217 return ATTR_COMBINE(char_attr, prim_attr);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2218 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2219 if (gui.in_use)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2220 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2221 if (char_attr > HL_ALL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2222 char_aep = syn_gui_attr2entry(char_attr);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2223 if (char_aep != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2224 new_en = *char_aep;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2225 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2226 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2227 vim_memset(&new_en, 0, sizeof(new_en));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2228 new_en.ae_u.gui.fg_color = INVALCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2229 new_en.ae_u.gui.bg_color = INVALCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2230 new_en.ae_u.gui.sp_color = INVALCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2231 if (char_attr <= HL_ALL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2232 new_en.ae_attr = char_attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2233 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2234
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2235 if (prim_attr <= HL_ALL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2236 new_en.ae_attr = ATTR_COMBINE(new_en.ae_attr, prim_attr);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2237 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2238 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2239 spell_aep = syn_gui_attr2entry(prim_attr);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2240 if (spell_aep != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2241 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2242 new_en.ae_attr = ATTR_COMBINE(new_en.ae_attr,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2243 spell_aep->ae_attr);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2244 if (spell_aep->ae_u.gui.fg_color != INVALCOLOR)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2245 new_en.ae_u.gui.fg_color = spell_aep->ae_u.gui.fg_color;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2246 if (spell_aep->ae_u.gui.bg_color != INVALCOLOR)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2247 new_en.ae_u.gui.bg_color = spell_aep->ae_u.gui.bg_color;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2248 if (spell_aep->ae_u.gui.sp_color != INVALCOLOR)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2249 new_en.ae_u.gui.sp_color = spell_aep->ae_u.gui.sp_color;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2250 if (spell_aep->ae_u.gui.font != NOFONT)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2251 new_en.ae_u.gui.font = spell_aep->ae_u.gui.font;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2252 # ifdef FEAT_XFONTSET
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2253 if (spell_aep->ae_u.gui.fontset != NOFONTSET)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2254 new_en.ae_u.gui.fontset = spell_aep->ae_u.gui.fontset;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2255 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2256 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2257 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2258 return get_attr_entry(&gui_attr_table, &new_en);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2259 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2260 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2261
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2262 if (IS_CTERM)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2263 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2264 if (char_attr > HL_ALL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2265 char_aep = syn_cterm_attr2entry(char_attr);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2266 if (char_aep != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2267 new_en = *char_aep;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2268 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2269 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2270 vim_memset(&new_en, 0, sizeof(new_en));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2271 #ifdef FEAT_TERMGUICOLORS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2272 new_en.ae_u.cterm.bg_rgb = INVALCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2273 new_en.ae_u.cterm.fg_rgb = INVALCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2274 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2275 if (char_attr <= HL_ALL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2276 new_en.ae_attr = char_attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2277 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2278
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2279 if (prim_attr <= HL_ALL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2280 new_en.ae_attr = ATTR_COMBINE(new_en.ae_attr, prim_attr);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2281 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2282 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2283 spell_aep = syn_cterm_attr2entry(prim_attr);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2284 if (spell_aep != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2285 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2286 new_en.ae_attr = ATTR_COMBINE(new_en.ae_attr,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2287 spell_aep->ae_attr);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2288 if (spell_aep->ae_u.cterm.fg_color > 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2289 new_en.ae_u.cterm.fg_color = spell_aep->ae_u.cterm.fg_color;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2290 if (spell_aep->ae_u.cterm.bg_color > 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2291 new_en.ae_u.cterm.bg_color = spell_aep->ae_u.cterm.bg_color;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2292 #ifdef FEAT_TERMGUICOLORS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2293 // If both fg and bg are not set fall back to cterm colors.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2294 // Helps for SpellBad which uses undercurl in the GUI.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2295 if (COLOR_INVALID(spell_aep->ae_u.cterm.fg_rgb)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2296 && COLOR_INVALID(spell_aep->ae_u.cterm.bg_rgb))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2297 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2298 if (spell_aep->ae_u.cterm.fg_color > 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2299 new_en.ae_u.cterm.fg_rgb = CTERMCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2300 if (spell_aep->ae_u.cterm.bg_color > 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2301 new_en.ae_u.cterm.bg_rgb = CTERMCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2302 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2303 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2304 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2305 if (spell_aep->ae_u.cterm.fg_rgb != INVALCOLOR)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2306 new_en.ae_u.cterm.fg_rgb = spell_aep->ae_u.cterm.fg_rgb;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2307 if (spell_aep->ae_u.cterm.bg_rgb != INVALCOLOR)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2308 new_en.ae_u.cterm.bg_rgb = spell_aep->ae_u.cterm.bg_rgb;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2309 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2310 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2311 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2312 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2313 return get_attr_entry(&cterm_attr_table, &new_en);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2314 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2315
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2316 if (char_attr > HL_ALL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2317 char_aep = syn_term_attr2entry(char_attr);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2318 if (char_aep != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2319 new_en = *char_aep;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2320 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2321 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2322 vim_memset(&new_en, 0, sizeof(new_en));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2323 if (char_attr <= HL_ALL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2324 new_en.ae_attr = char_attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2325 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2326
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2327 if (prim_attr <= HL_ALL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2328 new_en.ae_attr = ATTR_COMBINE(new_en.ae_attr, prim_attr);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2329 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2330 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2331 spell_aep = syn_term_attr2entry(prim_attr);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2332 if (spell_aep != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2333 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2334 new_en.ae_attr = ATTR_COMBINE(new_en.ae_attr, spell_aep->ae_attr);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2335 if (spell_aep->ae_u.term.start != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2336 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2337 new_en.ae_u.term.start = spell_aep->ae_u.term.start;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2338 new_en.ae_u.term.stop = spell_aep->ae_u.term.stop;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2339 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2340 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2341 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2342 return get_attr_entry(&term_attr_table, &new_en);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2343 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2344
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2345 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2346 attrentry_T *
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2347 syn_gui_attr2entry(int attr)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2348 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2349 attr -= ATTR_OFF;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2350 if (attr >= gui_attr_table.ga_len) // did ":syntax clear"
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2351 return NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2352 return &(GUI_ATTR_ENTRY(attr));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2353 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2354 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2355
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2356 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2357 * Get the highlight attributes (HL_BOLD etc.) from an attribute nr.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2358 * Only to be used when "attr" > HL_ALL.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2359 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2360 int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2361 syn_attr2attr(int attr)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2362 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2363 attrentry_T *aep;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2364
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2365 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2366 if (gui.in_use)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2367 aep = syn_gui_attr2entry(attr);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2368 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2369 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2370 if (IS_CTERM)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2371 aep = syn_cterm_attr2entry(attr);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2372 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2373 aep = syn_term_attr2entry(attr);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2374
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2375 if (aep == NULL) // highlighting not set
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2376 return 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2377 return aep->ae_attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2378 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2379
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2380
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2381 attrentry_T *
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2382 syn_term_attr2entry(int attr)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2383 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2384 attr -= ATTR_OFF;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2385 if (attr >= term_attr_table.ga_len) // did ":syntax clear"
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2386 return NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2387 return &(TERM_ATTR_ENTRY(attr));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2388 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2389
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2390 attrentry_T *
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2391 syn_cterm_attr2entry(int attr)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2392 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2393 attr -= ATTR_OFF;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2394 if (attr >= cterm_attr_table.ga_len) // did ":syntax clear"
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2395 return NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2396 return &(CTERM_ATTR_ENTRY(attr));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2397 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2398
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2399 #define LIST_ATTR 1
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2400 #define LIST_STRING 2
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2401 #define LIST_INT 3
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2402
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2403 static void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2404 highlight_list_one(int id)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2405 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2406 hl_group_T *sgp;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2407 int didh = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2408
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2409 sgp = &HL_TABLE()[id - 1]; // index is ID minus one
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2410
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2411 if (message_filtered(sgp->sg_name))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2412 return;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2413
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2414 didh = highlight_list_arg(id, didh, LIST_ATTR,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2415 sgp->sg_term, NULL, "term");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2416 didh = highlight_list_arg(id, didh, LIST_STRING,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2417 0, sgp->sg_start, "start");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2418 didh = highlight_list_arg(id, didh, LIST_STRING,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2419 0, sgp->sg_stop, "stop");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2420
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2421 didh = highlight_list_arg(id, didh, LIST_ATTR,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2422 sgp->sg_cterm, NULL, "cterm");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2423 didh = highlight_list_arg(id, didh, LIST_INT,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2424 sgp->sg_cterm_fg, NULL, "ctermfg");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2425 didh = highlight_list_arg(id, didh, LIST_INT,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2426 sgp->sg_cterm_bg, NULL, "ctermbg");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2427
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2428 #if defined(FEAT_GUI) || defined(FEAT_EVAL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2429 didh = highlight_list_arg(id, didh, LIST_ATTR,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2430 sgp->sg_gui, NULL, "gui");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2431 didh = highlight_list_arg(id, didh, LIST_STRING,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2432 0, sgp->sg_gui_fg_name, "guifg");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2433 didh = highlight_list_arg(id, didh, LIST_STRING,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2434 0, sgp->sg_gui_bg_name, "guibg");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2435 didh = highlight_list_arg(id, didh, LIST_STRING,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2436 0, sgp->sg_gui_sp_name, "guisp");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2437 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2438 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2439 didh = highlight_list_arg(id, didh, LIST_STRING,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2440 0, sgp->sg_font_name, "font");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2441 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2442
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2443 if (sgp->sg_link && !got_int)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2444 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2445 (void)syn_list_header(didh, 9999, id);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2446 didh = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2447 msg_puts_attr("links to", HL_ATTR(HLF_D));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2448 msg_putchar(' ');
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2449 msg_outtrans(HL_TABLE()[HL_TABLE()[id - 1].sg_link - 1].sg_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2450 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2451
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2452 if (!didh)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2453 highlight_list_arg(id, didh, LIST_STRING, 0, (char_u *)"cleared", "");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2454 #ifdef FEAT_EVAL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2455 if (p_verbose > 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2456 last_set_msg(sgp->sg_script_ctx);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2457 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2458 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2459
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2460 static int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2461 highlight_list_arg(
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2462 int id,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2463 int didh,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2464 int type,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2465 int iarg,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2466 char_u *sarg,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2467 char *name)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2468 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2469 char_u buf[100];
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2470 char_u *ts;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2471 int i;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2472
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2473 if (got_int)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2474 return FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2475 if (type == LIST_STRING ? (sarg != NULL) : (iarg != 0))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2476 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2477 ts = buf;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2478 if (type == LIST_INT)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2479 sprintf((char *)buf, "%d", iarg - 1);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2480 else if (type == LIST_STRING)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2481 ts = sarg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2482 else // type == LIST_ATTR
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2483 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2484 buf[0] = NUL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2485 for (i = 0; hl_attr_table[i] != 0; ++i)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2486 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2487 if (iarg & hl_attr_table[i])
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2488 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2489 if (buf[0] != NUL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2490 vim_strcat(buf, (char_u *)",", 100);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2491 vim_strcat(buf, (char_u *)hl_name_table[i], 100);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2492 iarg &= ~hl_attr_table[i]; // don't want "inverse"
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2493 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2494 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2495 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2496
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2497 (void)syn_list_header(didh,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2498 (int)(vim_strsize(ts) + STRLEN(name) + 1), id);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2499 didh = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2500 if (!got_int)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2501 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2502 if (*name != NUL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2503 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2504 msg_puts_attr(name, HL_ATTR(HLF_D));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2505 msg_puts_attr("=", HL_ATTR(HLF_D));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2506 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2507 msg_outtrans(ts);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2508 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2509 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2510 return didh;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2511 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2512
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2513 #if (((defined(FEAT_EVAL) || defined(FEAT_PRINTER))) && defined(FEAT_SYN_HL)) || defined(PROTO)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2514 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2515 * Return "1" if highlight group "id" has attribute "flag".
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2516 * Return NULL otherwise.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2517 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2518 char_u *
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2519 highlight_has_attr(
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2520 int id,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2521 int flag,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2522 int modec) // 'g' for GUI, 'c' for cterm, 't' for term
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2523 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2524 int attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2525
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2526 if (id <= 0 || id > highlight_ga.ga_len)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2527 return NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2528
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2529 #if defined(FEAT_GUI) || defined(FEAT_EVAL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2530 if (modec == 'g')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2531 attr = HL_TABLE()[id - 1].sg_gui;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2532 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2533 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2534 if (modec == 'c')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2535 attr = HL_TABLE()[id - 1].sg_cterm;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2536 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2537 attr = HL_TABLE()[id - 1].sg_term;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2538
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2539 if (attr & flag)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2540 return (char_u *)"1";
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2541 return NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2542 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2543 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2544
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2545 #if (defined(FEAT_SYN_HL) && defined(FEAT_EVAL)) || defined(PROTO)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2546 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2547 * Return color name of highlight group "id".
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2548 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2549 char_u *
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2550 highlight_color(
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2551 int id,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2552 char_u *what, // "font", "fg", "bg", "sp", "fg#", "bg#" or "sp#"
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2553 int modec) // 'g' for GUI, 'c' for cterm, 't' for term
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2554 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2555 static char_u name[20];
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2556 int n;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2557 int fg = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2558 int sp = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2559 int font = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2560
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2561 if (id <= 0 || id > highlight_ga.ga_len)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2562 return NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2563
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2564 if (TOLOWER_ASC(what[0]) == 'f' && TOLOWER_ASC(what[1]) == 'g')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2565 fg = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2566 else if (TOLOWER_ASC(what[0]) == 'f' && TOLOWER_ASC(what[1]) == 'o'
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2567 && TOLOWER_ASC(what[2]) == 'n' && TOLOWER_ASC(what[3]) == 't')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2568 font = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2569 else if (TOLOWER_ASC(what[0]) == 's' && TOLOWER_ASC(what[1]) == 'p')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2570 sp = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2571 else if (!(TOLOWER_ASC(what[0]) == 'b' && TOLOWER_ASC(what[1]) == 'g'))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2572 return NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2573 if (modec == 'g')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2574 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2575 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2576 # ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2577 // return font name
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2578 if (font)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2579 return HL_TABLE()[id - 1].sg_font_name;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2580 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2581
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2582 // return #RRGGBB form (only possible when GUI is running)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2583 if ((USE_24BIT) && what[2] == '#')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2584 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2585 guicolor_T color;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2586 long_u rgb;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2587 static char_u buf[10];
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2588
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2589 if (fg)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2590 color = HL_TABLE()[id - 1].sg_gui_fg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2591 else if (sp)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2592 # ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2593 color = HL_TABLE()[id - 1].sg_gui_sp;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2594 # else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2595 color = INVALCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2596 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2597 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2598 color = HL_TABLE()[id - 1].sg_gui_bg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2599 if (color == INVALCOLOR)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2600 return NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2601 rgb = (long_u)GUI_MCH_GET_RGB(color);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2602 sprintf((char *)buf, "#%02x%02x%02x",
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2603 (unsigned)(rgb >> 16),
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2604 (unsigned)(rgb >> 8) & 255,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2605 (unsigned)rgb & 255);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2606 return buf;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2607 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2608 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2609 if (fg)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2610 return (HL_TABLE()[id - 1].sg_gui_fg_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2611 if (sp)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2612 return (HL_TABLE()[id - 1].sg_gui_sp_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2613 return (HL_TABLE()[id - 1].sg_gui_bg_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2614 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2615 if (font || sp)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2616 return NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2617 if (modec == 'c')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2618 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2619 if (fg)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2620 n = HL_TABLE()[id - 1].sg_cterm_fg - 1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2621 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2622 n = HL_TABLE()[id - 1].sg_cterm_bg - 1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2623 if (n < 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2624 return NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2625 sprintf((char *)name, "%d", n);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2626 return name;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2627 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2628 // term doesn't have color
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2629 return NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2630 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2631 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2632
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2633 #if (defined(FEAT_SYN_HL) \
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2634 && (defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)) \
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2635 && defined(FEAT_PRINTER)) || defined(PROTO)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2636 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2637 * Return color name of highlight group "id" as RGB value.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2638 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2639 long_u
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2640 highlight_gui_color_rgb(
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2641 int id,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2642 int fg) // TRUE = fg, FALSE = bg
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2643 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2644 guicolor_T color;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2645
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2646 if (id <= 0 || id > highlight_ga.ga_len)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2647 return 0L;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2648
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2649 if (fg)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2650 color = HL_TABLE()[id - 1].sg_gui_fg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2651 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2652 color = HL_TABLE()[id - 1].sg_gui_bg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2653
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2654 if (color == INVALCOLOR)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2655 return 0L;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2656
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2657 return GUI_MCH_GET_RGB(color);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2658 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2659 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2660
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2661 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2662 * Output the syntax list header.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2663 * Return TRUE when started a new line.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2664 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2665 int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2666 syn_list_header(
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2667 int did_header, // did header already
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2668 int outlen, // length of string that comes
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2669 int id) // highlight group id
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2670 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2671 int endcol = 19;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2672 int newline = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2673 int name_col = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2674
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2675 if (!did_header)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2676 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2677 msg_putchar('\n');
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2678 if (got_int)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2679 return TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2680 msg_outtrans(HL_TABLE()[id - 1].sg_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2681 name_col = msg_col;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2682 endcol = 15;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2683 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2684 else if (msg_col + outlen + 1 >= Columns)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2685 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2686 msg_putchar('\n');
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2687 if (got_int)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2688 return TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2689 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2690 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2691 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2692 if (msg_col >= endcol) // wrap around is like starting a new line
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2693 newline = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2694 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2695
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2696 if (msg_col >= endcol) // output at least one space
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2697 endcol = msg_col + 1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2698 if (Columns <= endcol) // avoid hang for tiny window
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2699 endcol = Columns - 1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2700
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2701 msg_advance(endcol);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2702
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2703 // Show "xxx" with the attributes.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2704 if (!did_header)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2705 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2706 if (endcol == Columns - 1 && endcol <= name_col)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2707 msg_putchar(' ');
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2708 msg_puts_attr("xxx", syn_id2attr(id));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2709 msg_putchar(' ');
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2710 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2711
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2712 return newline;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2713 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2714
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2715 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2716 * Set the attribute numbers for a highlight group.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2717 * Called after one of the attributes has changed.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2718 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2719 static void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2720 set_hl_attr(
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2721 int idx) // index in array
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2722 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2723 attrentry_T at_en;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2724 hl_group_T *sgp = HL_TABLE() + idx;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2725
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2726 // The "Normal" group doesn't need an attribute number
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2727 if (sgp->sg_name_u != NULL && STRCMP(sgp->sg_name_u, "NORMAL") == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2728 return;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2729
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2730 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2731 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2732 * For the GUI mode: If there are other than "normal" highlighting
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2733 * attributes, need to allocate an attr number.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2734 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2735 if (sgp->sg_gui_fg == INVALCOLOR
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2736 && sgp->sg_gui_bg == INVALCOLOR
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2737 && sgp->sg_gui_sp == INVALCOLOR
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2738 && sgp->sg_font == NOFONT
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2739 # ifdef FEAT_XFONTSET
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2740 && sgp->sg_fontset == NOFONTSET
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2741 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2742 )
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2743 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2744 sgp->sg_gui_attr = sgp->sg_gui;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2745 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2746 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2747 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2748 at_en.ae_attr = sgp->sg_gui;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2749 at_en.ae_u.gui.fg_color = sgp->sg_gui_fg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2750 at_en.ae_u.gui.bg_color = sgp->sg_gui_bg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2751 at_en.ae_u.gui.sp_color = sgp->sg_gui_sp;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2752 at_en.ae_u.gui.font = sgp->sg_font;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2753 # ifdef FEAT_XFONTSET
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2754 at_en.ae_u.gui.fontset = sgp->sg_fontset;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2755 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2756 sgp->sg_gui_attr = get_attr_entry(&gui_attr_table, &at_en);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2757 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2758 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2759 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2760 * For the term mode: If there are other than "normal" highlighting
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2761 * attributes, need to allocate an attr number.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2762 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2763 if (sgp->sg_start == NULL && sgp->sg_stop == NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2764 sgp->sg_term_attr = sgp->sg_term;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2765 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2766 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2767 at_en.ae_attr = sgp->sg_term;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2768 at_en.ae_u.term.start = sgp->sg_start;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2769 at_en.ae_u.term.stop = sgp->sg_stop;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2770 sgp->sg_term_attr = get_attr_entry(&term_attr_table, &at_en);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2771 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2772
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2773 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2774 * For the color term mode: If there are other than "normal"
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2775 * highlighting attributes, need to allocate an attr number.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2776 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2777 if (sgp->sg_cterm_fg == 0 && sgp->sg_cterm_bg == 0
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2778 # ifdef FEAT_TERMGUICOLORS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2779 && sgp->sg_gui_fg == INVALCOLOR
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2780 && sgp->sg_gui_bg == INVALCOLOR
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2781 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2782 )
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2783 sgp->sg_cterm_attr = sgp->sg_cterm;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2784 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2785 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2786 at_en.ae_attr = sgp->sg_cterm;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2787 at_en.ae_u.cterm.fg_color = sgp->sg_cterm_fg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2788 at_en.ae_u.cterm.bg_color = sgp->sg_cterm_bg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2789 # ifdef FEAT_TERMGUICOLORS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2790 # ifdef MSWIN
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2791 # ifdef VIMDLL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2792 // Only when not using the GUI.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2793 if (!gui.in_use && !gui.starting)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2794 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2795 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2796 int id;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2797 guicolor_T fg, bg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2798
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2799 id = syn_name2id((char_u *)"Normal");
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2800 if (id > 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2801 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2802 syn_id2colors(id, &fg, &bg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2803 if (sgp->sg_gui_fg == INVALCOLOR)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2804 sgp->sg_gui_fg = fg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2805 if (sgp->sg_gui_bg == INVALCOLOR)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2806 sgp->sg_gui_bg = bg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2807 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2808
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2809 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2810 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2811 at_en.ae_u.cterm.fg_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_fg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2812 at_en.ae_u.cterm.bg_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_bg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2813 if (at_en.ae_u.cterm.fg_rgb == INVALCOLOR
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2814 && at_en.ae_u.cterm.bg_rgb == INVALCOLOR)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2815 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2816 // If both fg and bg are invalid fall back to the cterm colors.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2817 // Helps when the GUI only uses an attribute, e.g. undercurl.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2818 at_en.ae_u.cterm.fg_rgb = CTERMCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2819 at_en.ae_u.cterm.bg_rgb = CTERMCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2820 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2821 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2822 sgp->sg_cterm_attr = get_attr_entry(&cterm_attr_table, &at_en);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2823 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2824 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2825
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2826 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2827 * Lookup a highlight group name and return its ID.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2828 * If it is not found, 0 is returned.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2829 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2830 int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2831 syn_name2id(char_u *name)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2832 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2833 int i;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2834 char_u name_u[200];
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2835
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2836 // Avoid using stricmp() too much, it's slow on some systems
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2837 // Avoid alloc()/free(), these are slow too. ID names over 200 chars
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2838 // don't deserve to be found!
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2839 vim_strncpy(name_u, name, 199);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2840 vim_strup(name_u);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2841 for (i = highlight_ga.ga_len; --i >= 0; )
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2842 if (HL_TABLE()[i].sg_name_u != NULL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2843 && STRCMP(name_u, HL_TABLE()[i].sg_name_u) == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2844 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2845 return i + 1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2846 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2847
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2848 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2849 * Lookup a highlight group name and return its attributes.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2850 * Return zero if not found.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2851 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2852 int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2853 syn_name2attr(char_u *name)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2854 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2855 int id = syn_name2id(name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2856
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2857 if (id != 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2858 return syn_id2attr(id);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2859 return 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2860 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2861
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2862 #if defined(FEAT_EVAL) || defined(PROTO)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2863 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2864 * Return TRUE if highlight group "name" exists.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2865 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2866 int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2867 highlight_exists(char_u *name)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2868 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2869 return (syn_name2id(name) > 0);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2870 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2871
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2872 # if defined(FEAT_SEARCH_EXTRA) || defined(PROTO)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2873 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2874 * Return the name of highlight group "id".
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2875 * When not a valid ID return an empty string.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2876 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2877 char_u *
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2878 syn_id2name(int id)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2879 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2880 if (id <= 0 || id > highlight_ga.ga_len)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2881 return (char_u *)"";
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2882 return HL_TABLE()[id - 1].sg_name;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2883 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2884 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2885 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2886
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2887 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2888 * Like syn_name2id(), but take a pointer + length argument.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2889 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2890 int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2891 syn_namen2id(char_u *linep, int len)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2892 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2893 char_u *name;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2894 int id = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2895
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2896 name = vim_strnsave(linep, len);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2897 if (name != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2898 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2899 id = syn_name2id(name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2900 vim_free(name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2901 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2902 return id;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2903 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2904
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2905 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2906 * Find highlight group name in the table and return its ID.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2907 * The argument is a pointer to the name and the length of the name.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2908 * If it doesn't exist yet, a new entry is created.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2909 * Return 0 for failure.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2910 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2911 int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2912 syn_check_group(char_u *pp, int len)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2913 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2914 int id;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2915 char_u *name;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2916
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2917 name = vim_strnsave(pp, len);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2918 if (name == NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2919 return 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2920
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2921 id = syn_name2id(name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2922 if (id == 0) // doesn't exist yet
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2923 id = syn_add_group(name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2924 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2925 vim_free(name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2926 return id;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2927 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2928
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2929 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2930 * Add new highlight group and return its ID.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2931 * "name" must be an allocated string, it will be consumed.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2932 * Return 0 for failure.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2933 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2934 static int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2935 syn_add_group(char_u *name)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2936 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2937 char_u *p;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2938
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2939 // Check that the name is ASCII letters, digits and underscore.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2940 for (p = name; *p != NUL; ++p)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2941 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2942 if (!vim_isprintc(*p))
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2943 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2944 emsg(_("E669: Unprintable character in group name"));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2945 vim_free(name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2946 return 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2947 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2948 else if (!ASCII_ISALNUM(*p) && *p != '_')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2949 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2950 // This is an error, but since there previously was no check only
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2951 // give a warning.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2952 msg_source(HL_ATTR(HLF_W));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2953 msg(_("W18: Invalid character in group name"));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2954 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2955 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2956 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2957
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2958 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2959 * First call for this growarray: init growing array.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2960 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2961 if (highlight_ga.ga_data == NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2962 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2963 highlight_ga.ga_itemsize = sizeof(hl_group_T);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2964 highlight_ga.ga_growsize = 10;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2965 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2966
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2967 if (highlight_ga.ga_len >= MAX_HL_ID)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2968 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2969 emsg(_("E849: Too many highlight and syntax groups"));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2970 vim_free(name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2971 return 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2972 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2973
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2974 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2975 * Make room for at least one other syntax_highlight entry.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2976 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2977 if (ga_grow(&highlight_ga, 1) == FAIL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2978 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2979 vim_free(name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2980 return 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2981 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2982
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2983 vim_memset(&(HL_TABLE()[highlight_ga.ga_len]), 0, sizeof(hl_group_T));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2984 HL_TABLE()[highlight_ga.ga_len].sg_name = name;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2985 HL_TABLE()[highlight_ga.ga_len].sg_name_u = vim_strsave_up(name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2986 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2987 HL_TABLE()[highlight_ga.ga_len].sg_gui_bg = INVALCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2988 HL_TABLE()[highlight_ga.ga_len].sg_gui_fg = INVALCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2989 # ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2990 HL_TABLE()[highlight_ga.ga_len].sg_gui_sp = INVALCOLOR;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2991 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2992 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2993 ++highlight_ga.ga_len;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2994
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2995 return highlight_ga.ga_len; // ID is index plus one
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2996 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2997
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2998 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2999 * When, just after calling syn_add_group(), an error is discovered, this
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3000 * function deletes the new name.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3001 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3002 static void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3003 syn_unadd_group(void)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3004 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3005 --highlight_ga.ga_len;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3006 vim_free(HL_TABLE()[highlight_ga.ga_len].sg_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3007 vim_free(HL_TABLE()[highlight_ga.ga_len].sg_name_u);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3008 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3009
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3010 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3011 * Translate a group ID to highlight attributes.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3012 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3013 int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3014 syn_id2attr(int hl_id)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3015 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3016 int attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3017 hl_group_T *sgp;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3018
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3019 hl_id = syn_get_final_id(hl_id);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3020 sgp = &HL_TABLE()[hl_id - 1]; // index is ID minus one
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3021
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3022 #ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3023 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3024 * Only use GUI attr when the GUI is being used.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3025 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3026 if (gui.in_use)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3027 attr = sgp->sg_gui_attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3028 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3029 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3030 if (IS_CTERM)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3031 attr = sgp->sg_cterm_attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3032 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3033 attr = sgp->sg_term_attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3034
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3035 return attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3036 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3037
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3038 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) || defined(PROTO)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3039 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3040 * Get the GUI colors and attributes for a group ID.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3041 * NOTE: the colors will be INVALCOLOR when not set, the color otherwise.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3042 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3043 int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3044 syn_id2colors(int hl_id, guicolor_T *fgp, guicolor_T *bgp)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3045 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3046 hl_group_T *sgp;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3047
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3048 hl_id = syn_get_final_id(hl_id);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3049 sgp = &HL_TABLE()[hl_id - 1]; // index is ID minus one
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3050
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3051 *fgp = sgp->sg_gui_fg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3052 *bgp = sgp->sg_gui_bg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3053 return sgp->sg_gui;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3054 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3055 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3056
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3057 #if (defined(MSWIN) \
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3058 && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) \
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3059 && defined(FEAT_TERMGUICOLORS)) || defined(PROTO)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3060 void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3061 syn_id2cterm_bg(int hl_id, int *fgp, int *bgp)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3062 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3063 hl_group_T *sgp;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3064
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3065 hl_id = syn_get_final_id(hl_id);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3066 sgp = &HL_TABLE()[hl_id - 1]; // index is ID minus one
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3067 *fgp = sgp->sg_cterm_fg - 1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3068 *bgp = sgp->sg_cterm_bg - 1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3069 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3070 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3071
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3072 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3073 * Translate a group ID to the final group ID (following links).
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3074 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3075 int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3076 syn_get_final_id(int hl_id)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3077 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3078 int count;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3079 hl_group_T *sgp;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3080
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3081 if (hl_id > highlight_ga.ga_len || hl_id < 1)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3082 return 0; // Can be called from eval!!
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3083
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3084 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3085 * Follow links until there is no more.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3086 * Look out for loops! Break after 100 links.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3087 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3088 for (count = 100; --count >= 0; )
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3089 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3090 sgp = &HL_TABLE()[hl_id - 1]; // index is ID minus one
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3091 if (sgp->sg_link == 0 || sgp->sg_link > highlight_ga.ga_len)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3092 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3093 hl_id = sgp->sg_link;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3094 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3095
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3096 return hl_id;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3097 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3098
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3099 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) || defined(PROTO)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3100 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3101 * Call this function just after the GUI has started.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3102 * Also called when 'termguicolors' was set, gui.in_use will be FALSE then.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3103 * It finds the font and color handles for the highlighting groups.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3104 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3105 void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3106 highlight_gui_started(void)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3107 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3108 int idx;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3109
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3110 // First get the colors from the "Normal" and "Menu" group, if set
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3111 if (USE_24BIT)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3112 set_normal_colors();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3113
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3114 for (idx = 0; idx < highlight_ga.ga_len; ++idx)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3115 gui_do_one_color(idx, FALSE, FALSE);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3116
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3117 highlight_changed();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3118 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3119
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3120 static void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3121 gui_do_one_color(
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3122 int idx,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3123 int do_menu UNUSED, // TRUE: might set the menu font
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3124 int do_tooltip UNUSED) // TRUE: might set the tooltip font
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3125 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3126 int didit = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3127
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3128 # ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3129 # ifdef FEAT_TERMGUICOLORS
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3130 if (gui.in_use)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3131 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3132 if (HL_TABLE()[idx].sg_font_name != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3133 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3134 hl_do_font(idx, HL_TABLE()[idx].sg_font_name, FALSE, do_menu,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3135 do_tooltip, TRUE);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3136 didit = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3137 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3138 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3139 if (HL_TABLE()[idx].sg_gui_fg_name != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3140 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3141 HL_TABLE()[idx].sg_gui_fg =
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3142 color_name2handle(HL_TABLE()[idx].sg_gui_fg_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3143 didit = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3144 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3145 if (HL_TABLE()[idx].sg_gui_bg_name != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3146 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3147 HL_TABLE()[idx].sg_gui_bg =
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3148 color_name2handle(HL_TABLE()[idx].sg_gui_bg_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3149 didit = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3150 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3151 # ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3152 if (HL_TABLE()[idx].sg_gui_sp_name != NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3153 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3154 HL_TABLE()[idx].sg_gui_sp =
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3155 color_name2handle(HL_TABLE()[idx].sg_gui_sp_name);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3156 didit = TRUE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3157 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3158 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3159 if (didit) // need to get a new attr number
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3160 set_hl_attr(idx);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3161 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3162 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3163
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3164 #if defined(USER_HIGHLIGHT) && defined(FEAT_STL_OPT)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3165 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3166 * Apply difference between User[1-9] and HLF_S to HLF_SNC, HLF_ST or HLF_STNC.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3167 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3168 static void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3169 combine_stl_hlt(
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3170 int id,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3171 int id_S,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3172 int id_alt,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3173 int hlcnt,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3174 int i,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3175 int hlf,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3176 int *table)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3177 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3178 hl_group_T *hlt = HL_TABLE();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3179
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3180 if (id_alt == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3181 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3182 vim_memset(&hlt[hlcnt + i], 0, sizeof(hl_group_T));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3183 hlt[hlcnt + i].sg_term = highlight_attr[hlf];
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3184 hlt[hlcnt + i].sg_cterm = highlight_attr[hlf];
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3185 # if defined(FEAT_GUI) || defined(FEAT_EVAL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3186 hlt[hlcnt + i].sg_gui = highlight_attr[hlf];
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3187 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3188 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3189 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3190 mch_memmove(&hlt[hlcnt + i],
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3191 &hlt[id_alt - 1],
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3192 sizeof(hl_group_T));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3193 hlt[hlcnt + i].sg_link = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3194
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3195 hlt[hlcnt + i].sg_term ^=
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3196 hlt[id - 1].sg_term ^ hlt[id_S - 1].sg_term;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3197 if (hlt[id - 1].sg_start != hlt[id_S - 1].sg_start)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3198 hlt[hlcnt + i].sg_start = hlt[id - 1].sg_start;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3199 if (hlt[id - 1].sg_stop != hlt[id_S - 1].sg_stop)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3200 hlt[hlcnt + i].sg_stop = hlt[id - 1].sg_stop;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3201 hlt[hlcnt + i].sg_cterm ^=
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3202 hlt[id - 1].sg_cterm ^ hlt[id_S - 1].sg_cterm;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3203 if (hlt[id - 1].sg_cterm_fg != hlt[id_S - 1].sg_cterm_fg)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3204 hlt[hlcnt + i].sg_cterm_fg = hlt[id - 1].sg_cterm_fg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3205 if (hlt[id - 1].sg_cterm_bg != hlt[id_S - 1].sg_cterm_bg)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3206 hlt[hlcnt + i].sg_cterm_bg = hlt[id - 1].sg_cterm_bg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3207 # if defined(FEAT_GUI) || defined(FEAT_EVAL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3208 hlt[hlcnt + i].sg_gui ^=
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3209 hlt[id - 1].sg_gui ^ hlt[id_S - 1].sg_gui;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3210 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3211 # ifdef FEAT_GUI
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3212 if (hlt[id - 1].sg_gui_fg != hlt[id_S - 1].sg_gui_fg)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3213 hlt[hlcnt + i].sg_gui_fg = hlt[id - 1].sg_gui_fg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3214 if (hlt[id - 1].sg_gui_bg != hlt[id_S - 1].sg_gui_bg)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3215 hlt[hlcnt + i].sg_gui_bg = hlt[id - 1].sg_gui_bg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3216 if (hlt[id - 1].sg_gui_sp != hlt[id_S - 1].sg_gui_sp)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3217 hlt[hlcnt + i].sg_gui_sp = hlt[id - 1].sg_gui_sp;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3218 if (hlt[id - 1].sg_font != hlt[id_S - 1].sg_font)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3219 hlt[hlcnt + i].sg_font = hlt[id - 1].sg_font;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3220 # ifdef FEAT_XFONTSET
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3221 if (hlt[id - 1].sg_fontset != hlt[id_S - 1].sg_fontset)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3222 hlt[hlcnt + i].sg_fontset = hlt[id - 1].sg_fontset;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3223 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3224 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3225 highlight_ga.ga_len = hlcnt + i + 1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3226 set_hl_attr(hlcnt + i); // At long last we can apply
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3227 table[i] = syn_id2attr(hlcnt + i + 1);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3228 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3229 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3230
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3231 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3232 * Translate the 'highlight' option into attributes in highlight_attr[] and
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3233 * set up the user highlights User1..9. If FEAT_STL_OPT is in use, a set of
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3234 * corresponding highlights to use on top of HLF_SNC is computed.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3235 * Called only when the 'highlight' option has been changed and upon first
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3236 * screen redraw after any :highlight command.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3237 * Return FAIL when an invalid flag is found in 'highlight'. OK otherwise.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3238 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3239 int
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3240 highlight_changed(void)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3241 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3242 int hlf;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3243 int i;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3244 char_u *p;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3245 int attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3246 char_u *end;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3247 int id;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3248 #ifdef USER_HIGHLIGHT
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3249 char_u userhl[30]; // use 30 to avoid compiler warning
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3250 # ifdef FEAT_STL_OPT
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3251 int id_S = -1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3252 int id_SNC = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3253 # ifdef FEAT_TERMINAL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3254 int id_ST = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3255 int id_STNC = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3256 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3257 int hlcnt;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3258 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3259 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3260 static int hl_flags[HLF_COUNT] = HL_FLAGS;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3261
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3262 need_highlight_changed = FALSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3263
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3264 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3265 * Clear all attributes.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3266 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3267 for (hlf = 0; hlf < (int)HLF_COUNT; ++hlf)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3268 highlight_attr[hlf] = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3269
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3270 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3271 * First set all attributes to their default value.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3272 * Then use the attributes from the 'highlight' option.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3273 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3274 for (i = 0; i < 2; ++i)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3275 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3276 if (i)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3277 p = p_hl;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3278 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3279 p = get_highlight_default();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3280 if (p == NULL) // just in case
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3281 continue;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3282
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3283 while (*p)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3284 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3285 for (hlf = 0; hlf < (int)HLF_COUNT; ++hlf)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3286 if (hl_flags[hlf] == *p)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3287 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3288 ++p;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3289 if (hlf == (int)HLF_COUNT || *p == NUL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3290 return FAIL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3291
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3292 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3293 * Allow several hl_flags to be combined, like "bu" for
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3294 * bold-underlined.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3295 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3296 attr = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3297 for ( ; *p && *p != ','; ++p) // parse upto comma
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3298 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3299 if (VIM_ISWHITE(*p)) // ignore white space
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3300 continue;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3301
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3302 if (attr > HL_ALL) // Combination with ':' is not allowed.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3303 return FAIL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3304
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3305 switch (*p)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3306 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3307 case 'b': attr |= HL_BOLD;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3308 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3309 case 'i': attr |= HL_ITALIC;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3310 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3311 case '-':
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3312 case 'n': // no highlighting
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3313 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3314 case 'r': attr |= HL_INVERSE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3315 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3316 case 's': attr |= HL_STANDOUT;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3317 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3318 case 'u': attr |= HL_UNDERLINE;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3319 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3320 case 'c': attr |= HL_UNDERCURL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3321 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3322 case 't': attr |= HL_STRIKETHROUGH;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3323 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3324 case ':': ++p; // highlight group name
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3325 if (attr || *p == NUL) // no combinations
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3326 return FAIL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3327 end = vim_strchr(p, ',');
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3328 if (end == NULL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3329 end = p + STRLEN(p);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3330 id = syn_check_group(p, (int)(end - p));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3331 if (id == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3332 return FAIL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3333 attr = syn_id2attr(id);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3334 p = end - 1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3335 #if defined(FEAT_STL_OPT) && defined(USER_HIGHLIGHT)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3336 if (hlf == (int)HLF_SNC)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3337 id_SNC = syn_get_final_id(id);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3338 # ifdef FEAT_TERMINAL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3339 else if (hlf == (int)HLF_ST)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3340 id_ST = syn_get_final_id(id);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3341 else if (hlf == (int)HLF_STNC)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3342 id_STNC = syn_get_final_id(id);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3343 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3344 else if (hlf == (int)HLF_S)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3345 id_S = syn_get_final_id(id);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3346 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3347 break;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3348 default: return FAIL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3349 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3350 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3351 highlight_attr[hlf] = attr;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3352
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3353 p = skip_to_option_part(p); // skip comma and spaces
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3354 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3355 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3356
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3357 #ifdef USER_HIGHLIGHT
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3358 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3359 * Setup the user highlights
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3360 *
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3361 * Temporarily utilize 28 more hl entries:
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3362 * 9 for User1-User9 combined with StatusLineNC
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3363 * 9 for User1-User9 combined with StatusLineTerm
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3364 * 9 for User1-User9 combined with StatusLineTermNC
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3365 * 1 for StatusLine default
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3366 * Have to be in there simultaneously in case of table overflows in
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3367 * get_attr_entry()
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3368 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3369 # ifdef FEAT_STL_OPT
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3370 if (ga_grow(&highlight_ga, 28) == FAIL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3371 return FAIL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3372 hlcnt = highlight_ga.ga_len;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3373 if (id_S == -1)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3374 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3375 // Make sure id_S is always valid to simplify code below. Use the last
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3376 // entry.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3377 vim_memset(&HL_TABLE()[hlcnt + 27], 0, sizeof(hl_group_T));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3378 HL_TABLE()[hlcnt + 18].sg_term = highlight_attr[HLF_S];
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3379 id_S = hlcnt + 19;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3380 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3381 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3382 for (i = 0; i < 9; i++)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3383 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3384 sprintf((char *)userhl, "User%d", i + 1);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3385 id = syn_name2id(userhl);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3386 if (id == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3387 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3388 highlight_user[i] = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3389 # ifdef FEAT_STL_OPT
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3390 highlight_stlnc[i] = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3391 # ifdef FEAT_TERMINAL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3392 highlight_stlterm[i] = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3393 highlight_stltermnc[i] = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3394 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3395 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3396 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3397 else
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3398 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3399 highlight_user[i] = syn_id2attr(id);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3400 # ifdef FEAT_STL_OPT
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3401 combine_stl_hlt(id, id_S, id_SNC, hlcnt, i,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3402 HLF_SNC, highlight_stlnc);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3403 # ifdef FEAT_TERMINAL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3404 combine_stl_hlt(id, id_S, id_ST, hlcnt + 9, i,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3405 HLF_ST, highlight_stlterm);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3406 combine_stl_hlt(id, id_S, id_STNC, hlcnt + 18, i,
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3407 HLF_STNC, highlight_stltermnc);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3408 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3409 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3410 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3411 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3412 # ifdef FEAT_STL_OPT
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3413 highlight_ga.ga_len = hlcnt;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3414 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3415
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3416 #endif // USER_HIGHLIGHT
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3417
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3418 return OK;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3419 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3420
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3421 #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3422
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3423 static void highlight_list(void);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3424 static void highlight_list_two(int cnt, int attr);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3425
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3426 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3427 * Handle command line completion for :highlight command.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3428 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3429 void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3430 set_context_in_highlight_cmd(expand_T *xp, char_u *arg)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3431 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3432 char_u *p;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3433
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3434 // Default: expand group names
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3435 xp->xp_context = EXPAND_HIGHLIGHT;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3436 xp->xp_pattern = arg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3437 include_link = 2;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3438 include_default = 1;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3439
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3440 // (part of) subcommand already typed
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3441 if (*arg != NUL)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3442 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3443 p = skiptowhite(arg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3444 if (*p != NUL) // past "default" or group name
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3445 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3446 include_default = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3447 if (STRNCMP("default", arg, p - arg) == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3448 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3449 arg = skipwhite(p);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3450 xp->xp_pattern = arg;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3451 p = skiptowhite(arg);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3452 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3453 if (*p != NUL) // past group name
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3454 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3455 include_link = 0;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3456 if (arg[1] == 'i' && arg[0] == 'N')
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3457 highlight_list();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3458 if (STRNCMP("link", arg, p - arg) == 0
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3459 || STRNCMP("clear", arg, p - arg) == 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3460 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3461 xp->xp_pattern = skipwhite(p);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3462 p = skiptowhite(xp->xp_pattern);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3463 if (*p != NUL) // past first group name
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3464 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3465 xp->xp_pattern = skipwhite(p);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3466 p = skiptowhite(xp->xp_pattern);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3467 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3468 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3469 if (*p != NUL) // past group name(s)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3470 xp->xp_context = EXPAND_NOTHING;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3471 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3472 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3473 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3474 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3475
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3476 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3477 * List highlighting matches in a nice way.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3478 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3479 static void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3480 highlight_list(void)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3481 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3482 int i;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3483
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3484 for (i = 10; --i >= 0; )
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3485 highlight_list_two(i, HL_ATTR(HLF_D));
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3486 for (i = 40; --i >= 0; )
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3487 highlight_list_two(99, 0);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3488 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3489
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3490 static void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3491 highlight_list_two(int cnt, int attr)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3492 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3493 msg_puts_attr(&("N \bI \b! \b"[cnt / 11]), attr);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3494 msg_clr_eos();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3495 out_flush();
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3496 ui_delay(cnt == 99 ? 40L : (long)cnt * 50L, FALSE);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3497 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3498
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3499 #endif // FEAT_CMDL_COMPL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3500
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3501 #if defined(FEAT_CMDL_COMPL) || (defined(FEAT_SYN_HL) && defined(FEAT_EVAL)) \
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3502 || defined(FEAT_SIGNS) || defined(PROTO)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3503 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3504 * Function given to ExpandGeneric() to obtain the list of group names.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3505 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3506 char_u *
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3507 get_highlight_name(expand_T *xp UNUSED, int idx)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3508 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3509 return get_highlight_name_ext(xp, idx, TRUE);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3510 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3511
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3512 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3513 * Obtain a highlight group name.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3514 * When "skip_cleared" is TRUE don't return a cleared entry.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3515 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3516 char_u *
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3517 get_highlight_name_ext(expand_T *xp UNUSED, int idx, int skip_cleared)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3518 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3519 if (idx < 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3520 return NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3521
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3522 // Items are never removed from the table, skip the ones that were
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3523 // cleared.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3524 if (skip_cleared && idx < highlight_ga.ga_len && HL_TABLE()[idx].sg_cleared)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3525 return (char_u *)"";
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3526
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3527 #ifdef FEAT_CMDL_COMPL
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3528 if (idx == highlight_ga.ga_len && include_none != 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3529 return (char_u *)"none";
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3530 if (idx == highlight_ga.ga_len + include_none && include_default != 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3531 return (char_u *)"default";
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3532 if (idx == highlight_ga.ga_len + include_none + include_default
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3533 && include_link != 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3534 return (char_u *)"link";
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3535 if (idx == highlight_ga.ga_len + include_none + include_default + 1
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3536 && include_link != 0)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3537 return (char_u *)"clear";
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3538 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3539 if (idx >= highlight_ga.ga_len)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3540 return NULL;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3541 return HL_TABLE()[idx].sg_name;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3542 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3543 #endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3544
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3545 #if defined(FEAT_GUI) || defined(PROTO)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3546 /*
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3547 * Free all the highlight group fonts.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3548 * Used when quitting for systems which need it.
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3549 */
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3550 void
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3551 free_highlight_fonts(void)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3552 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3553 int idx;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3554
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3555 for (idx = 0; idx < highlight_ga.ga_len; ++idx)
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3556 {
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3557 gui_mch_free_font(HL_TABLE()[idx].sg_font);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3558 HL_TABLE()[idx].sg_font = NOFONT;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3559 # ifdef FEAT_XFONTSET
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3560 gui_mch_free_fontset(HL_TABLE()[idx].sg_fontset);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3561 HL_TABLE()[idx].sg_fontset = NOFONTSET;
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3562 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3563 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3564
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3565 gui_mch_free_font(gui.norm_font);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3566 # ifdef FEAT_XFONTSET
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3567 gui_mch_free_fontset(gui.fontset);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3568 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3569 # ifndef FEAT_GUI_GTK
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3570 gui_mch_free_font(gui.bold_font);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3571 gui_mch_free_font(gui.ital_font);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3572 gui_mch_free_font(gui.boldital_font);
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3573 # endif
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3574 }
635d7f5010b8 patch 8.1.1693: syntax coloring and highlighting is in one big file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3575 #endif