SF.net SVN: geany: [1433] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Sat Mar 31 11:39:57 UTC 2007
Revision: 1433
http://svn.sourceforge.net/geany/?rev=1433&view=rev
Author: ntrel
Date: 2007-03-31 04:39:56 -0700 (Sat, 31 Mar 2007)
Log Message:
-----------
Make file header optional for filetype templates - use the string
'{fileheader}' to mark where the file header should be placed, which
can be anywhere in the filetype template.
Modified Paths:
--------------
trunk/ChangeLog
trunk/doc/geany.docbook
trunk/src/templates.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-03-30 16:34:51 UTC (rev 1432)
+++ trunk/ChangeLog 2007-03-31 11:39:56 UTC (rev 1433)
@@ -1,3 +1,11 @@
+2007-03-31 Nick Treleaven <nick.treleaven at btinternet.com>
+
+ * src/templates.c, doc/geany.docbook:
+ Make file header optional for filetype templates - use the string
+ '{fileheader}' to mark where the file header should be placed, which
+ can be anywhere in the filetype template.
+
+
2007-03-30 Nick Treleaven <nick.treleaven at btinternet.com>
* geany.desktop.in:
Modified: trunk/doc/geany.docbook
===================================================================
--- trunk/doc/geany.docbook 2007-03-30 16:34:51 UTC (rev 1432)
+++ trunk/doc/geany.docbook 2007-03-31 11:39:56 UTC (rev 1433)
@@ -2005,17 +2005,29 @@
description.
</para>
<section>
+ <title>Template metadata</title>
+ <para>
+ Metadata can be used with all templates, but by default user set metadata is only
+ used for the ChangeLog and File header templates.
+ </para>
+ <para>
+ In the configuration dialog you can find a tab "Templates"
+ (see <xref linkend="confdialog_templ"/>). You can define the default values which
+ will be inserted in the templates. You should restart <application>Geany</application>
+ after making changes, because they are only read at startup.
+ </para>
+ </section>
+ <section>
<title>Filetype templates</title>
<para>
Filetype templates are templates used as the basis of a new file. To use them, choose
the <literal>New (with Template)</literal> menu item from the
- <literal>File</literal> menu. At creation of a new file with a filetype template, the
- fileheader template is automatically prepended.
+ <literal>File</literal> menu.
</para>
<para>
- By default, templates are created for certain filetypes. Other filetype templates can be
+ By default, templates are created for some filetypes. Other filetype templates can be
added by creating the appropriate template file and restarting
- <application>Geany</application>.
+ <application>Geany</application>. You can also edit the default filetype templates.
</para>
<para>
Filetype template files are read from the <filename>~/.geany/templates</filename>
@@ -2027,25 +2039,17 @@
'<filename>filetypes.</filename>'.
</para>
<para>
+ The file's contents are just the text to place in the document, except for the
+ optional <literal>{fileheader}</literal> template wildcard. This can be placed anywhere,
+ but is usually on the first line of the file, followed by a blank line.
+ </para>
+ <para>
There is also a template file <filename>template.none</filename> which is used when
the <literal>New</literal> command is used without a filetype. This is empty by
default.
</para>
</section>
<section>
- <title>Template metadata</title>
- <para>
- Metadata can be used with all templates, but by default user set metadata is only
- used for the ChangeLog and File header templates.
- </para>
- <para>
- In the configuration dialog you can find a tab "Templates"
- (see <xref linkend="confdialog_templ"/>). You can define the default values which
- will be inserted in the templates. You should restart <application>Geany</application>
- after making changes, because they are only read at startup.
- </para>
- </section>
- <section>
<title>Customizing templates</title>
<para>
Each template can be customized to your needs. The templates are stored in the
@@ -2162,6 +2166,13 @@
description template.</entry>
<entry>function description</entry>
</row>
+ <row>
+ <entry>fileheader</entry>
+ <entry>The file header template.
+ This wildcard will only be replaced in filetype
+ templates.</entry>
+ <entry>filetypes</entry>
+ </row>
</tbody>
</tgroup>
</table>
Modified: trunk/src/templates.c
===================================================================
--- trunk/src/templates.c 2007-03-30 16:34:51 UTC (rev 1432)
+++ trunk/src/templates.c 2007-03-31 11:39:56 UTC (rev 1433)
@@ -51,7 +51,8 @@
\n\
You should have received a copy of the GNU General Public License\n\
along with this program; if not, write to the Free Software\n\
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n\
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,\n\
+MA 02110-1301, USA.\n\
";
static const gchar templates_bsd_notice[] = "\
@@ -109,7 +110,7 @@
static const gchar templates_filetype_none[] = "";
-static const gchar templates_filetype_c[] = "\n\
+static const gchar templates_filetype_c[] = "{fileheader}\n\n\
#include <stdio.h>\n\
\n\
int main(int argc, char** argv)\n\
@@ -119,7 +120,7 @@
}\n\
";
-static const gchar templates_filetype_cpp[] = "\n\
+static const gchar templates_filetype_cpp[] = "{fileheader}\n\n\
#include <iostream>\n\
\n\
int main(int argc, char** argv)\n\
@@ -129,7 +130,7 @@
}\n\
";
-static const gchar templates_filetype_d[] = "\n\
+static const gchar templates_filetype_d[] = "{fileheader}\n\n\
import std.stdio;\n\
\n\
int main(char[][] args)\n\
@@ -139,7 +140,8 @@
}\n\
";
-static const gchar templates_filetype_php[] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\
+static const gchar templates_filetype_php[] = "{fileheader}\n\
+<!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\
\n\
@@ -155,7 +157,8 @@
</html>\n\
";
-static const gchar templates_filetype_html[] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\
+static const gchar templates_filetype_html[] = "{fileheader}\n\
+<!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\
\n\
@@ -171,7 +174,7 @@
</html>\n\
";
-static const gchar templates_filetype_pascal[] = "\n\
+static const gchar templates_filetype_pascal[] = "{fileheader}\n\n\
program {untitled};\n\
\n\
uses crt;\n\
@@ -183,7 +186,7 @@
END.\n\
";
-static const gchar templates_filetype_java[] = "\n\
+static const gchar templates_filetype_java[] = "{fileheader}\n\n\
public class {untitled} {\n\
\n\
public static void main (String args[]) {\
@@ -193,8 +196,7 @@
}\n\
";
-static const gchar templates_filetype_ruby[] = "\n\
-\n\
+static const gchar templates_filetype_ruby[] = "{fileheader}\n\n\
class StdClass\n\
def initialize\n\
\n\
@@ -560,7 +562,6 @@
gchar *templates_get_template_new_file(filetype *ft)
{
- gchar *template = NULL;
gchar *ft_template = NULL;
gchar *file_header = NULL;
@@ -569,10 +570,9 @@
file_header = get_file_header(ft, NULL); // file template only used for new files
ft_template = get_file_template(ft);
- template = g_strconcat(file_header, "\n", ft_template, NULL);
- g_free(ft_template);
+ ft_template = utils_str_replace(ft_template, "{fileheader}", file_header);
g_free(file_header);
- return template;
+ return ft_template;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list