anjuta r3559 - in trunk: . plugins/language-support-cpp-java plugins/sourceview



Author: jhs
Date: Thu Jan 31 22:49:14 2008
New Revision: 3559
URL: http://svn.gnome.org/viewvc/anjuta?rev=3559&view=rev

Log:
2008-01-31  Johannes Schmid <jhs gnome org>

	* plugins/language-support-cpp-java/cpp-java-assist.c:
	(get_iter_column), (cpp_java_assist_get_calltip_context),
	(cpp_java_assist_show_calltip), (cpp_java_assist_check),
	(on_assist_chosen), (cpp_java_assist_install):
	* plugins/language-support-cpp-java/plugin.c:
	(on_editor_char_inserted_cpp):
	Removed annoying DEBUG_PRINTs
	
	* plugins/sourceview/anjuta-view.c: (anjuta_view_key_press_event):
	* plugins/sourceview/sourceview-cell.c: (icell_get_attribute):
	* plugins/sourceview/sourceview.c: (iassist_show_tips):
	
	Fixed \"jumping\" tooltips, fixed indentation of brances

Modified:
   trunk/ChangeLog
   trunk/plugins/language-support-cpp-java/cpp-java-assist.c
   trunk/plugins/language-support-cpp-java/plugin.c
   trunk/plugins/sourceview/anjuta-view.c
   trunk/plugins/sourceview/sourceview-cell.c
   trunk/plugins/sourceview/sourceview.c

Modified: trunk/plugins/language-support-cpp-java/cpp-java-assist.c
==============================================================================
--- trunk/plugins/language-support-cpp-java/cpp-java-assist.c	(original)
+++ trunk/plugins/language-support-cpp-java/cpp-java-assist.c	Thu Jan 31 22:49:14 2008
@@ -103,7 +103,7 @@
 		ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (iter),
 										   0, NULL);
 	}
-	DEBUG_PRINT ("Iter column: %d", offset);
+	//DEBUG_PRINT ("Iter column: %d", offset);
 	return offset;
 }
 
@@ -445,14 +445,14 @@
 			return NULL;
 		if (!ianjuta_iterable_previous (iter, NULL))
 			return NULL;
-		DEBUG_PRINT ("calltip ')' brace: %f", g_timer_elapsed (timer, NULL));
+		//DEBUG_PRINT ("calltip ')' brace: %f", g_timer_elapsed (timer, NULL));
 	}
 	if (ch != '(')
 	{
 		if (!cpp_java_util_jump_to_matching_brace (iter, ')',
 												   BRACE_SEARCH_LIMIT))
 			return NULL;
-		DEBUG_PRINT ("calltip ')' brace: %f", g_timer_elapsed (timer, NULL));
+		//DEBUG_PRINT ("calltip ')' brace: %f", g_timer_elapsed (timer, NULL));
 	}
 	
 	/* Skip white spaces */
@@ -460,17 +460,17 @@
 		&& g_ascii_isspace (ianjuta_editor_cell_get_char
 								(IANJUTA_EDITOR_CELL (iter), 0, NULL)));
 
-	DEBUG_PRINT ("calltip skip whitespace: %f", g_timer_elapsed (timer, NULL));
+	//DEBUG_PRINT ("calltip skip whitespace: %f", g_timer_elapsed (timer, NULL));
 	
 	context = cpp_java_assist_get_scope_context
 		(IANJUTA_EDITOR (assist->priv->iassist), "(", iter);
 	
-	DEBUG_PRINT ("calltip get scope context: %f", g_timer_elapsed (timer, NULL));
+	//DEBUG_PRINT ("calltip get scope context: %f", g_timer_elapsed (timer, NULL));
 	
 	if (context_offset)
 	{
 		*context_offset = get_iter_column (assist, iter);
-		DEBUG_PRINT ("calltip get iter column: %f", g_timer_elapsed (timer, NULL));
+		//DEBUG_PRINT ("calltip get iter column: %f", g_timer_elapsed (timer, NULL));
 	}
 
 #ifdef DEBUG
@@ -508,7 +508,7 @@
 				gchar* white_name = g_strnfill (strlen(name) + 1, ' ');
 				
 				separator = g_strjoin (NULL, ", \n", white_name, NULL);
-				DEBUG_PRINT ("Separator: \n%s", separator);
+				//DEBUG_PRINT ("Separator: \n%s", separator);
 				
 				gchar** argv;
 				if (!args)
@@ -565,8 +565,8 @@
 	GTimer* timer = g_timer_new();
 #endif
 	
-	DEBUG_PRINT ("Autocomplete enable is: %d", autocomplete);
-	DEBUG_PRINT ("Calltips enable is: %d", calltips);
+	//DEBUG_PRINT ("Autocomplete enable is: %d", autocomplete);
+	//DEBUG_PRINT ("Calltips enable is: %d", calltips);
 	
 	if (!autocomplete && !calltips)
 		return FALSE; /* Nothing to do */
@@ -589,18 +589,18 @@
 	}
 	*/
 	
-	DEBUG_PRINT ("assist init: %f", g_timer_elapsed (timer, NULL));
+	//DEBUG_PRINT ("assist init: %f", g_timer_elapsed (timer, NULL));
 	
 	if (autocomplete)
 	{
 		pre_word = cpp_java_assist_get_pre_word (editor, iter);
-		DEBUG_PRINT ("assist pre word: %f", g_timer_elapsed (timer, NULL));
+		//DEBUG_PRINT ("assist pre word: %f", g_timer_elapsed (timer, NULL));
 		
 		scope_operator = cpp_java_assist_get_scope_operator (editor, iter);
-		DEBUG_PRINT ("assist scope operator: %f", g_timer_elapsed (timer, NULL));
+		//DEBUG_PRINT ("assist scope operator: %f", g_timer_elapsed (timer, NULL));
 		
-		DEBUG_PRINT ("Pre word: %s", pre_word);
-		DEBUG_PRINT ("Scope op: %s", scope_operator);
+		//DEBUG_PRINT ("Pre word: %s", pre_word);
+		//DEBUG_PRINT ("Scope op: %s", scope_operator);
 		
 		if (scope_operator)
 		{
@@ -641,7 +641,7 @@
 			ianjuta_editor_assist_hide_suggestions (assist->priv->iassist,
 													NULL);
 		}
-		DEBUG_PRINT ("assist autocomplete: %f", g_timer_elapsed (timer, NULL));
+		//DEBUG_PRINT ("assist autocomplete: %f", g_timer_elapsed (timer, NULL));
 	}
 #ifdef DEBUG
 	g_timer_reset (timer);
@@ -653,7 +653,7 @@
 			gint offset;
 			gchar *call_context =
 				cpp_java_assist_get_calltip_context (assist, iter, &offset);
-			DEBUG_PRINT ("get calltip context: %f", g_timer_elapsed (timer, NULL));
+			//DEBUG_PRINT ("get calltip context: %f", g_timer_elapsed (timer, NULL));
 			if (call_context)
 			{
 				shown = cpp_java_assist_show_calltip (assist, call_context,
@@ -665,7 +665,7 @@
 			}
 			g_free (call_context);
 		}
-		DEBUG_PRINT ("assist calltip: %f", g_timer_elapsed (timer, NULL));
+		//DEBUG_PRINT ("assist calltip: %f", g_timer_elapsed (timer, NULL));
 	}
 	g_object_unref (iter);
 	g_object_unref (iter_save);
@@ -707,7 +707,7 @@
 	gboolean add_space_after_func = FALSE;
 	gboolean add_brace_after_func = FALSE;
 	
-	DEBUG_PRINT ("assist-chosen: %d", selection);
+	//DEBUG_PRINT ("assist-chosen: %d", selection);
 	
 	if (assist->priv->completion_cache->cache)
 		tag = g_list_nth_data (assist->priv->completion_cache->cache,
@@ -775,7 +775,6 @@
 static void
 cpp_java_assist_install (CppJavaAssist *assist, IAnjutaEditorAssist *iassist)
 {
-	DEBUG_PRINT(__FUNCTION__);
 	g_return_if_fail (assist->priv->iassist == NULL);
 	
 	assist->priv->iassist = iassist;

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	Thu Jan 31 22:49:14 2008
@@ -1161,7 +1161,7 @@
 				ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (iter),
 												   0, NULL);
 				
-				/* DEBUG_PRINT ("Looking at char '%c'", ch); */
+				//DEBUG_PRINT ("Looking at char '%c'", ch);
 				
 				/* Break on begining of line (== end of previous line) */
 				if (iter_is_newline (iter, ch))

Modified: trunk/plugins/sourceview/anjuta-view.c
==============================================================================
--- trunk/plugins/sourceview/anjuta-view.c	(original)
+++ trunk/plugins/sourceview/anjuta-view.c	Thu Jan 31 22:49:14 2008
@@ -764,33 +764,35 @@
 	SourceviewCell* cell;
 	
 	buffer  = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-
+	
 	assist_win = view->priv->sv->priv->assist_win;
 	assist_tip = view->priv->sv->priv->assist_tip;
 	if (assist_win)
 	{
-	  if (assist_window_filter_keypress(assist_win, event->keyval))
-	  {
+		if (assist_window_filter_keypress(assist_win, event->keyval))
+		{
 			DEBUG_PRINT("key filtered: %d", event->keyval);
 			return TRUE;
-	  }
+		}
 	}
 	
 	switch (event->keyval)
-	 {
+	{
 		case GDK_Shift_L:
 		case GDK_Shift_R:
 		{
 			return TRUE;
 		}
 		default:
-		 {
+		{
 			gboolean retval = (* GTK_WIDGET_CLASS (anjuta_view_parent_class)->key_press_event)(widget, event);
 			gtk_text_buffer_get_iter_at_mark(buffer, &iter, 
-									 gtk_text_buffer_get_insert(buffer));
+											 gtk_text_buffer_get_insert(buffer));
+			/* Iter is at the position after the newly added character... */
+				gtk_text_iter_backward_char (&iter);
 			cell = sourceview_cell_new (&iter, GTK_TEXT_VIEW (view));
 			/* Handle char_added signal here */
-			if (event->keyval == GDK_Return)
+				if (event->keyval == GDK_Return)
 			{
 				g_signal_emit_by_name (G_OBJECT(view), "char_added",
 									   cell, '\n');
@@ -806,26 +808,25 @@
 									  cell, '\0');
 			}
 			else if (event->keyval == GDK_Escape || 
-							 event->keyval == GDK_Up ||
-							 event->keyval == GDK_Down)
+					 event->keyval == GDK_Up ||
+					 event->keyval == GDK_Down)
 			{
 				if (assist_tip)
-        {
+				{
 					gtk_widget_destroy (GTK_WIDGET(assist_tip));
 					g_object_unref (cell);
-          return retval;
-        }
+					return retval;
+				}
 			}
 			else if (event->keyval == GDK_Left || event->keyval == GDK_Right ||
-							 event->keyval == GDK_Up || event->keyval == GDK_Down ||
-							 event->keyval == GDK_Page_Up || event->keyval == GDK_Page_Down ||
-							 event->keyval == GDK_Begin || event->keyval == GDK_End)
+					 event->keyval == GDK_Up || event->keyval == GDK_Down ||
+					 event->keyval == GDK_Page_Up || event->keyval == GDK_Page_Down ||
+					 event->keyval == GDK_Begin || event->keyval == GDK_End)
 			{
 				/* Ignore those for char_added */
 				g_object_unref (cell);
 				return retval;
 			}
-							 
 			else
 			{
 				gchar* unistring = g_new0(gchar, 6);

Modified: trunk/plugins/sourceview/sourceview-cell.c
==============================================================================
--- trunk/plugins/sourceview/sourceview-cell.c	(original)
+++ trunk/plugins/sourceview/sourceview-cell.c	Thu Jan 31 22:49:14 2008
@@ -129,35 +129,6 @@
 {
 	SourceviewCell* cell = SOURCEVIEW_CELL(icell);
 	IAnjutaEditorAttribute attrib = IANJUTA_EDITOR_TEXT;
-	GSList* tags;
-	/* This is a kind of ugly hack. GtkSourceview does not really expose an
-		API to get the type of tag but the id holds the important stuff */
-	/*for (tags = gtk_text_iter_get_tags(cell->priv->iter); tags != NULL; tags = tags->next)
-	{
-		if (GTK_IS_SOURCE_TAG(tags->data))
-		{
-			gchar* id;
-			g_object_get(G_OBJECT(tags->data), "id", &id, NULL);
-			if (g_str_has_prefix(id, "Keyword") || g_str_has_suffix(id, "Keyword"))
-			{
-				attrib = IANJUTA_EDITOR_KEYWORD;
-				break;
-			}
-			if (g_str_has_prefix(id, "Comment") || g_str_has_suffix(id, "Comment"))
-			{
-				attrib = IANJUTA_EDITOR_COMMENT;
-				break;
-			}
-			if (g_str_has_prefix(id, "String") || g_str_has_suffix(id, "String") ||
-					g_str_equal (id, "Character Constant"))
-			{
-				attrib = IANJUTA_EDITOR_STRING;
-				break;
-			}
-			//DEBUG_PRINT("GtkSourceTag tag_style = %s", id);
-		}
-	}
-	g_slist_free(tags);*/
 	return attrib;
 }
 

Modified: trunk/plugins/sourceview/sourceview.c
==============================================================================
--- trunk/plugins/sourceview/sourceview.c	(original)
+++ trunk/plugins/sourceview/sourceview.c	Thu Jan 31 22:49:14 2008
@@ -1992,7 +1992,13 @@
 				   gint char_alignment, GError **err)
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(iassist);
-	int tip_position = ianjuta_iterable_get_position (ipos, NULL) - char_alignment;
+	GtkTextBuffer* buffer = GTK_TEXT_BUFFER (sv->priv->document);
+	GtkTextIter iter;
+	gint tip_position;
+	gtk_text_buffer_get_iter_at_mark (buffer, &iter,
+									  gtk_text_buffer_get_insert (buffer));
+	
+	tip_position = gtk_text_iter_get_offset (&iter) - char_alignment;
 	
 	if (tips == NULL)
 		return;



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