diff --git a/ChangeLog b/ChangeLog index a50f2193..194dd3c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-08-27 Nick Treleaven btinternet.com> + + * src/highlighting.c, src/plugindata.h, src/filetypes.c, + src/filetypes.h, src/symbols.c, THANKS, tagmanager/parsers.h, + tagmanager/c.c, data/filetypes.glsl, data/filetype_extensions.conf: + Add OpenGL Shader Language (GLSL) filetype (patch from Colomban + Wendling, thanks; closes #2060961). + + 2008-08-26 Nick Treleaven * src/highlighting.c: diff --git a/THANKS b/THANKS index a0ec098b..888e09de 100644 --- a/THANKS +++ b/THANKS @@ -45,6 +45,7 @@ Pierre Joye - Win32 process spawning patch Matti MÃ¥rds - create PHP tags script Robert McGinley - Documentation improvements Felipe Pena - Missing PHP keywords +Colomban Wendling - GLSL filetype patch Translators: ------------ diff --git a/data/filetype_extensions.conf b/data/filetype_extensions.conf index 42b85e42..1a1e365d 100644 --- a/data/filetype_extensions.conf +++ b/data/filetype_extensions.conf @@ -13,6 +13,7 @@ D=*.d;*.di; F77=*.f;*.for;*.ftn;*.f77; Fortran=*.f90;*.f95;*.f03; FreeBasic=*.bas;*.bi; +GLSL=*.glsl;*.frag;*.vert Haskell=*.hs;*.lhs; Haxe=*.hx; Java=*.java;*.jsp; diff --git a/data/filetypes.glsl b/data/filetypes.glsl new file mode 100644 index 00000000..2ab76ab2 --- /dev/null +++ b/data/filetypes.glsl @@ -0,0 +1,68 @@ +# For complete documentation of this file, please see Geany's main documentation +[styling] +# foreground;background;bold;italic +default=0x000000;0xffffff;false;false +comment=0xd00000;0xffffff;false;false +commentline=0xd00000;0xffffff;false;false +commentdoc=0x3f5fbf;0xffffff;false;false +number=0x007f00;0xffffff;false;false +word=0x00007f;0xffffff;true;false +word2=0x991111;0xffffff;true;false +string=0xff901e;0xffffff;false;false +character=0xff901e;0xffffff;false;false +uuid=0x404080;0xffffff;false;false +preprocessor=0x007F7F;0xffffff;false;false +operator=0x301010;0xffffff;false;false +identifier=0x000000;0xffffff;false;false +stringeol=0x000000;0xe0c0e0;false;false +verbatim=0x101030;0xffffff;false;false +regex=0x105090;0xffffff;false;false +commentlinedoc=0x3f5fbf;0xffffff;true;false +commentdockeyword=0x3f5fbf;0xffffff;true;true +commentdockeyworderror=0x3f5fbf;0xffffff;false;false +globalclass=0x0000d0;0xffffff;true;false +# whether arguments of preprocessor commands should be styled (only first argument is used) +# 1 to enable, 0 to disable +styling_within_preprocessor=1;0;false;false + +[keywords] +# all items must be in one line +primary=if else switch case default for while do discard return break continue true false struct void bool int uint float vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 uvec2 uvec3 uvec4 mat2 mat3 mat4 mat2x2 mat2x3 mat2x4 mat3x2 mat3x3 mat3x4 mat4x2 mat4x3 mat4x4 sampler1D sampler2D sampler3D samplerCube sampler1DShadow sampler2DShadow sampler1DArray sampler2DArray sampler1DArrayShadow sampler2DArrayShadow isampler1D isampler2D isampler3D isamplerCube isampler1DArray isampler2DArray usampler1D usampler2D usampler3D usamplerCube usampler1DArray usampler2DArray const invariant centroid in out inout attribute uniform varying smooth flat noperspective highp mediump lowp +secondary= +# these are some doxygen keywords (incomplete) +docComment=attention author brief bug class code date def enum example exception file fn namespace note param remarks return returns see since struct throw todo typedef var version warning union + +[settings] +# default extension used when saving files +#extension=glsl + +# the following characters are these which a "word" can contains, see documentation +#wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 + +# if only single comment char is supported like # in this file, leave comment_close blank +comment_open=// +comment_close= +# this is an alternative way, so multiline comments are used +#comment_open=/* +#comment_close=*/ + +# set to false if a comment character/string should start at column 0 of a line, true uses any +# indentation of the line, e.g. setting to true causes the following on pressing CTRL+d + #command_example(); +# setting to false would generate this +# command_example(); +# This setting works only for single line comments +comment_use_indent=true + +# context action command (please see Geany's main documentation for details) +context_action_cmd= + +[build_settings] +# %f will be replaced by the complete filename +# %e will be replaced by the filename without extension +# (use only one of it at one time) +#compiler= +#linker= +#run_cmd= + + diff --git a/src/filetypes.c b/src/filetypes.c index 7bfec3cb..77681fce 100644 --- a/src/filetypes.c +++ b/src/filetypes.c @@ -167,6 +167,16 @@ static void init_builtin_filetypes(void) ft->comment_open = g_strdup("c"); ft->comment_close = NULL; +#define GLSL + ft = filetypes[GEANY_FILETYPES_GLSL]; + ft->lang = 31; + ft->name = g_strdup("GLSL"); + ft->title = g_strdup_printf(_("%s source file"), "GLSL"); + ft->extension = g_strdup("glsl"); + ft->pattern = utils_strv_new("*.glsl", "*.frag", "*.vert", NULL); + ft->comment_open = g_strdup("/*"); + ft->comment_close = g_strdup("*/"); + #define CAML ft = filetypes[GEANY_FILETYPES_CAML]; ft->lang = -2; diff --git a/src/filetypes.h b/src/filetypes.h index 7a71a51a..b6c4d4a4 100644 --- a/src/filetypes.h +++ b/src/filetypes.h @@ -45,6 +45,7 @@ typedef enum GEANY_FILETYPES_F77, GEANY_FILETYPES_FORTRAN, GEANY_FILETYPES_BASIC, /* FreeBasic */ + GEANY_FILETYPES_GLSL, GEANY_FILETYPES_HASKELL, GEANY_FILETYPES_HAXE, GEANY_FILETYPES_JAVA, diff --git a/src/highlighting.c b/src/highlighting.c index 3f68703e..749fbeba 100644 --- a/src/highlighting.c +++ b/src/highlighting.c @@ -793,6 +793,61 @@ static void styleset_cpp(ScintillaObject *sci) } +static void styleset_glsl_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) +{ + new_style_array(GEANY_FILETYPES_GLSL, 21); + styleset_c_like_init(config, config_home, GEANY_FILETYPES_GLSL); + get_keyfile_int(config, config_home, "styling", "styling_within_preprocessor", + 1, 0, &style_sets[GEANY_FILETYPES_GLSL].styling[20]); + + style_sets[GEANY_FILETYPES_GLSL].keywords = g_new(gchar*, 4); + get_keyfile_keywords(config, config_home, "keywords", "primary", GEANY_FILETYPES_GLSL, 0, + "if else switch case default for while do discard return break" + "continue true false struct void bool int uint float vec2 vec3" + "vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 uvec2 uvec3 uvec4 mat2" + "mat3 mat4 mat2x2 mat2x3 mat2x4 mat3x2 mat3x3 mat3x4 mat4x2 mat4x3" + "mat4x4 sampler1D sampler2D sampler3D samplerCube sampler1DShadow" + "sampler2DShadow sampler1DArray sampler2DArray sampler1DArrayShadow" + "sampler2DArrayShadow isampler1D isampler2D isampler3D isamplerCube" + "isampler1DArray isampler2DArray usampler1D usampler2D usampler3D" + "usamplerCube usampler1DArray usampler2DArray const invariant" + "centroid in out inout attribute uniform varying smooth flat" + "noperspective highp mediump lowp"); + get_keyfile_keywords(config, config_home, "keywords", "secondary", GEANY_FILETYPES_GLSL, 1, ""); + get_keyfile_keywords(config, config_home, "keywords", "docComment", GEANY_FILETYPES_GLSL, 2, "TODO FIXME"); + style_sets[GEANY_FILETYPES_GLSL].keywords[3] = NULL; + + get_keyfile_wordchars(config, config_home, + &style_sets[GEANY_FILETYPES_GLSL].wordchars); +} + + +static void styleset_glsl(ScintillaObject *sci) +{ + const filetype_id ft_id = GEANY_FILETYPES_GLSL; + + styleset_common(sci, 5, ft_id); + + apply_filetype_properties(sci, SCLEX_CPP, ft_id); + + SSM(sci, SCI_SETKEYWORDS, 0, (sptr_t) style_sets[GEANY_FILETYPES_GLSL].keywords[0]); + /* for SCI_SETKEYWORDS = 1, see below*/ + SSM(sci, SCI_SETKEYWORDS, 2, (sptr_t) style_sets[GEANY_FILETYPES_GLSL].keywords[2]); + + /* assign global types, merge them with user defined keywords and set them */ + assign_global_and_user_keywords(sci, style_sets[GEANY_FILETYPES_GLSL].keywords[1], + filetypes[ft_id]->lang); + + styleset_c_like(sci, GEANY_FILETYPES_GLSL); + + if (style_sets[GEANY_FILETYPES_GLSL].styling[20].foreground == 1) + SSM(sci, SCI_SETPROPERTY, (sptr_t) "styling.within.preprocessor", (sptr_t) "1"); + SSM(sci, SCI_SETPROPERTY, (sptr_t) "preprocessor.symbol.$(file.patterns.cpp)", (sptr_t) "#"); + SSM(sci, SCI_SETPROPERTY, (sptr_t) "preprocessor.start.$(file.patterns.cpp)", (sptr_t) "if ifdef ifndef"); + SSM(sci, SCI_SETPROPERTY, (sptr_t) "preprocessor.middle.$(file.patterns.cpp)", (sptr_t) "else elif"); + SSM(sci, SCI_SETPROPERTY, (sptr_t) "preprocessor.end.$(file.patterns.cpp)", (sptr_t) "endif"); +} + static void styleset_cs_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) { new_style_array(GEANY_FILETYPES_CS, 21); @@ -2979,6 +3034,7 @@ void highlighting_init_styles(gint filetype_idx, GKeyFile *config, GKeyFile *con init_styleset_case(GEANY_FILETYPES_FERITE, ferite); init_styleset_case(GEANY_FILETYPES_F77, f77); init_styleset_case(GEANY_FILETYPES_FORTRAN, fortran); + init_styleset_case(GEANY_FILETYPES_GLSL, glsl); init_styleset_case(GEANY_FILETYPES_HASKELL, haskell); init_styleset_case(GEANY_FILETYPES_HAXE, haxe); init_styleset_case(GEANY_FILETYPES_HTML, html); @@ -3032,6 +3088,7 @@ void highlighting_set_styles(ScintillaObject *sci, gint filetype_idx) styleset_case(GEANY_FILETYPES_FERITE, ferite); styleset_case(GEANY_FILETYPES_F77, f77); styleset_case(GEANY_FILETYPES_FORTRAN, fortran); + styleset_case(GEANY_FILETYPES_GLSL, glsl); styleset_case(GEANY_FILETYPES_HASKELL, haskell); styleset_case(GEANY_FILETYPES_HAXE, haxe); styleset_case(GEANY_FILETYPES_HTML, html); diff --git a/src/plugindata.h b/src/plugindata.h index e799381d..26d42ce5 100644 --- a/src/plugindata.h +++ b/src/plugindata.h @@ -41,13 +41,13 @@ enum { /** The Application Programming Interface (API) version, incremented * whenever any plugin data types are modified or appended to. */ - GEANY_API_VERSION = 89, + GEANY_API_VERSION = 90, /** The Application Binary Interface (ABI) version, incremented whenever * existing fields in the plugin data types have to be changed or reordered. */ /* This should usually stay the same if fields are only appended, assuming only pointers to * structs and not structs themselves are declared by plugins. */ - GEANY_ABI_VERSION = 44 + GEANY_ABI_VERSION = 45 }; /** Check the plugin can be loaded by Geany. diff --git a/src/symbols.c b/src/symbols.c index 672ce14e..4c7e2bd9 100644 --- a/src/symbols.c +++ b/src/symbols.c @@ -232,6 +232,7 @@ const gchar *symbols_get_context_separator(gint ft_id) { case GEANY_FILETYPES_C: /* for C++ .h headers or C structs */ case GEANY_FILETYPES_CPP: + case GEANY_FILETYPES_GLSL: /* for structs */ /*case GEANY_FILETYPES_RUBY:*/ /* not sure what to use atm*/ { static gchar cc[] = "::"; diff --git a/tagmanager/c.c b/tagmanager/c.c index 6c0d511e..07a5c082 100644 --- a/tagmanager/c.c +++ b/tagmanager/c.c @@ -247,6 +247,7 @@ static langType Lang_cpp; static langType Lang_csharp; static langType Lang_java; static langType Lang_d; +static langType Lang_glsl; static langType Lang_ferite; /* Used to index into the CKinds table. */ @@ -2772,6 +2773,13 @@ static void initializeDParser (const langType language) buildKeywordHash (language, 1); /* C++ keywords */ } +static void initializeGLSLParser (const langType language) +{ + contextual_fake_count = 0; + Lang_glsl = language; + buildKeywordHash (language, 0); +} + static void initializeFeriteParser (const langType language) { contextual_fake_count = 0; @@ -2841,6 +2849,18 @@ extern parserDefinition* DParser (void) return def; } +extern parserDefinition* GLSLParser (void) +{ + static const char *const extensions [] = { "glsl", "frag", "vert", NULL }; + parserDefinition* def = parserNew ("GLSL"); + def->kinds = CKinds; + def->kindCount = KIND_COUNT (CKinds); + def->extensions = extensions; + def->parser2 = findCTags; + def->initialize = initializeGLSLParser; + return def; +} + extern parserDefinition* FeriteParser (void) { static const char *const extensions [] = { "fe", NULL }; diff --git a/tagmanager/parsers.h b/tagmanager/parsers.h index 0c0caa01..42828493 100644 --- a/tagmanager/parsers.h +++ b/tagmanager/parsers.h @@ -45,7 +45,8 @@ HaxeParser,\ RestParser, \ HtmlParser, \ - F77Parser + F77Parser, \ + GLSLParser /* langType of each parser @@ -80,6 +81,7 @@ langType of each parser 28 RestParser 29 HtmlParser 30 F77Parser +31 GLSLParser */ #endif /* _PARSERS_H */