textiter: add _gtk_text_iter_same_line()

This is a faster form to compare two text iter to see if they are on the
same line.
This commit is contained in:
Christian Hergert 2019-07-26 18:04:34 -07:00
parent 7eb5dfd294
commit b930c5a8a2
2 changed files with 21 additions and 0 deletions

View File

@ -5358,6 +5358,25 @@ gtk_text_iter_equal (const GtkTextIter *lhs,
}
}
gboolean
_gtk_text_iter_same_line (const GtkTextIter *lhs,
const GtkTextIter *rhs)
{
GtkTextRealIter *real_lhs;
GtkTextRealIter *real_rhs;
real_lhs = gtk_text_iter_make_surreal (lhs);
real_rhs = gtk_text_iter_make_surreal (rhs);
if (real_lhs == NULL || real_rhs == NULL)
return FALSE;
check_invariants (lhs);
check_invariants (rhs);
return real_lhs->line == real_rhs->line;
}
/**
* gtk_text_iter_compare:
* @lhs: a #GtkTextIter

View File

@ -41,6 +41,8 @@ gboolean _gtk_text_iter_forward_indexable_segment (GtkTextIter
gboolean _gtk_text_iter_backward_indexable_segment (GtkTextIter *iter);
gint _gtk_text_iter_get_segment_byte (const GtkTextIter *iter);
gint _gtk_text_iter_get_segment_char (const GtkTextIter *iter);
gboolean _gtk_text_iter_same_line (const GtkTextIter *lhs,
const GtkTextIter *rhs);
gboolean gtk_text_iter_get_attributes (const GtkTextIter *iter,
GtkTextAttributes *values);