Created
March 5, 2016 01:16
-
-
Save codebrainz/f024bf1128c948a1092e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/editor.c b/src/editor.c | |
index 595cd54..35105bc 100644 | |
--- a/src/editor.c | |
+++ b/src/editor.c | |
@@ -2626,7 +2626,7 @@ static gboolean snippets_complete_constructs(GeanyEditor *editor, gint pos, cons | |
gchar *str; | |
const gchar *completion; | |
gint str_len; | |
- gint ft_id = editor->document->file_type->id; | |
+ GeanyFiletypeID ft_id = editor->document->file_type->id; | |
str = g_strdup(word); | |
g_strstrip(str); | |
diff --git a/src/filetypes.c b/src/filetypes.c | |
index d7045d5..1b779cc 100644 | |
--- a/src/filetypes.c | |
+++ b/src/filetypes.c | |
@@ -24,7 +24,7 @@ | |
* Filetype detection, file extensions and filetype menu items. | |
*/ | |
-/* Note: we use filetype_id for some function arguments, but GeanyFiletype is better; we should | |
+/* Note: we use GeanyFiletypeID for some function arguments, but GeanyFiletype is better; we should | |
* only use GeanyFiletype for API functions. */ | |
#ifdef HAVE_CONFIG_H | |
@@ -110,7 +110,7 @@ static gchar *filetype_make_title(const char *name, enum TitleType type) | |
/* name argument (ie filetype name) must not be translated as it is used for | |
* filetype lookup. Use filetypes_get_display_name() instead.*/ | |
-static void ft_init(filetype_id ft_id, TMParserType lang, const char *name, | |
+static void ft_init(GeanyFiletypeID ft_id, TMParserType lang, const char *name, | |
const char *title_name, enum TitleType title_type, | |
GeanyFiletypeGroupID group_id) | |
{ | |
@@ -325,7 +325,7 @@ static void init_custom_filetypes(const gchar *path) | |
* Warning: GTK isn't necessarily initialized yet. */ | |
void filetypes_init_types(void) | |
{ | |
- filetype_id ft_id; | |
+ GeanyFiletypeID ft_id; | |
gchar *f; | |
g_return_if_fail(filetypes_array == NULL); | |
@@ -616,7 +616,7 @@ static GeanyFiletype *find_shebang(const gchar *utf8_filename, const gchar *line | |
{ | |
static const struct { | |
const gchar *name; | |
- filetype_id filetype; | |
+ GeanyFiletypeID filetype; | |
} intepreter_map[] = { | |
{ "sh", GEANY_FILETYPES_SH }, | |
{ "bash", GEANY_FILETYPES_SH }, | |
@@ -902,7 +902,7 @@ static void load_indent_settings(GeanyFiletype *ft, GKeyFile *config, GKeyFile * | |
} | |
-static void load_settings(guint ft_id, GKeyFile *config, GKeyFile *configh) | |
+static void load_settings(GeanyFiletypeID ft_id, GKeyFile *config, GKeyFile *configh) | |
{ | |
GeanyFiletype *ft = filetypes[ft_id]; | |
gchar *result; | |
@@ -1105,13 +1105,13 @@ static void load_system_keyfile(GKeyFile *key_file, const gchar *file, GKeyFileF | |
/* Load the configuration file for the associated filetype id. | |
* This should only be called when the filetype is needed, to save loading | |
* 20+ configuration files all at once. */ | |
-void filetypes_load_config(guint ft_id, gboolean reload) | |
+void filetypes_load_config(GeanyFiletypeID ft_id, gboolean reload) | |
{ | |
GKeyFile *config, *config_home; | |
GeanyFiletypePrivate *pft; | |
GeanyFiletype *ft; | |
- g_return_if_fail(ft_id < filetypes_array->len); | |
+ g_return_if_fail(ft_id >= 0 && ft_id < filetypes_array->len); | |
ft = filetypes[ft_id]; | |
pft = ft->priv; | |
@@ -1498,15 +1498,15 @@ void filetypes_reload_extensions(void) | |
/** Accessor function for @ref GeanyData::filetypes_array items. | |
* Example: @code ft = filetypes_index(GEANY_FILETYPES_C); @endcode | |
- * @param idx @c filetypes_array index. | |
- * @return @transfer{none} @nullable The filetype, or @c NULL if @a idx is out of range. | |
+ * @param id @c filetypes_array index. | |
+ * @return @transfer{none} @nullable The filetype, or @c NULL if @a id is out of range. | |
* | |
* @since 0.16 | |
*/ | |
GEANY_API_SYMBOL | |
-GeanyFiletype *filetypes_index(gint idx) | |
+GeanyFiletype *filetypes_index(GeanyFiletypeID id) | |
{ | |
- return (idx >= 0 && idx < (gint) filetypes_array->len) ? filetypes[idx] : NULL; | |
+ return (id >= 0 && id < (gint) filetypes_array->len) ? filetypes[id] : NULL; | |
} | |
diff --git a/src/filetypes.h b/src/filetypes.h | |
index 789ef74..6faea98 100644 | |
--- a/src/filetypes.h | |
+++ b/src/filetypes.h | |
@@ -177,7 +177,7 @@ GeanyFiletype *filetypes_detect_from_file(const gchar *utf8_filename); | |
GeanyFiletype *filetypes_lookup_by_name(const gchar *name); | |
-GeanyFiletype *filetypes_index(gint idx); | |
+GeanyFiletype *filetypes_index(GeanyFiletypeID id); | |
const gchar *filetypes_get_display_name(GeanyFiletype *ft); | |
@@ -209,7 +209,7 @@ GeanyFiletype *filetypes_detect_from_extension(const gchar *utf8_filename); | |
void filetypes_free_types(void); | |
-void filetypes_load_config(guint ft_id, gboolean reload); | |
+void filetypes_load_config(GeanyFiletypeID ft_id, gboolean reload); | |
void filetypes_save_commands(GeanyFiletype *ft); | |
diff --git a/src/highlighting.c b/src/highlighting.c | |
index 0a700b6..4ea7649 100644 | |
--- a/src/highlighting.c | |
+++ b/src/highlighting.c | |
@@ -164,7 +164,7 @@ static void free_styleset(guint file_type_id) | |
static void get_keyfile_keywords(GKeyFile *config, GKeyFile *configh, | |
- const gchar *key, guint ft_id, guint pos) | |
+ const gchar *key, GeanyFiletypeID ft_id, guint pos) | |
{ | |
style_sets[ft_id].keywords[pos] = | |
utils_get_setting(string, configh, config, "keywords", key, ""); | |
@@ -390,9 +390,9 @@ static guint invert(guint icolour) | |
} | |
-static GeanyLexerStyle *get_style(guint ft_id, guint styling_index) | |
+static GeanyLexerStyle *get_style(GeanyFiletypeID ft_id, guint styling_index) | |
{ | |
- g_assert(ft_id < filetypes_array->len); | |
+ g_assert(ft_id >= 0 && ft_id < filetypes_array->len); | |
if (G_UNLIKELY(ft_id == GEANY_FILETYPES_NONE)) | |
{ | |
@@ -409,7 +409,7 @@ static GeanyLexerStyle *get_style(guint ft_id, guint styling_index) | |
} | |
-static void set_sci_style(ScintillaObject *sci, guint style, guint ft_id, guint styling_index) | |
+static void set_sci_style(ScintillaObject *sci, guint style, GeanyFiletypeID ft_id, guint styling_index) | |
{ | |
GeanyLexerStyle *style_ptr = get_style(ft_id, styling_index); | |
@@ -585,7 +585,7 @@ static void styleset_common_init(GKeyFile *config, GKeyFile *config_home) | |
} | |
-static void set_character_classes(ScintillaObject *sci, guint ft_id) | |
+static void set_character_classes(ScintillaObject *sci, GeanyFiletypeID ft_id) | |
{ | |
const gchar *word = (ft_id == GEANY_FILETYPES_NONE ? | |
common_style_set.wordchars : style_sets[ft_id].wordchars); | |
@@ -610,7 +610,7 @@ static void set_character_classes(ScintillaObject *sci, guint ft_id) | |
} | |
-static void styleset_common(ScintillaObject *sci, guint ft_id) | |
+static void styleset_common(ScintillaObject *sci, GeanyFiletypeID ft_id) | |
{ | |
GeanyLexerStyle *style; | |
@@ -804,7 +804,7 @@ static void styleset_common(ScintillaObject *sci, guint ft_id) | |
/* Merge & assign global typedefs and user secondary keywords. | |
* keyword_idx is used for both style_sets[].keywords and scintilla keyword style number */ | |
-static void merge_type_keywords(ScintillaObject *sci, guint ft_id, guint keyword_idx) | |
+static void merge_type_keywords(ScintillaObject *sci, GeanyFiletypeID ft_id, guint keyword_idx) | |
{ | |
const gchar *user_words = style_sets[ft_id].keywords[keyword_idx]; | |
GString *s; | |
@@ -822,7 +822,7 @@ static void merge_type_keywords(ScintillaObject *sci, guint ft_id, guint keyword | |
} | |
-static void styleset_init_from_mapping(guint ft_id, GKeyFile *config, GKeyFile *config_home, | |
+static void styleset_init_from_mapping(GeanyFiletypeID ft_id, GKeyFile *config, GKeyFile *config_home, | |
const HLStyle *styles, gsize n_styles, | |
const HLKeyword *keywords, gsize n_keywords) | |
{ | |
@@ -851,7 +851,7 @@ static void styleset_init_from_mapping(guint ft_id, GKeyFile *config, GKeyFile * | |
/* STYLE_DEFAULT will be set to match the first style. */ | |
-static void styleset_from_mapping(ScintillaObject *sci, guint ft_id, guint lexer, | |
+static void styleset_from_mapping(ScintillaObject *sci, GeanyFiletypeID ft_id, guint lexer, | |
const HLStyle *styles, gsize n_styles, | |
const HLKeyword *keywords, gsize n_keywords, | |
const HLProperty *properties, gsize n_properties) | |
@@ -893,7 +893,7 @@ static void styleset_from_mapping(ScintillaObject *sci, guint ft_id, guint lexer | |
-static void styleset_default(ScintillaObject *sci, guint ft_id) | |
+static void styleset_default(ScintillaObject *sci, GeanyFiletypeID ft_id) | |
{ | |
sci_set_lexer(sci, SCLEX_NULL); | |
@@ -964,7 +964,7 @@ static guint get_lexer_filetype(GeanyFiletype *ft) | |
break | |
/* Called by filetypes_load_config(). */ | |
-void highlighting_init_styles(guint filetype_idx, GKeyFile *config, GKeyFile *configh) | |
+void highlighting_init_styles(GeanyFiletypeID filetype_idx, GKeyFile *config, GKeyFile *configh) | |
{ | |
GeanyFiletype *ft = filetypes[filetype_idx]; | |
guint lexer_id = get_lexer_filetype(ft); | |
@@ -1165,17 +1165,17 @@ void highlighting_set_styles(ScintillaObject *sci, GeanyFiletype *ft) | |
* @return A pointer to the style struct. | |
* @see Scintilla messages @c SCI_STYLEGETFORE, etc, for use with scintilla_send_message(). */ | |
GEANY_API_SYMBOL | |
-const GeanyLexerStyle *highlighting_get_style(gint ft_id, gint style_id) | |
+const GeanyLexerStyle *highlighting_get_style(GeanyFiletypeID ft_id, gint style_id) | |
{ | |
g_return_val_if_fail(ft_id >= 0 && (guint) ft_id < filetypes_array->len, NULL); | |
g_return_val_if_fail(style_id >= 0, NULL); | |
/* ensure filetype loaded */ | |
- filetypes_load_config((guint) ft_id, FALSE); | |
+ filetypes_load_config(ft_id, FALSE); | |
/* TODO: style_id might not be the real array index (Scintilla styles are not always synced | |
* with array indices) */ | |
- return get_style((guint) ft_id, (guint) style_id); | |
+ return get_style(ft_id, (guint) style_id); | |
} | |
diff --git a/src/highlighting.h b/src/highlighting.h | |
index c119051..7ff8d11 100644 | |
--- a/src/highlighting.h | |
+++ b/src/highlighting.h | |
@@ -46,7 +46,7 @@ typedef struct GeanyLexerStyle | |
GeanyLexerStyle; | |
-const GeanyLexerStyle *highlighting_get_style(gint ft_id, gint style_id); | |
+const GeanyLexerStyle *highlighting_get_style(GeanyFiletypeID ft_id, gint style_id); | |
void highlighting_set_styles(ScintillaObject *sci, GeanyFiletype *ft); | |
@@ -57,7 +57,7 @@ gboolean highlighting_is_code_style(gint lexer, gint style); | |
#ifdef GEANY_PRIVATE | |
-void highlighting_init_styles(guint filetype_idx, GKeyFile *config, GKeyFile *configh); | |
+void highlighting_init_styles(GeanyFiletypeID filetype_idx, GKeyFile *config, GKeyFile *configh); | |
void highlighting_free_styles(void); | |
diff --git a/src/symbols.c b/src/symbols.c | |
index cca9e59..66ea3b3 100644 | |
--- a/src/symbols.c | |
+++ b/src/symbols.c | |
@@ -139,7 +139,7 @@ static struct | |
symbol_menu; | |
static void html_tags_loaded(void); | |
-static void load_user_tags(filetype_id ft_id); | |
+static void load_user_tags(GeanyFiletypeID ft_id); | |
/* get the tags_ignore list, exported by tagmanager's options.c */ | |
extern gchar **c_tags_ignore; | |
@@ -320,7 +320,7 @@ GString *symbols_find_typenames_as_string(TMParserType lang, gboolean global) | |
* @since 0.19 | |
*/ | |
GEANY_API_SYMBOL | |
-const gchar *symbols_get_context_separator(gint ft_id) | |
+const gchar *symbols_get_context_separator(GeanyFiletypeID ft_id) | |
{ | |
return tm_tag_context_separator(filetypes[ft_id]->lang); | |
} | |
@@ -524,7 +524,7 @@ tag_list_add_groups(GtkTreeStore *tree_store, ...) | |
static void add_top_level_items(GeanyDocument *doc) | |
{ | |
- filetype_id ft_id = doc->file_type->id; | |
+ GeanyFiletypeID ft_id = doc->file_type->id; | |
GtkTreeStore *tag_store = doc->priv->tag_store; | |
if (top_level_iter_names == NULL) | |
@@ -998,7 +998,7 @@ static gchar *get_symbol_tooltip(GeanyDocument *doc, const TMTag *tag) | |
/* find the last word in "foo::bar::blah", e.g. "blah" */ | |
-static const gchar *get_parent_name(const TMTag *tag, filetype_id ft_id) | |
+static const gchar *get_parent_name(const TMTag *tag, GeanyFiletypeID ft_id) | |
{ | |
const gchar *scope = tag->scope; | |
const gchar *separator = symbols_get_context_separator(ft_id); | |
@@ -1798,7 +1798,7 @@ static void init_user_tags(void) | |
} | |
-static void load_user_tags(filetype_id ft_id) | |
+static void load_user_tags(GeanyFiletypeID ft_id) | |
{ | |
static guchar *tags_loaded = NULL; | |
static gboolean init_tags = FALSE; | |
diff --git a/src/symbols.h b/src/symbols.h | |
index 8a325aa..078475c 100644 | |
--- a/src/symbols.h | |
+++ b/src/symbols.h | |
@@ -29,7 +29,7 @@ | |
G_BEGIN_DECLS | |
-const gchar *symbols_get_context_separator(gint ft_id); | |
+const gchar *symbols_get_context_separator(GeanyFiletypeID ft_id); | |
#ifdef GEANY_PRIVATE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment