From eba0571fb69c381074ce3b7cfa022a2afbea9a8e Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Wed, 10 Nov 2010 17:47:55 +0000 Subject: [PATCH] Add xml_indent_tags filetype setting for documents using the HTML/XML lexers (patch by Eugene Arshinov, thanks). git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5392 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 4 ++++ data/filetypes.html | 4 ++++ data/filetypes.xml | 3 +++ src/editor.c | 6 ++++-- src/filetypes.c | 2 ++ src/filetypesprivate.h | 1 + 6 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c32bce989..59cfcb47e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,10 @@ * src/document.c: Fix not reporting an error message when saving a document fails. Check result of fclose(). + * src/filetypesprivate.h, src/filetypes.c, src/editor.c, + data/filetypes.xml, data/filetypes.html: + Add xml_indent_tags filetype setting for documents using the + HTML/XML lexers (patch by Eugene Arshinov, thanks). 2010-11-09 Nick Treleaven diff --git a/data/filetypes.html b/data/filetypes.html index 1e63c0c59..e18ce7540 100644 --- a/data/filetypes.html +++ b/data/filetypes.html @@ -32,6 +32,10 @@ comment_use_indent=true # context action command (please see Geany's main documentation for details) context_action_cmd= +# If this setting is set to true, a new line after a line ending with an +# unclosed tag will be automatically indented +xml_indent_tags=true + [build_settings] # %f will be replaced by the complete filename # %e will be replaced by the filename without extension diff --git a/data/filetypes.xml b/data/filetypes.xml index 13a37d206..e067e3df8 100644 --- a/data/filetypes.xml +++ b/data/filetypes.xml @@ -103,3 +103,6 @@ comment_use_indent=true # context action command (please see Geany's main documentation for details) context_action_cmd= +# If this setting is set to true, a new line after a line ending with an +# unclosed tag will be automatically indented +xml_indent_tags=true \ No newline at end of file diff --git a/src/editor.c b/src/editor.c index 2f9379efc..68b09f88c 100644 --- a/src/editor.c +++ b/src/editor.c @@ -55,6 +55,7 @@ #include "document.h" #include "documentprivate.h" #include "filetypes.h" +#include "filetypesprivate.h" #include "sciwrappers.h" #include "ui_utils.h" #include "utils.h" @@ -1356,8 +1357,9 @@ static gint get_indent_size_after_line(GeanyEditor *editor, gint line) * recommend us to insert additional indent, we are probably not in PHP/JavaScript chunk and * should make the XML-related check */ if (additional_indent == 0 && !editor_prefs.auto_close_xml_tags && - (editor->document->file_type->id == GEANY_FILETYPES_HTML || - editor->document->file_type->id == GEANY_FILETYPES_XML)) + (sci_get_lexer(sci) == SCLEX_HTML || + sci_get_lexer(sci) == SCLEX_XML) && + editor->document->file_type->priv->xml_indent_tags) { size += iprefs->width * get_xml_indent(sci, line); } diff --git a/src/filetypes.c b/src/filetypes.c index 1c9a90bdb..76c397e42 100644 --- a/src/filetypes.c +++ b/src/filetypes.c @@ -1139,6 +1139,8 @@ static void load_settings(gint ft_id, GKeyFile *config, GKeyFile *configh) ft->priv->symbol_list_sort_mode = utils_get_setting(integer, configh, config, "settings", "symbol_list_sort_mode", SYMBOLS_SORT_BY_NAME); + ft->priv->xml_indent_tags = utils_get_setting(boolean, configh, config, "settings", + "xml_indent_tags", FALSE); /* read build settings */ build_load_menu(config, GEANY_BCS_FT, (gpointer)ft); diff --git a/src/filetypesprivate.h b/src/filetypesprivate.h index 3a36ce92e..8a74ac748 100644 --- a/src/filetypesprivate.h +++ b/src/filetypesprivate.h @@ -43,6 +43,7 @@ typedef struct GeanyFiletypePrivate gchar *last_string; /* last one compiled */ gboolean custom; gint symbol_list_sort_mode; + gboolean xml_indent_tags; /* XML tag autoindentation, for HTML and XML filetypes */ } GeanyFiletypePrivate; -- 2.11.4.GIT