Revision: 2805 http://geany.svn.sourceforge.net/geany/?rev=2805&view=rev Author: ntrel Date: 2008-07-23 14:44:27 +0000 (Wed, 23 Jul 2008)
Log Message: ----------- Add dox for FiletypeFuncs and some of GeanyFiletype. Rename filetypes_detect_from_file() to filetypes_detect_from_document(). Rename filetypes_detect_from_filename() to filetypes_detect_from_file() because it also detects shebang lines. Remove function prototype comments for filetypes.h (see filetypes.c or API dox instead).
Modified Paths: -------------- trunk/ChangeLog trunk/src/document.c trunk/src/filetypes.c trunk/src/filetypes.h trunk/src/plugindata.h trunk/src/plugins.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2008-07-23 13:48:13 UTC (rev 2804) +++ trunk/ChangeLog 2008-07-23 14:44:27 UTC (rev 2805) @@ -5,6 +5,15 @@ Move utils_reload_configuration() to main.c. * src/main.c: Add doxygen file header for generating MainFuncs API documentation. + * src/plugindata.h, src/filetypes.c, src/filetypes.h, src/document.c, + src/plugins.c: + Add dox for FiletypeFuncs and some of GeanyFiletype. + Rename filetypes_detect_from_file() to + filetypes_detect_from_document(). + Rename filetypes_detect_from_filename() to + filetypes_detect_from_file() because it also detects shebang lines. + Remove function prototype comments for filetypes.h (see filetypes.c + or API dox instead).
2008-07-22 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/src/document.c =================================================================== --- trunk/src/document.c 2008-07-23 13:48:13 UTC (rev 2804) +++ trunk/src/document.c 2008-07-23 14:44:27 UTC (rev 2805) @@ -572,7 +572,7 @@
/*document_set_filetype(idx, (ft == NULL) ? filetypes[GEANY_FILETYPES_NONE] : ft);*/ if (ft == NULL && filename != NULL) /* guess the filetype from the filename if one is given */ - ft = filetypes_detect_from_file(doc); + ft = filetypes_detect_from_document(doc);
document_set_filetype(doc, ft); /* also clears taglist */ if (ft == NULL) @@ -1037,7 +1037,7 @@ /* "the" SCI signal (connect after initial setup(i.e. adding text)) */ g_signal_connect(doc->editor->sci, "sci-notify", G_CALLBACK(on_editor_notification), doc);
- use_ft = (ft != NULL) ? ft : filetypes_detect_from_file(doc); + use_ft = (ft != NULL) ? ft : filetypes_detect_from_document(doc); } else { /* reloading */ @@ -1260,7 +1260,7 @@ /* detect filetype */ if (FILETYPE_ID(doc->file_type) == GEANY_FILETYPES_NONE) { - GeanyFiletype *ft = filetypes_detect_from_file(doc); + GeanyFiletype *ft = filetypes_detect_from_document(doc);
document_set_filetype(doc, ft); if (document_get_current() == doc)
Modified: trunk/src/filetypes.c =================================================================== --- trunk/src/filetypes.c 2008-07-23 13:48:13 UTC (rev 2804) +++ trunk/src/filetypes.c 2008-07-23 14:44:27 UTC (rev 2805) @@ -21,7 +21,8 @@ * $Id$ */
-/* +/** + * @file filetypes.h * Filetype detection, file extensions and filetype menu items. */
@@ -666,8 +667,8 @@ }
-/* Detect the filetype for document idx. */ -GeanyFiletype *filetypes_detect_from_file(GeanyDocument *doc) +/* Detect the filetype for the document, checking for a shebang, then filename extension. */ +GeanyFiletype *filetypes_detect_from_document(GeanyDocument *doc) { GeanyFiletype *ft; gchar *line; @@ -682,9 +683,9 @@ }
-/* Detect filetype based on the filename extension. - * utf8_filename can include the full path. */ -GeanyFiletype *filetypes_detect_from_filename(const gchar *utf8_filename) +/** Detect filetype based on a shebang line in the file, or the filename extension. */ +/* Currently only used by external plugins. */ +GeanyFiletype *filetypes_detect_from_file(const gchar *utf8_filename) { gchar line[1024]; FILE *f;
Modified: trunk/src/filetypes.h =================================================================== --- trunk/src/filetypes.h 2008-07-23 13:48:13 UTC (rev 2804) +++ trunk/src/filetypes.h 2008-07-23 14:44:27 UTC (rev 2805) @@ -29,7 +29,9 @@ #include "ScintillaWidget.h"
-/* each group should be alpha-sorted, based on filetype::name (not enum name) */ +/* Each group should be alpha-sorted, based on filetype::name (not enum name). + * Warning: remember to break the plugin ABI when adding items (this enum needs to be changed + * to work with an ABI-stable filetype::group_name field. */ typedef enum { /* normally compiled languages */ @@ -103,15 +105,17 @@ gboolean modified; };
+/** Represents a filetype. */ struct GeanyFiletype { - filetype_id id; - langType lang; /* represents the langType of tagmanager(see the table */ - /* in tagmanager/parsers.h), -1 represents all, -2 none */ - gchar *name; /* will be used as name for tagmanager */ - gchar *title; /* will be shown in the file open dialog */ - gchar *extension; - gchar **pattern; + filetype_id id; /**< Index in @c filetypes_array. */ + /** Represents the langType of tagmanager (see the table + * in tagmanager/parsers.h), -1 represents all, -2 none. */ + langType lang; + gchar *name; /**< Used as name for tagmanager. E.g. "C". */ + gchar *title; /**< Shown in the file open dialog. E.g. "C source file". */ + gchar *extension; /**< Default file extension for new files. */ + gchar **pattern; /**< Array of filename-matching wildcard strings. */ gchar *context_action_cmd; gchar *comment_open; gchar *comment_close; @@ -130,22 +134,16 @@ GeanyFiletype *filetypes_lookup_by_name(const gchar *name);
-/* Calls filetypes_init_types() and creates the filetype menu. */ void filetypes_init(void);
-/* Create the filetype array and fill it with the known filetypes. */ void filetypes_init_types(void);
-/* Detect the filetype for document idx, checking for a shebang, then filename extension. */ -GeanyFiletype *filetypes_detect_from_file(GeanyDocument *doc); +GeanyFiletype *filetypes_detect_from_document(GeanyDocument *doc);
GeanyFiletype *filetypes_detect_from_extension(const gchar *utf8_filename);
-/* Detect filetype based on the filename extension. - * utf8_filename can include the full path. */ -GeanyFiletype *filetypes_detect_from_filename(const gchar *utf8_filename); +GeanyFiletype *filetypes_detect_from_file(const gchar *utf8_filename);
-/* frees the array and all related pointers */ void filetypes_free_types(void);
void filetypes_load_config(gint ft_id, gboolean reload);
Modified: trunk/src/plugindata.h =================================================================== --- trunk/src/plugindata.h 2008-07-23 13:48:13 UTC (rev 2804) +++ trunk/src/plugindata.h 2008-07-23 14:44:27 UTC (rev 2805) @@ -36,7 +36,7 @@
/* The API version should be incremented whenever any plugin data types below are * modified or appended to. */ -static const gint api_version = 80; +static const gint api_version = 81;
/* The ABI version should be incremented whenever existing fields in the plugin * data types below have to be changed or reordered. It should stay the same if fields
Modified: trunk/src/plugins.c =================================================================== --- trunk/src/plugins.c 2008-07-23 13:48:13 UTC (rev 2804) +++ trunk/src/plugins.c 2008-07-23 14:44:27 UTC (rev 2805) @@ -231,7 +231,7 @@
static FiletypeFuncs filetype_funcs = { - &filetypes_detect_from_filename, + &filetypes_detect_from_file, &filetypes_lookup_by_name };
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.