geany
1.38
About: Geany is a text editor (using GTK2) with basic features of an integrated development environment (syntax highlighting, code folding, symbol name auto-completion, ...). F: office T: editor programming GTK+ IDE
![]() ![]() |
#include "templates.h"
#include "app.h"
#include "document.h"
#include "encodingsprivate.h"
#include "filetypes.h"
#include "geany.h"
#include "geanymenubuttonaction.h"
#include "geanyobject.h"
#include "spawn.h"
#include "support.h"
#include "toolbar.h"
#include "ui_utils.h"
#include "utils.h"
#include <time.h>
#include <string.h>
#include <gtk/gtk.h>
Go to the source code of this file.
Functions | |
static void | replace_static_values (GString *text) |
static gchar * | get_template_fileheader (GeanyFiletype *ft) |
static void | templates_replace_default_dates (GString *text) |
static void | templates_replace_command (GString *text, const gchar *file_name, const gchar *file_type, const gchar *func_name) |
static gchar * | read_file (const gchar *locale_fname) |
static void | read_template (const gchar *name, gint id) |
static void | convert_eol_characters (GString *template, GeanyDocument *doc) |
static void | init_general_templates (void) |
void | templates_replace_common (GString *tmpl, const gchar *fname, GeanyFiletype *ft, const gchar *func_name) |
static gchar * | get_template_from_file (const gchar *locale_fname, const gchar *doc_filename, GeanyFiletype *ft) |
static void | on_new_with_file_template (GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer user_data) |
static void | add_file_item (const gchar *fname, GtkWidget *menu) |
static void | populate_file_template_menu (GtkWidget *menu) |
static void | create_file_template_menu (void) |
static void | on_document_save (G_GNUC_UNUSED GObject *object, GeanyDocument *doc) |
void | templates_init (void) |
static void | make_comment_block (GString *comment_text, gint filetype_idx, guint indent) |
gchar * | templates_get_template_licence (GeanyDocument *doc, gint licence_type) |
gchar * | templates_get_template_fileheader (gint filetype_idx, const gchar *fname) |
gchar * | templates_get_template_function (GeanyDocument *doc, const gchar *func_name) |
gchar * | templates_get_template_changelog (GeanyDocument *doc) |
static void | free_template_menu_items (GtkWidget *menu) |
void | templates_free_templates (void) |
void | templates_replace_valist (GString *text, const gchar *first_wildcard,...) |
static gchar * | run_command (const gchar *command, const gchar *file_name, const gchar *file_type, const gchar *func_name) |
Variables | |
GeanyTemplatePrefs | template_prefs |
static GtkWidget * | new_with_template_menu = NULL |
static GtkWidget * | new_with_template_toolbar_menu = NULL |
static gchar * | templates [GEANY_MAX_TEMPLATES] |
|
static |
Definition at line 239 of file templates.c.
References gtk_container_add(), label, NULL, on_new_with_file_template(), and utils_get_utf8_from_locale().
Referenced by populate_file_template_menu().
|
static |
Definition at line 112 of file templates.c.
References document_get_current(), GeanyDocument::editor, editor_get_eol_char_mode(), GeanyDocument::is_valid, NULL, and utils_ensure_same_eol_characters().
Referenced by templates_get_template_changelog(), templates_get_template_fileheader(), templates_get_template_function(), and templates_get_template_licence().
|
static |
Definition at line 274 of file templates.c.
References GEANY_MENU_BUTTON_ACTION, geany_menu_button_action_set_menu(), main_widgets, new_with_template_menu, new_with_template_toolbar_menu, toolbar_get_action_by_name(), ui_lookup_widget(), and GeanyMainWidgets::window.
Referenced by templates_init().
|
static |
Definition at line 506 of file templates.c.
References foreach_list.
Referenced by templates_free_templates().
|
static |
Definition at line 438 of file templates.c.
References filetypes_load_config(), GeanyFiletype::id, make_comment_block(), NULL, templates, and templates_replace_valist().
Referenced by get_template_from_file(), and templates_get_template_fileheader().
|
static |
Definition at line 172 of file templates.c.
References get_template_fileheader(), NULL, read_file(), templates_replace_common(), templates_replace_valist(), and utils_free_pointers().
Referenced by on_new_with_file_template().
|
static |
Definition at line 128 of file templates.c.
References read_template().
Referenced by templates_init().
|
static |
Definition at line 330 of file templates.c.
References EMPTY, filetype_get_comment_open_close(), filetypes_index(), indent, lines, NULL, SETPTR, utils_free_pointers(), utils_get_eol_char(), and utils_get_line_endings().
Referenced by get_template_fileheader(), templates_get_template_function(), and templates_get_template_licence().
|
static |
Definition at line 290 of file templates.c.
References app, GeanyApp::configdir, EMPTY, GEANY_TEMPLATES_SUBDIR, NULL, GeanyDocument::real_path, templates_free_templates(), and templates_init().
Referenced by templates_init().
|
static |
Definition at line 198 of file templates.c.
References _, app, GeanyApp::configdir, GeanyApp::datadir, document_new_file(), filetypes_detect_from_extension(), GEANY_STRING_UNTITLED, GEANY_TEMPLATES_SUBDIR, get_template_from_file(), NULL, SETPTR, ui_menu_item_get_text(), ui_set_statusbar(), utils_get_locale_from_utf8(), and utils_get_utf8_from_locale().
Referenced by add_file_item().
|
static |
Definition at line 258 of file templates.c.
References add_file_item(), foreach_slist, GEANY_TEMPLATES_SUBDIR, list, and utils_get_config_files().
Referenced by templates_init().
|
static |
Definition at line 68 of file templates.c.
References _, encodings_convert_to_utf8_auto(), NULL, SC_EOL_LF, ui_set_statusbar(), utils_ensure_same_eol_characters(), and utils_get_utf8_from_locale().
Referenced by get_template_from_file(), and read_template().
|
static |
Definition at line 96 of file templates.c.
References app, GeanyApp::configdir, GeanyApp::datadir, GEANY_TEMPLATES_SUBDIR, name, NULL, read_file(), SETPTR, and templates.
Referenced by init_general_templates().
|
static |
Definition at line 528 of file templates.c.
References GeanyTemplatePrefs::company, GeanyTemplatePrefs::developer, GEANY_STRING_UNTITLED, GeanyTemplatePrefs::initials, GeanyTemplatePrefs::mail, template_prefs, text, utils_string_replace_all(), and GeanyTemplatePrefs::version.
Referenced by templates_get_template_changelog(), templates_get_template_licence(), and templates_replace_valist().
|
static |
Definition at line 592 of file templates.c.
References _, command, error(), NULL, spawn_sync(), and utils_copy_environment().
Referenced by templates_replace_command().
void templates_free_templates | ( | void | ) |
Definition at line 517 of file templates.c.
References free_template_menu_items(), new_with_template_menu, new_with_template_toolbar_menu, and templates.
Referenced by do_main_quit(), main_reload_configuration(), and on_document_save().
gchar * templates_get_template_changelog | ( | GeanyDocument * | doc | ) |
Definition at line 488 of file templates.c.
References convert_eol_characters(), DOC_FILENAME, DOC_VALID, GeanyDocument::file_type, GeanyFiletype::name, NULL, replace_static_values(), templates, templates_replace_command(), and templates_replace_default_dates().
Referenced by on_comments_changelog_activate().
gchar * templates_get_template_fileheader | ( | gint | filetype_idx, |
const gchar * | fname | ||
) |
Definition at line 457 of file templates.c.
References convert_eol_characters(), filetypes, get_template_fileheader(), NULL, and templates_replace_common().
Referenced by on_comments_fileheader_activate().
gchar * templates_get_template_function | ( | GeanyDocument * | doc, |
const gchar * | func_name | ||
) |
Definition at line 470 of file templates.c.
References convert_eol_characters(), DOC_FILENAME, GeanyDocument::file_type, GeanyFiletype::id, make_comment_block(), GeanyFiletype::name, NULL, templates, templates_replace_command(), templates_replace_default_dates(), templates_replace_valist(), and text.
Referenced by on_comments_function_activate().
gchar * templates_get_template_licence | ( | GeanyDocument * | doc, |
gint | licence_type | ||
) |
Definition at line 419 of file templates.c.
References convert_eol_characters(), DOC_FILENAME, DOC_VALID, GeanyDocument::file_type, GeanyFiletype::id, make_comment_block(), GeanyFiletype::name, NULL, replace_static_values(), templates, templates_replace_command(), and templates_replace_default_dates().
Referenced by insert_comment_template().
void templates_init | ( | void | ) |
Definition at line 308 of file templates.c.
References create_file_template_menu(), geany_object, init_general_templates(), new_with_template_menu, new_with_template_toolbar_menu, NULL, on_document_save(), and populate_file_template_menu().
Referenced by main_lib(), main_reload_configuration(), and on_document_save().
|
static |
Definition at line 627 of file templates.c.
References match(), NULL, run_command(), strstr(), text, and utils_string_replace_first().
Referenced by templates_get_template_changelog(), templates_get_template_function(), templates_get_template_licence(), and templates_replace_common().
void templates_replace_common | ( | GString * | tmpl, |
const gchar * | fname, | ||
GeanyFiletype * | ft, | ||
const gchar * | func_name | ||
) |
Definition at line 139 of file templates.c.
References app, GeanyProject::description, GeanyFiletype::extension, GEANY_STRING_UNTITLED, GeanyFiletype::name, GeanyProject::name, NULL, GeanyApp::project, templates_replace_command(), templates_replace_default_dates(), and templates_replace_valist().
Referenced by get_template_from_file(), snippets_make_replacements(), and templates_get_template_fileheader().
|
static |
Definition at line 574 of file templates.c.
References GeanyTemplatePrefs::date_format, GeanyTemplatePrefs::datetime_format, NULL, template_prefs, templates_replace_valist(), text, utils_free_pointers(), utils_get_date_time(), and GeanyTemplatePrefs::year_format.
Referenced by templates_get_template_changelog(), templates_get_template_function(), templates_get_template_licence(), and templates_replace_common().
void templates_replace_valist | ( | GString * | text, |
const gchar * | first_wildcard, | ||
... | |||
) |
Definition at line 547 of file templates.c.
References NULL, replace_static_values(), text, and utils_string_replace_all().
Referenced by get_template_fileheader(), get_template_from_file(), snippets_make_replacements(), templates_get_template_function(), templates_replace_common(), and templates_replace_default_dates().
|
static |
Definition at line 52 of file templates.c.
Referenced by create_file_template_menu(), templates_free_templates(), and templates_init().
|
static |
Definition at line 53 of file templates.c.
Referenced by create_file_template_menu(), templates_free_templates(), and templates_init().
GeanyTemplatePrefs template_prefs |
Definition at line 50 of file templates.c.
Referenced by do_main_quit(), geany_data_init(), load_dialog_prefs(), main_lib(), on_comments_changelog_activate(), on_prefs_dialog_response(), prefs_init_dialog(), replace_static_values(), save_dialog_prefs(), and templates_replace_default_dates().
|
static |
Definition at line 56 of file templates.c.
Referenced by get_template_fileheader(), read_template(), templates_free_templates(), templates_get_template_changelog(), templates_get_template_function(), and templates_get_template_licence().