Commit f1de9df0 authored by Havoc Pennington's avatar Havoc Pennington Committed by Havoc Pennington

rename to gtk_text_mark_get_visible

2000-11-07  Havoc Pennington  <hp@redhat.com>

	* gtk/gtktextmark.c (gtk_text_mark_is_visible): rename
	to gtk_text_mark_get_visible

	* gtk/gtktextlayout.c (gtk_text_layout_move_iter_to_line_end): fix
	bug that was generating an invalid iterator

	* gtk/gtktextiter.c (gtk_text_iter_get_offset): move call to
	ensure_char_offsets() in front of code placing the iter in an
	invalid state.

	* gtk/gtktextbuffer.c (gtk_text_buffer_paste_primary):
	make override_location arg const
	(paste): Replace the selection if we paste into the
	current selection

	* gtk/gtkselection.h: Remove "GtkSelectioData"
	(struct _GtkSelectionData): move the definition here.

	* gtk/gtktextbuffer.c (gtk_text_buffer_update_primary_selection):
	Export the GTK_TEXT_BUFFER_CONTENTS target for in-process copies

	* gtk/gtktextiter.c (gtk_text_iter_get_tags): New function

	* gtk/gtktextbuffer.c (gtk_text_buffer_insert_range): implement
	(gtk_text_buffer_insert_range_interactive): implement
	(gtk_text_buffer_get_tags): Remove, replaced by
	gtk_text_iter_get_tags()

	* gtk/gtktextiter.c (gtk_text_iter_forward_search): Add a search
	limit parameter, to avoid infinite linear scan.
	(gtk_text_iter_backward_search): Add search limit
	(gtk_text_iter_forward_find_char): Add search limit
	(gtk_text_iter_backward_find_char): Add search limit
parent 163dc54d
2000-11-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextmark.c (gtk_text_mark_is_visible): rename
to gtk_text_mark_get_visible
* gtk/gtktextlayout.c (gtk_text_layout_move_iter_to_line_end): fix
bug that was generating an invalid iterator
* gtk/gtktextiter.c (gtk_text_iter_get_offset): move call to
ensure_char_offsets() in front of code placing the iter in an
invalid state.
* gtk/gtktextbuffer.c (gtk_text_buffer_paste_primary):
make override_location arg const
(paste): Replace the selection if we paste into the
current selection
* gtk/gtkselection.h: Remove "GtkSelectioData"
(struct _GtkSelectionData): move the definition here.
* gtk/gtktextbuffer.c (gtk_text_buffer_update_primary_selection):
Export the GTK_TEXT_BUFFER_CONTENTS target for in-process copies
* gtk/gtktextiter.c (gtk_text_iter_get_tags): New function
* gtk/gtktextbuffer.c (gtk_text_buffer_insert_range): implement
(gtk_text_buffer_insert_range_interactive): implement
(gtk_text_buffer_get_tags): Remove, replaced by
gtk_text_iter_get_tags()
* gtk/gtktextiter.c (gtk_text_iter_forward_search): Add a search
limit parameter, to avoid infinite linear scan.
(gtk_text_iter_backward_search): Add search limit
(gtk_text_iter_forward_find_char): Add search limit
(gtk_text_iter_backward_find_char): Add search limit
2000-11-07 Alexander Larsson <alla@lysator.liu.se>
* gdk/linux-fb/gdkcolor-fb.c, gdk/linux-fb/gdkdnd-fb.c,
......
2000-11-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextmark.c (gtk_text_mark_is_visible): rename
to gtk_text_mark_get_visible
* gtk/gtktextlayout.c (gtk_text_layout_move_iter_to_line_end): fix
bug that was generating an invalid iterator
* gtk/gtktextiter.c (gtk_text_iter_get_offset): move call to
ensure_char_offsets() in front of code placing the iter in an
invalid state.
* gtk/gtktextbuffer.c (gtk_text_buffer_paste_primary):
make override_location arg const
(paste): Replace the selection if we paste into the
current selection
* gtk/gtkselection.h: Remove "GtkSelectioData"
(struct _GtkSelectionData): move the definition here.
* gtk/gtktextbuffer.c (gtk_text_buffer_update_primary_selection):
Export the GTK_TEXT_BUFFER_CONTENTS target for in-process copies
* gtk/gtktextiter.c (gtk_text_iter_get_tags): New function
* gtk/gtktextbuffer.c (gtk_text_buffer_insert_range): implement
(gtk_text_buffer_insert_range_interactive): implement
(gtk_text_buffer_get_tags): Remove, replaced by
gtk_text_iter_get_tags()
* gtk/gtktextiter.c (gtk_text_iter_forward_search): Add a search
limit parameter, to avoid infinite linear scan.
(gtk_text_iter_backward_search): Add search limit
(gtk_text_iter_forward_find_char): Add search limit
(gtk_text_iter_backward_find_char): Add search limit
2000-11-07 Alexander Larsson <alla@lysator.liu.se>
* gdk/linux-fb/gdkcolor-fb.c, gdk/linux-fb/gdkdnd-fb.c,
......
2000-11-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextmark.c (gtk_text_mark_is_visible): rename
to gtk_text_mark_get_visible
* gtk/gtktextlayout.c (gtk_text_layout_move_iter_to_line_end): fix
bug that was generating an invalid iterator
* gtk/gtktextiter.c (gtk_text_iter_get_offset): move call to
ensure_char_offsets() in front of code placing the iter in an
invalid state.
* gtk/gtktextbuffer.c (gtk_text_buffer_paste_primary):
make override_location arg const
(paste): Replace the selection if we paste into the
current selection
* gtk/gtkselection.h: Remove "GtkSelectioData"
(struct _GtkSelectionData): move the definition here.
* gtk/gtktextbuffer.c (gtk_text_buffer_update_primary_selection):
Export the GTK_TEXT_BUFFER_CONTENTS target for in-process copies
* gtk/gtktextiter.c (gtk_text_iter_get_tags): New function
* gtk/gtktextbuffer.c (gtk_text_buffer_insert_range): implement
(gtk_text_buffer_insert_range_interactive): implement
(gtk_text_buffer_get_tags): Remove, replaced by
gtk_text_iter_get_tags()
* gtk/gtktextiter.c (gtk_text_iter_forward_search): Add a search
limit parameter, to avoid infinite linear scan.
(gtk_text_iter_backward_search): Add search limit
(gtk_text_iter_forward_find_char): Add search limit
(gtk_text_iter_backward_find_char): Add search limit
2000-11-07 Alexander Larsson <alla@lysator.liu.se>
* gdk/linux-fb/gdkcolor-fb.c, gdk/linux-fb/gdkdnd-fb.c,
......
2000-11-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextmark.c (gtk_text_mark_is_visible): rename
to gtk_text_mark_get_visible
* gtk/gtktextlayout.c (gtk_text_layout_move_iter_to_line_end): fix
bug that was generating an invalid iterator
* gtk/gtktextiter.c (gtk_text_iter_get_offset): move call to
ensure_char_offsets() in front of code placing the iter in an
invalid state.
* gtk/gtktextbuffer.c (gtk_text_buffer_paste_primary):
make override_location arg const
(paste): Replace the selection if we paste into the
current selection
* gtk/gtkselection.h: Remove "GtkSelectioData"
(struct _GtkSelectionData): move the definition here.
* gtk/gtktextbuffer.c (gtk_text_buffer_update_primary_selection):
Export the GTK_TEXT_BUFFER_CONTENTS target for in-process copies
* gtk/gtktextiter.c (gtk_text_iter_get_tags): New function
* gtk/gtktextbuffer.c (gtk_text_buffer_insert_range): implement
(gtk_text_buffer_insert_range_interactive): implement
(gtk_text_buffer_get_tags): Remove, replaced by
gtk_text_iter_get_tags()
* gtk/gtktextiter.c (gtk_text_iter_forward_search): Add a search
limit parameter, to avoid infinite linear scan.
(gtk_text_iter_backward_search): Add search limit
(gtk_text_iter_forward_find_char): Add search limit
(gtk_text_iter_backward_find_char): Add search limit
2000-11-07 Alexander Larsson <alla@lysator.liu.se>
* gdk/linux-fb/gdkcolor-fb.c, gdk/linux-fb/gdkdnd-fb.c,
......
2000-11-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextmark.c (gtk_text_mark_is_visible): rename
to gtk_text_mark_get_visible
* gtk/gtktextlayout.c (gtk_text_layout_move_iter_to_line_end): fix
bug that was generating an invalid iterator
* gtk/gtktextiter.c (gtk_text_iter_get_offset): move call to
ensure_char_offsets() in front of code placing the iter in an
invalid state.
* gtk/gtktextbuffer.c (gtk_text_buffer_paste_primary):
make override_location arg const
(paste): Replace the selection if we paste into the
current selection
* gtk/gtkselection.h: Remove "GtkSelectioData"
(struct _GtkSelectionData): move the definition here.
* gtk/gtktextbuffer.c (gtk_text_buffer_update_primary_selection):
Export the GTK_TEXT_BUFFER_CONTENTS target for in-process copies
* gtk/gtktextiter.c (gtk_text_iter_get_tags): New function
* gtk/gtktextbuffer.c (gtk_text_buffer_insert_range): implement
(gtk_text_buffer_insert_range_interactive): implement
(gtk_text_buffer_get_tags): Remove, replaced by
gtk_text_iter_get_tags()
* gtk/gtktextiter.c (gtk_text_iter_forward_search): Add a search
limit parameter, to avoid infinite linear scan.
(gtk_text_iter_backward_search): Add search limit
(gtk_text_iter_forward_find_char): Add search limit
(gtk_text_iter_backward_find_char): Add search limit
2000-11-07 Alexander Larsson <alla@lysator.liu.se>
* gdk/linux-fb/gdkcolor-fb.c, gdk/linux-fb/gdkdnd-fb.c,
......
2000-11-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextmark.c (gtk_text_mark_is_visible): rename
to gtk_text_mark_get_visible
* gtk/gtktextlayout.c (gtk_text_layout_move_iter_to_line_end): fix
bug that was generating an invalid iterator
* gtk/gtktextiter.c (gtk_text_iter_get_offset): move call to
ensure_char_offsets() in front of code placing the iter in an
invalid state.
* gtk/gtktextbuffer.c (gtk_text_buffer_paste_primary):
make override_location arg const
(paste): Replace the selection if we paste into the
current selection
* gtk/gtkselection.h: Remove "GtkSelectioData"
(struct _GtkSelectionData): move the definition here.
* gtk/gtktextbuffer.c (gtk_text_buffer_update_primary_selection):
Export the GTK_TEXT_BUFFER_CONTENTS target for in-process copies
* gtk/gtktextiter.c (gtk_text_iter_get_tags): New function
* gtk/gtktextbuffer.c (gtk_text_buffer_insert_range): implement
(gtk_text_buffer_insert_range_interactive): implement
(gtk_text_buffer_get_tags): Remove, replaced by
gtk_text_iter_get_tags()
* gtk/gtktextiter.c (gtk_text_iter_forward_search): Add a search
limit parameter, to avoid infinite linear scan.
(gtk_text_iter_backward_search): Add search limit
(gtk_text_iter_forward_find_char): Add search limit
(gtk_text_iter_backward_find_char): Add search limit
2000-11-07 Alexander Larsson <alla@lysator.liu.se>
* gdk/linux-fb/gdkcolor-fb.c, gdk/linux-fb/gdkdnd-fb.c,
......
2000-11-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextmark.c (gtk_text_mark_is_visible): rename
to gtk_text_mark_get_visible
* gtk/gtktextlayout.c (gtk_text_layout_move_iter_to_line_end): fix
bug that was generating an invalid iterator
* gtk/gtktextiter.c (gtk_text_iter_get_offset): move call to
ensure_char_offsets() in front of code placing the iter in an
invalid state.
* gtk/gtktextbuffer.c (gtk_text_buffer_paste_primary):
make override_location arg const
(paste): Replace the selection if we paste into the
current selection
* gtk/gtkselection.h: Remove "GtkSelectioData"
(struct _GtkSelectionData): move the definition here.
* gtk/gtktextbuffer.c (gtk_text_buffer_update_primary_selection):
Export the GTK_TEXT_BUFFER_CONTENTS target for in-process copies
* gtk/gtktextiter.c (gtk_text_iter_get_tags): New function
* gtk/gtktextbuffer.c (gtk_text_buffer_insert_range): implement
(gtk_text_buffer_insert_range_interactive): implement
(gtk_text_buffer_get_tags): Remove, replaced by
gtk_text_iter_get_tags()
* gtk/gtktextiter.c (gtk_text_iter_forward_search): Add a search
limit parameter, to avoid infinite linear scan.
(gtk_text_iter_backward_search): Add search limit
(gtk_text_iter_forward_find_char): Add search limit
(gtk_text_iter_backward_find_char): Add search limit
2000-11-07 Alexander Larsson <alla@lysator.liu.se>
* gdk/linux-fb/gdkcolor-fb.c, gdk/linux-fb/gdkdnd-fb.c,
......
......@@ -1720,7 +1720,7 @@ gtk_selection_default_handler (GtkWidget *widget,
}
GtkSelectioData*
GtkSelectionData*
gtk_selection_data_copy (GtkSelectionData *selection_data)
{
GtkSelectionData *new_data;
......
......@@ -36,10 +36,30 @@
extern "C" {
#endif /* __cplusplus */
typedef struct _GtkSelectionData GtkSelectioData;
typedef struct _GtkTargetList GtkTargetList;
typedef struct _GtkTargetEntry GtkTargetEntry;
/* The contents of a selection are returned in a GtkSelectionData
* structure. selection/target identify the request. type specifies
* the type of the return; if length < 0, and the data should be
* ignored. This structure has object semantics - no fields should be
* modified directly, they should not be created directly, and
* pointers to them should not be stored beyond the duration of a
* callback. (If the last is changed, we'll need to add reference
* counting.) The time field gives the timestamp at which the data was
* sent.
*/
struct _GtkSelectionData
{
GdkAtom selection;
GdkAtom target;
GdkAtom type;
gint format;
guchar *data;
gint length;
};
struct _GtkTargetEntry {
gchar *target;
guint flags;
......@@ -125,8 +145,8 @@ gint gtk_selection_notify (GtkWidget *widget,
GdkEventSelection *event);
gint gtk_selection_property_notify (GtkWidget *widget,
GdkEventProperty *event);
GtkSelectioData *gtk_selection_data_copy (GtkSelectionData *data);
void gtk_selection_data_free (GtkSelectionData *data);
GtkSelectionData *gtk_selection_data_copy (GtkSelectionData *data);
void gtk_selection_data_free (GtkSelectionData *data);
......
......@@ -2435,13 +2435,13 @@ ensure_not_off_end (GtkTextBTree *tree,
}
static GtkTextLineSegment*
real_set_mark (GtkTextBTree *tree,
GtkTextMark *existing_mark,
const gchar *name,
gboolean left_gravity,
real_set_mark (GtkTextBTree *tree,
GtkTextMark *existing_mark,
const gchar *name,
gboolean left_gravity,
const GtkTextIter *where,
gboolean should_exist,
gboolean redraw_selections)
gboolean should_exist,
gboolean redraw_selections)
{
GtkTextLineSegment *mark;
GtkTextIter iter;
......@@ -2465,10 +2465,14 @@ real_set_mark (GtkTextBTree *tree,
}
/* OK if !should_exist and it does already exist, in that case
we just move it. */
* we just move it.
*/
iter = *where;
if (gtk_debug_flags & GTK_DEBUG_TEXT)
gtk_text_iter_check (&iter);
if (mark != NULL)
{
if (redraw_selections &&
......@@ -2519,6 +2523,9 @@ real_set_mark (GtkTextBTree *tree,
mark);
}
if (gtk_debug_flags & GTK_DEBUG_TEXT)
gtk_text_iter_check (&iter);
/* Link mark into new location */
gtk_text_btree_link_segment (mark, &iter);
......@@ -2531,6 +2538,12 @@ real_set_mark (GtkTextBTree *tree,
redisplay_mark_if_visible (mark);
if (gtk_debug_flags & GTK_DEBUG_TEXT)
gtk_text_iter_check (&iter);
if (gtk_debug_flags & GTK_DEBUG_TEXT)
gtk_text_btree_check (tree);
return mark;
}
......@@ -3716,7 +3729,8 @@ gtk_text_line_byte_to_char_offsets (GtkTextLine *line,
g_assert (seg->char_count > 0); /* indexable. */
/* offset is now the number of bytes into the current segment we
want to go. Count chars into the current segment. */
* want to go. Count chars into the current segment.
*/
if (seg->type == &gtk_text_char_type)
{
......
This diff is collapsed.
......@@ -283,10 +283,6 @@ void gtk_text_buffer_get_iter_at_child_anchor (GtkTextBuffer *buffer,
/* There's no get_first_iter because you just get the iter for
line or char 0 */
GSList *gtk_text_buffer_get_tags (GtkTextBuffer *buffer,
const GtkTextIter *iter);
/* Used to keep track of whether the buffer needs saving; anytime the
buffer contents change, the modified flag is turned on. Whenever
you save, turn it off. Tags and marks do not affect the modified
......@@ -297,9 +293,9 @@ gboolean gtk_text_buffer_modified (GtkTextBuffer *buffer);
void gtk_text_buffer_set_modified (GtkTextBuffer *buffer,
gboolean setting);
void gtk_text_buffer_paste_primary (GtkTextBuffer *buffer,
GtkTextIter *override_location,
gboolean default_editable);
void gtk_text_buffer_paste_primary (GtkTextBuffer *buffer,
const GtkTextIter *override_location,
gboolean default_editable);
void gtk_text_buffer_cut_clipboard (GtkTextBuffer *buffer,
gboolean default_editable);
void gtk_text_buffer_copy_clipboard (GtkTextBuffer *buffer);
......
......@@ -580,11 +580,14 @@ gtk_text_iter_get_offset (const GtkTextIter *iter)
if (real == NULL)
return 0;
check_invariants (iter);
if (real->cached_char_index < 0)
{
ensure_char_offsets (real);
real->cached_char_index =
gtk_text_line_char_index (real->line);
ensure_char_offsets (real);
real->cached_char_index += real->line_char_offset;
}
......@@ -722,7 +725,7 @@ gtk_text_iter_get_char (const GtkTextIter *iter)
else if (real->segment->type == &gtk_text_char_type)
{
ensure_byte_offsets (real);
return g_utf8_get_char (real->segment->body.chars +
real->segment_byte_offset);
}
......@@ -743,7 +746,9 @@ gtk_text_iter_get_char (const GtkTextIter *iter)
* character 0xFFFD for iterable non-character elements in the buffer,
* such as images. Because images are encoded in the slice, byte and
* character offsets in the returned array will correspond to byte
* offsets in the text buffer.
* offsets in the text buffer. Note that 0xFFFD can occur in normal
* text as well, so it is not a reliable indicator that a pixbuf or
* widget is in the buffer.
*
* Return value: slice of text from the buffer
**/
......@@ -1169,6 +1174,56 @@ gtk_text_iter_has_tag (const GtkTextIter *iter,
}
}
/**
* gtk_text_iter_get_tags:
* @iter: a #GtkTextIter
*
* Returns a list of tags that apply to @iter, in ascending order of
* priority (highest-priority tags are last). The #GtkTextTag in the
* list don't have a reference added, but you have to free the list
* itself.
*
* Return value: list of #GtkTextTag
**/
GSList*
gtk_text_iter_get_tags (const GtkTextIter *iter)
{
GtkTextTag** tags;
gint tag_count = 0;
gint i;
GSList *retval;
g_return_val_if_fail (iter != NULL, NULL);
/* Get the tags at this spot */
tags = gtk_text_btree_get_tags (iter, &tag_count);
/* No tags, use default style */
if (tags == NULL || tag_count == 0)
{
if (tags)
g_free (tags);
return NULL;
}
/* Sort tags in ascending order of priority */
gtk_text_tag_array_sort (tags, tag_count);
retval = NULL;
i = 0;
while (i < tag_count)
{
retval = g_slist_prepend (retval, tags[i]);
++i;
}
g_free (tags);
/* Return tags in ascending order of priority */
return g_slist_reverse (retval);
}
/**
* gtk_text_iter_editable:
* @iter: an iterator
......@@ -2654,7 +2709,9 @@ gtk_text_iter_forward_to_newline (GtkTextIter *iter)
* #GtkTextTag @tag, or to the next toggle of any tag if
* @tag is NULL. If no matching tag toggles are found,
* returns FALSE, otherwise TRUE. Does not return toggles
* located at @iter, only toggles after @iter.
* located at @iter, only toggles after @iter. Sets @iter to
* the location of the toggle, or to the end of the buffer
* if no toggle is found.
*
* Return value: whether we found a tag toggle after @iter
**/
......@@ -2734,7 +2791,9 @@ gtk_text_iter_forward_to_tag_toggle (GtkTextIter *iter,
* #GtkTextTag @tag, or to the next toggle of any tag if
* @tag is NULL. If no matching tag toggles are found,
* returns FALSE, otherwise TRUE. Does not return toggles
* located at @iter, only toggles before @iter.
* located at @iter, only toggles before @iter. Sets @iter
* to the location of the toggle, or the start of the buffer
* if no toggle is found.
*
* Return value: whether we found a tag toggle before @iter
**/
......@@ -2836,16 +2895,37 @@ matches_pred (GtkTextIter *iter,
return (*pred) (ch, user_data);
}
/**
* gtk_text_iter_forward_find_char:
* @iter: a #GtkTextIter
* @pred: a function to be called on each character
* @user_data: user data for @pred
* @limit: search limit, or %NULL for none
*
* Advances @iter, calling @pred on each character. If
* @pred returns %TRUE, returns %TRUE and stops scanning.
* If @pred never returns %TRUE, @iter is set to @limit if
* @limit is non-%NULL, otherwise to the end iterator.
*
* Return value: whether a match was found
**/
gboolean
gtk_text_iter_forward_find_char (GtkTextIter *iter,
gtk_text_iter_forward_find_char (GtkTextIter *iter,
GtkTextCharPredicate pred,
gpointer user_data)
gpointer user_data,
const GtkTextIter *limit)
{
g_return_val_if_fail (iter != NULL, FALSE);
g_return_val_if_fail (pred != NULL, FALSE);
while (gtk_text_iter_next_char (iter))
{
if (limit &&
gtk_text_iter_compare (iter, limit) >= 0)
return FALSE;
while ((limit == NULL ||
!gtk_text_iter_equal (limit, iter)) &&
gtk_text_iter_next_char (iter))
{
if (matches_pred (iter, pred, user_data))
return TRUE;
}
......@@ -2854,14 +2934,21 @@ gtk_text_iter_forward_find_char (GtkTextIter *iter,
}
gboolean
gtk_text_iter_backward_find_char (GtkTextIter *iter,
gtk_text_iter_backward_find_char (GtkTextIter *iter,
GtkTextCharPredicate pred,
gpointer user_data)
gpointer user_data,
const GtkTextIter *limit)
{
g_return_val_if_fail (iter != NULL, FALSE);
g_return_val_if_fail (pred != NULL, FALSE);
while (gtk_text_iter_prev_char (iter))
if (limit &&
gtk_text_iter_compare (iter, limit) <= 0)
return FALSE;
while ((limit == NULL ||
!gtk_text_iter_equal (limit, iter)) &&
gtk_text_iter_prev_char (iter))
{
if (matches_pred (iter, pred, user_data))
return TRUE;
......@@ -3060,13 +3147,28 @@ strbreakup (const char *string,
return str_array;
}
/**
* gtk_text_iter_forward_search:
* @iter: start of search
* @str: a search string
* @visible_only: if %TRUE, search only visible text
* @slice: if %TRUE, @str contains 0xFFFD when we want to match widgets, pixbufs
* @match_start: return location for start of match, or %NULL
* @match_end: return location for end of match, or %NULL
* @limit: bound for the search, or %NULL for the end of the buffer
*
*
*
* Return value: whether a match was found
**/
gboolean
gtk_text_iter_forward_search (const GtkTextIter *iter,
const gchar *str,
gboolean visible_only,
gboolean slice,
GtkTextIter *match_start,
GtkTextIter *match_end)
GtkTextIter *match_end,
const GtkTextIter *limit)
{
gchar **lines = NULL;
GtkTextIter match;
......@@ -3076,12 +3178,21 @@ gtk_text_iter_forward_search (const GtkTextIter *iter,
g_return_val_if_fail (iter != NULL, FALSE);
g_return_val_if_fail (str != NULL, FALSE);
if (limit &&
gtk_text_iter_compare (iter, limit) >= 0)
return FALSE;
if (*str == '\0')
{
/* If we can move one char, return the empty string there */
match = *iter;
if (gtk_text_iter_next_char (&match))
{
if (limit &&
gtk_text_iter_equal (&match, limit))
return FALSE;
if (match_start)
*match_start = match;
if (match_end)
......@@ -3106,17 +3217,26 @@ gtk_text_iter_forward_search (const GtkTextIter *iter,
*/
GtkTextIter end;
if (limit &&
gtk_text_iter_compare (&search, limit) >= 0)
break;
if (lines_match (&search, (const gchar**)lines,
visible_only, slice, &match, &end))
{
retval = TRUE;
if (match_start)
*match_start = match;
if (match_end)
*match_end = end;
if (limit == NULL ||
(limit &&
gtk_text_iter_compare (&end, limit) < 0))
{
retval = TRUE;
if (match_start)
*match_start = match;
if (match_end)
*match_end = end;
}
break;
}
}
......@@ -3345,13 +3465,28 @@ my_strrstr (const gchar *haystack,
return NULL;
}
/**
* gtk_text_iter_backward_search:
* @iter: a #GtkTextIter where the search begins
* @str: search string
* @visible_only: if %TRUE search only visible text
* @slice: if %TRUE the search string contains 0xFFFD to match pixbufs, widgets
* @match_start: return location for start of match, or %NULL
* @match_end: return location for end of match, or %NULL
* @limit: location of last possible @match_start, or %NULL for start of buffer
*
*
*
* Return value: whether a match was found
**/
gboolean
gtk_text_iter_backward_search (const GtkTextIter *iter,
const gchar *str,
gboolean visible_only,
gboolean slice,
GtkTextIter *match_start,
GtkTextIter *match_end)
GtkTextIter *match_end,
const GtkTextIter *limit)
{
gchar **lines = NULL;
gchar **l;
......@@ -3362,11 +3497,18 @@ gtk_text_iter_backward_search (const GtkTextIter *iter,
g_return_val_if_fail (iter != NULL, FALSE);
g_return_val_if_fail (str != NULL, FALSE);
if (limit &&
gtk_text_iter_compare (limit, iter) > 0)
return FALSE;
if (*str == '\0')
{
/* If we can move one char, return the empty string there */
GtkTextIter match = *iter;
if (limit && gtk_text_iter_equal (limit, &match))
return FALSE;
if (gtk_text_iter_prev_char (&match))
{
if (match_start)
......@@ -3404,6 +3546,13 @@ gtk_text_iter_backward_search (const GtkTextIter *iter,
{
gchar *first_line_match;
if (limit &&
gtk_text_iter_compare (limit, &win.first_line_end) > 0)
{
/* We're now before the search limit, abort. */
goto out;
}
/* If there are multiple lines, the first line will
* end in '\n', so this will only match at the
* end of the first line, which is correct.
......@@ -3416,17 +3565,22 @@ gtk_text_iter_backward_search (const GtkTextIter *iter,
/* Match! */
gint offset;
GtkTextIter next;
GtkTextIter start_tmp;
/* Offset to start of search string */
offset = g_utf8_strlen (*win.lines, first_line_match - *win.lines);
next = win.first_line_start;
start_tmp = next;
forward