[gnome-text-editor] modelines: add support for indent width
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] modelines: add support for indent width
- Date: Wed, 27 Oct 2021 14:15:51 +0000 (UTC)
commit 6b6915026fa542539cb29625a013ee08b93c2308
Author: Christian Hergert <chergert redhat com>
Date: Wed Oct 27 07:14:38 2021 -0700
modelines: add support for indent width
Related #200
src/modelines/editor-modeline-settings-provider.c | 21 +++++++++++++++++++++
src/modelines/modeline-parser.h | 2 +-
2 files changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/src/modelines/editor-modeline-settings-provider.c
b/src/modelines/editor-modeline-settings-provider.c
index 2fa7890..e7ac630 100644
--- a/src/modelines/editor-modeline-settings-provider.c
+++ b/src/modelines/editor-modeline-settings-provider.c
@@ -36,9 +36,11 @@ struct _EditorModelineSettingsProvider
guint reload_source;
guint tab_width;
+ int indent_width;
guint right_margin_position;
guint tab_width_set : 1;
+ guint indent_width_set : 1;
guint wrap_text : 1;
guint wrap_text_set : 1;
guint right_margin_position_set : 1;
@@ -57,6 +59,15 @@ editor_modeline_settings_provider_get_tab_width (EditorPageSettingsProvider *pro
return self->tab_width_set;
}
+static gboolean
+editor_modeline_settings_provider_get_indent_width (EditorPageSettingsProvider *provider,
+ int *indent_width)
+{
+ EditorModelineSettingsProvider *self = EDITOR_MODELINE_SETTINGS_PROVIDER (provider);
+ *indent_width = self->indent_width;
+ return self->indent_width_set;
+}
+
static gboolean
editor_modeline_settings_provider_get_right_margin_position (EditorPageSettingsProvider *provider,
guint
*right_margin_position)
@@ -127,6 +138,15 @@ editor_modeline_settings_provider_reload (gpointer data)
if ((self->tab_width_set = modeline_has_option (options, MODELINE_SET_TAB_WIDTH)))
self->tab_width = options->tab_width;
+ if (modeline_has_option (options, MODELINE_SET_INDENT_WIDTH))
+ {
+ if (options->indent_width >= 1 && options->indent_width <= 32)
+ {
+ self->indent_width = options->indent_width;
+ self->indent_width_set = TRUE;
+ }
+ }
+
if ((self->wrap_text_set = modeline_has_option (options, MODELINE_SET_WRAP_MODE)))
self->wrap_text = options->wrap_mode != GTK_WRAP_NONE;
@@ -198,6 +218,7 @@ page_settings_provider_iface_init (EditorPageSettingsProviderInterface *iface)
{
iface->set_document = editor_modeline_settings_provider_set_document;
iface->get_tab_width = editor_modeline_settings_provider_get_tab_width;
+ iface->get_indent_width = editor_modeline_settings_provider_get_indent_width;
iface->get_wrap_text = editor_modeline_settings_provider_get_wrap_text;
iface->get_right_margin_position = editor_modeline_settings_provider_get_right_margin_position;
iface->get_show_right_margin = editor_modeline_settings_provider_get_show_right_margin;
diff --git a/src/modelines/modeline-parser.h b/src/modelines/modeline-parser.h
index 706ed95..1a32e81 100644
--- a/src/modelines/modeline-parser.h
+++ b/src/modelines/modeline-parser.h
@@ -59,7 +59,7 @@ static inline gboolean
modeline_has_option (const ModelineOptions *options,
ModelineSet set)
{
- return options->set & set;
+ return !!(options->set & set);
}
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]