Kaydet (Commit) 7bb57aca authored tarafından Nick Treleaven's avatar Nick Treleaven

Move filetype template defaults into custom file template files.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4273 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 2e7033af
......@@ -5,6 +5,14 @@
* src/templates.c, doc/geany.txt, doc/geany.html:
Read custom file templates from $prefix/share/geany/templates/files as
well as user dir.
* src/templates.c, data/templates, data/templates/files,
data/templates/files/file.rb, data/templates/files/file.html,
data/templates/files/main.java, data/templates/files/main.c,
data/templates/files/main.cxx, data/templates/files/file.php,
data/templates/files/main.d, data/templates/files/program.pas,
data/templates/files/main.py, data/templates/files/file.tex,
wscript, Makefile.am:
Move filetype template defaults into custom file template files.
2009-09-29 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
......
......@@ -22,7 +22,8 @@ SYS_DATA_FILES = \
$(srcdir)/data/filetypes.* \
data/filetype_extensions.conf \
data/snippets.conf \
data/ui_toolbar.xml
data/ui_toolbar.xml \
$(srcdir)/data/templates/files/*
EXTRA_DIST = \
autogen.sh \
......@@ -68,6 +69,13 @@ install-data-local:
$(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir)/; \
fi \
done
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/templates;
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/templates/files;
for file in $(srcdir)/data/templates/files/*; do \
if test -f $$file; then \
$(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir)/templates/files/; \
fi \
done
BZIP2_ENV =--best
......
{fileheader}
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
<head>
<title>{untitled}</title>
<meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\" />
<meta name=\"generator\" content=\"{geanyversion}\" />
</head>
<body>
</body>
</html>
<?php
{fileheader}
?>
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
<head>
<title>{untitled}</title>
<meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\" />
<meta name=\"generator\" content=\"{geanyversion}\" />
</head>
<body>
</body>
</html>
{fileheader}
class StdClass
def initialize
end
end
x = StdClass.new
\\documentclass[a4paper]{article}
\\usepackage[T1]{fontenc}
\\usepackage[utf8]{inputenc}
\\usepackage{lmodern}
\\usepackage{babel}
\\begin{document}
\\end{document}
{fileheader}
#include <stdio.h>
int main(int argc, char **argv)
{
return 0;
}
{fileheader}
#include <iostream>
int main(int argc, char **argv)
{
return 0;
}
{fileheader}
import std.stdio;
int main(char[][] args)
{
return 0;
}
{fileheader}
public class {untitled} {
public static void main (String args[]) {
}
}
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
{fileheader}
def main():
return 0
if __name__ == '__main__':
main()
{fileheader}
program {untitled};
uses crt;
var i : byte;
BEGIN
END.
......@@ -47,6 +47,8 @@ static GtkWidget *new_with_template_menu = NULL; /* File menu submenu */
static GtkWidget *toolbar_new_file_menu = NULL;
/* TODO: implement custom insertion templates, put these into files in data/templates */
/* default templates, only for initial tempate file creation on first start of Geany */
static const gchar templates_gpl_notice[] = "\
This program is free software; you can redistribute it and/or modify\n\
......@@ -118,133 +120,13 @@ static const gchar templates_changelog[] = "\
\n\
* \n\n\n";
/* Used when starting a new file normally */
static const gchar templates_filetype_none[] = "";
static const gchar templates_filetype_c[] = "{fileheader}\n\n\
#include <stdio.h>\n\
\n\
int main(int argc, char** argv)\n\
{\n\
\n\
return 0;\n\
}\n\
";
static const gchar templates_filetype_cpp[] = "{fileheader}\n\n\
#include <iostream>\n\
\n\
int main(int argc, char** argv)\n\
{\n\
\n\
return 0;\n\
}\n\
";
static const gchar templates_filetype_d[] = "{fileheader}\n\n\
import std.stdio;\n\
\n\
int main(char[][] args)\n\
{\n\
\n\
return 0;\n\
}\n\
";
static const gchar templates_filetype_php[] = "\
<?php\n\
{fileheader}\
?>\n\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\
<head>\n\
<title>{untitled}</title>\n\
<meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\" />\n\
<meta name=\"generator\" content=\"{geanyversion}\" />\n\
</head>\n\
\n\
<body>\n\
\n\
</body>\n\
</html>\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\
<head>\n\
<title>{untitled}</title>\n\
<meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\" />\n\
<meta name=\"generator\" content=\"{geanyversion}\" />\n\
</head>\n\
\n\
<body>\n\
\n\
</body>\n\
</html>\n\
";
static const gchar templates_filetype_pascal[] = "{fileheader}\n\n\
program {untitled};\n\
\n\
uses crt;\n\
var i : byte;\n\
\n\
BEGIN\n\
\n\
\n\
END.\n\
";
static const gchar templates_filetype_java[] = "{fileheader}\n\n\
public class {untitled} {\n\
\n\
public static void main (String args[]) {\
\n\
\n\
}\n\
}\n\
";
static const gchar templates_filetype_ruby[] = "{fileheader}\n\n\
class StdClass\n\
def initialize\n\
\n\
end\n\
end\n\
\n\
x = StdClass.new\n\
";
static const gchar templates_filetype_python[] = "#!/usr/bin/env python\n\
# -*- coding: utf-8 -*-\n#\n\
{fileheader}\n\n\
\n\
def main():\n\
\n\
return 0\n\
\n\
if __name__ == '__main__':\n\
main()\n\
";
static const gchar templates_filetype_latex[] = "\
\\documentclass[a4paper]{article}\n\
\\usepackage[T1]{fontenc}\n\
\\usepackage[utf8]{inputenc}\n\
\\usepackage{lmodern}\n\
\\usepackage{babel}\n\
\\begin{document}\n\
\n\
\\end{document}\n\
";
static gchar *templates[GEANY_MAX_TEMPLATES];
/* TODO: remove filetype templates, use custom file templates instead. */
/* We should probably remove filetype templates support soon - users can use custom
* file templates instead. */
static gchar *ft_templates[GEANY_MAX_BUILT_IN_FILETYPES] = {NULL};
......@@ -335,6 +217,7 @@ static void init_general_templates(const gchar *year, const gchar *date, const g
}
/* Users should use custom filetypes instead, except for filetype none template */
static void init_ft_templates(const gchar *year, const gchar *date, const gchar *datetime)
{
filetype_id ft_id;
......@@ -350,37 +233,8 @@ static void init_ft_templates(const gchar *year, const gchar *date, const gchar
case GEANY_FILETYPES_NONE:
create_template_file_if_necessary(fname, templates_filetype_none);
break;
case GEANY_FILETYPES_C:
create_template_file_if_necessary(fname, templates_filetype_c);
break;
case GEANY_FILETYPES_CPP:
create_template_file_if_necessary(fname, templates_filetype_cpp);
break;
case GEANY_FILETYPES_D:
create_template_file_if_necessary(fname, templates_filetype_d);
break;
case GEANY_FILETYPES_JAVA:
create_template_file_if_necessary(fname, templates_filetype_java);
break;
case GEANY_FILETYPES_PASCAL:
create_template_file_if_necessary(fname, templates_filetype_pascal);
break;
case GEANY_FILETYPES_PHP:
create_template_file_if_necessary(fname, templates_filetype_php);
break;
case GEANY_FILETYPES_HTML:
create_template_file_if_necessary(fname, templates_filetype_html);
break;
case GEANY_FILETYPES_RUBY:
create_template_file_if_necessary(fname, templates_filetype_ruby);
break;
case GEANY_FILETYPES_PYTHON:
create_template_file_if_necessary(fname, templates_filetype_python);
break;
case GEANY_FILETYPES_LATEX:
create_template_file_if_necessary(fname, templates_filetype_latex);
default:
break;
default: break;
}
TEMPLATES_READ_FILE(fname, &ft_templates[ft_id]);
ft_templates[ft_id] = replace_all(ft_templates[ft_id], year, date, datetime);
......
......@@ -503,6 +503,7 @@ def build(bld):
bld.install_files('${DATADIR}/%s' % dir, 'data/*.tags')
bld.install_files('${DATADIR}/%s' % dir, 'data/snippets.conf')
bld.install_files('${DATADIR}/%s' % dir, 'data/ui_toolbar.xml')
bld.install_files('${DATADIR}/%s/templates/files' % dir, 'data/templates/files/*.*')
bld.install_as('${DATADIR}/%s/GPL-2' % dir, 'COPYING')
# Icons
bld.install_files('${PREFIX}/share/icons'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment