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

don't create dangling pointers to the appearance attributes from the line

2000-11-30  Havoc Pennington  <hp@pobox.com>

* gtk/gtktextdisplay.c (gtk_text_layout_draw): don't create
dangling pointers to the appearance attributes from the
line display

* gdk/gdkdraw.c (gdk_drawable_get_image): allow negative
width/height to mean "full width/height of drawable"

* gtk/gtktextview.h, gtk/gtktextview.c: Implement double/triple
click to select word/line

* gtk/gtktextiter.c (test_log_attrs): include paragraph delimiters
when getting log attrs. Get a slice, so that pixmaps and stuff
are properly handled.

* gtk/gtktextbuffer.c (paste): Fix pasting to work properly if you
paste into the selection (replaces selection now, previously
crashed or added to selection). Reveals longstanding btree bug -
select multiple lines, middle-click on the selection, boom. This
isn't related to my changes though.

* gtk/gtkentry.c (gtk_entry_move_forward_word): Update to reflect
PangoLogAttrs changes
(gtk_entry_move_backward_word): ditto

        * gtk/gtktextlayout.h, gtk/gtktextlayout.c: Make the iter motion
	functions return bool whether the iter moved onto a
	dereferenceable position.

	 * gtk/gtktextview.h, gtk/gtktextview.c: Add a bunch of public
	 functions for motion in terms of display lines.

	 * gtk/gtktextmark.c (gtk_text_mark_get_buffer): Add function to
	 get the buffer a mark is inside
parent fb14d129
2000-12-01 <alexl@redhat.com>
2000-11-30 Havoc Pennington <hp@pobox.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): don't create
dangling pointers to the appearance attributes from the
line display
* gdk/gdkdraw.c (gdk_drawable_get_image): allow negative
width/height to mean "full width/height of drawable"
* gtk/gtktextview.h, gtk/gtktextview.c: Implement double/triple
click to select word/line
* gtk/gtktextiter.c (test_log_attrs): include paragraph delimiters
when getting log attrs. Get a slice, so that pixmaps and stuff
are properly handled.
* gtk/gtktextbuffer.c (paste): Fix pasting to work properly if you
paste into the selection (replaces selection now, previously
crashed or added to selection). Reveals longstanding btree bug -
select multiple lines, middle-click on the selection, boom. This
isn't related to my changes though.
* gtk/gtkentry.c (gtk_entry_move_forward_word): Update to reflect
PangoLogAttrs changes
(gtk_entry_move_backward_word): ditto
* gtk/gtktextlayout.h, gtk/gtktextlayout.c: Make the iter motion
functions return bool whether the iter moved onto a
dereferenceable position.
* gtk/gtktextview.h, gtk/gtktextview.c: Add a bunch of public
functions for motion in terms of display lines.
* gtk/gtktextmark.c (gtk_text_mark_get_buffer): Add function to
get the buffer a mark is inside
2000-12-01 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/Makefile.am:
* modules/linux-fb/Makefile.am:
......
2000-12-01 <alexl@redhat.com>
2000-11-30 Havoc Pennington <hp@pobox.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): don't create
dangling pointers to the appearance attributes from the
line display
* gdk/gdkdraw.c (gdk_drawable_get_image): allow negative
width/height to mean "full width/height of drawable"
* gtk/gtktextview.h, gtk/gtktextview.c: Implement double/triple
click to select word/line
* gtk/gtktextiter.c (test_log_attrs): include paragraph delimiters
when getting log attrs. Get a slice, so that pixmaps and stuff
are properly handled.
* gtk/gtktextbuffer.c (paste): Fix pasting to work properly if you
paste into the selection (replaces selection now, previously
crashed or added to selection). Reveals longstanding btree bug -
select multiple lines, middle-click on the selection, boom. This
isn't related to my changes though.
* gtk/gtkentry.c (gtk_entry_move_forward_word): Update to reflect
PangoLogAttrs changes
(gtk_entry_move_backward_word): ditto
* gtk/gtktextlayout.h, gtk/gtktextlayout.c: Make the iter motion
functions return bool whether the iter moved onto a
dereferenceable position.
* gtk/gtktextview.h, gtk/gtktextview.c: Add a bunch of public
functions for motion in terms of display lines.
* gtk/gtktextmark.c (gtk_text_mark_get_buffer): Add function to
get the buffer a mark is inside
2000-12-01 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/Makefile.am:
* modules/linux-fb/Makefile.am:
......
2000-12-01 <alexl@redhat.com>
2000-11-30 Havoc Pennington <hp@pobox.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): don't create
dangling pointers to the appearance attributes from the
line display
* gdk/gdkdraw.c (gdk_drawable_get_image): allow negative
width/height to mean "full width/height of drawable"
* gtk/gtktextview.h, gtk/gtktextview.c: Implement double/triple
click to select word/line
* gtk/gtktextiter.c (test_log_attrs): include paragraph delimiters
when getting log attrs. Get a slice, so that pixmaps and stuff
are properly handled.
* gtk/gtktextbuffer.c (paste): Fix pasting to work properly if you
paste into the selection (replaces selection now, previously
crashed or added to selection). Reveals longstanding btree bug -
select multiple lines, middle-click on the selection, boom. This
isn't related to my changes though.
* gtk/gtkentry.c (gtk_entry_move_forward_word): Update to reflect
PangoLogAttrs changes
(gtk_entry_move_backward_word): ditto
* gtk/gtktextlayout.h, gtk/gtktextlayout.c: Make the iter motion
functions return bool whether the iter moved onto a
dereferenceable position.
* gtk/gtktextview.h, gtk/gtktextview.c: Add a bunch of public
functions for motion in terms of display lines.
* gtk/gtktextmark.c (gtk_text_mark_get_buffer): Add function to
get the buffer a mark is inside
2000-12-01 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/Makefile.am:
* modules/linux-fb/Makefile.am:
......
2000-12-01 <alexl@redhat.com>
2000-11-30 Havoc Pennington <hp@pobox.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): don't create
dangling pointers to the appearance attributes from the
line display
* gdk/gdkdraw.c (gdk_drawable_get_image): allow negative
width/height to mean "full width/height of drawable"
* gtk/gtktextview.h, gtk/gtktextview.c: Implement double/triple
click to select word/line
* gtk/gtktextiter.c (test_log_attrs): include paragraph delimiters
when getting log attrs. Get a slice, so that pixmaps and stuff
are properly handled.
* gtk/gtktextbuffer.c (paste): Fix pasting to work properly if you
paste into the selection (replaces selection now, previously
crashed or added to selection). Reveals longstanding btree bug -
select multiple lines, middle-click on the selection, boom. This
isn't related to my changes though.
* gtk/gtkentry.c (gtk_entry_move_forward_word): Update to reflect
PangoLogAttrs changes
(gtk_entry_move_backward_word): ditto
* gtk/gtktextlayout.h, gtk/gtktextlayout.c: Make the iter motion
functions return bool whether the iter moved onto a
dereferenceable position.
* gtk/gtktextview.h, gtk/gtktextview.c: Add a bunch of public
functions for motion in terms of display lines.
* gtk/gtktextmark.c (gtk_text_mark_get_buffer): Add function to
get the buffer a mark is inside
2000-12-01 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/Makefile.am:
* modules/linux-fb/Makefile.am:
......
2000-12-01 <alexl@redhat.com>
2000-11-30 Havoc Pennington <hp@pobox.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): don't create
dangling pointers to the appearance attributes from the
line display
* gdk/gdkdraw.c (gdk_drawable_get_image): allow negative
width/height to mean "full width/height of drawable"
* gtk/gtktextview.h, gtk/gtktextview.c: Implement double/triple
click to select word/line
* gtk/gtktextiter.c (test_log_attrs): include paragraph delimiters
when getting log attrs. Get a slice, so that pixmaps and stuff
are properly handled.
* gtk/gtktextbuffer.c (paste): Fix pasting to work properly if you
paste into the selection (replaces selection now, previously
crashed or added to selection). Reveals longstanding btree bug -
select multiple lines, middle-click on the selection, boom. This
isn't related to my changes though.
* gtk/gtkentry.c (gtk_entry_move_forward_word): Update to reflect
PangoLogAttrs changes
(gtk_entry_move_backward_word): ditto
* gtk/gtktextlayout.h, gtk/gtktextlayout.c: Make the iter motion
functions return bool whether the iter moved onto a
dereferenceable position.
* gtk/gtktextview.h, gtk/gtktextview.c: Add a bunch of public
functions for motion in terms of display lines.
* gtk/gtktextmark.c (gtk_text_mark_get_buffer): Add function to
get the buffer a mark is inside
2000-12-01 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/Makefile.am:
* modules/linux-fb/Makefile.am:
......
2000-12-01 <alexl@redhat.com>
2000-11-30 Havoc Pennington <hp@pobox.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): don't create
dangling pointers to the appearance attributes from the
line display
* gdk/gdkdraw.c (gdk_drawable_get_image): allow negative
width/height to mean "full width/height of drawable"
* gtk/gtktextview.h, gtk/gtktextview.c: Implement double/triple
click to select word/line
* gtk/gtktextiter.c (test_log_attrs): include paragraph delimiters
when getting log attrs. Get a slice, so that pixmaps and stuff
are properly handled.
* gtk/gtktextbuffer.c (paste): Fix pasting to work properly if you
paste into the selection (replaces selection now, previously
crashed or added to selection). Reveals longstanding btree bug -
select multiple lines, middle-click on the selection, boom. This
isn't related to my changes though.
* gtk/gtkentry.c (gtk_entry_move_forward_word): Update to reflect
PangoLogAttrs changes
(gtk_entry_move_backward_word): ditto
* gtk/gtktextlayout.h, gtk/gtktextlayout.c: Make the iter motion
functions return bool whether the iter moved onto a
dereferenceable position.
* gtk/gtktextview.h, gtk/gtktextview.c: Add a bunch of public
functions for motion in terms of display lines.
* gtk/gtktextmark.c (gtk_text_mark_get_buffer): Add function to
get the buffer a mark is inside
2000-12-01 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/Makefile.am:
* modules/linux-fb/Makefile.am:
......
2000-12-01 <alexl@redhat.com>
2000-11-30 Havoc Pennington <hp@pobox.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): don't create
dangling pointers to the appearance attributes from the
line display
* gdk/gdkdraw.c (gdk_drawable_get_image): allow negative
width/height to mean "full width/height of drawable"
* gtk/gtktextview.h, gtk/gtktextview.c: Implement double/triple
click to select word/line
* gtk/gtktextiter.c (test_log_attrs): include paragraph delimiters
when getting log attrs. Get a slice, so that pixmaps and stuff
are properly handled.
* gtk/gtktextbuffer.c (paste): Fix pasting to work properly if you
paste into the selection (replaces selection now, previously
crashed or added to selection). Reveals longstanding btree bug -
select multiple lines, middle-click on the selection, boom. This
isn't related to my changes though.
* gtk/gtkentry.c (gtk_entry_move_forward_word): Update to reflect
PangoLogAttrs changes
(gtk_entry_move_backward_word): ditto
* gtk/gtktextlayout.h, gtk/gtktextlayout.c: Make the iter motion
functions return bool whether the iter moved onto a
dereferenceable position.
* gtk/gtktextview.h, gtk/gtktextview.c: Add a bunch of public
functions for motion in terms of display lines.
* gtk/gtktextmark.c (gtk_text_mark_get_buffer): Add function to
get the buffer a mark is inside
2000-12-01 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/Makefile.am:
* modules/linux-fb/Makefile.am:
......
......@@ -486,9 +486,12 @@ gdk_drawable_get_image (GdkDrawable *drawable,
g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (x >= 0, NULL);
g_return_val_if_fail (y >= 0, NULL);
g_return_val_if_fail (width >= 0, NULL);
g_return_val_if_fail (height >= 0, NULL);
if (width < 0 || height < 0)
gdk_drawable_get_size (drawable,
width < 0 ? &width : NULL,
height < 0 ? &height : NULL);
composite =
GDK_DRAWABLE_GET_CLASS (drawable)->get_composite_drawable (drawable,
x, y,
......
......@@ -2111,20 +2111,12 @@ gtk_entry_move_forward_word (GtkEntry *entry,
gint n_attrs;
pango_layout_get_log_attrs (layout, &log_attrs, &n_attrs);
/* Advance over white space */
while (new_pos < n_attrs && log_attrs[new_pos].is_white)
new_pos++;
/* Find the next word beginning */
/* Find the next word end */
new_pos++;
while (new_pos < n_attrs && !log_attrs[new_pos].is_word_stop)
while (new_pos < n_attrs && !log_attrs[new_pos].is_word_end)
new_pos++;
/* Back up over white space */
while (new_pos > 0 && log_attrs[new_pos - 1].is_white)
new_pos--;
g_free (log_attrs);
g_object_unref (G_OBJECT (layout));
}
......@@ -2155,7 +2147,7 @@ gtk_entry_move_backward_word (GtkEntry *entry,
new_pos = start - 1;
/* Find the previous word beginning */
while (new_pos > 0 && !log_attrs[new_pos].is_word_stop)
while (new_pos > 0 && !log_attrs[new_pos].is_word_start)
new_pos--;
g_free (log_attrs);
......
......@@ -2172,24 +2172,40 @@ pre_paste_prep (ClipboardRequest *request_data,
GtkTextIter *insert_point)
{
GtkTextBuffer *buffer = request_data->buffer;
get_paste_point (buffer, insert_point, TRUE);
/* If we're going to replace the selection, we insert before it to
* avoid messing it up, then we delete the selection after inserting.
*/
if (request_data->replace_selection)
{
GtkTextIter start, end;
if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
*insert_point = start;
}
}
static void
post_paste_cleanup (ClipboardRequest *request_data)
{
if (request_data->replace_selection)
{
GtkTextIter start, end;
if (gtk_text_buffer_get_selection_bounds (request_data->buffer,
&start, &end))
{
if (request_data->interactive)
gtk_text_buffer_delete_interactive (buffer,
gtk_text_buffer_delete_interactive (request_data->buffer,
&start,
&end,
request_data->default_editable);
else
gtk_text_buffer_delete (buffer, &start, &end);
gtk_text_buffer_delete (request_data->buffer, &start, &end);
}
}
get_paste_point (buffer, insert_point, TRUE);
}
/* Called when we request a paste and receive the text data
......@@ -2214,6 +2230,8 @@ clipboard_text_received (GtkClipboard *clipboard,
else
gtk_text_buffer_insert (buffer, &insert_point,
str, -1);
post_paste_cleanup (request_data);
}
g_object_unref (G_OBJECT (buffer));
......@@ -2253,6 +2271,33 @@ selection_data_get_buffer (GtkSelectionData *selection_data,
return src_buffer;
}
#if 0
/* These are pretty handy functions; maybe something like them
* should be in the public API. Also, there are other places in this
* file where they could be used.
*/
static gpointer
save_iter (const GtkTextIter *iter,
gboolean left_gravity)
{
return gtk_text_buffer_create_mark (gtk_text_iter_get_buffer (iter),
NULL,
iter,
TRUE);
}
static void
restore_iter (const GtkTextIter *iter,
gpointer save_id)
{
gtk_text_buffer_get_iter_at_mark (gtk_text_mark_get_buffer (save_id),
(GtkTextIter*) iter,
save_id);
gtk_text_buffer_delete_mark (gtk_text_mark_get_buffer (save_id),
save_id);
}
#endif
static void
paste_from_buffer (ClipboardRequest *request_data,
GtkTextBuffer *src_buffer,
......@@ -2274,6 +2319,8 @@ paste_from_buffer (ClipboardRequest *request_data,
end,
request_data->interactive);
}
post_paste_cleanup (request_data);
g_object_unref (G_OBJECT (src_buffer));
}
......@@ -2392,13 +2439,14 @@ paste (GtkTextBuffer *buffer,
* replace the selection with the new text, otherwise, you
* simply insert the new text at the point where the click
* occured, unselecting any selected text. The replace_selection
* flag toggles this behavior. FIXME set the flag based on something.
* flag toggles this behavior.
*/
data->replace_selection = FALSE;
get_paste_point (buffer, &paste_point, FALSE);
if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end) &&
gtk_text_iter_in_range (&paste_point, &start, &end))
(gtk_text_iter_in_range (&paste_point, &start, &end) ||
gtk_text_iter_equal (&paste_point, &end)))
data->replace_selection = TRUE;
if (is_clipboard)
......
......@@ -796,7 +796,9 @@ gtk_text_layout_draw (GtkTextLayout *layout,
current_y += line_display->height;
gtk_text_layout_free_line_display (layout, line_display);
render_state->last_appearance = NULL;
render_state->last_bg_appearance = NULL;
tmp_list = g_slist_next (tmp_list);
}
......
......@@ -2368,14 +2368,9 @@ find_word_end_func (PangoLogAttr *attrs,
{
++offset; /* We always go to the NEXT word end */
/* Find start of next word */
/* Find end of next word */
while (offset < min_offset + len &&
!attrs[offset].is_word_stop)
++offset;
/* Find end */
while (offset < min_offset + len &&
!attrs[offset].is_white)
!attrs[offset].is_word_end)
++offset;
*found_offset = offset;
......@@ -2383,6 +2378,16 @@ find_word_end_func (PangoLogAttr *attrs,
return offset < min_offset + len;
}
static gboolean
is_word_end_func (PangoLogAttr *attrs,
gint offset,
gint min_offset,
gint len,
gint *found_offset)
{
return attrs[offset].is_word_end;
}
static gboolean
find_word_start_func (PangoLogAttr *attrs,
gint offset,
......@@ -2392,14 +2397,9 @@ find_word_start_func (PangoLogAttr *attrs,
{
--offset; /* We always go to the NEXT word start */
/* Find end of prev word */
/* Find start of prev word */
while (offset >= min_offset &&
attrs[offset].is_white)
--offset;
/* Find start */
while (offset >= min_offset &&
!attrs[offset].is_word_stop)
!attrs[offset].is_word_start)
--offset;
*found_offset = offset;
......@@ -2407,31 +2407,53 @@ find_word_start_func (PangoLogAttr *attrs,
return offset >= min_offset;
}
/* FIXME this function is very, very gratuitously slow */
static gboolean
find_by_log_attrs (GtkTextIter *iter,
FindLogAttrFunc func,
gboolean forward)
is_word_start_func (PangoLogAttr *attrs,
gint offset,
gint min_offset,
gint len,
gint *found_offset)
{
return attrs[offset].is_word_start;
}
static gboolean
inside_word_func (PangoLogAttr *attrs,
gint offset,
gint min_offset,
gint len,
gint *found_offset)
{
/* Find next word start or end */
while (offset >= min_offset &&
!(attrs[offset].is_word_start || attrs[offset].is_word_end))
--offset;
return attrs[offset].is_word_start;
}
static gboolean
test_log_attrs (GtkTextIter *iter,
FindLogAttrFunc func,
gint *found_offset)
{
GtkTextIter orig;
GtkTextIter start;
GtkTextIter end;
gchar *paragraph;
gint char_len, byte_len;
PangoLogAttr *attrs;
int offset;
gboolean found = FALSE;
gboolean result = FALSE;
g_return_val_if_fail (iter != NULL, FALSE);
orig = *iter;
start = *iter;
end = *iter;
gtk_text_iter_set_line_offset (&start, 0);
gtk_text_iter_forward_to_newline (&end);
gtk_text_iter_forward_line (&end);
paragraph = gtk_text_iter_get_text (&start, &end);
paragraph = gtk_text_iter_get_slice (&start, &end);
char_len = g_utf8_strlen (paragraph, -1);
byte_len = strlen (paragraph);
......@@ -2451,13 +2473,32 @@ find_by_log_attrs (GtkTextIter *iter,
g_free (lang);
found = (* func) (attrs, offset, 0, char_len, &offset);
result = (* func) (attrs, offset, 0, char_len, found_offset);
g_free (attrs);
}
g_free (paragraph);
return result;
}
/* FIXME this function is very, very gratuitously slow */
static gboolean
find_by_log_attrs (GtkTextIter *iter,
FindLogAttrFunc func,
gboolean forward)
{
GtkTextIter orig;
gint offset = 0;
gboolean found = FALSE;
g_return_val_if_fail (iter != NULL, FALSE);
orig = *iter;
found = test_log_attrs (iter, func, &offset);
if (!found)
{
if (forward)
......@@ -2502,7 +2543,7 @@ gtk_text_iter_backward_word_start (GtkTextIter *iter)
*/
gboolean
gtk_text_iter_forward_word_ends (GtkTextIter *iter,
gint count)
gint count)
{
g_return_val_if_fail (iter != NULL, FALSE);
g_return_val_if_fail (count > 0, FALSE);
......@@ -2540,6 +2581,25 @@ gtk_text_iter_backward_word_starts (GtkTextIter *iter,
return TRUE;
}
gboolean
gtk_text_iter_starts_word (const GtkTextIter *iter)
{
return test_log_attrs (iter, is_word_start_func, NULL);
}
gboolean
gtk_text_iter_ends_word (const GtkTextIter *iter)
{
return test_log_attrs (iter, is_word_end_func, NULL);
}
gboolean
gtk_text_iter_inside_word (const GtkTextIter *iter)
{
return test_log_attrs (iter, inside_word_func, NULL);
}
void
gtk_text_iter_set_line_offset (GtkTextIter *iter,
gint char_on_line)
......
......@@ -124,6 +124,9 @@ GSList *gtk_text_iter_get_tags (const GtkTextIter *iter);
gboolean gtk_text_iter_editable (const GtkTextIter *iter,
gboolean default_setting);
gboolean gtk_text_iter_starts_word (const GtkTextIter *iter);
gboolean gtk_text_iter_ends_word (const GtkTextIter *iter);
gboolean gtk_text_iter_inside_word (const GtkTextIter *iter);
gboolean gtk_text_iter_starts_line (const GtkTextIter *iter);
gboolean gtk_text_iter_ends_line (const GtkTextIter *iter);
......
......@@ -2209,7 +2209,6 @@ find_display_line_below (GtkTextLayout *layout,
while (line && !found_line)
{
GtkTextLineDisplay *display = gtk_text_layout_get_line_display (layout, line, FALSE);
gint byte_index = 0;
PangoLayoutIter *layout_iter;
layout_iter = pango_layout_get_iter (display->layout);
......@@ -2221,7 +2220,7 @@ find_display_line_below (GtkTextLayout *layout,
gint first_y, last_y;
PangoLayoutLine *layout_line = pango_layout_iter_get_line (layout_iter);
found_byte = byte_index;
found_byte = layout_line->start_index;
if (line_top >= y)
{
......@@ -2231,8 +2230,6 @@ find_display_line_below (GtkTextLayout *layout,
pango_layout_iter_get_line_yrange (layout_iter, &first_y, &last_y);
line_top += (last_y - first_y) / PANGO_SCALE;
byte_index += layout_line->length;
}
while (pango_layout_iter_next_line (layout_iter));
......@@ -2278,8 +2275,6 @@ find_display_line_above (GtkTextLayout *layout,
{
GtkTextLineDisplay *display = gtk_text_layout_get_line_display (layout, line, FALSE);
PangoRectangle logical_rect;
gint byte_index = 0;
PangoLayoutIter *layout_iter;
gint tmp_top;
......@@ -2296,7 +2291,7 @@ find_display_line_above (GtkTextLayout *layout,
gint first_y, last_y;
PangoLayoutLine *layout_line = pango_layout_iter_get_line (layout_iter);
found_byte = byte_index;
found_byte = layout_line->start_index;
pango_layout_iter_get_line_yrange (layout_iter, &first_y, &last_y);
......@@ -2305,11 +2300,8 @@ find_display_line_above (GtkTextLayout *layout,
if (tmp_top < y)
{
found_line = line;
found_byte = byte_index;
goto done;
}
byte_index += layout_line->length;
}
while (pango_layout_iter_next_line (layout_iter));
......@@ -2383,7 +2375,7 @@ gtk_text_layout_clamp_iter_to_vrange (GtkTextLayout *layout,
* Move the iterator to the beginning of the previous line. The lines
* of a wrapped paragraph are treated as distinct for this operation.
**/
void
gboolean
gtk_text_layout_move_iter_to_previous_line (GtkTextLayout *layout,
GtkTextIter *iter)
{
......@@ -2392,11 +2384,14 @@ gtk_text_layout_move_iter_to_previous_line (GtkTextLayout *layout,
gint line_byte;
GSList *tmp_list;
PangoLayoutLine *layout_line;
GtkTextIter orig;
g_return_val_if_fail (layout != NULL, FALSE);
g_return_val_if_fail (GTK_IS_TEXT_LAYOUT (layout), FALSE);
g_return_val_if_fail (iter != NULL, FALSE);
g_return_if_fail (layout != NULL);
g_return_if_fail (GTK_IS_TEXT_LAYOUT (layout));
g_return_if_fail (iter != NULL);
orig = *iter;
line = gtk_text_iter_get_text_line (iter);
display = gtk_text_layout_get_line_display (layout, line, FALSE);
line_byte = line_display_iter_to_index (layout, display, iter);
......@@ -2410,49 +2405,49 @@ gtk_text_layout_move_iter_to_previous_line (GtkTextLayout *layout,
if (prev_line)
{
gint byte_offset = 0;
gtk_text_layout_free_line_display (layout, display);
display = gtk_text_layout_get_line_display (layout, prev_line, FALSE);
tmp_list = pango_layout_get_lines (display->layout);
tmp_list = pango_layout_get_lines (display->layout);
while (tmp_list->next)
{
layout_line = tmp_list->data;
tmp_list = tmp_list->next;
byte_offset += layout_line->length;
}
line_display_index_to_iter (layout, display,