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
This commit is contained in:
Nick Treleaven 2010-11-10 17:47:55 +00:00
parent 1355795908
commit eba0571fb6
6 changed files with 18 additions and 2 deletions

View File

@ -7,6 +7,10 @@
* src/document.c: * src/document.c:
Fix not reporting an error message when saving a document fails. Fix not reporting an error message when saving a document fails.
Check result of fclose(). 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 <nick(dot)treleaven(at)btinternet(dot)com> 2010-11-09 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>

View File

@ -32,6 +32,10 @@ comment_use_indent=true
# context action command (please see Geany's main documentation for details) # context action command (please see Geany's main documentation for details)
context_action_cmd= 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] [build_settings]
# %f will be replaced by the complete filename # %f will be replaced by the complete filename
# %e will be replaced by the filename without extension # %e will be replaced by the filename without extension

View File

@ -103,3 +103,6 @@ comment_use_indent=true
# context action command (please see Geany's main documentation for details) # context action command (please see Geany's main documentation for details)
context_action_cmd= 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

View File

@ -55,6 +55,7 @@
#include "document.h" #include "document.h"
#include "documentprivate.h" #include "documentprivate.h"
#include "filetypes.h" #include "filetypes.h"
#include "filetypesprivate.h"
#include "sciwrappers.h" #include "sciwrappers.h"
#include "ui_utils.h" #include "ui_utils.h"
#include "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 * recommend us to insert additional indent, we are probably not in PHP/JavaScript chunk and
* should make the XML-related check */ * should make the XML-related check */
if (additional_indent == 0 && !editor_prefs.auto_close_xml_tags && if (additional_indent == 0 && !editor_prefs.auto_close_xml_tags &&
(editor->document->file_type->id == GEANY_FILETYPES_HTML || (sci_get_lexer(sci) == SCLEX_HTML ||
editor->document->file_type->id == GEANY_FILETYPES_XML)) sci_get_lexer(sci) == SCLEX_XML) &&
editor->document->file_type->priv->xml_indent_tags)
{ {
size += iprefs->width * get_xml_indent(sci, line); size += iprefs->width * get_xml_indent(sci, line);
} }

View File

@ -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", ft->priv->symbol_list_sort_mode = utils_get_setting(integer, configh, config, "settings",
"symbol_list_sort_mode", SYMBOLS_SORT_BY_NAME); "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 */ /* read build settings */
build_load_menu(config, GEANY_BCS_FT, (gpointer)ft); build_load_menu(config, GEANY_BCS_FT, (gpointer)ft);

View File

@ -43,6 +43,7 @@ typedef struct GeanyFiletypePrivate
gchar *last_string; /* last one compiled */ gchar *last_string; /* last one compiled */
gboolean custom; gboolean custom;
gint symbol_list_sort_mode; gint symbol_list_sort_mode;
gboolean xml_indent_tags; /* XML tag autoindentation, for HTML and XML filetypes */
} }
GeanyFiletypePrivate; GeanyFiletypePrivate;