added template support for filetypes with comment character #, updated GPL to the current address of the FSF

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@318 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2006-05-10 19:54:44 +00:00
parent 10dfa4f7ab
commit 2be53d0f07
5 changed files with 236 additions and 58 deletions

View File

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* *
* $Id$ * $Id$
*/ */
@ -2284,7 +2284,7 @@ on_comments_function_activate (GtkMenuItem *menuitem,
{ {
line = utils_get_current_tag(idx, &cur_tag); line = utils_get_current_tag(idx, &cur_tag);
// utils_get_current_tag returns -1 on failure, so sci_get_position_from_line // utils_get_current_tag returns -1 on failure, so sci_get_position_from_line
// returns the current position, soit should be safe // returns the current position, so it should be safe
pos = sci_get_position_from_line(doc_list[idx].sci, line - 1); pos = sci_get_position_from_line(doc_list[idx].sci, line - 1);
} }
@ -2295,14 +2295,28 @@ on_comments_function_activate (GtkMenuItem *menuitem,
cur_tag = g_strdup(_("unknown")); cur_tag = g_strdup(_("unknown"));
} }
if (doc_list[idx].file_type->id == GEANY_FILETYPES_PASCAL) switch (doc_list[idx].file_type->id)
{
case GEANY_FILETYPES_PASCAL:
{ {
text = templates_get_template_function(GEANY_TEMPLATE_FUNCTION_PASCAL, cur_tag); text = templates_get_template_function(GEANY_TEMPLATE_FUNCTION_PASCAL, cur_tag);
break;
} }
else case GEANY_FILETYPES_PYTHON:
case GEANY_FILETYPES_RUBY:
case GEANY_FILETYPES_SH:
case GEANY_FILETYPES_MAKE:
case GEANY_FILETYPES_PERL:
{
text = templates_get_template_function(GEANY_TEMPLATE_FUNCTION_ROUTE, cur_tag);
break;
}
default:
{ {
text = templates_get_template_function(GEANY_TEMPLATE_FUNCTION, cur_tag); text = templates_get_template_function(GEANY_TEMPLATE_FUNCTION, cur_tag);
} }
}
sci_insert_text(doc_list[idx].sci, pos, text); sci_insert_text(doc_list[idx].sci, pos, text);
g_free(cur_tag); g_free(cur_tag);
g_free(text); g_free(text);
@ -2316,14 +2330,28 @@ on_comments_multiline_activate (GtkMenuItem *menuitem,
gint idx = document_get_cur_idx(); gint idx = document_get_cur_idx();
gchar *text; gchar *text;
if (doc_list[idx].file_type->id == GEANY_FILETYPES_PASCAL) switch (doc_list[idx].file_type->id)
{
case GEANY_FILETYPES_PASCAL:
{ {
text = templates_get_template_generic(GEANY_TEMPLATE_MULTILINE_PASCAL); text = templates_get_template_generic(GEANY_TEMPLATE_MULTILINE_PASCAL);
break;
} }
else case GEANY_FILETYPES_PYTHON:
case GEANY_FILETYPES_RUBY:
case GEANY_FILETYPES_SH:
case GEANY_FILETYPES_MAKE:
case GEANY_FILETYPES_PERL:
{
text = templates_get_template_generic(GEANY_TEMPLATE_MULTILINE_ROUTE);
break;
}
default:
{ {
text = templates_get_template_generic(GEANY_TEMPLATE_MULTILINE); text = templates_get_template_generic(GEANY_TEMPLATE_MULTILINE);
} }
}
sci_insert_text(doc_list[idx].sci, -1, text); sci_insert_text(doc_list[idx].sci, -1, text);
g_free(text); g_free(text);
} }
@ -2336,14 +2364,28 @@ on_comments_gpl_activate (GtkMenuItem *menuitem,
gint idx = document_get_cur_idx(); gint idx = document_get_cur_idx();
gchar *text; gchar *text;
if (doc_list[idx].file_type->id == GEANY_FILETYPES_PASCAL) switch (doc_list[idx].file_type->id)
{
case GEANY_FILETYPES_PASCAL:
{ {
text = templates_get_template_gpl(GEANY_TEMPLATE_GPL_PASCAL); text = templates_get_template_gpl(GEANY_TEMPLATE_GPL_PASCAL);
break;
} }
else case GEANY_FILETYPES_PYTHON:
case GEANY_FILETYPES_RUBY:
case GEANY_FILETYPES_SH:
case GEANY_FILETYPES_MAKE:
case GEANY_FILETYPES_PERL:
{
text = templates_get_template_gpl(GEANY_TEMPLATE_GPL_ROUTE);
break;
}
default:
{ {
text = templates_get_template_gpl(GEANY_TEMPLATE_GPL); text = templates_get_template_gpl(GEANY_TEMPLATE_GPL);
} }
}
sci_insert_text(doc_list[idx].sci, -1, text); sci_insert_text(doc_list[idx].sci, -1, text);
g_free(text); g_free(text);
} }
@ -2375,14 +2417,28 @@ on_comments_fileheader_activate (GtkMenuItem *menuitem,
gint idx = document_get_cur_idx(); gint idx = document_get_cur_idx();
gchar *text; gchar *text;
if (doc_list[idx].file_type->id == GEANY_FILETYPES_PASCAL) switch (doc_list[idx].file_type->id)
{
case GEANY_FILETYPES_PASCAL:
{ {
text = templates_get_template_fileheader(GEANY_TEMPLATE_FILEHEADER_PASCAL, NULL, idx); text = templates_get_template_fileheader(GEANY_TEMPLATE_FILEHEADER_PASCAL, NULL, idx);
break;
} }
else case GEANY_FILETYPES_PYTHON:
case GEANY_FILETYPES_RUBY:
case GEANY_FILETYPES_SH:
case GEANY_FILETYPES_MAKE:
case GEANY_FILETYPES_PERL:
{
text = templates_get_template_fileheader(GEANY_TEMPLATE_FILEHEADER_ROUTE, NULL, idx);
break;
}
default:
{ {
text = templates_get_template_fileheader(GEANY_TEMPLATE_FILEHEADER, NULL, idx); text = templates_get_template_fileheader(GEANY_TEMPLATE_FILEHEADER, NULL, idx);
} }
}
sci_insert_text(doc_list[idx].sci, 0, text); sci_insert_text(doc_list[idx].sci, 0, text);
sci_goto_pos(doc_list[idx].sci, 0, FALSE); sci_goto_pos(doc_list[idx].sci, 0, FALSE);
g_free(text); g_free(text);

View File

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* *
* $Id$ * $Id$
*/ */
@ -908,14 +908,21 @@ void document_update_tag_list(gint idx)
g_free(locale_filename); g_free(locale_filename);
if (! doc_list[idx].tm_file) return; if (! doc_list[idx].tm_file) return;
tm_workspace_add_object(doc_list[idx].tm_file); tm_workspace_add_object(doc_list[idx].tm_file);
/// TODO seems to be useless, but I'm not sure
// parse the file after setting the filetype // parse the file after setting the filetype
TM_SOURCE_FILE(doc_list[idx].tm_file)->lang = getNamedLanguage((doc_list[idx].file_type)->name); //TM_SOURCE_FILE(doc_list[idx].tm_file)->lang = getNamedLanguage((doc_list[idx].file_type)->name);
tm_source_file_update(doc_list[idx].tm_file, TRUE, FALSE, TRUE); //tm_source_file_update(doc_list[idx].tm_file, TRUE, FALSE, TRUE);
utils_update_tag_list(idx, TRUE); utils_update_tag_list(idx, TRUE);
} }
else else
{ {
gint len = sci_get_length(doc_list[idx].sci) + 1;
gchar *buf = (gchar*) g_malloc(len);
sci_get_text(doc_list[idx].sci, len, buf);
if (tm_source_file_update(doc_list[idx].tm_file, TRUE, FALSE, TRUE)) if (tm_source_file_update(doc_list[idx].tm_file, TRUE, FALSE, TRUE))
//if (tm_source_file_buffer_update(doc_list[idx].tm_file, buf, len, TRUE))
{ {
utils_update_tag_list(idx, TRUE); utils_update_tag_list(idx, TRUE);
} }
@ -999,8 +1006,8 @@ gchar *document_get_eol_mode(gint idx)
gchar *document_prepare_template(filetype *ft) gchar *document_prepare_template(filetype *ft)
{ {
gchar *gpl_notice = NULL; gchar *gpl_notice = NULL;
gchar *template; gchar *template = NULL;
gchar *ft_template; gchar *ft_template = NULL;
if (ft != NULL) if (ft != NULL)
{ {
@ -1020,6 +1027,16 @@ gchar *document_prepare_template(filetype *ft)
GEANY_TEMPLATE_FILEHEADER_PASCAL, ft->extension, -1); GEANY_TEMPLATE_FILEHEADER_PASCAL, ft->extension, -1);
break; break;
} }
case GEANY_FILETYPES_PYTHON:
case GEANY_FILETYPES_RUBY:
case GEANY_FILETYPES_SH:
case GEANY_FILETYPES_MAKE:
case GEANY_FILETYPES_PERL:
{
gpl_notice = templates_get_template_fileheader(
GEANY_TEMPLATE_FILEHEADER_ROUTE, ft->extension, -1);
break;
}
default: default:
{ // -> C, C++, Java, ... { // -> C, C++, Java, ...
gpl_notice = templates_get_template_fileheader( gpl_notice = templates_get_template_fileheader(

View File

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* *
* $Id$ * $Id$
*/ */
@ -275,7 +275,7 @@ void filetypes_init_types(void)
filetypes[GEANY_FILETYPES_CSS] = g_new0(filetype, 1); filetypes[GEANY_FILETYPES_CSS] = g_new0(filetype, 1);
filetypes[GEANY_FILETYPES_CSS]->id = GEANY_FILETYPES_CSS; filetypes[GEANY_FILETYPES_CSS]->id = GEANY_FILETYPES_CSS;
filetypes[GEANY_FILETYPES_CSS]->name = g_strdup("CSS"); filetypes[GEANY_FILETYPES_CSS]->name = g_strdup("CSS");
filetypes[GEANY_FILETYPES_CSS]->has_tags = FALSE; filetypes[GEANY_FILETYPES_CSS]->has_tags = TRUE;
filetypes[GEANY_FILETYPES_CSS]->title = g_strdup(_("Cascading StyleSheet")); filetypes[GEANY_FILETYPES_CSS]->title = g_strdup(_("Cascading StyleSheet"));
filetypes[GEANY_FILETYPES_CSS]->extension = g_strdup("css"); filetypes[GEANY_FILETYPES_CSS]->extension = g_strdup("css");
filetypes[GEANY_FILETYPES_CSS]->pattern = g_new0(gchar*, 2); filetypes[GEANY_FILETYPES_CSS]->pattern = g_new0(gchar*, 2);
@ -371,6 +371,24 @@ void filetypes_init_types(void)
filetypes_init_build_programs(filetypes[GEANY_FILETYPES_OMS]); filetypes_init_build_programs(filetypes[GEANY_FILETYPES_OMS]);
filetypes_create_menu_item(filetype_menu, filetypes[GEANY_FILETYPES_OMS]->title, filetypes[GEANY_FILETYPES_OMS]); filetypes_create_menu_item(filetype_menu, filetypes[GEANY_FILETYPES_OMS]->title, filetypes[GEANY_FILETYPES_OMS]);
#define RUBY
filetypes[GEANY_FILETYPES_RUBY] = g_new0(filetype, 1);
filetypes[GEANY_FILETYPES_RUBY]->id = GEANY_FILETYPES_RUBY;
filetypes[GEANY_FILETYPES_RUBY]->name = g_strdup("Ruby");
filetypes[GEANY_FILETYPES_RUBY]->has_tags = TRUE;
filetypes[GEANY_FILETYPES_RUBY]->title = g_strdup(_("Ruby source file"));
filetypes[GEANY_FILETYPES_RUBY]->extension = g_strdup("rb");
filetypes[GEANY_FILETYPES_RUBY]->pattern = g_new0(gchar*, 3);
filetypes[GEANY_FILETYPES_RUBY]->pattern[0] = g_strdup("*.rb");
filetypes[GEANY_FILETYPES_RUBY]->pattern[1] = g_strdup("*.rhtml");
filetypes[GEANY_FILETYPES_RUBY]->pattern[2] = NULL;
filetypes[GEANY_FILETYPES_RUBY]->style_func_ptr = styleset_ruby;
filetypes[GEANY_FILETYPES_RUBY]->comment_open = g_strdup("#");
filetypes[GEANY_FILETYPES_RUBY]->comment_close = NULL;
filetypes_init_build_programs(filetypes[GEANY_FILETYPES_RUBY]);
filetypes_create_menu_item(filetype_menu, filetypes[GEANY_FILETYPES_RUBY]->title, filetypes[GEANY_FILETYPES_RUBY]);
filetypes_create_newmenu_item(template_menu, filetypes[GEANY_FILETYPES_RUBY]->title, filetypes[GEANY_FILETYPES_RUBY]);
#define ALL #define ALL
filetypes[GEANY_FILETYPES_ALL] = g_new0(filetype, 1); filetypes[GEANY_FILETYPES_ALL] = g_new0(filetype, 1);
filetypes[GEANY_FILETYPES_ALL]->id = GEANY_FILETYPES_ALL; filetypes[GEANY_FILETYPES_ALL]->id = GEANY_FILETYPES_ALL;
@ -523,6 +541,8 @@ gchar *filetypes_get_template(filetype *ft)
return templates_get_template_generic(GEANY_TEMPLATE_FILETYPE_JAVA); break; return templates_get_template_generic(GEANY_TEMPLATE_FILETYPE_JAVA); break;
case GEANY_FILETYPES_PASCAL: case GEANY_FILETYPES_PASCAL:
return templates_get_template_generic(GEANY_TEMPLATE_FILETYPE_PASCAL); break; return templates_get_template_generic(GEANY_TEMPLATE_FILETYPE_PASCAL); break;
case GEANY_FILETYPES_RUBY:
return templates_get_template_generic(GEANY_TEMPLATE_FILETYPE_RUBY); break;
default: return NULL; default: return NULL;
} }
} }

View File

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* *
* $Id$ * $Id$
*/ */
@ -44,12 +44,16 @@ void templates_init(void)
{ {
gchar *template_filename_fileheader = templates_get_filename("template.fileheader"); gchar *template_filename_fileheader = templates_get_filename("template.fileheader");
gchar *template_filename_fileheader_pascal =templates_get_filename("template.fileheader.pascal"); gchar *template_filename_fileheader_pascal =templates_get_filename("template.fileheader.pascal");
gchar *template_filename_fileheader_route =templates_get_filename("template.fileheader.route");
gchar *template_filename_gpl = templates_get_filename("template.gpl"); gchar *template_filename_gpl = templates_get_filename("template.gpl");
gchar *template_filename_gpl_pascal = templates_get_filename("template.gpl.pascal"); gchar *template_filename_gpl_pascal = templates_get_filename("template.gpl.pascal");
gchar *template_filename_gpl_route = templates_get_filename("template.gpl.route");
gchar *template_filename_function = templates_get_filename("template.function"); gchar *template_filename_function = templates_get_filename("template.function");
gchar *template_filename_function_pascal = templates_get_filename("template.function.pascal"); gchar *template_filename_function_pascal = templates_get_filename("template.function.pascal");
gchar *template_filename_function_route = templates_get_filename("template.function.route");
gchar *template_filename_multiline = templates_get_filename("template.multiline"); gchar *template_filename_multiline = templates_get_filename("template.multiline");
gchar *template_filename_multiline_pascal = templates_get_filename("template.multiline.pascal"); gchar *template_filename_multiline_pascal = templates_get_filename("template.multiline.pascal");
gchar *template_filename_multiline_route = templates_get_filename("template.multiline.route");
gchar *template_filename_changelog = templates_get_filename("template.changelog"); gchar *template_filename_changelog = templates_get_filename("template.changelog");
gchar *template_filename_filetype_none = templates_get_filename("template.filetype.none"); gchar *template_filename_filetype_none = templates_get_filename("template.filetype.none");
gchar *template_filename_filetype_c = templates_get_filename("template.filetype.c"); gchar *template_filename_filetype_c = templates_get_filename("template.filetype.c");
@ -57,7 +61,7 @@ void templates_init(void)
gchar *template_filename_filetype_java = templates_get_filename("template.filetype.java"); gchar *template_filename_filetype_java = templates_get_filename("template.filetype.java");
gchar *template_filename_filetype_pascal = templates_get_filename("template.filetype.pascal"); gchar *template_filename_filetype_pascal = templates_get_filename("template.filetype.pascal");
gchar *template_filename_filetype_php = templates_get_filename("template.filetype.php"); gchar *template_filename_filetype_php = templates_get_filename("template.filetype.php");
gchar *template_filename_filetype_latex = templates_get_filename("template.filetype.latex"); gchar *template_filename_filetype_ruby = templates_get_filename("template.filetype.ruby");
time_t tp = time(NULL); time_t tp = time(NULL);
const struct tm *tm = localtime(&tp); const struct tm *tm = localtime(&tp);
@ -68,12 +72,16 @@ void templates_init(void)
// create the template files in the configuration directory, if they don't exist // create the template files in the configuration directory, if they don't exist
templates_create_file(template_filename_fileheader, templates_fileheader); templates_create_file(template_filename_fileheader, templates_fileheader);
templates_create_file(template_filename_fileheader_pascal, templates_fileheader_pascal); templates_create_file(template_filename_fileheader_pascal, templates_fileheader_pascal);
templates_create_file(template_filename_fileheader_route, templates_fileheader_route);
templates_create_file(template_filename_gpl, templates_gpl_notice); templates_create_file(template_filename_gpl, templates_gpl_notice);
templates_create_file(template_filename_gpl_pascal, templates_gpl_notice_pascal); templates_create_file(template_filename_gpl_pascal, templates_gpl_notice_pascal);
templates_create_file(template_filename_gpl_route, templates_gpl_notice_route);
templates_create_file(template_filename_function, templates_function_description); templates_create_file(template_filename_function, templates_function_description);
templates_create_file(template_filename_function_pascal, templates_function_description_pascal); templates_create_file(template_filename_function_pascal, templates_function_description_pascal);
templates_create_file(template_filename_function_route, templates_function_description_route);
templates_create_file(template_filename_multiline, templates_multiline); templates_create_file(template_filename_multiline, templates_multiline);
templates_create_file(template_filename_multiline_pascal, templates_multiline_pascal); templates_create_file(template_filename_multiline_pascal, templates_multiline_pascal);
templates_create_file(template_filename_multiline_route, templates_multiline_route);
templates_create_file(template_filename_changelog, templates_changelog); templates_create_file(template_filename_changelog, templates_changelog);
templates_create_file(template_filename_filetype_none, templates_filetype_none); templates_create_file(template_filename_filetype_none, templates_filetype_none);
templates_create_file(template_filename_filetype_c, templates_filetype_c); templates_create_file(template_filename_filetype_c, templates_filetype_c);
@ -81,7 +89,7 @@ void templates_init(void)
templates_create_file(template_filename_filetype_java, templates_filetype_java); templates_create_file(template_filename_filetype_java, templates_filetype_java);
templates_create_file(template_filename_filetype_pascal, templates_filetype_pascal); templates_create_file(template_filename_filetype_pascal, templates_filetype_pascal);
templates_create_file(template_filename_filetype_php, templates_filetype_php); templates_create_file(template_filename_filetype_php, templates_filetype_php);
templates_create_file(template_filename_filetype_latex, templates_filetype_none); templates_create_file(template_filename_filetype_ruby, templates_filetype_ruby);
// read the contents // read the contents
templates_read_file(template_filename_fileheader, &templates[GEANY_TEMPLATE_FILEHEADER]); templates_read_file(template_filename_fileheader, &templates[GEANY_TEMPLATE_FILEHEADER]);
@ -90,24 +98,36 @@ void templates_init(void)
templates_read_file(template_filename_fileheader_pascal, &templates[GEANY_TEMPLATE_FILEHEADER_PASCAL]); templates_read_file(template_filename_fileheader_pascal, &templates[GEANY_TEMPLATE_FILEHEADER_PASCAL]);
templates[GEANY_TEMPLATE_FILEHEADER_PASCAL] = templates_replace_all(templates[GEANY_TEMPLATE_FILEHEADER_PASCAL], year, date); templates[GEANY_TEMPLATE_FILEHEADER_PASCAL] = templates_replace_all(templates[GEANY_TEMPLATE_FILEHEADER_PASCAL], year, date);
templates_read_file(template_filename_fileheader_route, &templates[GEANY_TEMPLATE_FILEHEADER_ROUTE]);
templates[GEANY_TEMPLATE_FILEHEADER_ROUTE] = templates_replace_all(templates[GEANY_TEMPLATE_FILEHEADER_ROUTE], year, date);
templates_read_file(template_filename_gpl, &templates[GEANY_TEMPLATE_GPL]); templates_read_file(template_filename_gpl, &templates[GEANY_TEMPLATE_GPL]);
//templates[GEANY_TEMPLATE_GPL] = templates_replace_all(templates[GEANY_TEMPLATE_GPL], year, date); //templates[GEANY_TEMPLATE_GPL] = templates_replace_all(templates[GEANY_TEMPLATE_GPL], year, date);
templates_read_file(template_filename_gpl_pascal, &templates[GEANY_TEMPLATE_GPL_PASCAL]); templates_read_file(template_filename_gpl_pascal, &templates[GEANY_TEMPLATE_GPL_PASCAL]);
//templates[GEANY_TEMPLATE_GPL_PASCAL] = templates_replace_all(templates[GEANY_TEMPLATE_GPL_PASCAL], year, date); //templates[GEANY_TEMPLATE_GPL_PASCAL] = templates_replace_all(templates[GEANY_TEMPLATE_GPL_PASCAL], year, date);
templates_read_file(template_filename_gpl_route, &templates[GEANY_TEMPLATE_GPL_ROUTE]);
//templates[GEANY_TEMPLATE_GPL_ROUTE] = templates_replace_all(templates[GEANY_TEMPLATE_GPL_ROUTE], year, date);
templates_read_file(template_filename_function, &templates[GEANY_TEMPLATE_FUNCTION]); templates_read_file(template_filename_function, &templates[GEANY_TEMPLATE_FUNCTION]);
templates[GEANY_TEMPLATE_FUNCTION] = templates_replace_all(templates[GEANY_TEMPLATE_FUNCTION], year, date); templates[GEANY_TEMPLATE_FUNCTION] = templates_replace_all(templates[GEANY_TEMPLATE_FUNCTION], year, date);
templates_read_file(template_filename_function_pascal, &templates[GEANY_TEMPLATE_FUNCTION_PASCAL]); templates_read_file(template_filename_function_pascal, &templates[GEANY_TEMPLATE_FUNCTION_PASCAL]);
templates[GEANY_TEMPLATE_FUNCTION_PASCAL] = templates_replace_all(templates[GEANY_TEMPLATE_FUNCTION_PASCAL], year, date); templates[GEANY_TEMPLATE_FUNCTION_PASCAL] = templates_replace_all(templates[GEANY_TEMPLATE_FUNCTION_PASCAL], year, date);
templates_read_file(template_filename_function_route, &templates[GEANY_TEMPLATE_FUNCTION_ROUTE]);
templates[GEANY_TEMPLATE_FUNCTION_ROUTE] = templates_replace_all(templates[GEANY_TEMPLATE_FUNCTION_ROUTE], year, date);
templates_read_file(template_filename_multiline, &templates[GEANY_TEMPLATE_MULTILINE]); templates_read_file(template_filename_multiline, &templates[GEANY_TEMPLATE_MULTILINE]);
//templates[GEANY_TEMPLATE_MULTILINE] = templates_replace_all(templates[GEANY_TEMPLATE_MULTILINE], year, date); //templates[GEANY_TEMPLATE_MULTILINE] = templates_replace_all(templates[GEANY_TEMPLATE_MULTILINE], year, date);
templates_read_file(template_filename_multiline_pascal, &templates[GEANY_TEMPLATE_MULTILINE_PASCAL]); templates_read_file(template_filename_multiline_pascal, &templates[GEANY_TEMPLATE_MULTILINE_PASCAL]);
//templates[GEANY_TEMPLATE_MULTILINE_PASCAL] = templates_replace_all(templates[GEANY_TEMPLATE_MULTILINE_PASCAL], year, date); //templates[GEANY_TEMPLATE_MULTILINE_PASCAL] = templates_replace_all(templates[GEANY_TEMPLATE_MULTILINE_PASCAL], year, date);
templates_read_file(template_filename_multiline_route, &templates[GEANY_TEMPLATE_MULTILINE_ROUTE]);
//templates[GEANY_TEMPLATE_MULTILINE_ROUTE] = templates_replace_all(templates[GEANY_TEMPLATE_MULTILINE_ROUTE], year, date);
templates_read_file(template_filename_changelog, &templates[GEANY_TEMPLATE_CHANGELOG]); templates_read_file(template_filename_changelog, &templates[GEANY_TEMPLATE_CHANGELOG]);
templates[GEANY_TEMPLATE_CHANGELOG] = templates_replace_all(templates[GEANY_TEMPLATE_CHANGELOG], year, date); templates[GEANY_TEMPLATE_CHANGELOG] = templates_replace_all(templates[GEANY_TEMPLATE_CHANGELOG], year, date);
@ -130,9 +150,8 @@ void templates_init(void)
templates_read_file(template_filename_filetype_php, &templates[GEANY_TEMPLATE_FILETYPE_PHP]); templates_read_file(template_filename_filetype_php, &templates[GEANY_TEMPLATE_FILETYPE_PHP]);
templates[GEANY_TEMPLATE_FILETYPE_PHP] = templates_replace_all(templates[GEANY_TEMPLATE_FILETYPE_PHP], year, date); templates[GEANY_TEMPLATE_FILETYPE_PHP] = templates_replace_all(templates[GEANY_TEMPLATE_FILETYPE_PHP], year, date);
templates_read_file(template_filename_filetype_latex, &templates[GEANY_TEMPLATE_FILETYPE_LATEX]); templates_read_file(template_filename_filetype_ruby, &templates[GEANY_TEMPLATE_FILETYPE_RUBY]);
templates[GEANY_TEMPLATE_FILETYPE_LATEX] = templates_replace_all(templates[GEANY_TEMPLATE_FILETYPE_LATEX], year, date); templates[GEANY_TEMPLATE_FILETYPE_RUBY] = templates_replace_all(templates[GEANY_TEMPLATE_FILETYPE_RUBY], year, date);
// free the whole stuff // free the whole stuff
@ -140,12 +159,16 @@ void templates_init(void)
g_free(year); g_free(year);
g_free(template_filename_fileheader); g_free(template_filename_fileheader);
g_free(template_filename_fileheader_pascal); g_free(template_filename_fileheader_pascal);
g_free(template_filename_fileheader_route);
g_free(template_filename_gpl); g_free(template_filename_gpl);
g_free(template_filename_gpl_pascal); g_free(template_filename_gpl_pascal);
g_free(template_filename_gpl_route);
g_free(template_filename_function); g_free(template_filename_function);
g_free(template_filename_function_pascal); g_free(template_filename_function_pascal);
g_free(template_filename_function_route);
g_free(template_filename_multiline); g_free(template_filename_multiline);
g_free(template_filename_multiline_pascal); g_free(template_filename_multiline_pascal);
g_free(template_filename_multiline_route);
g_free(template_filename_changelog); g_free(template_filename_changelog);
g_free(template_filename_filetype_none); g_free(template_filename_filetype_none);
g_free(template_filename_filetype_c); g_free(template_filename_filetype_c);
@ -153,7 +176,7 @@ void templates_init(void)
g_free(template_filename_filetype_java); g_free(template_filename_filetype_java);
g_free(template_filename_filetype_php); g_free(template_filename_filetype_php);
g_free(template_filename_filetype_pascal); g_free(template_filename_filetype_pascal);
g_free(template_filename_filetype_latex); g_free(template_filename_filetype_ruby);
} }
@ -184,6 +207,10 @@ gchar *templates_get_template_fileheader(gint template, const gchar *extension,
{ {
result = utils_str_replace(result, "{gpl}", templates[GEANY_TEMPLATE_GPL_PASCAL]); result = utils_str_replace(result, "{gpl}", templates[GEANY_TEMPLATE_GPL_PASCAL]);
} }
else if (template == GEANY_TEMPLATE_FILEHEADER_ROUTE)
{
result = utils_str_replace(result, "{gpl}", templates[GEANY_TEMPLATE_GPL_ROUTE]);
}
else else
{ {
result = utils_str_replace(result, "{gpl}", templates[GEANY_TEMPLATE_GPL]); result = utils_str_replace(result, "{gpl}", templates[GEANY_TEMPLATE_GPL]);
@ -219,14 +246,23 @@ gchar *templates_get_template_function(gint template, gchar *func_name)
gchar *templates_get_template_gpl(gint template) gchar *templates_get_template_gpl(gint template)
{ {
if (template == GEANY_TEMPLATE_GPL_PASCAL) switch (template)
{
case GEANY_TEMPLATE_GPL_PASCAL:
{ {
return g_strconcat("{\n", templates[template], "}\n", NULL); return g_strconcat("{\n", templates[template], "}\n", NULL);
break;
} }
else case GEANY_TEMPLATE_GPL_ROUTE:
{
return g_strconcat("#\n", templates[template], "#\n", NULL);
break;
}
default:
{ {
return g_strconcat("/*\n", templates[template], "*/\n", NULL); return g_strconcat("/*\n", templates[template], "*/\n", NULL);
} }
}
} }

View File

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* *
* $Id$ * $Id$
*/ */
@ -42,14 +42,18 @@ void templates_free_templates(void);
enum enum
{ {
GEANY_TEMPLATE_GPL_PASCAL = 0, GEANY_TEMPLATE_GPL_PASCAL = 0,
GEANY_TEMPLATE_GPL_ROUTE,
GEANY_TEMPLATE_GPL, GEANY_TEMPLATE_GPL,
GEANY_TEMPLATE_FILEHEADER_PASCAL, GEANY_TEMPLATE_FILEHEADER_PASCAL,
GEANY_TEMPLATE_FILEHEADER_ROUTE,
GEANY_TEMPLATE_FILEHEADER, GEANY_TEMPLATE_FILEHEADER,
GEANY_TEMPLATE_CHANGELOG, GEANY_TEMPLATE_CHANGELOG,
GEANY_TEMPLATE_FUNCTION, GEANY_TEMPLATE_FUNCTION,
GEANY_TEMPLATE_FUNCTION_PASCAL, GEANY_TEMPLATE_FUNCTION_PASCAL,
GEANY_TEMPLATE_FUNCTION_ROUTE,
GEANY_TEMPLATE_MULTILINE, GEANY_TEMPLATE_MULTILINE,
GEANY_TEMPLATE_MULTILINE_PASCAL, GEANY_TEMPLATE_MULTILINE_PASCAL,
GEANY_TEMPLATE_MULTILINE_ROUTE,
GEANY_TEMPLATE_FILETYPE_NONE, GEANY_TEMPLATE_FILETYPE_NONE,
GEANY_TEMPLATE_FILETYPE_C, GEANY_TEMPLATE_FILETYPE_C,
@ -57,7 +61,7 @@ enum
GEANY_TEMPLATE_FILETYPE_JAVA, GEANY_TEMPLATE_FILETYPE_JAVA,
GEANY_TEMPLATE_FILETYPE_PHP, GEANY_TEMPLATE_FILETYPE_PHP,
GEANY_TEMPLATE_FILETYPE_PASCAL, GEANY_TEMPLATE_FILETYPE_PASCAL,
GEANY_TEMPLATE_FILETYPE_LATEX, GEANY_TEMPLATE_FILETYPE_RUBY,
GEANY_MAX_TEMPLATES GEANY_MAX_TEMPLATES
}; };
@ -79,7 +83,7 @@ static const gchar templates_gpl_notice[] = "\
*\n\ *\n\
* You should have received a copy of the GNU General Public License\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\ * along with this program; if not, write to the Free Software\n\
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n\ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n\
"; ";
static const gchar templates_gpl_notice_pascal[] = "\ static const gchar templates_gpl_notice_pascal[] = "\
@ -95,7 +99,23 @@ static const gchar templates_gpl_notice_pascal[] = "\
\n\ \n\
You should have received a copy of the GNU General Public License\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\ along with this program; if not, write to the Free Software\n\
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n\ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n\
";
static const gchar templates_gpl_notice_route[] = "\
# This program is free software; you can redistribute it and/or modify\n\
# it under the terms of the GNU General Public License as published by\n\
# the Free Software Foundation; either version 2 of the License, or\n\
# (at your option) any later version.\n\
#\n\
# This program is distributed in the hope that it will be useful,\n\
# but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
# GNU General Public License for more details.\n\
#\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\
"; ";
static const gchar templates_function_description[] = "\ static const gchar templates_function_description[] = "\
@ -112,6 +132,13 @@ static const gchar templates_function_description_pascal[] = "\
@return\n\ @return\n\
}\n"; }\n";
static const gchar templates_function_description_route[] = "\
#\n\
# name: {functionname}\n\
# @param\n\
# @return\n\
";
static const gchar templates_multiline[] = "\ static const gchar templates_multiline[] = "\
/* \n\ /* \n\
* \n\ * \n\
@ -122,6 +149,10 @@ static const gchar templates_multiline_pascal[] = "\
\n\ \n\
}"; }";
static const gchar templates_multiline_route[] = "\
#\n\
#";
static const gchar templates_fileheader[] = "\ static const gchar templates_fileheader[] = "\
/*\n\ /*\n\
* {filename}\n\ * {filename}\n\
@ -140,6 +171,15 @@ static const gchar templates_fileheader_pascal[] = "\
{gpl}\ {gpl}\
}\n\n"; }\n\n";
static const gchar templates_fileheader_route[] = "\
#\n\
# {filename}\n\
#\n\
# Copyright {year} {developer} <{mail}>\n\
#\n\
{gpl}\
#\n\n";
static const gchar templates_changelog[] = "\ static const gchar templates_changelog[] = "\
{date} {developer} <{mail}>\n\ {date} {developer} <{mail}>\n\
\n\ \n\
@ -205,6 +245,15 @@ public class {untitled} {\n\
}\n\ }\n\
"; ";
static const gchar templates_filetype_latex[] = ""; static const gchar templates_filetype_ruby[] = "\n\
\n\
class StdClass\n\
def initialize\n\
\n\
end\n\
end\n\
\n\
x = StdClass.new\\n\
";
#endif #endif