Revision: 4339 http://geany.svn.sourceforge.net/geany/?rev=4339&view=rev Author: ntrel Date: 2009-10-19 14:24:40 +0000 (Mon, 19 Oct 2009)
Log Message: ----------- Add filetype "tag_parser" key so custom filetypes can use an existing tag parser. Add tm_source_file_get_named_lang().
Modified Paths: -------------- trunk/ChangeLog trunk/doc/geany.html trunk/doc/geany.txt trunk/src/document.c trunk/src/filetypes.c trunk/src/filetypes.h trunk/tagmanager/include/tm_source_file.h trunk/tagmanager/tm_source_file.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-10-19 12:15:42 UTC (rev 4338) +++ trunk/ChangeLog 2009-10-19 14:24:40 UTC (rev 4339) @@ -2,6 +2,12 @@
* doc/geany.txt, doc/geany.html: Add 'Custom filetypes' section. + * src/filetypes.c, src/filetypes.h, src/document.c, + doc/geany.txt, doc/geany.html, tagmanager/tm_source_file.c, + tagmanager/include/tm_source_file.h: + Add filetype "tag_parser" key so custom filetypes can use an existing + tag parser. + Add tm_source_file_get_named_lang().
2009-10-19 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
Modified: trunk/doc/geany.html =================================================================== --- trunk/doc/geany.html 2009-10-19 12:15:42 UTC (rev 4338) +++ trunk/doc/geany.html 2009-10-19 14:24:40 UTC (rev 4339) @@ -6,7 +6,7 @@ <meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" /> <title>Geany</title> <meta name="authors" content="Enrico Tröger Nick Treleaven Frank Lanitz" /> -<meta name="date" content="2009-10-15" /> +<meta name="date" content="2009-10-19" /> <style type="text/css">
/* @@ -139,7 +139,7 @@ <br />Nick Treleaven <br />Frank Lanitz</td></tr> <tr><th class="docinfo-name">Date:</th> -<td>2009-10-15</td></tr> +<td>2009-10-19</td></tr> <tr><th class="docinfo-name">Version:</th> <td>0.19</td></tr> </tbody> @@ -3972,6 +3972,7 @@ <tt class="docutils literal"><span class="pre">filetype_extensions.conf</span></tt>).</li> <li>Filetype settings in the [settings] section (see <a class="reference" href="#format">Format</a>).</li> <li>Build commands.</li> +<li>Tag parsing (<tt class="docutils literal"><span class="pre">tag_parser</span></tt> key).</li> </ul> </div> <div class="section"> @@ -4116,6 +4117,8 @@ context_action_cmd=firefox "<a class="reference" href="http://www.php.net/%s">http://www.php.net/%s</a>"</p> <p class="last"><em>Example:</em> <tt class="docutils literal"><span class="pre">context_action_cmd=devhelp</span> <span class="pre">-s</span> <span class="pre">"%s"</span></tt></p> </dd> +<dt>tag_parser</dt> +<dd>The TagManager language name, e.g. "C".</dd> </dl> </div> <div class="section"> @@ -5750,7 +5753,7 @@ <div class="footer"> <hr class="footer" /> <a class="reference" href="geany.txt">View document source</a>. -Generated on: 2009-10-19 12:10 UTC. +Generated on: 2009-10-19 14:14 UTC. Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div>
Modified: trunk/doc/geany.txt =================================================================== --- trunk/doc/geany.txt 2009-10-19 12:15:42 UTC (rev 4338) +++ trunk/doc/geany.txt 2009-10-19 14:24:40 UTC (rev 4339) @@ -3335,6 +3335,7 @@ ``filetype_extensions.conf``). * Filetype settings in the [settings] section (see `Format`_). * Build commands. +* Tag parsing (``tag_parser`` key).
System files ^^^^^^^^^^^^ @@ -3502,7 +3503,10 @@
*Example:* ``context_action_cmd=devhelp -s "%s"``
+tag_parser + The TagManager language name, e.g. "C".
+ [build_settings] Section ````````````````````````
Modified: trunk/src/document.c =================================================================== --- trunk/src/document.c 2009-10-19 12:15:42 UTC (rev 4338) +++ trunk/src/document.c 2009-10-19 14:24:40 UTC (rev 4339) @@ -2321,8 +2321,11 @@ if (doc->tm_file == NULL) { gchar *locale_filename = utils_get_locale_from_utf8(doc->file_name); + const gchar *name;
- doc->tm_file = tm_source_file_new(locale_filename, FALSE, doc->file_type->name); + /* lookup the name rather than using filetype name to support custom filetypes */ + name = tm_source_file_get_lang_name(doc->file_type->lang); + doc->tm_file = tm_source_file_new(locale_filename, FALSE, name); g_free(locale_filename);
if (doc->tm_file)
Modified: trunk/src/filetypes.c =================================================================== --- trunk/src/filetypes.c 2009-10-19 12:15:42 UTC (rev 4338) +++ trunk/src/filetypes.c 2009-10-19 14:24:40 UTC (rev 4339) @@ -1235,10 +1235,18 @@ filetypes[ft_id]->context_action_cmd = result; }
+ result = utils_get_setting_string(configh, "settings", "tag_parser", NULL); + if (!result) + result = utils_get_setting_string(config, "settings", "tag_parser", NULL); + if (result) + { + ft->lang = tm_source_file_get_named_lang(result); + g_free(result); + } + /* read build settings */ build_load_menu(config, GEANY_BCS_FT, (gpointer)ft); build_load_menu(configh, GEANY_BCS_HOME_FT, (gpointer)ft); - }
Modified: trunk/src/filetypes.h =================================================================== --- trunk/src/filetypes.h 2009-10-19 12:15:42 UTC (rev 4338) +++ trunk/src/filetypes.h 2009-10-19 14:24:40 UTC (rev 4339) @@ -109,7 +109,7 @@ /** 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 *name; /**< Short name, e.g. "C". */ gchar *title; /**< Shown in the file open dialog. E.g. "C source file". */ gchar *extension; /**< Default file extension for new files, or @c NULL. */ gchar **pattern; /**< Array of filename-matching wildcard strings. */
Modified: trunk/tagmanager/include/tm_source_file.h =================================================================== --- trunk/tagmanager/include/tm_source_file.h 2009-10-19 12:15:42 UTC (rev 4338) +++ trunk/tagmanager/include/tm_source_file.h 2009-10-19 14:24:40 UTC (rev 4339) @@ -144,6 +144,12 @@ */ const gchar *tm_source_file_get_lang_name(gint lang);
+/* Gets the language index for \a name. + \param name The language name. + \return The language index, or -2. +*/ +gint tm_source_file_get_named_lang(const gchar *name); + #ifdef __cplusplus } #endif
Modified: trunk/tagmanager/tm_source_file.c =================================================================== --- trunk/tagmanager/tm_source_file.c 2009-10-19 12:15:42 UTC (rev 4338) +++ trunk/tagmanager/tm_source_file.c 2009-10-19 14:24:40 UTC (rev 4339) @@ -323,3 +323,15 @@ return getLanguageName(lang); }
+gint tm_source_file_get_named_lang(const gchar *name) +{ + if (NULL == LanguageTable) + { + initializeParsing(); + installLanguageMapDefaults(); + if (NULL == TagEntryFunction) + TagEntryFunction = tm_source_file_tags; + } + return getNamedLanguage(name); +} +
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.