From 1469e56fea4c227ea822f5564578f225fe999e59 Mon Sep 17 00:00:00 2001 From: Lex Trotman Date: Mon, 10 Nov 2008 12:28:06 +0000 Subject: [PATCH] Prototype C and C++ header filetypes git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/branches/build-system@3196 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 20 +++++++++++++ data/filetype_extensions.conf | 6 ++-- data/filetypes.h | 68 +++++++++++++++++++++++++++++++++++++++++++ data/filetypes.hpp | 67 ++++++++++++++++++++++++++++++++++++++++++ src/filetypes.c | 40 +++++++++++++++++++++---- src/filetypes.h | 6 ++-- src/highlighting.c | 4 +++ 7 files changed, 202 insertions(+), 9 deletions(-) create mode 100755 data/filetypes.h create mode 100755 data/filetypes.hpp diff --git a/ChangeLog b/ChangeLog index 43f26d18a..b72f9e2bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,25 @@ 2008-11-10 Lex Trotman + Prototype C and CPP header filetypes, also detects .h or no extension + files with -*-C++-*- on line 1 as C++ header + + * src/highlighting.c + highlighting_set_styles() & highlighting_init_styles() added filetypes + H & HPP to switches + * src/filetypes.h + added H and HPP to filetypes enum, changed guard name to aviod clash + with GEANY_FILETYPE_H + * src/filetypes.c + init_builtin_filetypes() added new filetypes for H and HPP and moved + header extensions from C and CPP to them + filetypes_detect_from_file_internal() if extensions are .h or none check + for '-*-C++-*-' on line 1 and set to filetype HPP if found + * data/filetypes.h and data/filetypes.hpp added (copies of .c and .cpp) + * data/extensions.conf added H and H++ types + + +2008-11-10 Lex Trotman + Fixed build menu updating after dialog close * src/build.c: diff --git a/data/filetype_extensions.conf b/data/filetype_extensions.conf index b8f3b23b7..f1b4f3019 100644 --- a/data/filetype_extensions.conf +++ b/data/filetype_extensions.conf @@ -5,8 +5,10 @@ #See Geany's main documentation for details. [Extensions] ASM=*.asm; -C=*.c;*.h; -C++=*.cpp;*.cxx;*.c++;*.cc;*.h;*.hpp;*.hxx;*.h++;*.hh;*.C; +C=*.c; +H=*.h; +C++=*.cpp;*.cxx;*.c++;*.cc;*.C; +H++=*.hpp;*.h;*.hxx;*.h++;*.hh; C#=*.cs;*.vala; CAML=*.ml;*.mli; D=*.d;*.di; diff --git a/data/filetypes.h b/data/filetypes.h new file mode 100755 index 000000000..b5d7806c3 --- /dev/null +++ b/data/filetypes.h @@ -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=volatile default export goto sizeof typename asm enum bool union NULL FALSE TRUE typedef struct char int float double void unsigned signed long short extern static register auto const if else switch for while do break continue return inline case +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 see since struct throw todo typedef var version warning union + +[settings] +# default extension used when saving files +#extension=c + +# 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=gcc -Wall -c "%f" +linker= +run_cmd= + + diff --git a/data/filetypes.hpp b/data/filetypes.hpp new file mode 100755 index 000000000..4b58e444a --- /dev/null +++ b/data/filetypes.hpp @@ -0,0 +1,67 @@ +# 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=and and_eq asm auto bitand bitor bool break case catch char class compl const const_cast continue default delete do double dynamic_cast else enum explicit export extern false float for friend goto if inline int long mutable namespace new not not_eq operator or or_eq private protected public register reinterpret_cast return short signed sizeof static static_cast struct switch template this throw true try typedef typeid typename union unsigned using virtual void volatile wchar_t while xor xor_eq +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 see since struct throw todo typedef var version warning union + +[settings] +# default extension used when saving files +#extension=cpp + +# 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=g++ -Wall -c "%f" +linker= +run_cmd= + diff --git a/src/filetypes.c b/src/filetypes.c index 09f58e52c..f6a885768 100644 --- a/src/filetypes.c +++ b/src/filetypes.c @@ -84,7 +84,18 @@ static void init_builtin_filetypes(void) ft->name = g_strdup("C"); ft->title = g_strdup_printf(_("%s source file"), "C"); ft->extension = g_strdup("c"); - ft->pattern = utils_strv_new("*.c", "*.h", NULL); + ft->pattern = utils_strv_new("*.c", NULL); + ft->comment_open = g_strdup("/*"); + ft->comment_close = g_strdup("*/"); + ft->group = GEANY_FILETYPE_GROUP_COMPILED; + +#define CH + ft = filetypes[GEANY_FILETYPES_H]; + ft->lang = 0; + ft->name = g_strdup("H"); + ft->title = g_strdup_printf(_("%s header file"), "C"); + ft->extension = g_strdup("h"); + ft->pattern = utils_strv_new("*.h", NULL); ft->comment_open = g_strdup("/*"); ft->comment_close = g_strdup("*/"); ft->group = GEANY_FILETYPE_GROUP_COMPILED; @@ -96,7 +107,18 @@ static void init_builtin_filetypes(void) ft->title = g_strdup_printf(_("%s source file"), "C++"); ft->extension = g_strdup("cpp"); ft->pattern = utils_strv_new("*.cpp", "*.cxx", "*.c++", "*.cc", - "*.h", "*.hpp", "*.hxx", "*.h++", "*.hh", "*.C", NULL); + "*.C", NULL); + ft->comment_open = g_strdup("//"); + ft->comment_close = NULL; + ft->group = GEANY_FILETYPE_GROUP_COMPILED; + +#define HPP + ft = filetypes[GEANY_FILETYPES_HPP]; + ft->lang = 1; + ft->name = g_strdup("H++"); + ft->title = g_strdup_printf(_("%s header file"), "C++"); + ft->extension = g_strdup("hpp"); + ft->pattern = utils_strv_new("*.h", "*.hpp", "*.hxx", "*.h++", "*.hh", NULL); ft->comment_open = g_strdup("//"); ft->comment_close = NULL; ft->group = GEANY_FILETYPE_GROUP_COMPILED; @@ -767,6 +789,7 @@ static GeanyFiletype *filetypes_detect_from_file_internal(const gchar *utf8_file const gchar *line) { GeanyFiletype *ft; + filetype_id id; /* try to find a shebang and if found use it prior to the filename extension * also checks for