gtksourceview r2202 - in branches/indenters: . gtksourceview



Author: icq
Date: Thu Mar  5 12:45:38 2009
New Revision: 2202
URL: http://svn.gnome.org/viewvc/gtksourceview?rev=2202&view=rev

Log:
2009-03-05  Ignacio Casal Quinteiro  <nacho resa gmail com>

        * gtksourceview/simple-indenter.c:
        Use gint instead of gfloat for indentation level.

        * gtksourceview/gtksourceview.c:
        If we have any indentation when we press \n delete it      
        before insert the new indentation.



Modified:
   branches/indenters/ChangeLog
   branches/indenters/gtksourceview/gtksourceview.c
   branches/indenters/gtksourceview/simple-indenter.c

Modified: branches/indenters/gtksourceview/gtksourceview.c
==============================================================================
--- branches/indenters/gtksourceview/gtksourceview.c	(original)
+++ branches/indenters/gtksourceview/gtksourceview.c	Thu Mar  5 12:45:38 2009
@@ -3412,6 +3412,9 @@
 		
 		if (indent != NULL)
 		{
+			GtkTextIter copy;
+			gunichar c;
+			
 			/* Allow input methods to internally handle a key press event.
 			 * If this function returns TRUE, then no further processing should be done
 			 * for this keystroke. */
@@ -3422,9 +3425,21 @@
 			 * the cur iterm may be invalid, so get the iter again */
 			gtk_text_buffer_get_iter_at_mark (buf, &cur, mark);
 
-			/* Insert new line and auto-indent. */
-			//FIXME: Remove current indentation before insert the new one
+			copy = cur;
 			gtk_text_buffer_begin_user_action (buf);
+			
+			/* Remove current indentation before insert the new one */
+			c = gtk_text_iter_get_char (&copy);
+			while (g_unichar_isspace (c) &&
+			       c != '\n' &&
+			       c != '\r')
+			{
+				gtk_text_iter_forward_char (&copy);
+				c = gtk_text_iter_get_char (&copy);
+			}
+			
+			/* Insert new line and auto-indent. */
+			gtk_text_buffer_delete (buf, &cur, &copy);
 			gtk_text_buffer_insert (buf, &cur, "\n", 1);
 			gtk_text_buffer_insert (buf, &cur, indent, strlen (indent));
 			g_free (indent);

Modified: branches/indenters/gtksourceview/simple-indenter.c
==============================================================================
--- branches/indenters/gtksourceview/simple-indenter.c	(original)
+++ branches/indenters/gtksourceview/simple-indenter.c	Thu Mar  5 12:45:38 2009
@@ -22,7 +22,7 @@
 
 #include "simple-indenter.h"
 #include "gtksourceindenter.h"
-#include "gtksourceview-utils.h"
+#include "gtksourceindenter-utils.h"
 
 #define SIMPLE_INDENTER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object),\
 					    SIMPLE_TYPE_INDENTER, SimpleIndenterPrivate))
@@ -33,7 +33,7 @@
 
 G_DEFINE_TYPE (SimpleIndenter, simple_indenter, GTK_TYPE_SOURCE_INDENTER)
 
-static gfloat
+static gint
 simple_indenter_get_indentation_level (GtkSourceIndenter *indenter,
 				       GtkTextView *view,
 				       GtkTextIter *iter,



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