summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-11-12 10:34:48 -0500
committerMatthias Clasen <mclasen@redhat.com>2015-11-12 10:36:26 -0500
commit0dc66f5125196ee10c7e851b75f16e9f5669eb49 (patch)
treed92d23e753c265be0291853acc604dbb584982f1 /gtk
parenta875a848468d6df12f63e7c0604615ed60f102eb (diff)
downloadgtk+-0dc66f5125196ee10c7e851b75f16e9f5669eb49.tar.gz
Revert "textbuffer: nicer get_iter functions"
This reverts commit cf51c4f6dbd91dae1878a0cb0d08b24c67e15232. This change broke binding api.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtktextbuffer.c95
-rw-r--r--gtk/gtktextbuffer.h34
2 files changed, 37 insertions, 92 deletions
diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c
index 7295021ccd..1bf1b68823 100644
--- a/gtk/gtktextbuffer.c
+++ b/gtk/gtktextbuffer.c
@@ -2862,48 +2862,22 @@ gtk_text_buffer_remove_all_tags (GtkTextBuffer *buffer,
* @line_number: line number counting from 0
* @char_offset: char offset from start of line
*
- * Obtains an iterator pointing to @char_offset within the given line. Note
- * characters, not bytes; UTF-8 may encode one character as multiple bytes.
- *
- * Before the 3.20 version, it was not allowed to pass an invalid location.
- *
- * Since the 3.20 version, if @line_number is greater than the number of lines
- * in the @buffer, the end iterator is returned. And if @char_offset is off the
- * end of the line, the iterator at the end of the line is returned.
- *
- * Returns: whether the exact position has been found (since 3.20).
+ * Obtains an iterator pointing to @char_offset within the given
+ * line. The @char_offset must exist, offsets off the end of the line
+ * are not allowed. Note characters, not bytes;
+ * UTF-8 may encode one character as multiple bytes.
**/
-gboolean
+void
gtk_text_buffer_get_iter_at_line_offset (GtkTextBuffer *buffer,
GtkTextIter *iter,
gint line_number,
gint char_offset)
{
- GtkTextIter end_line_iter;
-
- g_return_val_if_fail (iter != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), FALSE);
-
- if (line_number >= gtk_text_buffer_get_line_count (buffer))
- {
- gtk_text_buffer_get_end_iter (buffer, iter);
- return FALSE;
- }
-
- _gtk_text_btree_get_iter_at_line_char (get_btree (buffer), iter, line_number, 0);
-
- end_line_iter = *iter;
- if (!gtk_text_iter_ends_line (&end_line_iter))
- gtk_text_iter_forward_to_line_end (&end_line_iter);
-
- if (char_offset > gtk_text_iter_get_line_offset (&end_line_iter))
- {
- *iter = end_line_iter;
- return FALSE;
- }
+ g_return_if_fail (iter != NULL);
+ g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
- gtk_text_iter_set_line_offset (iter, char_offset);
- return TRUE;
+ _gtk_text_btree_get_iter_at_line_char (get_btree (buffer),
+ iter, line_number, char_offset);
}
/**
@@ -2914,48 +2888,21 @@ gtk_text_buffer_get_iter_at_line_offset (GtkTextBuffer *buffer,
* @byte_index: byte index from start of line
*
* Obtains an iterator pointing to @byte_index within the given line.
- * @byte_index must be the start of a UTF-8 character. Note bytes, not
+ * @byte_index must be the start of a UTF-8 character, and must not be
+ * beyond the end of the line. Note bytes, not
* characters; UTF-8 may encode one character as multiple bytes.
- *
- * Before the 3.20 version, it was not allowed to pass an invalid location.
- *
- * Since the 3.20 version, if @line_number is greater than the number of lines
- * in the @buffer, the end iterator is returned. And if @byte_index is off the
- * end of the line, the iterator at the end of the line is returned.
- *
- * Returns: whether the exact position has been found (since 3.20).
**/
-gboolean
+void
gtk_text_buffer_get_iter_at_line_index (GtkTextBuffer *buffer,
GtkTextIter *iter,
gint line_number,
gint byte_index)
{
- GtkTextIter end_line_iter;
-
- g_return_val_if_fail (iter != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), FALSE);
-
- if (line_number >= gtk_text_buffer_get_line_count (buffer))
- {
- gtk_text_buffer_get_end_iter (buffer, iter);
- return FALSE;
- }
-
- gtk_text_buffer_get_iter_at_line (buffer, iter, line_number);
-
- end_line_iter = *iter;
- if (!gtk_text_iter_ends_line (&end_line_iter))
- gtk_text_iter_forward_to_line_end (&end_line_iter);
-
- if (byte_index > gtk_text_iter_get_line_index (&end_line_iter))
- {
- *iter = end_line_iter;
- return FALSE;
- }
+ g_return_if_fail (iter != NULL);
+ g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
- gtk_text_iter_set_line_index (iter, byte_index);
- return TRUE;
+ _gtk_text_btree_get_iter_at_line_byte (get_btree (buffer),
+ iter, line_number, byte_index);
}
/**
@@ -2966,18 +2913,16 @@ gtk_text_buffer_get_iter_at_line_index (GtkTextBuffer *buffer,
*
* Initializes @iter to the start of the given line. If @line_number is greater
* than the number of lines in the @buffer, the end iterator is returned.
- *
- * Returns: whether the exact position has been found (since 3.20).
**/
-gboolean
+void
gtk_text_buffer_get_iter_at_line (GtkTextBuffer *buffer,
GtkTextIter *iter,
gint line_number)
{
- g_return_val_if_fail (iter != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), FALSE);
+ g_return_if_fail (iter != NULL);
+ g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
- return gtk_text_buffer_get_iter_at_line_offset (buffer, iter, line_number, 0);
+ gtk_text_buffer_get_iter_at_line_offset (buffer, iter, line_number, 0);
}
/**
diff --git a/gtk/gtktextbuffer.h b/gtk/gtktextbuffer.h
index 8894542342..9227be8874 100644
--- a/gtk/gtktextbuffer.h
+++ b/gtk/gtktextbuffer.h
@@ -373,23 +373,23 @@ GtkTextTag *gtk_text_buffer_create_tag (GtkTextBuffer *buffer,
* iterator around using the GtkTextIter operators
*/
GDK_AVAILABLE_IN_ALL
-gboolean gtk_text_buffer_get_iter_at_line_offset (GtkTextBuffer *buffer,
- GtkTextIter *iter,
- gint line_number,
- gint char_offset);
-GDK_AVAILABLE_IN_ALL
-gboolean gtk_text_buffer_get_iter_at_line_index (GtkTextBuffer *buffer,
- GtkTextIter *iter,
- gint line_number,
- gint byte_index);
-GDK_AVAILABLE_IN_ALL
-void gtk_text_buffer_get_iter_at_offset (GtkTextBuffer *buffer,
- GtkTextIter *iter,
- gint char_offset);
-GDK_AVAILABLE_IN_ALL
-gboolean gtk_text_buffer_get_iter_at_line (GtkTextBuffer *buffer,
- GtkTextIter *iter,
- gint line_number);
+void gtk_text_buffer_get_iter_at_line_offset (GtkTextBuffer *buffer,
+ GtkTextIter *iter,
+ gint line_number,
+ gint char_offset);
+GDK_AVAILABLE_IN_ALL
+void gtk_text_buffer_get_iter_at_line_index (GtkTextBuffer *buffer,
+ GtkTextIter *iter,
+ gint line_number,
+ gint byte_index);
+GDK_AVAILABLE_IN_ALL
+void gtk_text_buffer_get_iter_at_offset (GtkTextBuffer *buffer,
+ GtkTextIter *iter,
+ gint char_offset);
+GDK_AVAILABLE_IN_ALL
+void gtk_text_buffer_get_iter_at_line (GtkTextBuffer *buffer,
+ GtkTextIter *iter,
+ gint line_number);
GDK_AVAILABLE_IN_ALL
void gtk_text_buffer_get_start_iter (GtkTextBuffer *buffer,
GtkTextIter *iter);