[anjuta/gnome-3-6] indentation-c-style: When removing opening bracket also remove the closing one.
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/gnome-3-6] indentation-c-style: When removing opening bracket also remove the closing one.
- Date: Wed, 31 Oct 2012 11:15:17 +0000 (UTC)
commit 0ce433bd70bd0c34a65ad905c431e0f7f7486064
Author: Carl-Anton Ingmarsson <ca ingmarsson gmail com>
Date: Thu Oct 4 01:17:09 2012 +0200
indentation-c-style: When removing opening bracket also remove the closing one.
...if the closing one is right next to the opening bracket.
https://bugzilla.gnome.org/show_bug.cgi?id=687216
plugins/indentation-c-style/indentation.c | 40 +++++++++++++++++++++++++++++
plugins/indentation-c-style/indentation.h | 9 ++++++
plugins/indentation-c-style/plugin.c | 7 +++++
3 files changed, 56 insertions(+), 0 deletions(-)
---
diff --git a/plugins/indentation-c-style/indentation.c b/plugins/indentation-c-style/indentation.c
index 177bb97..0cade36 100644
--- a/plugins/indentation-c-style/indentation.c
+++ b/plugins/indentation-c-style/indentation.c
@@ -1353,6 +1353,46 @@ cpp_java_indentation_char_added (IAnjutaEditor *editor,
g_object_unref (iter);
}
+static void
+erase_editor_blocked (IAnjutaEditor* editor,
+ IAnjutaIterable* start,
+ IAnjutaIterable* end,
+ IndentCPlugin* plugin)
+{
+ g_signal_handlers_block_by_func (editor, cpp_java_indentation_changed, plugin);
+ ianjuta_editor_erase (editor, start, end, NULL);
+ g_signal_handlers_unblock_by_func (editor, cpp_java_indentation_changed, plugin);
+}
+
+void
+cpp_java_indentation_changed (IAnjutaEditor *editor,
+ IAnjutaIterable *position,
+ gboolean added,
+ gint length,
+ gint lines,
+ const gchar *text,
+ IndentCPlugin* plugin)
+{
+ /* If autoindent is enabled*/
+ if (plugin->smart_indentation)
+ {
+ if (g_settings_get_boolean (plugin->settings, PREF_BRACE_AUTOCOMPLETION))
+ {
+ if (!added && length == 1 && (*text == '[' || *text == '('))
+ {
+ IAnjutaIterable *next;
+ gchar *next_char;
+
+ next = ianjuta_iterable_clone (position, NULL);
+ ianjuta_iterable_next (next, NULL);
+ next_char = ianjuta_editor_get_text (editor, position, next, NULL);
+ if ((*text == '[' && *next_char == ']') || (*text == '(' && *next_char == ')'))
+ erase_editor_blocked (editor, position, next, plugin);
+ }
+ }
+ }
+}
+
void
cpp_auto_indentation (IAnjutaEditor *editor,
IndentCPlugin *lang_plugin,
diff --git a/plugins/indentation-c-style/indentation.h b/plugins/indentation-c-style/indentation.h
index 38970c1..c3333c2 100644
--- a/plugins/indentation-c-style/indentation.h
+++ b/plugins/indentation-c-style/indentation.h
@@ -27,6 +27,15 @@ cpp_java_indentation_char_added (IAnjutaEditor *editor,
IndentCPlugin *plugin);
void
+cpp_java_indentation_changed (IAnjutaEditor *editor,
+ IAnjutaIterable *position,
+ gboolean added,
+ gint length,
+ gint lines,
+ const gchar *text,
+ IndentCPlugin* plugin);
+
+void
cpp_auto_indentation (IAnjutaEditor *editor,
IndentCPlugin *plugin,
IAnjutaIterable *start,
diff --git a/plugins/indentation-c-style/plugin.c b/plugins/indentation-c-style/plugin.c
index 59eed5b..08a4551 100644
--- a/plugins/indentation-c-style/plugin.c
+++ b/plugins/indentation-c-style/plugin.c
@@ -356,6 +356,10 @@ install_support (IndentCPlugin *lang_plugin)
"char-added",
G_CALLBACK (cpp_java_indentation_char_added),
lang_plugin);
+ g_signal_connect (lang_plugin->current_editor,
+ "changed",
+ G_CALLBACK (cpp_java_indentation_changed),
+ lang_plugin);
}
else
{
@@ -381,6 +385,9 @@ uninstall_support (IndentCPlugin *lang_plugin)
g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
G_CALLBACK (cpp_java_indentation_char_added),
lang_plugin);
+ g_signal_handlers_disconnect_by_func (lang_plugin->current_editor,
+ G_CALLBACK (cpp_java_indentation_changed),
+ lang_plugin);
}
lang_plugin->support_installed = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]