gtksourceview r2193 - in branches/indenters: . gtksourceview
- From: icq svn gnome org
- To: svn-commits-list gnome org
- Subject: gtksourceview r2193 - in branches/indenters: . gtksourceview
- Date: Sun, 1 Mar 2009 11:20:29 +0000 (UTC)
Author: icq
Date: Sun Mar 1 11:20:29 2009
New Revision: 2193
URL: http://svn.gnome.org/viewvc/gtksourceview?rev=2193&view=rev
Log:
2009-03-01 Ignacio Casal Quinteiro <nacho resa gmail com>
* gtksourceview/c-indenter.c:
Get the right indent level when having something like:
if (true)
hello ();
* gtksourceview/gtksourceview.c:
Fix a false positive when checking whitespaces.
Modified:
branches/indenters/ChangeLog
branches/indenters/gtksourceview/c-indenter.c
branches/indenters/gtksourceview/gtksourceview.c
Modified: branches/indenters/gtksourceview/c-indenter.c
==============================================================================
--- branches/indenters/gtksourceview/c-indenter.c (original)
+++ branches/indenters/gtksourceview/c-indenter.c Sun Mar 1 11:20:29 2009
@@ -114,6 +114,29 @@
return is_case;
}
+static gboolean
+find_char_inline (GtkTextIter *iter,
+ gunichar c)
+{
+ gunichar f;
+ gboolean found = FALSE;
+
+ f = gtk_text_iter_get_char (iter);
+
+ while (f != c && gtk_text_iter_get_line_offset (iter) != 0)
+ {
+ gtk_text_iter_backward_char (iter);
+ f = gtk_text_iter_get_char (iter);
+ }
+
+ if (f == c)
+ {
+ found = TRUE;
+ }
+
+ return found;
+}
+
static gfloat
c_indenter_get_indentation_level (GtkSourceIndenter *indenter,
GtkTextView *view,
@@ -163,45 +186,59 @@
}
else if (c == ';')
{
- gfloat current_indent;
+ GtkTextIter copy;
+
+ copy = iter;
- current_indent = gtk_source_indenter_get_amount_indents (view,
- &iter);
-
/*
* We have to check that we are not in something like:
* hello (eoeo,
* eoeo);
*/
- gtk_text_iter_backward_char (&iter);
- c = gtk_text_iter_get_char (&iter);
- if (c == ')' && gtk_source_indenter_find_open_char (&iter, '(', ')', FALSE))
+ if (find_char_inline (©, ')') &&
+ gtk_source_indenter_find_open_char (©, '(', ')', FALSE))
{
amount = gtk_source_indenter_get_amount_indents (view,
- &iter);
+ ©);
+
+ /*
+ * We have to check if we are in just one line block
+ */
+ while (!gtk_text_iter_ends_line (©) &&
+ gtk_text_iter_backward_char (©))
+ continue;
+
+ gtk_text_iter_backward_char (©);
+
+ if (match_regexes (©))
+ {
+ gtk_source_indenter_find_open_char (©, '(', ')', FALSE);
+
+ amount = gtk_source_indenter_get_amount_indents (view,
+ ©);
+ }
}
else
{
+ amount = gtk_source_indenter_get_amount_indents (view,
+ &iter);
+
/*
* We have to check if we are in just one line block
*/
while (!gtk_text_iter_ends_line (&iter) &&
gtk_text_iter_backward_char (&iter))
continue;
-
+
gtk_text_iter_backward_char (&iter);
-
+
if (match_regexes (&iter))
{
gtk_source_indenter_find_open_char (&iter, '(', ')', FALSE);
-
+
amount = gtk_source_indenter_get_amount_indents (view,
&iter);
}
- else
- {
- amount = current_indent;
- }
}
}
else if (c == '}')
Modified: branches/indenters/gtksourceview/gtksourceview.c
==============================================================================
--- branches/indenters/gtksourceview/gtksourceview.c (original)
+++ branches/indenters/gtksourceview/gtksourceview.c Sun Mar 1 11:20:29 2009
@@ -3171,6 +3171,9 @@
gtk_text_buffer_delete_mark (buf, mark);
}
+/*
+ * This function tries to match the same as a regular expresion like: ^\s*
+ */
static gboolean
check_whitespaces (GtkTextIter *cur)
{
@@ -3186,7 +3189,7 @@
/*
* Check the first char is not space
*/
- if (!g_unichar_isspace (c))
+ if (gtk_text_iter_get_line_offset (cur) == 0)
return TRUE;
while (gtk_text_iter_compare (&start, cur) < 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]