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
This commit is contained in:
parent
2e7033afd2
commit
7bb57aca2b
@ -5,6 +5,14 @@
|
|||||||
* src/templates.c, doc/geany.txt, doc/geany.html:
|
* src/templates.c, doc/geany.txt, doc/geany.html:
|
||||||
Read custom file templates from $prefix/share/geany/templates/files as
|
Read custom file templates from $prefix/share/geany/templates/files as
|
||||||
well as user dir.
|
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>
|
2009-09-29 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
||||||
|
|||||||
10
Makefile.am
10
Makefile.am
@ -22,7 +22,8 @@ SYS_DATA_FILES = \
|
|||||||
$(srcdir)/data/filetypes.* \
|
$(srcdir)/data/filetypes.* \
|
||||||
data/filetype_extensions.conf \
|
data/filetype_extensions.conf \
|
||||||
data/snippets.conf \
|
data/snippets.conf \
|
||||||
data/ui_toolbar.xml
|
data/ui_toolbar.xml \
|
||||||
|
$(srcdir)/data/templates/files/*
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
autogen.sh \
|
autogen.sh \
|
||||||
@ -68,6 +69,13 @@ install-data-local:
|
|||||||
$(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir)/; \
|
$(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir)/; \
|
||||||
fi \
|
fi \
|
||||||
done
|
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
|
BZIP2_ENV =--best
|
||||||
|
|||||||
16
data/templates/files/file.html
Normal file
16
data/templates/files/file.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{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>
|
||||||
|
|
||||||
20
data/templates/files/file.php
Normal file
20
data/templates/files/file.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
<?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>
|
||||||
|
|
||||||
10
data/templates/files/file.rb
Normal file
10
data/templates/files/file.rb
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{fileheader}
|
||||||
|
|
||||||
|
class StdClass
|
||||||
|
def initialize
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
x = StdClass.new
|
||||||
|
|
||||||
10
data/templates/files/file.tex
Normal file
10
data/templates/files/file.tex
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
\\documentclass[a4paper]{article}
|
||||||
|
\\usepackage[T1]{fontenc}
|
||||||
|
\\usepackage[utf8]{inputenc}
|
||||||
|
\\usepackage{lmodern}
|
||||||
|
\\usepackage{babel}
|
||||||
|
\\begin{document}
|
||||||
|
|
||||||
|
\\end{document}
|
||||||
|
|
||||||
10
data/templates/files/main.c
Normal file
10
data/templates/files/main.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{fileheader}
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
10
data/templates/files/main.cxx
Normal file
10
data/templates/files/main.cxx
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{fileheader}
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
10
data/templates/files/main.d
Normal file
10
data/templates/files/main.d
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{fileheader}
|
||||||
|
|
||||||
|
import std.stdio;
|
||||||
|
|
||||||
|
int main(char[][] args)
|
||||||
|
{
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
10
data/templates/files/main.java
Normal file
10
data/templates/files/main.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{fileheader}
|
||||||
|
|
||||||
|
public class {untitled} {
|
||||||
|
|
||||||
|
public static void main (String args[]) {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
13
data/templates/files/main.py
Normal file
13
data/templates/files/main.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
{fileheader}
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
||||||
12
data/templates/files/program.pas
Normal file
12
data/templates/files/program.pas
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{fileheader}
|
||||||
|
|
||||||
|
program {untitled};
|
||||||
|
|
||||||
|
uses crt;
|
||||||
|
var i : byte;
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
|
||||||
|
|
||||||
|
END.
|
||||||
|
|
||||||
160
src/templates.c
160
src/templates.c
@ -47,6 +47,8 @@ static GtkWidget *new_with_template_menu = NULL; /* File menu submenu */
|
|||||||
static GtkWidget *toolbar_new_file_menu = NULL;
|
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 */
|
/* default templates, only for initial tempate file creation on first start of Geany */
|
||||||
static const gchar templates_gpl_notice[] = "\
|
static const gchar templates_gpl_notice[] = "\
|
||||||
This program is free software; you can redistribute it and/or modify\n\
|
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\n";
|
* \n\n\n";
|
||||||
|
|
||||||
|
/* Used when starting a new file normally */
|
||||||
static const gchar templates_filetype_none[] = "";
|
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];
|
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};
|
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)
|
static void init_ft_templates(const gchar *year, const gchar *date, const gchar *datetime)
|
||||||
{
|
{
|
||||||
filetype_id ft_id;
|
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:
|
case GEANY_FILETYPES_NONE:
|
||||||
create_template_file_if_necessary(fname, templates_filetype_none);
|
create_template_file_if_necessary(fname, templates_filetype_none);
|
||||||
break;
|
break;
|
||||||
case GEANY_FILETYPES_C:
|
default:
|
||||||
create_template_file_if_necessary(fname, templates_filetype_c);
|
|
||||||
break;
|
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);
|
|
||||||
break;
|
|
||||||
default: break;
|
|
||||||
}
|
}
|
||||||
TEMPLATES_READ_FILE(fname, &ft_templates[ft_id]);
|
TEMPLATES_READ_FILE(fname, &ft_templates[ft_id]);
|
||||||
ft_templates[ft_id] = replace_all(ft_templates[ft_id], year, date, datetime);
|
ft_templates[ft_id] = replace_all(ft_templates[ft_id], year, date, datetime);
|
||||||
|
|||||||
1
wscript
1
wscript
@ -503,6 +503,7 @@ def build(bld):
|
|||||||
bld.install_files('${DATADIR}/%s' % dir, 'data/*.tags')
|
bld.install_files('${DATADIR}/%s' % dir, 'data/*.tags')
|
||||||
bld.install_files('${DATADIR}/%s' % dir, 'data/snippets.conf')
|
bld.install_files('${DATADIR}/%s' % dir, 'data/snippets.conf')
|
||||||
bld.install_files('${DATADIR}/%s' % dir, 'data/ui_toolbar.xml')
|
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')
|
bld.install_as('${DATADIR}/%s/GPL-2' % dir, 'COPYING')
|
||||||
# Icons
|
# Icons
|
||||||
bld.install_files('${PREFIX}/share/icons'
|
bld.install_files('${PREFIX}/share/icons'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user