Added new filetype D(patch by Christop Berg, thanks).

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@544 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2006-07-09 14:41:53 +00:00
parent 2e31c57b44
commit 6cc29173be
13 changed files with 2573 additions and 9 deletions

View File

@ -1,3 +1,11 @@
2006-07-09 Enrico Tröger <enrico.troeger@uvena.de>
* tagmanager/d.c, tagmanager/Makefile.am, tagmanager/parsers.h,
src/filetypes.c, src/highlighting.c, src/utils.c, src/build.c,
src/templates.c, data/filetypes.d:
Added new filetype D(patch by Christop Berg, thanks).
2006-07-08 Nick Treleaven <nick.treleaven@btinternet.com>
* src/keyfile.c: Fix saving the terminal tool on quitting.

67
data/filetypes.d Normal file
View File

@ -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=0x0000ff;0xffffff;false;false
commentline=0x0000ff;0xffffff;false;false
commentdoc=0x0000ff;0xffffff;false;false
number=0x007f00;0xffffff;false;false
word=0x991111;0xffffff;true;false
word2=0x00007F;0xffffff;true;false
string=0x1E90FF;0xffffff;false;false
character=0x1E90FF;0xffffff;false;false
uuid=0x804040;0xffffff;false;false
preprocessor=0x7F7F00;0xffffff;false;false
operator=0x101030;0xffffff;false;false
identifier=0x100000;0xffffff;false;false
stringeol=0x000000;0xe0c0e0;false;false
verbatim=0x101030;0xffffff;false;false
regex=0x905010;0xffffff;false;false
commentlinedoc=0x0000ff;0xffffff;true;false
commentdockeyword=0x0000ff;0xffffff;true;true
globalclass=0xbb1111;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=__FILE__ __LINE__ __DATA__ __TIME__ __TIMESTAMP__ abstract alias align asm assert auto body bool break byte case cast catch cdouble cent cfloat char class const continue creal dchar debug default delegate delete deprecated do double else enum export extern false final finally float for foreach function goto idouble if ifloat import in inout int interface invariant ireal is long mixin module new null out override package pragma private protected public real return scope short static struct super switch synchronized template this throw true try typedef typeof ubyte ucent uint ulong union unittest ushort version void volatile wchar while with
docComment=TODO FIXME
[settings]
# 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=*/
# this is alternative way, so multiline comments are used
#comment_open=/+
#comment_close=+/
# set to false if a comment character/string should start a column 0 of a line, true uses any
# indention 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
[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=dmd -w -c "%f"
# the -of option is automatically added by Geany
linker=dmd -w "%f"
# you can also use the gdc compiler, please use the "gdmd" wrapper script(included with gdc)
#compiler=gdmd -w -c "%f"
#linker=gdmd -w "%f"
run_cmd="./%e"

View File

@ -209,11 +209,25 @@ GPid build_link_file(gint idx)
}
}
argv = g_new0(gchar *, 4);
argv[0] = g_strdup(doc_list[idx].file_type->programs->linker);
argv[1] = g_strdup("-o");
argv[2] = g_path_get_basename(executable);
argv[3] = NULL;
if (doc_list[idx].file_type->id == GEANY_FILETYPES_D)
{ // the dmd compiler needs -of instead of -o and it accepts no whitespace after -of
gchar *tmp = g_path_get_basename(executable);
argv = g_new0(gchar *, 3);
argv[0] = g_strdup(doc_list[idx].file_type->programs->linker);
argv[1] = g_strconcat("-of", tmp, NULL);
argv[2] = NULL;
g_free(tmp);
}
else
{
argv = g_new0(gchar *, 4);
argv[0] = g_strdup(doc_list[idx].file_type->programs->linker);
argv[1] = g_strdup("-o");
argv[2] = g_path_get_basename(executable);
argv[3] = NULL;
}
g_free(executable);
g_free(object_file);

View File

@ -432,6 +432,25 @@ void filetypes_init_types(void)
filetypes_init_build_programs(filetypes[GEANY_FILETYPES_TCL]);
filetypes_create_menu_item(filetype_menu, filetypes[GEANY_FILETYPES_TCL]->title, filetypes[GEANY_FILETYPES_TCL]);
#define D
filetypes[GEANY_FILETYPES_D] = g_new0(filetype, 1);
filetypes[GEANY_FILETYPES_D]->id = GEANY_FILETYPES_D;
filetypes[GEANY_FILETYPES_D]->lang = 17;
filetypes[GEANY_FILETYPES_D]->name = g_strdup("D");
filetypes[GEANY_FILETYPES_D]->has_tags = TRUE;
filetypes[GEANY_FILETYPES_D]->title = g_strdup(_("D source file"));
filetypes[GEANY_FILETYPES_D]->extension = g_strdup("d");
filetypes[GEANY_FILETYPES_D]->pattern = g_new0(gchar*, 3);
filetypes[GEANY_FILETYPES_D]->pattern[0] = g_strdup("*.d");
filetypes[GEANY_FILETYPES_D]->pattern[1] = g_strdup("*.di");
filetypes[GEANY_FILETYPES_D]->pattern[2] = NULL;
filetypes[GEANY_FILETYPES_D]->comment_open = g_strdup("//");
filetypes[GEANY_FILETYPES_D]->comment_close = NULL;
filetypes[GEANY_FILETYPES_D]->style_func_ptr = styleset_d;
filetypes_init_build_programs(filetypes[GEANY_FILETYPES_D]);
filetypes_create_menu_item(filetype_menu, filetypes[GEANY_FILETYPES_D]->title, filetypes[GEANY_FILETYPES_D]);
filetypes_create_newmenu_item(template_menu, filetypes[GEANY_FILETYPES_D]->title, filetypes[GEANY_FILETYPES_D]);
#define ALL
filetypes[GEANY_FILETYPES_ALL] = g_new0(filetype, 1);
filetypes[GEANY_FILETYPES_ALL]->id = GEANY_FILETYPES_ALL;
@ -587,6 +606,8 @@ gchar *filetypes_get_template(filetype *ft)
return templates_get_template_generic(GEANY_TEMPLATE_FILETYPE_PASCAL); break;
case GEANY_FILETYPES_RUBY:
return templates_get_template_generic(GEANY_TEMPLATE_FILETYPE_RUBY); break;
case GEANY_FILETYPES_D:
return templates_get_template_generic(GEANY_TEMPLATE_FILETYPE_D); break;
default: return NULL;
}
}

View File

@ -47,8 +47,9 @@ enum
GEANY_FILETYPES_OMS, // 17
GEANY_FILETYPES_RUBY, // 18
GEANY_FILETYPES_TCL, // 19
GEANY_FILETYPES_ALL, // 20
GEANY_MAX_FILE_TYPES // 21
GEANY_FILETYPES_D, // 20
GEANY_FILETYPES_ALL, // 21
GEANY_MAX_FILE_TYPES // 22
};
struct build_menu_items

View File

@ -2246,5 +2246,125 @@ void styleset_tcl(ScintillaObject *sci)
SSM(sci, SCI_SETWHITESPACEFORE, 1, invert(0xc0c0c0));
}
static void styleset_d_init(void)
{
GKeyFile *config = g_key_file_new();
GKeyFile *config_home = g_key_file_new();
gchar *f = g_strconcat(app->configdir, G_DIR_SEPARATOR_S GEANY_FILEDEFS_SUBDIR G_DIR_SEPARATOR_S, "filetypes.d", NULL);
styleset_load_file(config, GEANY_DATA_DIR G_DIR_SEPARATOR_S "filetypes.d", G_KEY_FILE_KEEP_COMMENTS, NULL);
g_key_file_load_from_file(config_home, f, G_KEY_FILE_KEEP_COMMENTS, NULL);
types[GEANY_FILETYPES_D] = g_new(style_set, 1);
styleset_get_hex(config, config_home, "styling", "default", "0x000000", "0xffffff", "false", types[GEANY_FILETYPES_D]->styling[0]);
styleset_get_hex(config, config_home, "styling", "comment", "0x0000ff", "0xffffff", "false", types[GEANY_FILETYPES_D]->styling[1]);
styleset_get_hex(config, config_home, "styling", "commentline", "0x0000ff", "0xffffff", "false", types[GEANY_FILETYPES_D]->styling[2]);
styleset_get_hex(config, config_home, "styling", "commentdoc", "0x0000ff", "0xffffff", "false", types[GEANY_FILETYPES_D]->styling[3]);
styleset_get_hex(config, config_home, "styling", "number", "0x007f00", "0xffffff", "false", types[GEANY_FILETYPES_D]->styling[4]);
styleset_get_hex(config, config_home, "styling", "word", "0x991111", "0xffffff", "true", types[GEANY_FILETYPES_D]->styling[5]);
styleset_get_hex(config, config_home, "styling", "word2", "0x00007F", "0xffffff", "true", types[GEANY_FILETYPES_D]->styling[6]);
styleset_get_hex(config, config_home, "styling", "string", "0x1E90FF", "0xffffff", "false", types[GEANY_FILETYPES_D]->styling[7]);
styleset_get_hex(config, config_home, "styling", "character", "0x1E90FF", "0xffffff", "false", types[GEANY_FILETYPES_D]->styling[8]);
styleset_get_hex(config, config_home, "styling", "uuid", "0x804040", "0xffffff", "false", types[GEANY_FILETYPES_D]->styling[9]);
styleset_get_hex(config, config_home, "styling", "preprocessor", "0x7F7F00", "0xffffff", "false", types[GEANY_FILETYPES_D]->styling[10]);
styleset_get_hex(config, config_home, "styling", "operator", "0x101030", "0xffffff", "false", types[GEANY_FILETYPES_D]->styling[11]);
styleset_get_hex(config, config_home, "styling", "identifier", "0x100000", "0xffffff", "false", types[GEANY_FILETYPES_D]->styling[12]);
styleset_get_hex(config, config_home, "styling", "stringeol", "0x000000", "0xe0c0e0", "false", types[GEANY_FILETYPES_D]->styling[13]);
styleset_get_hex(config, config_home, "styling", "verbatim", "0x101030", "0xffffff", "false", types[GEANY_FILETYPES_D]->styling[14]);
styleset_get_hex(config, config_home, "styling", "regex", "0x101030", "0xffffff", "false", types[GEANY_FILETYPES_D]->styling[15]);
styleset_get_hex(config, config_home, "styling", "commentlinedoc", "0x0000ff", "0xffffff", "true", types[GEANY_FILETYPES_D]->styling[16]);
styleset_get_hex(config, config_home, "styling", "commentdockeyword", "0x0000ff", "0xffffff", "true", types[GEANY_FILETYPES_D]->styling[17]);
styleset_get_hex(config, config_home, "styling", "globalclass", "0xbb1111", "0xffffff", "true", types[GEANY_FILETYPES_D]->styling[18]);
styleset_get_int(config, config_home, "styling", "styling_within_preprocessor", 1, 0, types[GEANY_FILETYPES_D]->styling[19]);
types[GEANY_FILETYPES_D]->keywords = g_new(gchar*, 3);
styleset_get_keywords(config, config_home, "keywords", "primary", GEANY_FILETYPES_D, 0, "__FILE__ __LINE__ __DATA__ __TIME__ __TIMESTAMP__ abstract alias align asm assert auto body bool break byte case cast catch cdouble cent cfloat char class const continue creal dchar debug default delegate delete deprecated do double else enum export extern false final finally float for foreach function goto idouble if ifloat import in inout int interface invariant ireal is long mixin module new null out override package pragma private protected public real return scope short static struct super switch synchronized template this throw true try typedef typeof ubyte ucent uint ulong union unittest ushort version void volatile wchar while with");
styleset_get_keywords(config, config_home, "keywords", "docComment", GEANY_FILETYPES_D, 1, "TODO FIXME");
types[GEANY_FILETYPES_D]->keywords[2] = NULL;
styleset_get_wordchars(config, config_home, GEANY_FILETYPES_D, GEANY_WORDCHARS);
filetypes_get_config(config, config_home, GEANY_FILETYPES_D);
g_key_file_free(config);
g_key_file_free(config_home);
g_free(f);
// load global tags file for C autocompletion
if (! app->ignore_global_tags && ! global_c_tags_loaded)
{
// 0 is the langType used in TagManager (see the table in tagmanager/parsers.h)
// C++ is a special case, here we use 0 to have C global tags in C++, too
tm_workspace_load_global_tags(GEANY_DATA_DIR G_DIR_SEPARATOR_S "global.tags", 0);
global_c_tags_loaded = TRUE;
}
}
void styleset_d(ScintillaObject *sci)
{
if (types[GEANY_FILETYPES_D] == NULL) styleset_d_init();
styleset_common(sci, 5);
/* Assign global keywords */
if ((app->tm_workspace) && (app->tm_workspace->global_tags))
{
guint j;
GPtrArray *g_typedefs = tm_tags_extract(app->tm_workspace->global_tags, tm_tag_typedef_t | tm_tag_struct_t | tm_tag_class_t);
if ((g_typedefs) && (g_typedefs->len > 0))
{
GString *s = g_string_sized_new(g_typedefs->len * 10);
for (j = 0; j < g_typedefs->len; ++j)
{
if (!(TM_TAG(g_typedefs->pdata[j])->atts.entry.scope))
{
g_string_append(s, TM_TAG(g_typedefs->pdata[j])->name);
g_string_append_c(s, ' ');
}
}
SSM(sci, SCI_SETKEYWORDS, 1, (sptr_t) s->str);
g_string_free(s, TRUE);
}
g_ptr_array_free(g_typedefs, TRUE);
}
SSM(sci, SCI_SETWORDCHARS, 0, (sptr_t) types[GEANY_FILETYPES_D]->wordchars);
SSM(sci, SCI_AUTOCSETMAXHEIGHT, 8, 0);
SSM(sci, SCI_SETLEXER, SCLEX_CPP, 0);
//SSM(sci, SCI_SETCONTROLCHARSYMBOL, 32, 0);
SSM(sci, SCI_SETKEYWORDS, 0, (sptr_t) types[GEANY_FILETYPES_D]->keywords[0]);
SSM(sci, SCI_SETKEYWORDS, 2, (sptr_t) types[GEANY_FILETYPES_D]->keywords[1]);
styleset_set_style(sci, SCE_C_DEFAULT, GEANY_FILETYPES_D, 0);
styleset_set_style(sci, SCE_C_COMMENT, GEANY_FILETYPES_D, 1);
styleset_set_style(sci, SCE_C_COMMENTLINE, GEANY_FILETYPES_D, 2);
styleset_set_style(sci, SCE_C_COMMENTDOC, GEANY_FILETYPES_D, 3);
styleset_set_style(sci, SCE_C_NUMBER, GEANY_FILETYPES_D, 4);
styleset_set_style(sci, SCE_C_WORD, GEANY_FILETYPES_D, 5);
styleset_set_style(sci, SCE_C_WORD2, GEANY_FILETYPES_D, 6);
styleset_set_style(sci, SCE_C_STRING, GEANY_FILETYPES_D, 7);
styleset_set_style(sci, SCE_C_CHARACTER, GEANY_FILETYPES_D, 8);
styleset_set_style(sci, SCE_C_UUID, GEANY_FILETYPES_D, 9);
styleset_set_style(sci, SCE_C_PREPROCESSOR, GEANY_FILETYPES_D, 10);
styleset_set_style(sci, SCE_C_OPERATOR, GEANY_FILETYPES_D, 11);
styleset_set_style(sci, SCE_C_IDENTIFIER, GEANY_FILETYPES_D, 12);
styleset_set_style(sci, SCE_C_STRINGEOL, GEANY_FILETYPES_D, 13);
styleset_set_style(sci, SCE_C_VERBATIM, GEANY_FILETYPES_D, 14);
styleset_set_style(sci, SCE_C_REGEX, GEANY_FILETYPES_D, 15);
styleset_set_style(sci, SCE_C_COMMENTLINEDOC, GEANY_FILETYPES_D, 16);
styleset_set_style(sci, SCE_C_COMMENTDOCKEYWORD, GEANY_FILETYPES_D, 17);
SSM(sci, SCI_STYLESETFORE, SCE_C_COMMENTDOCKEYWORDERROR, invert(0x0000ff));
SSM(sci, SCI_STYLESETBACK, SCE_C_COMMENTDOCKEYWORDERROR, invert(0xffffff));
SSM(sci, SCI_STYLESETITALIC, SCE_C_COMMENTDOCKEYWORDERROR, TRUE);
// is used for local structs and typedefs
styleset_set_style(sci, SCE_C_GLOBALCLASS, GEANY_FILETYPES_D, 18);
SSM(sci, SCI_SETWHITESPACEFORE, 1, invert(0xc0c0c0));
}

View File

@ -81,4 +81,6 @@ void styleset_oms(ScintillaObject *sci);
void styleset_tcl(ScintillaObject *sci);
void styleset_d(ScintillaObject *sci);
#endif

View File

@ -58,6 +58,7 @@ void templates_init(void)
gchar *template_filename_filetype_none = templates_get_filename("template.filetype.none");
gchar *template_filename_filetype_c = templates_get_filename("template.filetype.c");
gchar *template_filename_filetype_cpp = templates_get_filename("template.filetype.cpp");
gchar *template_filename_filetype_d = templates_get_filename("template.filetype.d");
gchar *template_filename_filetype_java = templates_get_filename("template.filetype.java");
gchar *template_filename_filetype_pascal = templates_get_filename("template.filetype.pascal");
gchar *template_filename_filetype_php = templates_get_filename("template.filetype.php");
@ -86,6 +87,7 @@ void templates_init(void)
templates_create_file(template_filename_filetype_none, templates_filetype_none);
templates_create_file(template_filename_filetype_c, templates_filetype_c);
templates_create_file(template_filename_filetype_cpp, templates_filetype_cpp);
templates_create_file(template_filename_filetype_d, templates_filetype_d);
templates_create_file(template_filename_filetype_java, templates_filetype_java);
templates_create_file(template_filename_filetype_pascal, templates_filetype_pascal);
templates_create_file(template_filename_filetype_php, templates_filetype_php);
@ -138,6 +140,9 @@ void templates_init(void)
templates_read_file(template_filename_filetype_c, &templates[GEANY_TEMPLATE_FILETYPE_C]);
templates[GEANY_TEMPLATE_FILETYPE_C] = templates_replace_all(templates[GEANY_TEMPLATE_FILETYPE_C], year, date);
templates_read_file(template_filename_filetype_d, &templates[GEANY_TEMPLATE_FILETYPE_D]);
templates[GEANY_TEMPLATE_FILETYPE_D] = templates_replace_all(templates[GEANY_TEMPLATE_FILETYPE_D], year, date);
templates_read_file(template_filename_filetype_cpp, &templates[GEANY_TEMPLATE_FILETYPE_CPP]);
templates[GEANY_TEMPLATE_FILETYPE_CPP] = templates_replace_all(templates[GEANY_TEMPLATE_FILETYPE_CPP], year, date);
@ -173,6 +178,7 @@ void templates_init(void)
g_free(template_filename_filetype_none);
g_free(template_filename_filetype_c);
g_free(template_filename_filetype_cpp);
g_free(template_filename_filetype_d);
g_free(template_filename_filetype_java);
g_free(template_filename_filetype_php);
g_free(template_filename_filetype_pascal);

View File

@ -62,6 +62,7 @@ enum
GEANY_TEMPLATE_FILETYPE_PHP,
GEANY_TEMPLATE_FILETYPE_PASCAL,
GEANY_TEMPLATE_FILETYPE_RUBY,
GEANY_TEMPLATE_FILETYPE_D,
GEANY_MAX_TEMPLATES
};
@ -207,6 +208,16 @@ int main(int argc, char** argv)\n\
}\n\
";
static const gchar templates_filetype_d[] = "\n\
import std.stdio;\n\
\n\
int main(char[][] args)\n\
{\n\
\n\
return 0;\n\
}\n\
";
static const gchar templates_filetype_php[] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n\

View File

@ -2436,13 +2436,21 @@ void utils_parse_compiler_error_line(const gchar *string, gchar **filename, gint
case GEANY_FILETYPES_PASCAL:
{
// bandit.pas(149,3) Fatal: Syntax error, ";" expected but "ELSE" found
// still untested with other files than the opened
pattern = "(";
field_min_len = 2;
field_idx_line = 1;
field_idx_file = 0;
break;
}
case GEANY_FILETYPES_D:
{
// warning - pi.d(118): implicit conversion of expression (digit) of type int ...
pattern = " (";
field_min_len = 4;
field_idx_line = 3;
field_idx_file = 2;
break;
}
default: return;
}

View File

@ -27,6 +27,7 @@ libtagmanager_a_SOURCES =\
args.c\
args.h\
c.c\
d.c\
conf.c\
css.c\
docbook.c\

2303
tagmanager/d.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,8 @@
CssParser, \
RubyParser, \
TclParser, \
ShParser
ShParser, \
DParser
/*
langType of each parser
@ -52,6 +53,7 @@ langType of each parser
14 RubyParser
15 TclParser
16 ShParser
17 DParser
*/
#endif /* _PARSERS_H */