[gnome-builder] auto-indent: add }; for enun and struct.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] auto-indent: add }; for enun and struct.
- Date: Sat, 6 Dec 2014 03:26:14 +0000 (UTC)
commit b11ed51d6238ad91eb3b27d9307c8553669fda6a
Author: Christian Hergert <christian hergert me>
Date: Fri Dec 5 19:26:06 2014 -0800
auto-indent: add }; for enun and struct.
src/auto-indent/gb-source-auto-indenter-c.c | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/src/auto-indent/gb-source-auto-indenter-c.c b/src/auto-indent/gb-source-auto-indenter-c.c
index a6be81a..98c3e24 100644
--- a/src/auto-indent/gb-source-auto-indenter-c.c
+++ b/src/auto-indent/gb-source-auto-indenter-c.c
@@ -1104,6 +1104,32 @@ maybe_add_brace (GbSourceAutoIndenterC *c,
(gtk_text_iter_get_char (&iter) == '{') &&
(gtk_text_iter_get_char (begin) != '}'))
{
+ GtkTextIter copy = iter;
+
+ gtk_text_iter_assign (©, &iter);
+
+ if (gtk_text_iter_backward_word_start (©))
+ {
+ GtkTextIter copy2 = copy;
+
+ if (gtk_text_iter_forward_word_end (©2))
+ {
+ gchar *word;
+
+ word = gtk_text_iter_get_slice (©, ©2);
+
+ if ((g_strcmp0 (word, "enum") == 0) ||
+ (g_strcmp0 (word, "struct") == 0))
+ {
+ *cursor_offset = -2;
+ g_free (word);
+ return g_strdup ("};");
+ }
+
+ g_free (word);
+ }
+ }
+
*cursor_offset = -1;
return g_strdup ("}");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]