Merge custom-filetypes branch:

Support adding custom filetype files e.g. filetypes.Foo.conf.
- Code:
Allow GeanyFiletype::extension to be NULL.
Add note about using GeanyFiletype pointer instead of filetype_id
for filetypes.c function arguments.
Replace styleset_none() with styleset_default().



git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4143 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2009-08-31 16:11:46 +00:00
commit 20c42f845a
10 changed files with 174 additions and 89 deletions

View File

@ -3,6 +3,16 @@
* src/plugins.c: * src/plugins.c:
Add warning if only one of the plugin_key_group[_info] symbols is Add warning if only one of the plugin_key_group[_info] symbols is
defined for a plugin. defined for a plugin.
* src/templates.c, src/highlighting.c, src/dialogs.c, src/filetypes.c,
src/filetypes.h, src/document.c, src/main.c, src/symbols.c,
TODO:
Merge custom-filetypes branch:
Support adding custom filetype files e.g. filetypes.Foo.conf.
- Code:
Allow GeanyFiletype::extension to be NULL.
Add note about using GeanyFiletype pointer instead of filetype_id
for filetypes.c function arguments.
Replace styleset_none() with styleset_default().
2009-08-30 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> 2009-08-30 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>

2
TODO
View File

@ -13,7 +13,7 @@ Note: features included in brackets have lower priority.
filetypes.common named styles) filetypes.common named styles)
o configurable filetype and project make commands (e.g. using o configurable filetype and project make commands (e.g. using
bud for D) - see the build-system SVN branch bud for D) - see the build-system SVN branch
o (custom filetypes) o (better custom filetype support)
o (support for adding plugin filetypes - SCI_LOADLEXERLIBRARY?) o (support for adding plugin filetypes - SCI_LOADLEXERLIBRARY?)
o (selectable menu of arguments to use for Make, from Make Custom) o (selectable menu of arguments to use for Make, from Make Custom)
o (DBUS) o (DBUS)

View File

@ -88,7 +88,7 @@ on_file_open_dialog_response (GtkDialog *dialog,
gboolean ro = (response == GEANY_RESPONSE_VIEW); /* View clicked */ gboolean ro = (response == GEANY_RESPONSE_VIEW); /* View clicked */
/* ignore detect from file item */ /* ignore detect from file item */
if (filetype_idx > 0 && filetype_idx < GEANY_MAX_BUILT_IN_FILETYPES) if (filetype_idx > 0)
ft = g_slist_nth_data(filetypes_by_title, filetype_idx); ft = g_slist_nth_data(filetypes_by_title, filetype_idx);
if (encoding_idx >= 0 && encoding_idx < GEANY_ENCODINGS_MAX) if (encoding_idx >= 0 && encoding_idx < GEANY_ENCODINGS_MAX)
charset = encodings[encoding_idx].charset; charset = encodings[encoding_idx].charset;
@ -511,8 +511,7 @@ static gboolean gtk_show_save_as(void)
{ {
gchar *fname = NULL; gchar *fname = NULL;
if (doc->file_type != NULL && doc->file_type->id != GEANY_FILETYPES_NONE && if (doc->file_type != NULL && doc->file_type->extension != NULL)
doc->file_type->extension != NULL)
fname = g_strconcat(GEANY_STRING_UNTITLED, ".", fname = g_strconcat(GEANY_STRING_UNTITLED, ".",
doc->file_type->extension, NULL); doc->file_type->extension, NULL);
else else

View File

@ -1464,7 +1464,11 @@ static void replace_header_filename(GeanyDocument *doc)
g_return_if_fail(doc != NULL); g_return_if_fail(doc != NULL);
g_return_if_fail(doc->file_type != NULL); g_return_if_fail(doc->file_type != NULL);
filebase = g_strconcat(GEANY_STRING_UNTITLED, ".", (doc->file_type)->extension, NULL); if (doc->file_type->extension)
filebase = g_strconcat(GEANY_STRING_UNTITLED, ".", doc->file_type->extension, NULL);
else
filebase = g_strdup(GEANY_STRING_UNTITLED);
filename = g_path_get_basename(doc->file_name); filename = g_path_get_basename(doc->file_name);
/* only search the first 3 lines */ /* only search the first 3 lines */

View File

@ -26,6 +26,9 @@
* Filetype detection, file extensions and filetype menu items. * Filetype detection, file extensions and filetype menu items.
*/ */
/* Note: we use filetype_id for some function arguments, but GeanyFiletype is better; we should
* only use GeanyFiletype for API functions. */
#include <string.h> #include <string.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
@ -62,6 +65,7 @@ typedef struct GeanyFiletypePrivate
gboolean error_regex_compiled; gboolean error_regex_compiled;
gchar *last_string; /* last one compiled */ gchar *last_string; /* last one compiled */
#endif #endif
gboolean custom;
} }
GeanyFiletypePrivate; GeanyFiletypePrivate;
@ -113,7 +117,7 @@ static void init_builtin_filetypes(void)
ft->lang = -2; ft->lang = -2;
ft->name = g_strdup(_("None")); ft->name = g_strdup(_("None"));
ft->title = g_strdup(_("None")); ft->title = g_strdup(_("None"));
ft->extension = g_strdup("*"); ft->extension = NULL;
ft->pattern = utils_strv_new("*", NULL); ft->pattern = utils_strv_new("*", NULL);
ft->comment_open = NULL; ft->comment_open = NULL;
ft->comment_close = NULL; ft->comment_close = NULL;
@ -658,6 +662,57 @@ static void filetype_add(GeanyFiletype *ft)
} }
static void add_custom_filetype(const gchar *filename)
{
gchar *fn = utils_strdupa(strstr(filename, ".") + 1);
gchar *dot = g_strrstr(fn, ".conf");
GeanyFiletype *ft;
g_return_if_fail(dot);
*dot = 0x0;
if (g_hash_table_lookup(filetypes_hash, fn))
return;
geany_debug("Adding filetype %s.", fn);
ft = filetype_new();
ft->name = g_strdup(fn);
filetype_make_title(ft, TITLE_FILE);
ft->pattern = g_new0(gchar*, 1);
ft->priv->custom = TRUE;
filetype_add(ft);
}
static void init_custom_filetypes(const gchar *path)
{
GDir *dir;
g_return_if_fail(path);
dir = g_dir_open(path, 0, NULL);
if (dir == NULL)
return;
while (1)
{
const gchar prefix[] = "filetypes.";
const gchar *filename = g_dir_read_name(dir);
if (filename == NULL)
break;
if (g_str_has_prefix(filename, prefix) &&
g_str_has_suffix(filename + strlen(prefix), ".conf"))
{
add_custom_filetype(filename);
}
}
g_dir_close(dir);
}
/* Create the filetypes array and fill it with the known filetypes. */ /* Create the filetypes array and fill it with the known filetypes. */
void filetypes_init_types() void filetypes_init_types()
{ {
@ -681,6 +736,8 @@ void filetypes_init_types()
{ {
filetype_add(filetypes[ft_id]); filetype_add(filetypes[ft_id]);
} }
init_custom_filetypes(app->datadir);
init_custom_filetypes(utils_build_path(app->configdir, GEANY_FILEDEFS_SUBDIR, NULL));
} }
@ -747,16 +804,18 @@ static void create_set_filetype_menu(void)
{ {
GeanyFiletype *ft = node->data; GeanyFiletype *ft = node->data;
if (ft->id != GEANY_FILETYPES_NONE) if (ft->group != GEANY_FILETYPE_GROUP_NONE)
create_radio_menu_item(group_menus[ft->group], ft); create_radio_menu_item(group_menus[ft->group], ft);
else
create_radio_menu_item(filetype_menu, ft);
} }
create_radio_menu_item(filetype_menu, filetypes[GEANY_FILETYPES_NONE]);
} }
void filetypes_init() void filetypes_init()
{ {
filetypes_init_types(); filetypes_init_types();
create_set_filetype_menu(); create_set_filetype_menu();
setup_config_file_menus(); setup_config_file_menus();
} }
@ -1168,13 +1227,16 @@ static void load_settings(gint ft_id, GKeyFile *config, GKeyFile *configh)
/* simple wrapper function to print file errors in DEBUG mode */ /* simple wrapper function to print file errors in DEBUG mode */
static void load_system_keyfile(GKeyFile *key_file, const gchar *file, GKeyFileFlags flags, static void load_system_keyfile(GKeyFile *key_file, const gchar *file, GKeyFileFlags flags,
G_GNUC_UNUSED GError **just_for_compatibility) GeanyFiletype *ft)
{ {
GError *error = NULL; GError *error = NULL;
gboolean done = g_key_file_load_from_file(key_file, file, flags, &error); gboolean done = g_key_file_load_from_file(key_file, file, flags, &error);
if (G_UNLIKELY(! done) && G_UNLIKELY(error != NULL))
if (error != NULL)
{ {
if (!done && !ft->priv->custom)
geany_debug("Failed to open %s (%s)", file, error->message); geany_debug("Failed to open %s (%s)", file, error->message);
g_error_free(error); g_error_free(error);
error = NULL; error = NULL;
} }
@ -1188,10 +1250,12 @@ void filetypes_load_config(gint ft_id, gboolean reload)
{ {
GKeyFile *config, *config_home; GKeyFile *config, *config_home;
GeanyFiletypePrivate *pft; GeanyFiletypePrivate *pft;
GeanyFiletype *ft;
g_return_if_fail(ft_id >= 0 && ft_id < (gint) filetypes_array->len); g_return_if_fail(ft_id >= 0 && ft_id < (gint) filetypes_array->len);
pft = filetypes[ft_id]->priv; ft = filetypes[ft_id];
pft = ft->priv;
/* when reloading, proceed only if the settings were already loaded */ /* when reloading, proceed only if the settings were already loaded */
if (reload && G_UNLIKELY(! pft->keyfile_loaded)) if (reload && G_UNLIKELY(! pft->keyfile_loaded))
@ -1212,7 +1276,7 @@ void filetypes_load_config(gint ft_id, gboolean reload)
gchar *f = g_strconcat(app->configdir, gchar *f = g_strconcat(app->configdir,
G_DIR_SEPARATOR_S GEANY_FILEDEFS_SUBDIR G_DIR_SEPARATOR_S "filetypes.", ext, NULL); G_DIR_SEPARATOR_S GEANY_FILEDEFS_SUBDIR G_DIR_SEPARATOR_S "filetypes.", ext, NULL);
load_system_keyfile(config, f0, G_KEY_FILE_KEEP_COMMENTS, NULL); load_system_keyfile(config, f0, G_KEY_FILE_KEEP_COMMENTS, ft);
g_key_file_load_from_file(config_home, f, G_KEY_FILE_KEEP_COMMENTS, NULL); g_key_file_load_from_file(config_home, f, G_KEY_FILE_KEEP_COMMENTS, NULL);
g_free(ext); g_free(ext);
@ -1231,6 +1295,10 @@ void filetypes_load_config(gint ft_id, gboolean reload)
gchar *filetypes_get_conf_extension(gint filetype_idx) gchar *filetypes_get_conf_extension(gint filetype_idx)
{ {
gchar *result; gchar *result;
GeanyFiletype *ft = filetypes[filetype_idx];
if (ft->priv->custom)
return g_strconcat(ft->name, ".conf", NULL);
/* Handle any special extensions different from lowercase filetype->name */ /* Handle any special extensions different from lowercase filetype->name */
switch (filetype_idx) switch (filetype_idx)
@ -1238,7 +1306,7 @@ gchar *filetypes_get_conf_extension(gint filetype_idx)
case GEANY_FILETYPES_CPP: result = g_strdup("cpp"); break; case GEANY_FILETYPES_CPP: result = g_strdup("cpp"); break;
case GEANY_FILETYPES_CS: result = g_strdup("cs"); break; case GEANY_FILETYPES_CS: result = g_strdup("cs"); break;
case GEANY_FILETYPES_MAKE: result = g_strdup("makefile"); break; case GEANY_FILETYPES_MAKE: result = g_strdup("makefile"); break;
default: result = g_ascii_strdown(filetypes[filetype_idx]->name, -1); break; default: result = g_ascii_strdown(ft->name, -1); break;
} }
return result; return result;
} }
@ -1248,9 +1316,9 @@ void filetypes_save_commands(void)
{ {
gchar *conf_prefix = g_strconcat(app->configdir, gchar *conf_prefix = g_strconcat(app->configdir,
G_DIR_SEPARATOR_S GEANY_FILEDEFS_SUBDIR G_DIR_SEPARATOR_S "filetypes.", NULL); G_DIR_SEPARATOR_S GEANY_FILEDEFS_SUBDIR G_DIR_SEPARATOR_S "filetypes.", NULL);
gint i; guint i;
for (i = 1; i < GEANY_MAX_BUILT_IN_FILETYPES; i++) for (i = 1; i < filetypes_array->len; i++)
{ {
GKeyFile *config_home; GKeyFile *config_home;
gchar *fname, *ext, *data; gchar *fname, *ext, *data;

View File

@ -109,7 +109,7 @@ struct GeanyFiletype
langType lang; langType lang;
gchar *name; /**< Used as name for tagmanager. E.g. "C". */ gchar *name; /**< Used as name for tagmanager. E.g. "C". */
gchar *title; /**< Shown in the file open dialog. E.g. "C source file". */ gchar *title; /**< Shown in the file open dialog. E.g. "C source file". */
gchar *extension; /**< Default file extension for new files. */ gchar *extension; /**< Default file extension for new files, or @c NULL. */
gchar **pattern; /**< Array of filename-matching wildcard strings. */ gchar **pattern; /**< Array of filename-matching wildcard strings. */
gchar *context_action_cmd; gchar *context_action_cmd;
gchar *comment_open; gchar *comment_open;

View File

@ -62,7 +62,7 @@ typedef struct
} StyleSet; } StyleSet;
/* each filetype has a styleset except GEANY_FILETYPES_NONE, which uses common_style_set */ /* each filetype has a styleset except GEANY_FILETYPES_NONE, which uses common_style_set */
static StyleSet style_sets[GEANY_MAX_BUILT_IN_FILETYPES] = {{0, NULL, NULL, NULL}}; static StyleSet *style_sets = NULL;
enum /* Geany common styling */ enum /* Geany common styling */
@ -123,7 +123,7 @@ static GHashTable *named_style_hash = NULL;
static GeanyLexerStyle gsd_default = {0x000000, 0xffffff, FALSE, FALSE}; static GeanyLexerStyle gsd_default = {0x000000, 0xffffff, FALSE, FALSE};
static void new_style_array(gint file_type_id, gint styling_count) static void new_styleset(gint file_type_id, gint styling_count)
{ {
StyleSet *set = &style_sets[file_type_id]; StyleSet *set = &style_sets[file_type_id];
@ -132,7 +132,7 @@ static void new_style_array(gint file_type_id, gint styling_count)
} }
static void styleset_free(gint file_type_id) static void free_styleset(gint file_type_id)
{ {
StyleSet *style_ptr; StyleSet *style_ptr;
style_ptr = &style_sets[file_type_id]; style_ptr = &style_sets[file_type_id];
@ -402,7 +402,7 @@ static guint invert(guint icolour)
static GeanyLexerStyle *get_style(guint ft_id, guint styling_index) static GeanyLexerStyle *get_style(guint ft_id, guint styling_index)
{ {
g_assert(ft_id < GEANY_MAX_BUILT_IN_FILETYPES); g_assert(ft_id < filetypes_array->len);
if (G_UNLIKELY(ft_id == GEANY_FILETYPES_NONE)) if (G_UNLIKELY(ft_id == GEANY_FILETYPES_NONE))
{ {
@ -432,13 +432,16 @@ static void set_sci_style(ScintillaObject *sci, gint style, guint ft_id, guint s
void highlighting_free_styles() void highlighting_free_styles()
{ {
gint i; guint i;
for (i = 0; i < GEANY_MAX_BUILT_IN_FILETYPES; i++) for (i = 0; i < filetypes_array->len; i++)
styleset_free(i); free_styleset(i);
if (named_style_hash) if (named_style_hash)
g_hash_table_destroy(named_style_hash); g_hash_table_destroy(named_style_hash);
if (style_sets)
g_free(style_sets);
} }
@ -600,10 +603,15 @@ static void styleset_common_init(gint ft_id, GKeyFile *config, GKeyFile *config_
} }
static void styleset_common(ScintillaObject *sci) static void styleset_common(ScintillaObject *sci, filetype_id ft_id)
{ {
SSM(sci, SCI_STYLECLEARALL, 0, 0); SSM(sci, SCI_STYLECLEARALL, 0, 0);
SSM(sci, SCI_SETWORDCHARS, 0, (sptr_t) (ft_id == GEANY_FILETYPES_NONE ?
common_style_set.wordchars : style_sets[ft_id].wordchars));
/* have to set whitespace after setting wordchars */
SSM(sci, SCI_SETWHITESPACECHARS, 0, (sptr_t) whitespace_chars);
/* caret colour, style and width */ /* caret colour, style and width */
SSM(sci, SCI_SETCARETFORE, invert(common_style_set.styling[GCS_CARET].foreground), 0); SSM(sci, SCI_SETCARETFORE, invert(common_style_set.styling[GCS_CARET].foreground), 0);
SSM(sci, SCI_SETCARETWIDTH, common_style_set.styling[GCS_CARET].background, 0); SSM(sci, SCI_SETCARETWIDTH, common_style_set.styling[GCS_CARET].background, 0);
@ -793,13 +801,7 @@ apply_filetype_properties(ScintillaObject *sci, gint lexer, filetype_id ft_id)
SSM(sci, SCI_SETLEXER, lexer, 0); SSM(sci, SCI_SETLEXER, lexer, 0);
SSM(sci, SCI_SETWORDCHARS, 0, (sptr_t) style_sets[ft_id].wordchars); styleset_common(sci, ft_id);
/* have to set whitespace after setting wordchars */
SSM(sci, SCI_SETWHITESPACECHARS, 0, (sptr_t) whitespace_chars);
SSM(sci, SCI_AUTOCSETMAXHEIGHT, editor_prefs.symbolcompletion_max_height, 0);
styleset_common(sci);
} }
@ -832,7 +834,7 @@ static void load_style_entries(GKeyFile *config, GKeyFile *config_home, gint fil
} }
/* call new_style_array(filetype_idx, >= 20) before using this. */ /* call new_styleset(filetype_idx, >= 20) before using this. */
static void static void
styleset_c_like_init(GKeyFile *config, GKeyFile *config_home, gint filetype_idx) styleset_c_like_init(GKeyFile *config, GKeyFile *config_home, gint filetype_idx)
{ {
@ -896,7 +898,7 @@ static void styleset_c_like(ScintillaObject *sci, gint filetype_idx)
static void styleset_c_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_c_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_C, 21); new_styleset(GEANY_FILETYPES_C, 21);
styleset_c_like_init(config, config_home, GEANY_FILETYPES_C); styleset_c_like_init(config, config_home, GEANY_FILETYPES_C);
get_keyfile_int(config, config_home, "styling", "styling_within_preprocessor", get_keyfile_int(config, config_home, "styling", "styling_within_preprocessor",
1, 0, &style_sets[GEANY_FILETYPES_C].styling[20]); 1, 0, &style_sets[GEANY_FILETYPES_C].styling[20]);
@ -935,7 +937,7 @@ static void styleset_c(ScintillaObject *sci)
static void styleset_cpp_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_cpp_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_CPP, 21); new_styleset(GEANY_FILETYPES_CPP, 21);
styleset_c_like_init(config, config_home, GEANY_FILETYPES_CPP); styleset_c_like_init(config, config_home, GEANY_FILETYPES_CPP);
get_keyfile_int(config, config_home, "styling", "styling_within_preprocessor", get_keyfile_int(config, config_home, "styling", "styling_within_preprocessor",
1, 0, &style_sets[GEANY_FILETYPES_CPP].styling[20]); 1, 0, &style_sets[GEANY_FILETYPES_CPP].styling[20]);
@ -975,7 +977,7 @@ static void styleset_cpp(ScintillaObject *sci)
static void styleset_glsl_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_glsl_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_GLSL, 21); new_styleset(GEANY_FILETYPES_GLSL, 21);
styleset_c_like_init(config, config_home, GEANY_FILETYPES_GLSL); styleset_c_like_init(config, config_home, GEANY_FILETYPES_GLSL);
get_keyfile_int(config, config_home, "styling", "styling_within_preprocessor", get_keyfile_int(config, config_home, "styling", "styling_within_preprocessor",
1, 0, &style_sets[GEANY_FILETYPES_GLSL].styling[20]); 1, 0, &style_sets[GEANY_FILETYPES_GLSL].styling[20]);
@ -1025,7 +1027,7 @@ static void styleset_glsl(ScintillaObject *sci)
static void styleset_cs_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_cs_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_CS, 21); new_styleset(GEANY_FILETYPES_CS, 21);
styleset_c_like_init(config, config_home, GEANY_FILETYPES_CS); styleset_c_like_init(config, config_home, GEANY_FILETYPES_CS);
get_keyfile_int(config, config_home, "styling", "styling_within_preprocessor", get_keyfile_int(config, config_home, "styling", "styling_within_preprocessor",
1, 0, &style_sets[GEANY_FILETYPES_CS].styling[20]); 1, 0, &style_sets[GEANY_FILETYPES_CS].styling[20]);
@ -1067,7 +1069,7 @@ static void styleset_cs(ScintillaObject *sci)
static void styleset_vala_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_vala_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_VALA, 21); new_styleset(GEANY_FILETYPES_VALA, 21);
styleset_c_like_init(config, config_home, GEANY_FILETYPES_VALA); styleset_c_like_init(config, config_home, GEANY_FILETYPES_VALA);
get_keyfile_int(config, config_home, "styling", "styling_within_preprocessor", get_keyfile_int(config, config_home, "styling", "styling_within_preprocessor",
1, 0, &style_sets[GEANY_FILETYPES_VALA].styling[20]); 1, 0, &style_sets[GEANY_FILETYPES_VALA].styling[20]);
@ -1124,7 +1126,7 @@ static void styleset_vala(ScintillaObject *sci)
static void styleset_pascal_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_pascal_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_PASCAL, 15); new_styleset(GEANY_FILETYPES_PASCAL, 15);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PASCAL].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PASCAL].styling[0]);
get_keyfile_hex(config, config_home, "identifier", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PASCAL].styling[1]); get_keyfile_hex(config, config_home, "identifier", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PASCAL].styling[1]);
get_keyfile_hex(config, config_home, "comment", 0xd00000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PASCAL].styling[2]); get_keyfile_hex(config, config_home, "comment", 0xd00000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PASCAL].styling[2]);
@ -1180,7 +1182,7 @@ static void styleset_pascal(ScintillaObject *sci)
static void styleset_makefile_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_makefile_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_MAKE, 7); new_styleset(GEANY_FILETYPES_MAKE, 7);
get_keyfile_hex(config, config_home, "default", 0x00002f, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_MAKE].styling[0]); get_keyfile_hex(config, config_home, "default", 0x00002f, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_MAKE].styling[0]);
get_keyfile_named_style(config, config_home, "comment", "comment", &style_sets[GEANY_FILETYPES_MAKE].styling[1]); get_keyfile_named_style(config, config_home, "comment", "comment", &style_sets[GEANY_FILETYPES_MAKE].styling[1]);
get_keyfile_hex(config, config_home, "preprocessor", 0x007f7f, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_MAKE].styling[2]); get_keyfile_hex(config, config_home, "preprocessor", 0x007f7f, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_MAKE].styling[2]);
@ -1212,7 +1214,7 @@ static void styleset_makefile(ScintillaObject *sci)
static void styleset_diff_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_diff_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_DIFF, 8); new_styleset(GEANY_FILETYPES_DIFF, 8);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_DIFF].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_DIFF].styling[0]);
get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_DIFF].styling[1]); get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_DIFF].styling[1]);
get_keyfile_hex(config, config_home, "command", 0x7f7f00, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_DIFF].styling[2]); get_keyfile_hex(config, config_home, "command", 0x7f7f00, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_DIFF].styling[2]);
@ -1246,7 +1248,7 @@ static void styleset_diff(ScintillaObject *sci)
static void styleset_latex_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_latex_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_LATEX, 5); new_styleset(GEANY_FILETYPES_LATEX, 5);
get_keyfile_hex(config, config_home, "default", 0x00002f, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_LATEX].styling[0]); get_keyfile_hex(config, config_home, "default", 0x00002f, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_LATEX].styling[0]);
get_keyfile_hex(config, config_home, "command", 0xff0000, 0xffffff, TRUE, &style_sets[GEANY_FILETYPES_LATEX].styling[1]); get_keyfile_hex(config, config_home, "command", 0xff0000, 0xffffff, TRUE, &style_sets[GEANY_FILETYPES_LATEX].styling[1]);
get_keyfile_hex(config, config_home, "tag", 0x007f7f, 0xffffff, TRUE, &style_sets[GEANY_FILETYPES_LATEX].styling[2]); get_keyfile_hex(config, config_home, "tag", 0x007f7f, 0xffffff, TRUE, &style_sets[GEANY_FILETYPES_LATEX].styling[2]);
@ -1316,7 +1318,7 @@ static void styleset_html(ScintillaObject *sci)
static void styleset_markup_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_markup_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_XML, 56); new_styleset(GEANY_FILETYPES_XML, 56);
get_keyfile_hex(config, config_home, "html_default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_XML].styling[0]); get_keyfile_hex(config, config_home, "html_default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_XML].styling[0]);
get_keyfile_hex(config, config_home, "html_tag", 0x000099, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_XML].styling[1]); get_keyfile_hex(config, config_home, "html_tag", 0x000099, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_XML].styling[1]);
get_keyfile_hex(config, config_home, "html_tagunknown", 0xff0000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_XML].styling[2]); get_keyfile_hex(config, config_home, "html_tagunknown", 0xff0000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_XML].styling[2]);
@ -1546,7 +1548,7 @@ static void styleset_markup(ScintillaObject *sci, gboolean set_keywords)
static void styleset_java_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_java_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_JAVA, 20); new_styleset(GEANY_FILETYPES_JAVA, 20);
styleset_c_like_init(config, config_home, GEANY_FILETYPES_JAVA); styleset_c_like_init(config, config_home, GEANY_FILETYPES_JAVA);
style_sets[GEANY_FILETYPES_JAVA].keywords = g_new(gchar*, 5); style_sets[GEANY_FILETYPES_JAVA].keywords = g_new(gchar*, 5);
@ -1581,7 +1583,7 @@ static void styleset_java(ScintillaObject *sci)
static void styleset_perl_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_perl_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_PERL, 35); new_styleset(GEANY_FILETYPES_PERL, 35);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PERL].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PERL].styling[0]);
get_keyfile_hex(config, config_home, "error", 0xff0000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PERL].styling[1]); get_keyfile_hex(config, config_home, "error", 0xff0000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PERL].styling[1]);
get_keyfile_named_style(config, config_home, "commentline", "comment", &style_sets[GEANY_FILETYPES_PERL].styling[2]); get_keyfile_named_style(config, config_home, "commentline", "comment", &style_sets[GEANY_FILETYPES_PERL].styling[2]);
@ -1703,7 +1705,7 @@ static void styleset_perl(ScintillaObject *sci)
static void styleset_python_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_python_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_PYTHON, 16); new_styleset(GEANY_FILETYPES_PYTHON, 16);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PYTHON].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PYTHON].styling[0]);
get_keyfile_hex(config, config_home, "commentline", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PYTHON].styling[1]); get_keyfile_hex(config, config_home, "commentline", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PYTHON].styling[1]);
get_keyfile_hex(config, config_home, "number", 0x400080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PYTHON].styling[2]); get_keyfile_hex(config, config_home, "number", 0x400080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PYTHON].styling[2]);
@ -1762,7 +1764,7 @@ static void styleset_python(ScintillaObject *sci)
static void styleset_cmake_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_cmake_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_CMAKE, 15); new_styleset(GEANY_FILETYPES_CMAKE, 15);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_CMAKE].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_CMAKE].styling[0]);
get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_CMAKE].styling[1]); get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_CMAKE].styling[1]);
get_keyfile_hex(config, config_home, "stringdq", 0xff901e, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_CMAKE].styling[2]); get_keyfile_hex(config, config_home, "stringdq", 0xff901e, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_CMAKE].styling[2]);
@ -1818,7 +1820,7 @@ static void styleset_cmake(ScintillaObject *sci)
static void styleset_r_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_r_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_R, 12); new_styleset(GEANY_FILETYPES_R, 12);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_R].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_R].styling[0]);
get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_R].styling[1]); get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_R].styling[1]);
@ -1869,7 +1871,7 @@ static void styleset_r(ScintillaObject *sci)
static void styleset_ruby_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_ruby_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_RUBY, 35); new_styleset(GEANY_FILETYPES_RUBY, 35);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_RUBY].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_RUBY].styling[0]);
get_keyfile_named_style(config, config_home, "commentline", "comment", &style_sets[GEANY_FILETYPES_RUBY].styling[1]); get_keyfile_named_style(config, config_home, "commentline", "comment", &style_sets[GEANY_FILETYPES_RUBY].styling[1]);
get_keyfile_hex(config, config_home, "number", 0x400080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_RUBY].styling[2]); get_keyfile_hex(config, config_home, "number", 0x400080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_RUBY].styling[2]);
@ -1961,7 +1963,7 @@ static void styleset_ruby(ScintillaObject *sci)
static void styleset_sh_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_sh_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_SH, 14); new_styleset(GEANY_FILETYPES_SH, 14);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_SH].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_SH].styling[0]);
get_keyfile_named_style(config, config_home, "commentline", "comment", &style_sets[GEANY_FILETYPES_SH].styling[1]); get_keyfile_named_style(config, config_home, "commentline", "comment", &style_sets[GEANY_FILETYPES_SH].styling[1]);
get_keyfile_hex(config, config_home, "number", 0x007f00, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_SH].styling[2]); get_keyfile_hex(config, config_home, "number", 0x007f00, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_SH].styling[2]);
@ -2022,7 +2024,7 @@ static void styleset_xml(ScintillaObject *sci)
static void styleset_docbook_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_docbook_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_DOCBOOK, 29); new_styleset(GEANY_FILETYPES_DOCBOOK, 29);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_DOCBOOK].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_DOCBOOK].styling[0]);
get_keyfile_hex(config, config_home, "tag", 0x000099, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_DOCBOOK].styling[1]); get_keyfile_hex(config, config_home, "tag", 0x000099, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_DOCBOOK].styling[1]);
get_keyfile_hex(config, config_home, "tagunknown", 0xff0000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_DOCBOOK].styling[2]); get_keyfile_hex(config, config_home, "tagunknown", 0xff0000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_DOCBOOK].styling[2]);
@ -2164,23 +2166,20 @@ static void styleset_docbook(ScintillaObject *sci)
} }
static void styleset_none(ScintillaObject *sci) static void styleset_default(ScintillaObject *sci, gint ft_id)
{ {
SSM(sci, SCI_SETLEXER, SCLEX_NULL, 0); SSM(sci, SCI_SETLEXER, SCLEX_NULL, 0);
/* we need to set STYLE_DEFAULT before we call SCI_STYLECLEARALL in styleset_common() */ /* we need to set STYLE_DEFAULT before we call SCI_STYLECLEARALL in styleset_common() */
set_sci_style(sci, STYLE_DEFAULT, GEANY_FILETYPES_NONE, GCS_DEFAULT); set_sci_style(sci, STYLE_DEFAULT, GEANY_FILETYPES_NONE, GCS_DEFAULT);
styleset_common(sci); styleset_common(sci, ft_id);
SSM(sci, SCI_SETWORDCHARS, 0, (sptr_t) common_style_set.wordchars);
SSM(sci, SCI_SETWHITESPACECHARS, 0, (sptr_t) whitespace_chars);
} }
static void styleset_css_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_css_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_CSS, 22); new_styleset(GEANY_FILETYPES_CSS, 22);
get_keyfile_hex(config, config_home, "default", 0x003399, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_CSS].styling[0]); get_keyfile_hex(config, config_home, "default", 0x003399, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_CSS].styling[0]);
get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_CSS].styling[1]); get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_CSS].styling[1]);
get_keyfile_hex(config, config_home, "tag", 0x2166a4, 0xffffff, TRUE, &style_sets[GEANY_FILETYPES_CSS].styling[2]); get_keyfile_hex(config, config_home, "tag", 0x2166a4, 0xffffff, TRUE, &style_sets[GEANY_FILETYPES_CSS].styling[2]);
@ -2257,7 +2256,7 @@ static void styleset_css(ScintillaObject *sci)
static void styleset_nsis_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_nsis_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_NSIS, 19); new_styleset(GEANY_FILETYPES_NSIS, 19);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_NSIS].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_NSIS].styling[0]);
get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_NSIS].styling[1]); get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_NSIS].styling[1]);
get_keyfile_hex(config, config_home, "stringdq", 0xff901e, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_NSIS].styling[2]); get_keyfile_hex(config, config_home, "stringdq", 0xff901e, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_NSIS].styling[2]);
@ -2326,7 +2325,7 @@ static void styleset_nsis(ScintillaObject *sci)
static void styleset_po_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_po_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_PO, 9); new_styleset(GEANY_FILETYPES_PO, 9);
get_keyfile_hex(config, config_home, "default", 0x7f0000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PO].styling[0]); get_keyfile_hex(config, config_home, "default", 0x7f0000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PO].styling[0]);
get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PO].styling[1]); get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_PO].styling[1]);
get_keyfile_hex(config, config_home, "msgid", 0x00007f, 0xffffff, TRUE, &style_sets[GEANY_FILETYPES_PO].styling[2]); get_keyfile_hex(config, config_home, "msgid", 0x00007f, 0xffffff, TRUE, &style_sets[GEANY_FILETYPES_PO].styling[2]);
@ -2362,7 +2361,7 @@ static void styleset_po(ScintillaObject *sci)
static void styleset_conf_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_conf_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_CONF, 6); new_styleset(GEANY_FILETYPES_CONF, 6);
get_keyfile_hex(config, config_home, "default", 0x7f0000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_CONF].styling[0]); get_keyfile_hex(config, config_home, "default", 0x7f0000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_CONF].styling[0]);
get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_CONF].styling[1]); get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_CONF].styling[1]);
get_keyfile_hex(config, config_home, "section", 0x000090, 0xffffff, TRUE, &style_sets[GEANY_FILETYPES_CONF].styling[2]); get_keyfile_hex(config, config_home, "section", 0x000090, 0xffffff, TRUE, &style_sets[GEANY_FILETYPES_CONF].styling[2]);
@ -2394,7 +2393,7 @@ static void styleset_conf(ScintillaObject *sci)
static void styleset_asm_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_asm_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_ASM, 15); new_styleset(GEANY_FILETYPES_ASM, 15);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_ASM].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_ASM].styling[0]);
get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_ASM].styling[1]); get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_ASM].styling[1]);
get_keyfile_hex(config, config_home, "number", 0x007f00, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_ASM].styling[2]); get_keyfile_hex(config, config_home, "number", 0x007f00, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_ASM].styling[2]);
@ -2452,7 +2451,7 @@ static void styleset_asm(ScintillaObject *sci)
static void styleset_f77_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_f77_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_F77, 15); new_styleset(GEANY_FILETYPES_F77, 15);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_F77].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_F77].styling[0]);
get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_F77].styling[1]); get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_F77].styling[1]);
get_keyfile_hex(config, config_home, "number", 0x007f00, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_F77].styling[2]); get_keyfile_hex(config, config_home, "number", 0x007f00, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_F77].styling[2]);
@ -2508,7 +2507,7 @@ static void styleset_f77(ScintillaObject *sci)
static void styleset_fortran_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_fortran_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_FORTRAN, 15); new_styleset(GEANY_FILETYPES_FORTRAN, 15);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_FORTRAN].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_FORTRAN].styling[0]);
get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_FORTRAN].styling[1]); get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_FORTRAN].styling[1]);
get_keyfile_hex(config, config_home, "number", 0x007f00, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_FORTRAN].styling[2]); get_keyfile_hex(config, config_home, "number", 0x007f00, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_FORTRAN].styling[2]);
@ -2564,7 +2563,7 @@ static void styleset_fortran(ScintillaObject *sci)
static void styleset_sql_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_sql_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_SQL, 15); new_styleset(GEANY_FILETYPES_SQL, 15);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_SQL].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_SQL].styling[0]);
get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_SQL].styling[1]); get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_SQL].styling[1]);
get_keyfile_hex(config, config_home, "commentline", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_SQL].styling[2]); get_keyfile_hex(config, config_home, "commentline", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_SQL].styling[2]);
@ -2643,7 +2642,7 @@ static void styleset_sql(ScintillaObject *sci)
static void styleset_markdown_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_markdown_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_MARKDOWN, 17); new_styleset(GEANY_FILETYPES_MARKDOWN, 17);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_MARKDOWN].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_MARKDOWN].styling[0]);
get_keyfile_hex(config, config_home, "strong", 0xff0000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_MARKDOWN].styling[1]); get_keyfile_hex(config, config_home, "strong", 0xff0000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_MARKDOWN].styling[1]);
@ -2699,7 +2698,7 @@ static void styleset_markdown(ScintillaObject *sci)
static void styleset_haskell_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_haskell_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_HASKELL, 17); new_styleset(GEANY_FILETYPES_HASKELL, 17);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_HASKELL].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_HASKELL].styling[0]);
get_keyfile_hex(config, config_home, "commentline", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_HASKELL].styling[1]); get_keyfile_hex(config, config_home, "commentline", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_HASKELL].styling[1]);
@ -2757,7 +2756,7 @@ static void styleset_haskell(ScintillaObject *sci)
static void styleset_caml_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_caml_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_CAML, 14); new_styleset(GEANY_FILETYPES_CAML, 14);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_CAML].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_CAML].styling[0]);
get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_CAML].styling[1]); get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_CAML].styling[1]);
@ -2814,7 +2813,7 @@ static void styleset_caml(ScintillaObject *sci)
static void styleset_tcl_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_tcl_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_TCL, 16); new_styleset(GEANY_FILETYPES_TCL, 16);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_TCL].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_TCL].styling[0]);
get_keyfile_named_style(config, config_home, "comment", "comment", &style_sets[GEANY_FILETYPES_TCL].styling[1]); get_keyfile_named_style(config, config_home, "comment", "comment", &style_sets[GEANY_FILETYPES_TCL].styling[1]);
get_keyfile_named_style(config, config_home, "commentline", "comment", &style_sets[GEANY_FILETYPES_TCL].styling[2]); get_keyfile_named_style(config, config_home, "commentline", "comment", &style_sets[GEANY_FILETYPES_TCL].styling[2]);
@ -2876,7 +2875,7 @@ static void styleset_tcl(ScintillaObject *sci)
static void styleset_matlab_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_matlab_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_MATLAB, 9); new_styleset(GEANY_FILETYPES_MATLAB, 9);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_MATLAB].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_MATLAB].styling[0]);
get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_MATLAB].styling[1]); get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_MATLAB].styling[1]);
get_keyfile_hex(config, config_home, "command", 0x111199, 0xffffff, TRUE, &style_sets[GEANY_FILETYPES_MATLAB].styling[2]); get_keyfile_hex(config, config_home, "command", 0x111199, 0xffffff, TRUE, &style_sets[GEANY_FILETYPES_MATLAB].styling[2]);
@ -2897,8 +2896,6 @@ static void styleset_matlab(ScintillaObject *sci)
{ {
const filetype_id ft_id = GEANY_FILETYPES_MATLAB; const filetype_id ft_id = GEANY_FILETYPES_MATLAB;
styleset_common(sci);
apply_filetype_properties(sci, SCLEX_MATLAB, ft_id); apply_filetype_properties(sci, SCLEX_MATLAB, ft_id);
SSM(sci, SCI_SETKEYWORDS, 0, (sptr_t) style_sets[GEANY_FILETYPES_MATLAB].keywords[0]); SSM(sci, SCI_SETKEYWORDS, 0, (sptr_t) style_sets[GEANY_FILETYPES_MATLAB].keywords[0]);
@ -2918,7 +2915,7 @@ static void styleset_matlab(ScintillaObject *sci)
static void styleset_d_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_d_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_D, 18); new_styleset(GEANY_FILETYPES_D, 18);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_D].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_D].styling[0]);
get_keyfile_hex(config, config_home, "comment", 0xd00000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_D].styling[1]); get_keyfile_hex(config, config_home, "comment", 0xd00000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_D].styling[1]);
@ -2999,7 +2996,7 @@ static void styleset_d(ScintillaObject *sci)
static void styleset_ferite_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_ferite_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_FERITE, 20); new_styleset(GEANY_FILETYPES_FERITE, 20);
styleset_c_like_init(config, config_home, GEANY_FILETYPES_FERITE); styleset_c_like_init(config, config_home, GEANY_FILETYPES_FERITE);
style_sets[GEANY_FILETYPES_FERITE].keywords = g_new(gchar*, 4); style_sets[GEANY_FILETYPES_FERITE].keywords = g_new(gchar*, 4);
@ -3026,7 +3023,7 @@ static void styleset_ferite(ScintillaObject *sci)
static void styleset_vhdl_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_vhdl_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_VHDL, 15); new_styleset(GEANY_FILETYPES_VHDL, 15);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_VHDL].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_VHDL].styling[0]);
get_keyfile_hex(config, config_home, "comment", 0xd00000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_VHDL].styling[1]); get_keyfile_hex(config, config_home, "comment", 0xd00000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_VHDL].styling[1]);
@ -3112,7 +3109,7 @@ static void styleset_vhdl(ScintillaObject *sci)
static void styleset_yaml_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_yaml_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_YAML, 10); new_styleset(GEANY_FILETYPES_YAML, 10);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_YAML].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_YAML].styling[0]);
get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_YAML].styling[1]); get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_YAML].styling[1]);
@ -3155,7 +3152,7 @@ static void styleset_yaml(ScintillaObject *sci)
static void styleset_js_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_js_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_JS, 20); new_styleset(GEANY_FILETYPES_JS, 20);
styleset_c_like_init(config, config_home, GEANY_FILETYPES_JS); styleset_c_like_init(config, config_home, GEANY_FILETYPES_JS);
style_sets[GEANY_FILETYPES_JS].keywords = g_new(gchar*, 2); style_sets[GEANY_FILETYPES_JS].keywords = g_new(gchar*, 2);
@ -3191,7 +3188,7 @@ static void styleset_js(ScintillaObject *sci)
static void styleset_lua_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_lua_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_LUA, 20); new_styleset(GEANY_FILETYPES_LUA, 20);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_LUA].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_LUA].styling[0]);
get_keyfile_hex(config, config_home, "comment", 0xd00000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_LUA].styling[1]); get_keyfile_hex(config, config_home, "comment", 0xd00000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_LUA].styling[1]);
@ -3295,7 +3292,7 @@ static void styleset_lua(ScintillaObject *sci)
static void styleset_basic_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_basic_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_BASIC, 19); new_styleset(GEANY_FILETYPES_BASIC, 19);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_BASIC].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_BASIC].styling[0]);
get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_BASIC].styling[1]); get_keyfile_hex(config, config_home, "comment", 0x808080, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_BASIC].styling[1]);
@ -3374,7 +3371,7 @@ static void styleset_basic(ScintillaObject *sci)
static void styleset_actionscript_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_actionscript_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_AS, 20); new_styleset(GEANY_FILETYPES_AS, 20);
styleset_c_like_init(config, config_home, GEANY_FILETYPES_AS); styleset_c_like_init(config, config_home, GEANY_FILETYPES_AS);
style_sets[GEANY_FILETYPES_AS].keywords = g_new(gchar *, 4); style_sets[GEANY_FILETYPES_AS].keywords = g_new(gchar *, 4);
@ -3400,7 +3397,7 @@ static void styleset_actionscript(ScintillaObject *sci)
static void styleset_haxe_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_haxe_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_HAXE, 20); new_styleset(GEANY_FILETYPES_HAXE, 20);
styleset_c_like_init(config, config_home, GEANY_FILETYPES_HAXE); styleset_c_like_init(config, config_home, GEANY_FILETYPES_HAXE);
style_sets[GEANY_FILETYPES_HAXE].keywords = g_new(gchar*, 4); style_sets[GEANY_FILETYPES_HAXE].keywords = g_new(gchar*, 4);
@ -3443,7 +3440,7 @@ static void styleset_haxe(ScintillaObject *sci)
static void styleset_ada_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) static void styleset_ada_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{ {
new_style_array(GEANY_FILETYPES_ADA, 12); new_styleset(GEANY_FILETYPES_ADA, 12);
get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_ADA].styling[0]); get_keyfile_hex(config, config_home, "default", 0x000000, 0xffffff, FALSE, &style_sets[GEANY_FILETYPES_ADA].styling[0]);
get_keyfile_hex(config, config_home, "word", 0x00007f, 0xffffff, TRUE, &style_sets[GEANY_FILETYPES_ADA].styling[1]); get_keyfile_hex(config, config_home, "word", 0x00007f, 0xffffff, TRUE, &style_sets[GEANY_FILETYPES_ADA].styling[1]);
@ -3497,8 +3494,11 @@ static void styleset_ada(ScintillaObject *sci)
/* Called by filetypes_load_config(). */ /* Called by filetypes_load_config(). */
void highlighting_init_styles(gint filetype_idx, GKeyFile *config, GKeyFile *configh) void highlighting_init_styles(gint filetype_idx, GKeyFile *config, GKeyFile *configh)
{ {
/* Clear old information if necessary - e.g. reloading config */ if (!style_sets)
styleset_free(filetype_idx); style_sets = g_new0(StyleSet, filetypes_array->len);
/* Clear old information if necessary - e.g. when reloading config */
free_styleset(filetype_idx);
/* All stylesets depend on filetypes.common */ /* All stylesets depend on filetypes.common */
if (filetype_idx != GEANY_FILETYPES_NONE) if (filetype_idx != GEANY_FILETYPES_NONE)
@ -3616,8 +3616,9 @@ void highlighting_set_styles(ScintillaObject *sci, gint filetype_idx)
styleset_case(GEANY_FILETYPES_VHDL, styleset_vhdl); styleset_case(GEANY_FILETYPES_VHDL, styleset_vhdl);
styleset_case(GEANY_FILETYPES_XML, styleset_xml); styleset_case(GEANY_FILETYPES_XML, styleset_xml);
styleset_case(GEANY_FILETYPES_YAML, styleset_yaml); styleset_case(GEANY_FILETYPES_YAML, styleset_yaml);
case GEANY_FILETYPES_NONE:
default: default:
styleset_case(GEANY_FILETYPES_NONE, styleset_none); styleset_default(sci, filetype_idx);
} }
} }
@ -3632,7 +3633,7 @@ void highlighting_set_styles(ScintillaObject *sci, gint filetype_idx)
* @see Scintilla messages @c SCI_STYLEGETFORE, etc, for use with ScintillaFuncs::send_message(). */ * @see Scintilla messages @c SCI_STYLEGETFORE, etc, for use with ScintillaFuncs::send_message(). */
const GeanyLexerStyle *highlighting_get_style(gint ft_id, gint style_id) const GeanyLexerStyle *highlighting_get_style(gint ft_id, gint style_id)
{ {
if (ft_id < 0 || ft_id > GEANY_MAX_BUILT_IN_FILETYPES) if (ft_id < 0 || ft_id >= (gint)filetypes_array->len)
return NULL; return NULL;
/* ensure filetype loaded */ /* ensure filetype loaded */

View File

@ -1078,7 +1078,6 @@ void main_quit()
navqueue_free(); navqueue_free();
keybindings_free(); keybindings_free();
filetypes_save_commands(); filetypes_save_commands();
filetypes_free_types();
highlighting_free_styles(); highlighting_free_styles();
templates_free_templates(); templates_free_templates();
msgwin_finalize(); msgwin_finalize();
@ -1093,6 +1092,7 @@ void main_quit()
toolbar_finalize(); toolbar_finalize();
treeviews_finalize(); treeviews_finalize();
configuration_finalize(); configuration_finalize();
filetypes_free_types();
log_finalize(); log_finalize();
tm_workspace_free(TM_WORK_OBJECT(app->tm_workspace)); tm_workspace_free(TM_WORK_OBJECT(app->tm_workspace));

View File

@ -1487,15 +1487,16 @@ static GHashTable *init_user_tags(void)
static void load_user_tags(filetype_id ft_id) static void load_user_tags(filetype_id ft_id)
{ {
static guchar tags_loaded[GEANY_MAX_BUILT_IN_FILETYPES] = {0}; static guchar *tags_loaded = NULL;
static GHashTable *lang_hash = NULL; static GHashTable *lang_hash = NULL;
GList *fnames; GList *fnames;
const GList *node; const GList *node;
GeanyFiletype *ft = filetypes[ft_id]; GeanyFiletype *ft = filetypes[ft_id];
g_return_if_fail(ft_id > 0); g_return_if_fail(ft_id > 0);
g_return_if_fail(ft_id < GEANY_MAX_BUILT_IN_FILETYPES);
if (!tags_loaded)
tags_loaded = g_new0(guchar, filetypes_array->len);
if (tags_loaded[ft_id]) if (tags_loaded[ft_id])
return; return;
tags_loaded[ft_id] = TRUE; /* prevent reloading */ tags_loaded[ft_id] = TRUE; /* prevent reloading */

View File

@ -242,6 +242,8 @@ static const gchar templates_filetype_latex[] = "\
"; ";
static gchar *templates[GEANY_MAX_TEMPLATES]; static gchar *templates[GEANY_MAX_TEMPLATES];
/* TODO: remove filetype templates, use custom file templates instead. */
static gchar *ft_templates[GEANY_MAX_BUILT_IN_FILETYPES] = {NULL}; static gchar *ft_templates[GEANY_MAX_BUILT_IN_FILETYPES] = {NULL};
@ -686,7 +688,7 @@ gchar *templates_get_template_fileheader(gint filetype_idx, const gchar *fname)
if (fname == NULL) if (fname == NULL)
{ {
if (ft_id == GEANY_FILETYPES_NONE) if (!ft->extension)
shortname = g_strdup(GEANY_STRING_UNTITLED); shortname = g_strdup(GEANY_STRING_UNTITLED);
else else
shortname = g_strconcat(GEANY_STRING_UNTITLED, ".", ft->extension, NULL); shortname = g_strconcat(GEANY_STRING_UNTITLED, ".", ft->extension, NULL);