anjuta r4719 - in trunk: . plugins/language-support-cpp-java src



Author: jhs
Date: Mon Feb  9 21:34:47 2009
New Revision: 4719
URL: http://svn.gnome.org/viewvc/anjuta?rev=4719&view=rev

Log:
2009-02-09  Johannes Schmid  <jhs gnome org>

	* src/anjuta-app.c (anjuta_app_add_widget_full):
	Call set_default_position() on widgets that are never floating to avoid
	another critical warning with bug #570492
	* plugins/language-support-cpp-java/plugin.c
	(get_line_indentation_string), (set_line_indentation),
	(get_line_indentation_base), (get_line_auto_indentation),
	(on_editor_char_inserted_cpp), (on_auto_indent):
	#567606 â Auto-indentation in Anjuta gets tab indentation wrong for function paramaters

Modified:
   trunk/ChangeLog
   trunk/plugins/language-support-cpp-java/plugin.c
   trunk/src/anjuta-app.c

Modified: trunk/plugins/language-support-cpp-java/plugin.c
==============================================================================
--- trunk/plugins/language-support-cpp-java/plugin.c	(original)
+++ trunk/plugins/language-support-cpp-java/plugin.c	Mon Feb  9 21:34:47 2009
@@ -185,35 +185,37 @@
 }
 
 static gchar *
-get_line_indentation_string (IAnjutaEditor *editor, gint spaces)
+get_line_indentation_string (IAnjutaEditor *editor, gint spaces, gint line_indent_spaces)
 {
 	gint i;
+	gchar *indent_string;
 	
-	/* DEBUG_PRINT ("In %s()", __FUNCTION__); */
 	g_return_val_if_fail (spaces >= 0, NULL);
 	
+	
+	g_warning ("Spaces: %d", line_indent_spaces);
+	
 	if (spaces <= 0)
 		return NULL;
 	
 	if (USE_SPACES_FOR_INDENTATION)
 	{
-		gchar *indent_string = g_new0 (gchar, spaces + 1);
-		for (i = 0; i < spaces; i++)
+		indent_string = g_new0 (gchar, spaces + line_indent_spaces + 1);
+		for (i = 0; i < (spaces + line_indent_spaces); i++)
 			indent_string[i] = ' ';
-		return indent_string;
 	}
 	else
 	{
 		gint num_tabs = spaces / TAB_SIZE;
 		gint num_spaces = spaces % TAB_SIZE;
-		gchar *indent_string = g_new0 (gchar, num_tabs + num_spaces + 1);
+		indent_string = g_new0 (gchar, num_tabs + num_spaces + line_indent_spaces + 1);
 		
 		for (i = 0; i < num_tabs; i++)
 			indent_string[i] = '\t';
-		for (; i < num_tabs + num_spaces; i++)
+		for (; i < num_tabs + (num_spaces + line_indent_spaces); i++)
 			indent_string[i] = ' ';
-		return indent_string;
 	}
+	return indent_string;
 }
 
 /* Sets the iter to line end of previous line and TRUE is returned.
@@ -675,7 +677,8 @@
 }
 
 static gint
-set_line_indentation (IAnjutaEditor *editor, gint line_num, gint indentation)
+set_line_indentation (IAnjutaEditor *editor, gint line_num, gint indentation,
+					  gint line_indent_spaces)
 {
 	IAnjutaIterable *line_begin, *line_end, *indent_position;
 	IAnjutaIterable *current_pos;
@@ -721,9 +724,9 @@
 	//DEBUG_PRINT ("carat offset is = %d", carat_offset);
 	
 	/* Set new indentation */
-	if (indentation > 0)
+	if ((indentation + line_indent_spaces) > 0)
 	{
-		indent_string = get_line_indentation_string (editor, indentation);
+		indent_string = get_line_indentation_string (editor, indentation, line_indent_spaces);
 		nchars = g_utf8_strlen (indent_string, -1);
 		
 		/* Only indent if there is something to indent with */
@@ -822,6 +825,7 @@
 						   IAnjutaEditor *editor,
 						   gint line_num,
 						   gint *incomplete_statement,
+						   gint *line_indent_spaces,
 						   gboolean *colon_indent)
 {
 	IAnjutaIterable *iter;
@@ -834,6 +838,7 @@
 	gboolean line_checked_for_comment = FALSE;
 	
 	*incomplete_statement = -1;
+	*line_indent_spaces = 0;
 	
 	if (line_num <= 1)
 		return 0;
@@ -1077,9 +1082,9 @@
 				if (dummy_ch == '\t')
 					line_indent += TAB_SIZE;
 				else
-					line_indent++;
+					(*line_indent_spaces)++;
 			}
-			line_indent += 1;
+			(*line_indent_spaces)++;
 			line_indent += extra_indent;
 			
 			/* Although statement is incomplete at this point, we don't
@@ -1176,6 +1181,8 @@
 	}
 	g_object_unref (iter);
 	
+	g_warning ("Proposed spaces: %d", *line_indent_spaces);
+	
 	return line_indent;
 }
 
@@ -1220,7 +1227,7 @@
 
 static gint
 get_line_auto_indentation (CppJavaPlugin *plugin, IAnjutaEditor *editor,
-						   gint line)
+						   gint line, gint *line_indent_spaces)
 {
 	IAnjutaIterable *iter;
 	IAnjutaIterable *end_iter;
@@ -1242,7 +1249,9 @@
 	else
 	{
 		line_indent = get_line_indentation_base (plugin, editor, line,
-												 &incomplete_statement, &colon_indent);
+												 &incomplete_statement, 
+												 line_indent_spaces,
+												 &colon_indent);
 	}
 	
 	if (colon_indent)
@@ -1278,6 +1287,7 @@
 		if (is_iter_inside_string (iter))
 		{
 			line_indent = get_line_indentation (editor, line - 1);
+			*line_indent_spaces = 0;
 			break;
 		}
 		ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (iter),
@@ -1318,6 +1328,7 @@
 																   iter,
 																   NULL);
 				line_indent = get_line_indentation (editor, line);
+				*line_indent_spaces = 0;
 			}
 			break;
 		}
@@ -1404,12 +1415,13 @@
 		{
 			gint insert_line;
 			gint line_indent;
+			gint line_indent_spaces;
 		
 			ianjuta_document_begin_undo_action (IANJUTA_DOCUMENT(editor), NULL);
 			initialize_indentation_params (plugin);
 			insert_line = ianjuta_editor_get_lineno (editor, NULL);
-			line_indent = get_line_auto_indentation (plugin, editor, insert_line);
-			set_line_indentation (editor, insert_line, line_indent);
+			line_indent = get_line_auto_indentation (plugin, editor, insert_line, &line_indent_spaces);
+			set_line_indentation (editor, insert_line, line_indent, line_indent_spaces);
 			ianjuta_document_end_undo_action (IANJUTA_DOCUMENT(editor), NULL);
 		}
 	}
@@ -1825,10 +1837,12 @@
 	
 	for (insert_line = line_start; insert_line <= line_end; insert_line++)
 	{
+		gint line_indent_spaces = 0;
 		line_indent = get_line_auto_indentation (lang_plugin, editor,
-												 insert_line);
+												 insert_line,
+												 &line_indent_spaces);
 		/* DEBUG_PRINT ("Line indent for line %d = %d", insert_line, line_indent); */
-		set_line_indentation (editor, insert_line, line_indent);
+		set_line_indentation (editor, insert_line, line_indent, line_indent_spaces);
 	}
 	ianjuta_document_end_undo_action (IANJUTA_DOCUMENT(editor), NULL);
 }

Modified: trunk/src/anjuta-app.c
==============================================================================
--- trunk/src/anjuta-app.c	(original)
+++ trunk/src/anjuta-app.c	Mon Feb  9 21:34:47 2009
@@ -886,6 +886,10 @@
 	gtk_container_add (GTK_CONTAINER (item), widget);
     gdl_dock_add_item (GDL_DOCK (app->dock),
                        GDL_DOCK_ITEM (item), placement);
+	
+	if (locked)
+		gdl_dock_item_set_default_position(GDL_DOCK_ITEM(item), GDL_DOCK_OBJECT(app->dock));
+	
 	gtk_widget_show_all (item);
 	
 	/* Add toggle button for the widget */



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