anjuta r3516 - in trunk: . plugins/editor



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

Log:
	* plugins/editor/text-editor-iterable.c: (iiter_get_length):
	* plugins/editor/text_editor.c: (itext_editor_get_text_all),
	(itext_editor_get_text), (itext_editor_get_length): Fixes implementations
	of ianjuta_editor_get_length(), ianjuta_iterable_get_length() and
	ianjuta_editor_get_text_all(). Current Search-replace and symbol-db
	should work now.


Modified:
   trunk/ChangeLog
   trunk/plugins/editor/text-editor-iterable.c
   trunk/plugins/editor/text_editor.c

Modified: trunk/plugins/editor/text-editor-iterable.c
==============================================================================
--- trunk/plugins/editor/text-editor-iterable.c	(original)
+++ trunk/plugins/editor/text-editor-iterable.c	Thu Jan 24 11:42:05 2008
@@ -619,18 +619,26 @@
 static gint
 iiter_get_length (IAnjutaIterable* iter, GError** e)
 {
-	gchar *data;
-	gint length;
+	gint byte_length;
 	
 	TextEditorCell* cell = TEXT_EDITOR_CELL(iter);
 	
 	/* FIXME: Find a more optimal solution */
-	data = (gchar *) aneditor_command (TEXT_EDITOR
-									   (cell->priv->editor)->editor_id,
-									   ANE_GETTEXTRANGE, 0, -1);
-	length = g_utf8_strlen (data, -1);
-	g_free (data);
-	return length;
+	byte_length = scintilla_send_message (SCINTILLA (cell->priv->editor->scintilla),
+										  SCI_GETLENGTH, 0, 0);
+	if (byte_length > 0)
+	{
+		gchar *data;
+		gint char_length;
+		
+		data = (gchar *) aneditor_command (TEXT_EDITOR
+										   (cell->priv->editor)->editor_id,
+										   ANE_GETTEXTRANGE, 0, byte_length);
+		char_length = g_utf8_strlen (data, -1);
+		g_free (data);
+		return char_length;
+	}
+	return 0;
 }
 
 static IAnjutaIterable *

Modified: trunk/plugins/editor/text_editor.c
==============================================================================
--- trunk/plugins/editor/text_editor.c	(original)
+++ trunk/plugins/editor/text_editor.c	Thu Jan 24 11:42:05 2008
@@ -2265,7 +2265,13 @@
 itext_editor_get_text_all (IAnjutaEditor *editor, GError **e)
 {
 	TextEditor *te = TEXT_EDITOR (editor);
-	return (gchar *) aneditor_command (te->editor_id, ANE_GETTEXTRANGE, 0, -1);
+	gint length = scintilla_send_message (SCINTILLA (te->scintilla),
+										  SCI_GETLENGTH, 0, 0);
+	if (length > 0)
+		return (gchar *) aneditor_command (te->editor_id, ANE_GETTEXTRANGE,
+										   0, length);
+	else
+		return NULL;
 }
 
 static gchar*
@@ -2276,7 +2282,8 @@
 	gint start_pos = text_editor_cell_get_position (TEXT_EDITOR_CELL (begin));
 	gint end_pos = text_editor_cell_get_position (TEXT_EDITOR_CELL (end));
 	TextEditor *te = TEXT_EDITOR (editor);
-	data =	(gchar *) aneditor_command (te->editor_id, ANE_GETTEXTRANGE, start_pos, end_pos);
+	data =	(gchar *) aneditor_command (te->editor_id, ANE_GETTEXTRANGE,
+										  start_pos, end_pos);
 	return data;
 }
 
@@ -2308,15 +2315,22 @@
 static gint
 itext_editor_get_length (IAnjutaEditor *editor, GError **e)
 {
+	TextEditor *te = TEXT_EDITOR (editor);
+	
 	/* FIXME: Find a more optimal solution */
-	gint char_position;
-	gchar *data =
-		(gchar *) aneditor_command (TEXT_EDITOR (editor)->editor_id,
-									ANE_GETTEXTRANGE, 0,
-									-1);
-	char_position = g_utf8_strlen (data, -1);
-	g_free (data);
-	return char_position;
+	gint length = scintilla_send_message (SCINTILLA (te->scintilla),
+										  SCI_GETLENGTH, 0, 0);
+	if (length > 0)
+	{
+		gint char_position;
+		gchar *data =
+			(gchar *) aneditor_command (te->editor_id, ANE_GETTEXTRANGE, 0,
+										length);
+		char_position = g_utf8_strlen (data, -1);
+		g_free (data);
+		return char_position;
+	}
+	return 0;
 }
 
 static gchar*



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