forked from aniani/vim
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)
This commit is contained in:
parent
b8be54dcc5
commit
f9cc9f209e
2
Filelist
2
Filelist
@ -50,6 +50,7 @@ SRC_ALL = \
|
||||
src/gui_beval.c \
|
||||
src/hardcopy.c \
|
||||
src/hashtab.c \
|
||||
src/highlight.c \
|
||||
src/indent.c \
|
||||
src/insexpand.c \
|
||||
src/json.c \
|
||||
@ -190,6 +191,7 @@ SRC_ALL = \
|
||||
src/proto/gui_beval.pro \
|
||||
src/proto/hardcopy.pro \
|
||||
src/proto/hashtab.pro \
|
||||
src/proto/highlight.pro \
|
||||
src/proto/indent.pro \
|
||||
src/proto/insexpand.pro \
|
||||
src/proto/json.pro \
|
||||
|
@ -730,6 +730,7 @@ OBJ = \
|
||||
$(OUTDIR)/getchar.o \
|
||||
$(OUTDIR)/hardcopy.o \
|
||||
$(OUTDIR)/hashtab.o \
|
||||
$(OUTDIR)/highlight.o \
|
||||
$(OUTDIR)/indent.o \
|
||||
$(OUTDIR)/insexpand.o \
|
||||
$(OUTDIR)/json.o \
|
||||
|
@ -50,6 +50,7 @@ SRC = arabic.c \
|
||||
getchar.c \
|
||||
hardcopy.c \
|
||||
hashtab.c \
|
||||
highlight.c \
|
||||
indent.c \
|
||||
insexpand.c \
|
||||
json.c \
|
||||
|
@ -739,6 +739,7 @@ OBJ = \
|
||||
$(OUTDIR)\getchar.obj \
|
||||
$(OUTDIR)\hardcopy.obj \
|
||||
$(OUTDIR)\hashtab.obj \
|
||||
$(OUTDIR)\highlight.obj \
|
||||
$(OUTDIR)\indent.obj \
|
||||
$(OUTDIR)\insexpand.obj \
|
||||
$(OUTDIR)\json.obj \
|
||||
@ -1487,6 +1488,8 @@ $(OUTDIR)/hardcopy.obj: $(OUTDIR) hardcopy.c $(INCL)
|
||||
|
||||
$(OUTDIR)/hashtab.obj: $(OUTDIR) hashtab.c $(INCL)
|
||||
|
||||
$(OUTDIR)/highlight.obj: $(OUTDIR) highlight.c $(INCL)
|
||||
|
||||
$(OUTDIR)/indent.obj: $(OUTDIR) indent.c $(INCL)
|
||||
|
||||
$(OUTDIR)/insexpand.obj: $(OUTDIR) insexpand.c $(INCL)
|
||||
@ -1747,6 +1750,7 @@ proto.h: \
|
||||
proto/getchar.pro \
|
||||
proto/hardcopy.pro \
|
||||
proto/hashtab.pro \
|
||||
proto/highlight.pro \
|
||||
proto/indent.pro \
|
||||
proto/insexpand.pro \
|
||||
proto/json.pro \
|
||||
|
@ -311,12 +311,13 @@ SRC = arabic.c autocmd.c beval.c blob.c blowfish.c buffer.c change.c charset.c \
|
||||
crypt.c crypt_zip.c debugger.c dict.c diff.c digraph.c edit.c eval.c \
|
||||
evalfunc.c ex_cmds.c ex_cmds2.c ex_docmd.c ex_eval.c ex_getln.c \
|
||||
if_cscope.c if_xcmdsrv.c fileio.c findfile.c fold.c getchar.c \
|
||||
hardcopy.c hashtab.c indent.c insexpand.c json.c list.c main.c mark.c \
|
||||
menu.c mbyte.c memfile.c memline.c message.c misc1.c misc2.c move.c \
|
||||
normal.c ops.c option.c popupmnu.c popupwin.c profiler.c quickfix.c \
|
||||
regexp.c search.c sha256.c sign.c spell.c spellfile.c syntax.c tag.c \
|
||||
term.c termlib.c testing.c textprop.c ui.c undo.c usercmd.c userfunc.c \
|
||||
version.c screen.c window.c os_unix.c os_vms.c pathdef.c \
|
||||
hardcopy.c hashtab.c highlight.c indent.c insexpand.c json.c list.c \
|
||||
main.c mark.c menu.c mbyte.c memfile.c memline.c message.c misc1.c \
|
||||
misc2.c move.c normal.c ops.c option.c popupmnu.c popupwin.c \
|
||||
profiler.c quickfix.c regexp.c search.c sha256.c sign.c spell.c \
|
||||
spellfile.c syntax.c tag.c term.c termlib.c testing.c textprop.c ui.c \
|
||||
undo.c usercmd.c userfunc.c version.c screen.c window.c os_unix.c \
|
||||
os_vms.c pathdef.c \
|
||||
$(GUI_SRC) $(PERL_SRC) $(PYTHON_SRC) $(TCL_SRC) \
|
||||
$(RUBY_SRC) $(HANGULIN_SRC) $(MZSCH_SRC) $(XDIFF_SRC)
|
||||
|
||||
@ -325,14 +326,14 @@ OBJ = arabic.obj autocmd.obj beval.obj blob.obj blowfish.obj buffer.obj change.
|
||||
digraph.obj edit.obj eval.obj evalfunc.obj ex_cmds.obj ex_cmds2.obj \
|
||||
ex_docmd.obj ex_eval.obj ex_getln.obj if_cscope.obj if_xcmdsrv.obj \
|
||||
fileio.obj findfile.obj fold.obj getchar.obj hardcopy.obj hashtab.obj \
|
||||
indent.obj insexpand.obj json.obj list.obj main.obj mark.obj \
|
||||
menu.obj memfile.obj memline.obj message.obj misc1.obj misc2.obj \
|
||||
move.obj mbyte.obj normal.obj ops.obj option.obj popupmnu.obj \
|
||||
popupwin.obj profiler.obj quickfix.obj regexp.obj search.obj \
|
||||
sha256.obj sign.obj spell.obj spellfile.obj syntax.obj tag.obj \
|
||||
term.obj termlib.obj testing.obj textprop.obj ui.obj undo.obj usercmd.obj \
|
||||
userfunc.obj screen.obj version.obj window.obj os_unix.obj os_vms.obj \
|
||||
pathdef.obj if_mzsch.obj \
|
||||
highlight.obj indent.obj insexpand.obj json.obj list.obj main.obj \
|
||||
mark.obj menu.obj memfile.obj memline.obj message.obj misc1.obj \
|
||||
misc2.obj move.obj mbyte.obj normal.obj ops.obj option.obj \
|
||||
popupmnu.obj popupwin.obj profiler.obj quickfix.obj regexp.obj \
|
||||
search.obj sha256.obj sign.obj spell.obj spellfile.obj syntax.obj \
|
||||
tag.obj term.obj termlib.obj testing.obj textprop.obj ui.obj undo.obj \
|
||||
usercmd.obj userfunc.obj screen.obj version.obj window.obj \
|
||||
os_unix.obj os_vms.obj pathdef.obj if_mzsch.obj \
|
||||
$(GUI_OBJ) $(PERL_OBJ) $(PYTHON_OBJ) $(TCL_OBJ) \
|
||||
$(RUBY_OBJ) $(HANGULIN_OBJ) $(MZSCH_OBJ) $(XDIFF_OBJ)
|
||||
|
||||
@ -599,6 +600,10 @@ hashtab.obj : hashtab.c vim.h [.auto]config.h feature.h os_unix.h \
|
||||
ascii.h keymap.h term.h macros.h structs.h regexp.h \
|
||||
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
|
||||
globals.h
|
||||
highlight.obj : highlight.c vim.h [.auto]config.h feature.h os_unix.h \
|
||||
ascii.h keymap.h term.h macros.h structs.h regexp.h \
|
||||
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
|
||||
globals.h
|
||||
if_cscope.obj : if_cscope.c vim.h [.auto]config.h feature.h os_unix.h \
|
||||
ascii.h keymap.h term.h macros.h structs.h regexp.h \
|
||||
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
|
||||
|
10
src/Makefile
10
src/Makefile
@ -1604,6 +1604,7 @@ BASIC_SRC = \
|
||||
getchar.c \
|
||||
hardcopy.c \
|
||||
hashtab.c \
|
||||
highlight.c \
|
||||
if_cscope.c \
|
||||
if_xcmdsrv.c \
|
||||
indent.c \
|
||||
@ -1725,6 +1726,7 @@ OBJ_COMMON = \
|
||||
objects/getchar.o \
|
||||
objects/hardcopy.o \
|
||||
objects/hashtab.o \
|
||||
objects/highlight.o \
|
||||
$(HANGULIN_OBJ) \
|
||||
objects/if_cscope.o \
|
||||
objects/if_xcmdsrv.o \
|
||||
@ -1860,6 +1862,7 @@ PRO_AUTO = \
|
||||
hardcopy.pro \
|
||||
hashtab.pro \
|
||||
hangulin.pro \
|
||||
highlight.pro \
|
||||
if_cscope.pro \
|
||||
if_lua.pro \
|
||||
if_mzsch.pro \
|
||||
@ -3103,6 +3106,9 @@ objects/gui_mac.o: gui_mac.c
|
||||
objects/hangulin.o: hangulin.c
|
||||
$(CCC) -o $@ hangulin.c
|
||||
|
||||
objects/highlight.o: highlight.c
|
||||
$(CCC) -o $@ highlight.c
|
||||
|
||||
objects/if_cscope.o: if_cscope.c
|
||||
$(CCC) -o $@ if_cscope.c
|
||||
|
||||
@ -3554,6 +3560,10 @@ objects/hashtab.o: hashtab.c vim.h protodef.h auto/config.h feature.h os_unix.h
|
||||
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
|
||||
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
|
||||
proto.h globals.h
|
||||
objects/highlight.o: highlight.c vim.h protodef.h auto/config.h feature.h os_unix.h \
|
||||
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
|
||||
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
|
||||
proto.h globals.h
|
||||
objects/if_cscope.o: if_cscope.c vim.h protodef.h auto/config.h feature.h \
|
||||
os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
|
||||
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
|
||||
|
@ -34,6 +34,7 @@ fileio.c | reading and writing files
|
||||
findfile.c | search for files in 'path'
|
||||
fold.c | folding
|
||||
getchar.c | getting characters and key mapping
|
||||
highlight.c | syntax highlighting
|
||||
indent.c | C and Lisp indentation
|
||||
insexpand.c | Insert mode completion
|
||||
mark.c | marks
|
||||
|
@ -355,6 +355,16 @@ EXTERN char_u hash_removed;
|
||||
EXTERN int scroll_region INIT(= FALSE); /* term supports scroll region */
|
||||
EXTERN int t_colors INIT(= 0); /* int value of T_CCO */
|
||||
|
||||
// highlight groups for 'highlight' option
|
||||
EXTERN garray_T highlight_ga INIT(= {0 COMMA 0 COMMA sizeof(hl_group_T) COMMA 10 COMMA NULL});
|
||||
|
||||
#ifdef FEAT_CMDL_COMPL
|
||||
// Flags to indicate an additional string for highlight name completion.
|
||||
EXTERN int include_none INIT(= 0); // when 1 include "None"
|
||||
EXTERN int include_default INIT(= 0); // when 1 include "default"
|
||||
EXTERN int include_link INIT(= 0); // when 2 include "link" and "clear"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* When highlight_match is TRUE, highlight a match, starting at the cursor
|
||||
* position. Search_match_lines is the number of lines after the match (0 for
|
||||
|
3575
src/highlight.c
Normal file
3575
src/highlight.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -89,6 +89,7 @@ extern int _stricoll(char *a, char *b);
|
||||
# endif
|
||||
# include "hardcopy.pro"
|
||||
# include "hashtab.pro"
|
||||
# include "highlight.pro"
|
||||
# include "indent.pro"
|
||||
# ifdef FEAT_INS_EXPAND
|
||||
# include "insexpand.pro"
|
||||
|
43
src/proto/highlight.pro
Normal file
43
src/proto/highlight.pro
Normal file
@ -0,0 +1,43 @@
|
||||
/* highlight.c */
|
||||
void init_highlight(int both, int reset);
|
||||
int load_colors(char_u *name);
|
||||
int lookup_color(int idx, int foreground, int *boldp);
|
||||
void do_highlight(char_u *line, int forceit, int init);
|
||||
void free_highlight(void);
|
||||
void restore_cterm_colors(void);
|
||||
void set_normal_colors(void);
|
||||
char_u *hl_get_font_name(void);
|
||||
void hl_set_font_name(char_u *font_name);
|
||||
void hl_set_bg_color_name(char_u *name);
|
||||
void hl_set_fg_color_name(char_u *name);
|
||||
guicolor_T color_name2handle(char_u *name);
|
||||
int get_cterm_attr_idx(int attr, int fg, int bg);
|
||||
int get_tgc_attr_idx(int attr, guicolor_T fg, guicolor_T bg);
|
||||
int get_gui_attr_idx(int attr, guicolor_T fg, guicolor_T bg);
|
||||
void clear_hl_tables(void);
|
||||
int hl_combine_attr(int char_attr, int prim_attr);
|
||||
attrentry_T *syn_gui_attr2entry(int attr);
|
||||
int syn_attr2attr(int attr);
|
||||
attrentry_T *syn_term_attr2entry(int attr);
|
||||
attrentry_T *syn_cterm_attr2entry(int attr);
|
||||
char_u *highlight_has_attr(int id, int flag, int modec);
|
||||
char_u *highlight_color(int id, char_u *what, int modec);
|
||||
long_u highlight_gui_color_rgb(int id, int fg);
|
||||
int syn_list_header(int did_header, int outlen, int id);
|
||||
int syn_name2id(char_u *name);
|
||||
int syn_name2attr(char_u *name);
|
||||
int highlight_exists(char_u *name);
|
||||
char_u *syn_id2name(int id);
|
||||
int syn_namen2id(char_u *linep, int len);
|
||||
int syn_check_group(char_u *pp, int len);
|
||||
int syn_id2attr(int hl_id);
|
||||
int syn_id2colors(int hl_id, guicolor_T *fgp, guicolor_T *bgp);
|
||||
void syn_id2cterm_bg(int hl_id, int *fgp, int *bgp);
|
||||
int syn_get_final_id(int hl_id);
|
||||
void highlight_gui_started(void);
|
||||
int highlight_changed(void);
|
||||
void set_context_in_highlight_cmd(expand_T *xp, char_u *arg);
|
||||
char_u *get_highlight_name(expand_T *xp, int idx);
|
||||
char_u *get_highlight_name_ext(expand_T *xp, int idx, int skip_cleared);
|
||||
void free_highlight_fonts(void);
|
||||
/* vim: set ft=c : */
|
@ -22,44 +22,4 @@ int syn_get_stack_item(int i);
|
||||
int syn_get_foldlevel(win_T *wp, long lnum);
|
||||
void ex_syntime(exarg_T *eap);
|
||||
char_u *get_syntime_arg(expand_T *xp, int idx);
|
||||
void init_highlight(int both, int reset);
|
||||
int load_colors(char_u *name);
|
||||
int lookup_color(int idx, int foreground, int *boldp);
|
||||
void do_highlight(char_u *line, int forceit, int init);
|
||||
void free_highlight(void);
|
||||
void restore_cterm_colors(void);
|
||||
void set_normal_colors(void);
|
||||
char_u *hl_get_font_name(void);
|
||||
void hl_set_font_name(char_u *font_name);
|
||||
void hl_set_bg_color_name(char_u *name);
|
||||
void hl_set_fg_color_name(char_u *name);
|
||||
guicolor_T color_name2handle(char_u *name);
|
||||
int get_cterm_attr_idx(int attr, int fg, int bg);
|
||||
int get_tgc_attr_idx(int attr, guicolor_T fg, guicolor_T bg);
|
||||
int get_gui_attr_idx(int attr, guicolor_T fg, guicolor_T bg);
|
||||
void clear_hl_tables(void);
|
||||
int hl_combine_attr(int char_attr, int prim_attr);
|
||||
attrentry_T *syn_gui_attr2entry(int attr);
|
||||
int syn_attr2attr(int attr);
|
||||
attrentry_T *syn_term_attr2entry(int attr);
|
||||
attrentry_T *syn_cterm_attr2entry(int attr);
|
||||
char_u *highlight_has_attr(int id, int flag, int modec);
|
||||
char_u *highlight_color(int id, char_u *what, int modec);
|
||||
long_u highlight_gui_color_rgb(int id, int fg);
|
||||
int syn_name2id(char_u *name);
|
||||
int syn_name2attr(char_u *name);
|
||||
int highlight_exists(char_u *name);
|
||||
char_u *syn_id2name(int id);
|
||||
int syn_namen2id(char_u *linep, int len);
|
||||
int syn_check_group(char_u *pp, int len);
|
||||
int syn_id2attr(int hl_id);
|
||||
int syn_id2colors(int hl_id, guicolor_T *fgp, guicolor_T *bgp);
|
||||
void syn_id2cterm_bg(int hl_id, int *fgp, int *bgp);
|
||||
int syn_get_final_id(int hl_id);
|
||||
void highlight_gui_started(void);
|
||||
int highlight_changed(void);
|
||||
void set_context_in_highlight_cmd(expand_T *xp, char_u *arg);
|
||||
char_u *get_highlight_name(expand_T *xp, int idx);
|
||||
char_u *get_highlight_name_ext(expand_T *xp, int idx, int skip_cleared);
|
||||
void free_highlight_fonts(void);
|
||||
/* vim: set ft=c : */
|
||||
|
@ -999,6 +999,58 @@ struct syn_state
|
||||
};
|
||||
#endif // FEAT_SYN_HL
|
||||
|
||||
/*
|
||||
* Structure that stores information about a highlight group.
|
||||
* The ID of a highlight group is also called group ID. It is the index in
|
||||
* the highlight_ga array PLUS ONE.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char_u *sg_name; // highlight group name
|
||||
char_u *sg_name_u; // uppercase of sg_name
|
||||
int sg_cleared; // "hi clear" was used
|
||||
// for normal terminals
|
||||
int sg_term; // "term=" highlighting attributes
|
||||
char_u *sg_start; // terminal string for start highl
|
||||
char_u *sg_stop; // terminal string for stop highl
|
||||
int sg_term_attr; // Screen attr for term mode
|
||||
// for color terminals
|
||||
int sg_cterm; // "cterm=" highlighting attr
|
||||
int sg_cterm_bold; // bold attr was set for light color
|
||||
int sg_cterm_fg; // terminal fg color number + 1
|
||||
int sg_cterm_bg; // terminal bg color number + 1
|
||||
int sg_cterm_attr; // Screen attr for color term mode
|
||||
// for when using the GUI
|
||||
#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
|
||||
guicolor_T sg_gui_fg; // GUI foreground color handle
|
||||
guicolor_T sg_gui_bg; // GUI background color handle
|
||||
#endif
|
||||
#ifdef FEAT_GUI
|
||||
guicolor_T sg_gui_sp; // GUI special color handle
|
||||
GuiFont sg_font; // GUI font handle
|
||||
#ifdef FEAT_XFONTSET
|
||||
GuiFontset sg_fontset; // GUI fontset handle
|
||||
#endif
|
||||
char_u *sg_font_name; // GUI font or fontset name
|
||||
int sg_gui_attr; // Screen attr for GUI mode
|
||||
#endif
|
||||
#if defined(FEAT_GUI) || defined(FEAT_EVAL)
|
||||
// Store the sp color name for the GUI or synIDattr()
|
||||
int sg_gui; // "gui=" highlighting attributes
|
||||
char_u *sg_gui_fg_name;// GUI foreground color name
|
||||
char_u *sg_gui_bg_name;// GUI background color name
|
||||
char_u *sg_gui_sp_name;// GUI special color name
|
||||
#endif
|
||||
int sg_link; // link to this highlight group ID
|
||||
int sg_set; // combination of SG_* flags
|
||||
#ifdef FEAT_EVAL
|
||||
sctx_T sg_script_ctx; // script in which the group was last set
|
||||
#endif
|
||||
} hl_group_T;
|
||||
|
||||
#define HL_TABLE() ((hl_group_T *)((highlight_ga.ga_data)))
|
||||
#define MAX_HL_ID 20000 // maximum value for a highlight ID.
|
||||
|
||||
/*
|
||||
* Structure shared between syntax.c, screen.c and gui_x11.c.
|
||||
*/
|
||||
|
3637
src/syntax.c
3637
src/syntax.c
File diff suppressed because it is too large
Load Diff
@ -777,6 +777,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1693,
|
||||
/**/
|
||||
1692,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user