[anjuta] libanjuta: Allow to set indentation and tab size separately



commit 9565bd2088c2f2aec707556daf9a8bf60b87065f
Author: SÃbastien Granjoux <seb sfo free fr>
Date:   Mon Dec 24 19:55:26 2012 +0100

    libanjuta: Allow to set indentation and tab size separately
    
    This is useful in Scintilla for indenting using the Tab key.

 libanjuta/interfaces/libanjuta.idl                 |   22 ++++++++++++++++++++
 plugins/indentation-c-style/plugin.c               |    4 +++
 .../indentation-python-style/python-indentation.c  |    4 +++
 plugins/sourceview/sourceview.c                    |   18 ++++++++++++++-
 4 files changed, 46 insertions(+), 2 deletions(-)
---
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index 78ef3ec..277c6c8 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -1458,6 +1458,28 @@ interface IAnjutaEditor
 	void set_auto_indent (gboolean auto_indent);
 
 	/**
+	 * ianjuta_editor_get_indentsize:
+	 * @obj: Self
+	 * @err: Error propagation and reporting
+	 *
+	 * Returns the indentation size in spaces currently used by the
+	 * editor.
+	 *
+	 * Returns: indentation size in number of spaces
+	 */
+	gint   get_indentsize ();
+
+	/**
+	 * ianjuta_editor_set_indentsize:
+	 * @obj: Self
+	 * @tabsize: Indentation size in spaces
+	 * @err: Error propagation and reporting
+	 *
+	 * Sets the indentation size of the editor.
+	 */
+	void   set_indentsize (gint indentsize);
+
+	/**
 	 * ianjuta_editor_erase_range:
 	 * @obj: Self
 	 * @position_start: Start position of chars to erase.
diff --git a/plugins/indentation-c-style/plugin.c b/plugins/indentation-c-style/plugin.c
index 1b158be..2aad90c 100644
--- a/plugins/indentation-c-style/plugin.c
+++ b/plugins/indentation-c-style/plugin.c
@@ -82,6 +82,8 @@ set_indentation_param_emacs (IndentCPlugin* plugin, const gchar *param,
     else if (strcasecmp (param, "c-basic-offset") == 0)
     {
         plugin->param_statement_indentation = atoi (value);
+        ianjuta_editor_set_indentsize (IANJUTA_EDITOR (plugin->current_editor),
+                                       plugin->param_statement_indentation, NULL);
     }
     else if (strcasecmp (param, "tab-width") == 0)
     {
@@ -116,6 +118,8 @@ set_indentation_param_vim (IndentCPlugin* plugin, const gchar *param,
              g_str_equal (param, "sw"))
     {
         plugin->param_statement_indentation = atoi (value);
+        ianjuta_editor_set_indentsize (IANJUTA_EDITOR (plugin->current_editor),
+                                       plugin->param_statement_indentation, NULL);
     }
     else if (g_str_equal (param, "softtabstop") ||
              g_str_equal (param, "sts") ||
diff --git a/plugins/indentation-python-style/python-indentation.c b/plugins/indentation-python-style/python-indentation.c
index 227d05f..e783243 100644
--- a/plugins/indentation-python-style/python-indentation.c
+++ b/plugins/indentation-python-style/python-indentation.c
@@ -217,6 +217,8 @@ set_indentation_param_emacs (IndentPythonPlugin* plugin, const gchar *param,
 	else if (strcasecmp (param, "c-basic-offset") == 0)
 	{
 		plugin->param_statement_indentation = atoi (value);
+		ianjuta_editor_set_indentsize (IANJUTA_EDITOR (plugin->current_editor),
+		                               plugin->param_statement_indentation, NULL);
 	}
 	else if (strcasecmp (param, "tab-width") == 0)
 	{
@@ -251,6 +253,8 @@ set_indentation_param_vim (IndentPythonPlugin* plugin, const gchar *param,
 	         g_str_equal (param, "sw"))
 	{
 		plugin->param_statement_indentation = atoi (value);
+		ianjuta_editor_set_indentsize (IANJUTA_EDITOR (plugin->current_editor),
+		                               plugin->param_statement_indentation, NULL);
 	}
 	else if (g_str_equal (param, "softtabstop") ||
 	         g_str_equal (param, "sts") ||
diff --git a/plugins/sourceview/sourceview.c b/plugins/sourceview/sourceview.c
index a7f4f10..46a4934 100644
--- a/plugins/sourceview/sourceview.c
+++ b/plugins/sourceview/sourceview.c
@@ -1060,7 +1060,6 @@ ieditor_set_tab_size (IAnjutaEditor *editor, gint tabsize, GError **e)
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
 	gtk_source_view_set_tab_width(GTK_SOURCE_VIEW(sv->priv->view), tabsize);
-	gtk_source_view_set_indent_width (GTK_SOURCE_VIEW (sv->priv->view), tabsize);
 }
 
 static gboolean
@@ -1086,6 +1085,19 @@ ieditor_set_auto_indent (IAnjutaEditor *editor, gboolean auto_indent, GError **e
 									auto_indent);
 }
 
+static gint
+ieditor_get_indent_size (IAnjutaEditor *editor, GError **e)
+{
+	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
+	return gtk_source_view_get_indent_width (GTK_SOURCE_VIEW (sv->priv->view));
+}
+
+static void
+ieditor_set_indent_size (IAnjutaEditor *editor, gint indentsize, GError **e)
+{
+	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
+	gtk_source_view_set_indent_width (GTK_SOURCE_VIEW (sv->priv->view), indentsize);
+}
 
 /* Scroll to line */
 static void ieditor_goto_line(IAnjutaEditor *editor, gint line, GError **e)
@@ -1426,7 +1438,9 @@ ieditor_iface_init (IAnjutaEditorIface *iface)
 	iface->set_tabsize = ieditor_set_tab_size;
 	iface->get_use_spaces = ieditor_get_use_spaces;
 	iface->set_use_spaces = ieditor_set_use_spaces;
-    iface->set_auto_indent = ieditor_set_auto_indent;
+	iface->set_auto_indent = ieditor_set_auto_indent;
+	iface->get_indentsize = ieditor_get_indent_size;
+	iface->set_indentsize = ieditor_set_indent_size;
 	iface->goto_line = ieditor_goto_line;
 	iface->goto_position = ieditor_goto_position;
 	iface->get_text = ieditor_get_text;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]