anjuta r3514 - in trunk: . plugins plugins/sourceview



Author: jhs
Date: Thu Jan 24 11:21:05 2008
New Revision: 3514
URL: http://svn.gnome.org/viewvc/anjuta?rev=3514&view=rev

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

	* plugins/Makefile.am:
	* plugins/sourceview/anjuta-document.c:
	* plugins/sourceview/anjuta-marshal.list:
	* plugins/sourceview/anjuta-view.c: (anjuta_view_class_init),
	(anjuta_view_key_press_event):
	* plugins/sourceview/sourceview-cell.c: (icell_iface_init),
	(iiter_next), (iiter_previous), (iiter_last), (iiter_compare),
	(iiter_diff), (iiter_iface_init):
	* plugins/sourceview/sourceview.c: (on_document_char_added),
	(ieditor_goto_position), (ieditor_get_text),
	(ieditor_get_text_all), (ieditor_get_position), (ieditor_insert),
	(ieditor_erase), (ieditor_get_line_from_position),
	(ieditor_get_line_begin_position), (ieditor_get_line_end_position),
	(ieditor_get_position_from_offset), (ieditor_get_start_position),
	(ieditor_get_end_position), (ieditor_goto_start),
	(ieditor_goto_end), (ieditor_iface_init), (iconvert_to_upper),
	(iconvert_to_lower), (iindic_set), (iassist_suggest),
	(iassist_show_tips):
	
	Implemented new iterators interface in sourceview editor and
	re-enabled it.

Modified:
   trunk/ChangeLog
   trunk/plugins/Makefile.am
   trunk/plugins/sourceview/anjuta-document.c
   trunk/plugins/sourceview/anjuta-marshal.list
   trunk/plugins/sourceview/anjuta-view.c
   trunk/plugins/sourceview/sourceview-cell.c
   trunk/plugins/sourceview/sourceview.c

Modified: trunk/plugins/Makefile.am
==============================================================================
--- trunk/plugins/Makefile.am	(original)
+++ trunk/plugins/Makefile.am	Thu Jan 24 11:21:05 2008
@@ -31,9 +31,10 @@
 	devhelp \
 	profiler \
 	language-manager \
-	symbol-db
+	symbol-db \
+	sourceview
+
 # indent
-# sourceview
 
 ## This a temporary measure to insure anjuta does not crash due to old plugin.
 ## Make sure there are no old plugins left

Modified: trunk/plugins/sourceview/anjuta-document.c
==============================================================================
--- trunk/plugins/sourceview/anjuta-document.c	(original)
+++ trunk/plugins/sourceview/anjuta-document.c	Thu Jan 24 11:21:05 2008
@@ -107,7 +107,6 @@
 	LOADED,
 	SAVING,
 	SAVED,
-	CHAR_ADDED,
 	LAST_SIGNAL
 };
 

Modified: trunk/plugins/sourceview/anjuta-marshal.list
==============================================================================
--- trunk/plugins/sourceview/anjuta-marshal.list	(original)
+++ trunk/plugins/sourceview/anjuta-marshal.list	Thu Jan 24 11:21:05 2008
@@ -7,4 +7,4 @@
 VOID:UINT64,UINT64
 VOID:BOOLEAN,POINTER
 VOID:BOXED,BOXED
-VOID:INT,CHAR
+VOID:OBJECT,CHAR

Modified: trunk/plugins/sourceview/anjuta-view.c
==============================================================================
--- trunk/plugins/sourceview/anjuta-view.c	(original)
+++ trunk/plugins/sourceview/anjuta-view.c	Thu Jan 24 11:21:05 2008
@@ -221,7 +221,7 @@
 			      G_SIGNAL_RUN_LAST,
 			      G_STRUCT_OFFSET (AnjutaViewClass, char_added),
 			      NULL, NULL,
-			      anjuta_marshal_VOID__INT_CHAR,
+			      anjuta_marshal_VOID__OBJECT_CHAR,
 			      G_TYPE_NONE,
 			      2,
 				  G_TYPE_INT,
@@ -758,16 +758,12 @@
 {
 	GtkTextBuffer *buffer;
 	AnjutaView* view = ANJUTA_VIEW(widget);
-	gint pos;
 	GtkTextIter iter;
 	AssistWindow* assist_win;
 	AssistTip* assist_tip;
+	SourceviewCell* cell;
 	
 	buffer  = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-	gtk_text_buffer_get_iter_at_mark(buffer, &iter, 
-									 gtk_text_buffer_get_insert(buffer));
-
-	pos = gtk_text_iter_get_offset(&iter);
 
 	assist_win = view->priv->sv->priv->assist_win;
 	assist_tip = view->priv->sv->priv->assist_tip;
@@ -790,22 +786,24 @@
 		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));
+			cell = sourceview_cell_new (&iter, GTK_TEXT_VIEW (view));
 			/* Handle char_added signal here */
 			if (event->keyval == GDK_Return)
 			{
 				g_signal_emit_by_name (G_OBJECT(view), "char_added",
-									   pos, '\n');
+									   cell, '\n');
 			}
 			else if (event->keyval == GDK_Tab)
 			{
 				g_signal_emit_by_name (G_OBJECT(view), "char_added",
-									   pos, '\t');
+									   cell, '\t');
 			}
 			else if (event->keyval == GDK_BackSpace)
 			{
 				g_signal_emit_by_name(G_OBJECT(view), "char_added", 
-									  pos, '\0');
+									  cell, '\0');
 			}
 			else if (event->keyval == GDK_Escape || 
 							 event->keyval == GDK_Up ||
@@ -814,6 +812,7 @@
 				if (assist_tip)
         {
 					gtk_widget_destroy (GTK_WIDGET(assist_tip));
+					g_object_unref (cell);
           return retval;
         }
 			}
@@ -823,6 +822,7 @@
 							 event->keyval == GDK_Begin || event->keyval == GDK_End)
 			{
 				/* Ignore those for char_added */
+				g_object_unref (cell);
 				return retval;
 			}
 							 
@@ -838,7 +838,11 @@
 					if (string != NULL && read == 1 && written == 1)
 					{
 						g_signal_emit_by_name (G_OBJECT(view), "char_added",
-											   pos, string[0]);
+											   cell, string[0]);
+					}
+					else
+					{
+						g_object_unref (cell);
 					}
 					g_free(string);
 				}

Modified: trunk/plugins/sourceview/sourceview-cell.c
==============================================================================
--- trunk/plugins/sourceview/sourceview-cell.c	(original)
+++ trunk/plugins/sourceview/sourceview-cell.c	Thu Jan 24 11:21:05 2008
@@ -113,13 +113,6 @@
 	return g_unichar_to_utf8(gtk_text_iter_get_char(cell->priv->iter), NULL);
 }
 
-static gint
-icell_get_line (IAnjutaEditorCell* icell, GError** e)
-{
-  SourceviewCell* cell = SOURCEVIEW_CELL(icell);
-  return gtk_text_iter_get_line (cell->priv->iter);
-}
-
 static gchar
 icell_get_char(IAnjutaEditorCell* icell, gint index, GError** e)
 {
@@ -175,7 +168,6 @@
 	iface->get_char = icell_get_char;
 	iface->get_length = icell_get_length;
 	iface->get_attribute = icell_get_attribute;
-  iface->get_line = icell_get_line;
 }
 
 static
@@ -243,12 +235,7 @@
 {
 	SourceviewCell* cell = SOURCEVIEW_CELL(iter);
 
-	if (gtk_text_iter_forward_char(cell->priv->iter))
-	{
-		return TRUE;
-	}
-	else
-		return FALSE;
+	return gtk_text_iter_forward_char(cell->priv->iter);
 }
 
 static gboolean
@@ -256,12 +243,7 @@
 {
 	SourceviewCell* cell = SOURCEVIEW_CELL(iter);
 	
-	if (gtk_text_iter_backward_char(cell->priv->iter))
-	{
-		return TRUE;
-	}
-	else
-		return FALSE;
+	return gtk_text_iter_backward_char(cell->priv->iter);
 }
 
 static gboolean
@@ -270,7 +252,6 @@
 	SourceviewCell* cell = SOURCEVIEW_CELL(iter);
 
 	gtk_text_iter_forward_to_end(cell->priv->iter);
-	iiter_previous (iter, NULL);
 	return TRUE;
 }
 
@@ -332,6 +313,24 @@
 	cell->priv->iter = gtk_text_iter_copy (src_cell->priv->iter);
 }
 
+static gint
+iiter_compare (IAnjutaIterable *iter, IAnjutaIterable *other_iter, GError **e)
+{
+	SourceviewCell* cell = SOURCEVIEW_CELL(iter);
+	SourceviewCell* other_cell = SOURCEVIEW_CELL(other_iter);
+	
+  return gtk_text_iter_compare (cell->priv->iter, other_cell->priv->iter);
+}
+
+static gint
+iiter_diff (IAnjutaIterable *iter, IAnjutaIterable *other_iter, GError **e)
+{
+	SourceviewCell* cell = SOURCEVIEW_CELL(iter);
+	SourceviewCell* other_cell = SOURCEVIEW_CELL(other_iter);
+	return (gtk_text_iter_get_offset (cell->priv->iter) 
+					- gtk_text_iter_get_offset (other_cell->priv->iter));
+}
+
 static void
 iiter_iface_init(IAnjutaIterableIface* iface)
 {
@@ -345,6 +344,8 @@
 	iface->get_length = iiter_get_length;
 	iface->assign = iiter_assign;
 	iface->clone = iiter_clone;
+	iface->diff = iiter_diff;
+	iface->compare = iiter_compare;
 }
 
 

Modified: trunk/plugins/sourceview/sourceview.c
==============================================================================
--- trunk/plugins/sourceview/sourceview.c	(original)
+++ trunk/plugins/sourceview/sourceview.c	Thu Jan 24 11:21:05 2008
@@ -119,7 +119,7 @@
 }
 
 /* Called when a character is added */
-static void on_document_char_added(AnjutaView* view, gint pos,
+static void on_document_char_added(AnjutaView* view, IAnjutaIterable* pos,
 								   gchar ch,
 								   Sourceview* sv)
 {
@@ -773,46 +773,21 @@
 }
 
 /* Scroll to position */
-static void ieditor_goto_position(IAnjutaEditor *editor, gint position, GError **e)
+static void ieditor_goto_position(IAnjutaEditor *editor, IAnjutaIterable* icell,
+								  GError **e)
 {
-	GtkTextIter iter;
-	
+	SourceviewCell* cell = SOURCEVIEW_CELL (icell);
+	GtkTextIter* iter = sourceview_cell_get_iter (cell);
 	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
-	gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(sv->priv->document),
-									   &iter, position);
-	gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (sv->priv->document), &iter);
+	gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (sv->priv->document), iter);
 	gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (sv->priv->view),
-								  &iter, 0, FALSE, 0, 0);
-}
-
-/* Return a newly allocated pointer containing the whole text */
-static gchar* ieditor_get_text(IAnjutaEditor* editor, gint position,
-							   gint length, GError **e)
-{
-	GtkTextIter start_iter;
-	GtkTextIter end_iter;
-	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
-	
-	g_return_val_if_fail (position >= 0, NULL);
-	if (length == 0)
-		return NULL;
-
-	gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(sv->priv->document),
-								   &start_iter, position);
-	if (length > 0)
-		gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(sv->priv->document),
-										   &end_iter, position + length);
-	else
-		gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(sv->priv->document),
-										   &end_iter, -1);
-	return gtk_text_buffer_get_slice(GTK_TEXT_BUFFER(sv->priv->document),
-									&start_iter, &end_iter, TRUE);
+								  iter, 0, FALSE, 0, 0);
 }
 
 /* Return a newly allocated pointer containing the whole text */
-static gchar* ieditor_get_text_iter (IAnjutaEditor* editor, 
-									 IAnjutaIterable* start,
-									 IAnjutaIterable* end, GError **e)
+static gchar* ieditor_get_text (IAnjutaEditor* editor, 
+								IAnjutaIterable* start,
+								IAnjutaIterable* end, GError **e)
 {
 	GtkTextIter* start_iter;
 	GtkTextIter* end_iter;
@@ -820,31 +795,29 @@
 	
 	start_iter = sourceview_cell_get_iter (SOURCEVIEW_CELL (start));
 	end_iter = sourceview_cell_get_iter (SOURCEVIEW_CELL (end));
-	/* Include end character like stated in the docs */
-	if (!gtk_text_iter_is_end(end_iter))
-	{
-		gtk_text_iter_forward_char (end_iter);
-	}
 	
 	return gtk_text_buffer_get_slice(GTK_TEXT_BUFFER(sv->priv->document),
 									start_iter, end_iter, TRUE);
 }
 
-/* Get cursor position */
-static gint ieditor_get_position(IAnjutaEditor* editor, GError **e)
+static gchar*
+ieditor_get_text_all (IAnjutaEditor* edit, GError **e)
 {
-	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
-	GtkTextBuffer* buffer = GTK_TEXT_BUFFER(sv->priv->document);
-	GtkTextIter iter;
+	GtkTextIter start_iter;
+	GtkTextIter end_iter;
+	Sourceview* sv = ANJUTA_SOURCEVIEW(edit);
+	GtkTextBuffer* buffer = GTK_TEXT_BUFFER (sv->priv->document);
 	
-	gtk_text_buffer_get_iter_at_mark(buffer, &iter, 
-									 gtk_text_buffer_get_insert(buffer));
-
-	return gtk_text_iter_get_offset(&iter);
+	gtk_text_buffer_get_iter_at_offset (buffer, &start_iter, 0);
+	gtk_text_buffer_get_iter_at_offset (buffer, &end_iter, -1);
+	
+	return gtk_text_buffer_get_slice(GTK_TEXT_BUFFER(sv->priv->document),
+									&start_iter, &end_iter, TRUE);
 }
 
+/* Get cursor position */
 static IAnjutaIterable*
-ieditor_get_position_iter (IAnjutaEditor* editor, GError **e)
+ieditor_get_position (IAnjutaEditor* editor, GError **e)
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
 	GtkTextBuffer* buffer = GTK_TEXT_BUFFER(sv->priv->document);
@@ -903,16 +876,15 @@
 }
 
 /* Insert text at position */
-static void ieditor_insert(IAnjutaEditor *editor, gint position,
+static void ieditor_insert(IAnjutaEditor *editor, IAnjutaIterable* icell,
 							   const gchar* text, gint length, GError **e)
 {
-	GtkTextIter iter;
+	SourceviewCell* cell = SOURCEVIEW_CELL (icell);
+	GtkTextIter* iter = sourceview_cell_get_iter (cell);
 	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
 	
-	gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(sv->priv->document),
-									   &iter, position);
 	gtk_text_buffer_insert(GTK_TEXT_BUFFER(sv->priv->document),
-						   &iter, text, length);
+						   iter, text, length);
 }
 
 /* Append text to buffer */
@@ -928,23 +900,17 @@
 						   &iter, text, length);
 }
 
-static void ieditor_erase(IAnjutaEditor* editor, gint position, gint length, GError **e)
+static void ieditor_erase(IAnjutaEditor* editor, IAnjutaIterable* istart_cell, 
+						  IAnjutaIterable* iend_cell, GError **e)
 {
-	GtkTextIter start, end;
+	SourceviewCell* start_cell = SOURCEVIEW_CELL (istart_cell);
+	GtkTextIter* start = sourceview_cell_get_iter (start_cell);
+	SourceviewCell* end_cell = SOURCEVIEW_CELL (iend_cell);
+	GtkTextIter* end = sourceview_cell_get_iter (end_cell);
 	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
 	GtkTextBuffer* buffer = GTK_TEXT_BUFFER(sv->priv->document);
-
-	g_return_if_fail (position >= 0);
-	if (length == 0)
-		return;
-
-	gtk_text_buffer_get_iter_at_offset(buffer, &start, position);
-
-	if (length > 0)
-		gtk_text_buffer_get_iter_at_offset(buffer, &end, position + length);
-	else
-		gtk_text_buffer_get_iter_at_offset(buffer, &end, -1);
-	gtk_text_buffer_delete (buffer, &start, &end);
+	
+	gtk_text_buffer_delete (buffer, start, end);
 }
 
 static void ieditor_erase_all(IAnjutaEditor *editor, GError **e)
@@ -983,47 +949,40 @@
 
 /* Convert from position to line */
 static gint ieditor_get_line_from_position(IAnjutaEditor *editor, 
-										   gint position, GError **e)
+										   IAnjutaIterable* icell, GError **e)
 {
-	GtkTextIter iter;
-	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
-	gint line;
-	gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(sv->priv->document),
-									   &iter, position);
-
-	line = gtk_text_iter_get_line(&iter) + 1;
-	/* line = line ? line - 1 : 0; */
-	
-	return line;
+	SourceviewCell* cell = SOURCEVIEW_CELL (icell);
+	GtkTextIter* iter = sourceview_cell_get_iter (cell);
+	return LINE_TO_LOCATION (gtk_text_iter_get_line(iter));
 }
 
-static gint ieditor_get_line_begin_position(IAnjutaEditor *editor,
+static IAnjutaIterable* ieditor_get_line_begin_position(IAnjutaEditor *editor,
 											gint line, GError **e)
 {
 	GtkTextIter iter;
 	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
 	
 	gtk_text_buffer_get_iter_at_line_offset (GTK_TEXT_BUFFER(sv->priv->document),
-											 &iter, line - 1, 0);
-	return gtk_text_iter_get_offset (&iter);
+											 &iter, LOCATION_TO_LINE (line), 0);
+	return IANJUTA_ITERABLE (sourceview_cell_new (&iter, GTK_TEXT_VIEW (sv->priv->view)));
 }
 
-static gint ieditor_get_line_end_position(IAnjutaEditor *editor,
+static IAnjutaIterable* ieditor_get_line_end_position(IAnjutaEditor *editor,
 											gint line, GError **e)
 {
 	GtkTextIter iter;
 	Sourceview* sv = ANJUTA_SOURCEVIEW(editor);
 	
-	gtk_text_buffer_get_iter_at_line(GTK_TEXT_BUFFER(sv->priv->document),
-									 &iter, line - 1);
+	gtk_text_buffer_get_iter_at_line_offset (GTK_TEXT_BUFFER(sv->priv->document),
+											 &iter, LOCATION_TO_LINE (line), 0);
 	/* If iter is not at line end, move it */
 	if (!gtk_text_iter_ends_line(&iter))
 		gtk_text_iter_forward_to_line_end (&iter);
-	return gtk_text_iter_get_offset(&iter);
+	return IANJUTA_ITERABLE (sourceview_cell_new (&iter, GTK_TEXT_VIEW (sv->priv->view)));
 }
 
 static IAnjutaIterable*
-ieditor_get_cell_iter(IAnjutaEditor* edit, gint position, GError** e)
+ieditor_get_position_from_offset(IAnjutaEditor* edit, gint position, GError** e)
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(edit);
 	GtkTextBuffer* buffer = GTK_TEXT_BUFFER(sv->priv->document);
@@ -1036,6 +995,58 @@
 	return IANJUTA_ITERABLE(cell);
 }
 
+static IAnjutaIterable*
+ieditor_get_start_position (IAnjutaEditor* edit, GError** e)
+{
+	Sourceview* sv = ANJUTA_SOURCEVIEW(edit);
+	GtkTextBuffer* buffer = GTK_TEXT_BUFFER(sv->priv->document);
+	GtkTextIter iter;
+	SourceviewCell* cell;
+	
+	gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
+	cell = sourceview_cell_new(&iter, GTK_TEXT_VIEW(sv->priv->view));
+	
+	return IANJUTA_ITERABLE(cell);
+}
+
+static IAnjutaIterable*
+ieditor_get_end_position (IAnjutaEditor* edit, GError** e)
+{
+	Sourceview* sv = ANJUTA_SOURCEVIEW(edit);
+	GtkTextBuffer* buffer = GTK_TEXT_BUFFER(sv->priv->document);
+	GtkTextIter iter;
+	SourceviewCell* cell;
+	
+	gtk_text_buffer_get_iter_at_offset(buffer, &iter, -1);
+	cell = sourceview_cell_new(&iter, GTK_TEXT_VIEW(sv->priv->view));
+	
+	return IANJUTA_ITERABLE(cell);
+}
+
+static void
+ieditor_goto_start (IAnjutaEditor* edit, GError** e)
+{
+	Sourceview* sv = ANJUTA_SOURCEVIEW(edit);
+	GtkTextIter iter;
+	gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (sv->priv->document),
+										&iter, 0);
+	gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (sv->priv->document), &iter);
+	gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (sv->priv->view),
+								  &iter, 0, FALSE, 0, 0);  
+}
+
+static void
+ieditor_goto_end (IAnjutaEditor* edit, GError** e)
+{
+	Sourceview* sv = ANJUTA_SOURCEVIEW(edit);
+	GtkTextIter iter;
+	gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (sv->priv->document),
+										&iter, -1);
+	gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (sv->priv->document), &iter);
+	gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (sv->priv->view),
+								  &iter, 0, FALSE, 0, 0); 
+}
+
 static void
 ieditor_iface_init (IAnjutaEditorIface *iface)
 {
@@ -1047,9 +1058,8 @@
 	iface->goto_line = ieditor_goto_line;
 	iface->goto_position = ieditor_goto_position;
 	iface->get_text = ieditor_get_text;
-	iface->get_text_iter = ieditor_get_text_iter;
+	iface->get_text_all = ieditor_get_text_all;
 	iface->get_position = ieditor_get_position;
-	iface->get_position_iter = ieditor_get_position_iter;
 	iface->get_lineno = ieditor_get_lineno;
 	iface->get_length = ieditor_get_length;
 	iface->get_current_word = ieditor_get_current_word;
@@ -1061,9 +1071,13 @@
 	iface->get_overwrite = ieditor_get_overwrite;
 	iface->set_popup_menu = ieditor_set_popup_menu;
 	iface->get_line_from_position = ieditor_get_line_from_position;
-	iface->get_cell_iter = ieditor_get_cell_iter;
 	iface->get_line_begin_position = ieditor_get_line_begin_position;
-	iface->get_line_end_position = ieditor_get_line_end_position;	
+	iface->get_line_end_position = ieditor_get_line_end_position;
+	iface->goto_start = ieditor_goto_start;
+	iface->goto_end = ieditor_goto_end;
+	iface->get_position_from_offset = ieditor_get_position_from_offset;
+	iface->get_start_position = ieditor_get_start_position;
+	iface->get_end_position = ieditor_get_end_position;
 }
 
 /* Return true if editor can redo */
@@ -1378,32 +1392,40 @@
 /* IAnjutaEditorConvert Interface */
 
 static void
-iconvert_to_upper(IAnjutaEditorConvert* edit, gint start_pos, gint end_pos, GError** e)
+iconvert_to_upper(IAnjutaEditorConvert* edit, IAnjutaIterable *start_position,
+				  IAnjutaIterable *end_position, GError** e)
 {
-	gchar *buffer;
-	
-	buffer = iselect_get(IANJUTA_EDITOR_SELECTION(edit), e);
-	if (buffer)
-	{
-		buffer = g_utf8_strup(buffer, g_utf8_strlen(buffer, -1));
-		iselect_replace(IANJUTA_EDITOR_SELECTION(edit), buffer, g_utf8_strlen(buffer,  -1), e);	
-		g_free(buffer);
-	}
-
+  Sourceview* sv = ANJUTA_SOURCEVIEW(edit);
+  GtkTextBuffer* buffer = GTK_TEXT_BUFFER (sv->priv->document);
+  GtkTextIter* start = sourceview_cell_get_iter (SOURCEVIEW_CELL (start_position));
+  GtkTextIter* end = sourceview_cell_get_iter (SOURCEVIEW_CELL (end_position));
+	
+  gchar* text_buffer = gtk_text_buffer_get_text (buffer,
+											start, end, TRUE);
+  gtk_text_buffer_begin_user_action (buffer);
+  gtk_text_buffer_delete (buffer, start, end);
+  gtk_text_buffer_insert (buffer, start, g_utf8_strup (text_buffer, -1), -1);
+  gtk_text_buffer_end_user_action (buffer);
+  g_free (text_buffer);
 }
 
 static void
-iconvert_to_lower(IAnjutaEditorConvert* edit, gint start_pos, gint end_pos, GError** e)
-{
-	gchar *buffer;
-	
-	buffer = iselect_get(IANJUTA_EDITOR_SELECTION(edit), e);
-	if (buffer)
-	{
-		buffer = g_utf8_strdown(buffer, g_utf8_strlen(buffer, -1));
-		iselect_replace(IANJUTA_EDITOR_SELECTION(edit), buffer, g_utf8_strlen(buffer,  -1), e);	
-		g_free(buffer);
-	}
+iconvert_to_lower(IAnjutaEditorConvert* edit, IAnjutaIterable *start_position,
+				  IAnjutaIterable *end_position, GError** e)
+{
+  Sourceview* sv = ANJUTA_SOURCEVIEW(edit);
+  GtkTextBuffer* buffer = GTK_TEXT_BUFFER (sv->priv->document);
+  GtkTextIter* start = sourceview_cell_get_iter (SOURCEVIEW_CELL (start_position));
+  GtkTextIter* end = sourceview_cell_get_iter (SOURCEVIEW_CELL (end_position));
+	
+  gchar* text_buffer = gtk_text_buffer_get_text (buffer,
+											start, end, TRUE);
+  gtk_text_buffer_begin_user_action (buffer);
+  gtk_text_buffer_delete (buffer, start, end);
+  gtk_text_buffer_insert (buffer, start, g_utf8_strdown (text_buffer, -1), -1);
+  gtk_text_buffer_end_user_action (buffer);
+  g_free (text_buffer);
+
 }
 
 static void
@@ -1589,11 +1611,10 @@
 }
 
 static void
-iindic_set (IAnjutaIndicable *indic, gint begin_location, gint end_location, 
+iindic_set (IAnjutaIndicable *indic, IAnjutaIterable* ibegin, IAnjutaIterable *iend, 
             IAnjutaIndicableIndicator indicator, GError **e)
 {
 	GtkTextTag *tag = NULL;
-	GtkTextIter start, end;
 	Sourceview* sv = ANJUTA_SOURCEVIEW(indic);
 	
 	switch (indicator)
@@ -1611,12 +1632,9 @@
 			return;
 	}
 
-	gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER(sv->priv->document), 
-	                                    &start, begin_location);
-	gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER(sv->priv->document), 
-	                                    &end, end_location);
 	gtk_text_buffer_apply_tag (GTK_TEXT_BUFFER(sv->priv->document), tag, 
-	                           &start, &end);
+	                           sourceview_cell_get_iter (SOURCEVIEW_CELL (ibegin)),
+							   sourceview_cell_get_iter (SOURCEVIEW_CELL (iend)));
 }
 
 static void
@@ -1920,7 +1938,7 @@
 }
 
 static void
-iassist_suggest (IAnjutaEditorAssist *iassist, GList* choices, int position,
+iassist_suggest (IAnjutaEditorAssist *iassist, GList* choices, IAnjutaIterable* ipos,
 				 int char_alignment, GError **err)
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(iassist);
@@ -1935,7 +1953,7 @@
 		if (!sv->priv->assist_win)
 		{
 			sv->priv->assist_win = assist_window_new(GTK_TEXT_VIEW(sv->priv->view), NULL,
-													 position);
+													 ianjuta_iterable_get_position (ipos, NULL));
 			g_signal_connect(G_OBJECT(sv->priv->assist_win), "destroy", 
 								 G_CALLBACK(on_assist_window_destroyed), sv);
 			g_signal_connect(G_OBJECT(sv->priv->assist_win), "chosen", 
@@ -1971,11 +1989,11 @@
 }
 
 static void 
-iassist_show_tips (IAnjutaEditorAssist *iassist, GList* tips, gint position,
+iassist_show_tips (IAnjutaEditorAssist *iassist, GList* tips, IAnjutaIterable* ipos,
 				   gint char_alignment, GError **err)
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(iassist);
-	int tip_position = position - char_alignment;
+	int tip_position = ianjuta_iterable_get_position (ipos, NULL) - char_alignment;
 	
 	if (tips == NULL)
 		return;



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