Merge branch 'matthiasc/for-main' into 'main'

Use pango api better

See merge request GNOME/gtk!4409
This commit is contained in:
Matthias Clasen 2022-01-23 04:29:58 +00:00
commit 044ff82d0b
4 changed files with 99 additions and 91 deletions

View File

@ -1,5 +1,5 @@
/* GDK - The GIMP Drawing Kit /* GDK - The GIMP Drawing Kit
* Copyright (C) 2000 Red Hat, Inc. * Copyright (C) 2000 Red Hat, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -52,25 +52,25 @@ layout_iter_get_line_clip_region (PangoLayoutIter *iter,
i = 0; i = 0;
while (i < n_ranges) while (i < n_ranges)
{ {
int *pixel_ranges = NULL; int *pixel_ranges = NULL;
int n_pixel_ranges = 0; int n_pixel_ranges = 0;
int j; int j;
/* Note that get_x_ranges returns layout coordinates /* Note that get_x_ranges returns layout coordinates
*/ */
if (index_ranges[i*2+1] >= line->start_index && if (index_ranges[i*2+1] >= pango_layout_line_get_start_index (line) &&
index_ranges[i*2] < line->start_index + line->length) index_ranges[i*2] < pango_layout_line_get_start_index (line) + pango_layout_line_get_length (line))
pango_layout_line_get_x_ranges (line, pango_layout_line_get_x_ranges (line,
index_ranges[i*2], index_ranges[i*2],
index_ranges[i*2+1], index_ranges[i*2+1],
&pixel_ranges, &n_pixel_ranges); &pixel_ranges, &n_pixel_ranges);
for (j = 0; j < n_pixel_ranges; j++) for (j = 0; j < n_pixel_ranges; j++)
{ {
GdkRectangle rect; GdkRectangle rect;
int x_off, y_off; int x_off, y_off;
x_off = PANGO_PIXELS (pixel_ranges[2*j] - logical_rect.x); x_off = PANGO_PIXELS (pixel_ranges[2*j] - logical_rect.x);
y_off = PANGO_PIXELS (baseline - logical_rect.y); y_off = PANGO_PIXELS (baseline - logical_rect.y);
@ -124,14 +124,14 @@ gdk_pango_layout_line_get_clip_region (PangoLayoutLine *line,
{ {
cairo_region_t *clip_region; cairo_region_t *clip_region;
PangoLayoutIter *iter; PangoLayoutIter *iter;
g_return_val_if_fail (line != NULL, NULL); g_return_val_if_fail (line != NULL, NULL);
g_return_val_if_fail (index_ranges != NULL, NULL); g_return_val_if_fail (index_ranges != NULL, NULL);
iter = pango_layout_get_iter (line->layout); iter = pango_layout_get_iter (line->layout);
while (pango_layout_iter_get_line_readonly (iter) != line) while (pango_layout_iter_get_line_readonly (iter) != line)
pango_layout_iter_next_line (iter); pango_layout_iter_next_line (iter);
clip_region = layout_iter_get_line_clip_region(iter, x_origin, y_origin, index_ranges, n_ranges); clip_region = layout_iter_get_line_clip_region(iter, x_origin, y_origin, index_ranges, n_ranges);
pango_layout_iter_free (iter); pango_layout_iter_free (iter);
@ -167,26 +167,26 @@ gdk_pango_layout_get_clip_region (PangoLayout *layout,
const int *index_ranges, const int *index_ranges,
int n_ranges) int n_ranges)
{ {
PangoLayoutIter *iter; PangoLayoutIter *iter;
cairo_region_t *clip_region; cairo_region_t *clip_region;
g_return_val_if_fail (PANGO_IS_LAYOUT (layout), NULL); g_return_val_if_fail (PANGO_IS_LAYOUT (layout), NULL);
g_return_val_if_fail (index_ranges != NULL, NULL); g_return_val_if_fail (index_ranges != NULL, NULL);
clip_region = cairo_region_create (); clip_region = cairo_region_create ();
iter = pango_layout_get_iter (layout); iter = pango_layout_get_iter (layout);
do do
{ {
PangoRectangle logical_rect; PangoRectangle logical_rect;
cairo_region_t *line_region; cairo_region_t *line_region;
int baseline; int baseline;
pango_layout_iter_get_line_extents (iter, NULL, &logical_rect);
baseline = pango_layout_iter_get_baseline (iter);
line_region = layout_iter_get_line_clip_region(iter, pango_layout_iter_get_line_extents (iter, NULL, &logical_rect);
baseline = pango_layout_iter_get_baseline (iter);
line_region = layout_iter_get_line_clip_region(iter,
x_origin + PANGO_PIXELS (logical_rect.x), x_origin + PANGO_PIXELS (logical_rect.x),
y_origin + PANGO_PIXELS (baseline), y_origin + PANGO_PIXELS (baseline),
index_ranges, index_ranges,

View File

@ -126,6 +126,22 @@ pango_wrap_mode_to_string (PangoWrapMode mode)
} }
} }
static const char *
pango_align_to_string (PangoAlignment align)
{
switch (align)
{
case PANGO_ALIGN_LEFT:
return "left";
case PANGO_ALIGN_CENTER:
return "center";
case PANGO_ALIGN_RIGHT:
return "right";
default:
g_assert_not_reached ();
}
}
void void
gtk_pango_get_font_attributes (PangoFontDescription *font, gtk_pango_get_font_attributes (PangoFontDescription *font,
GVariantBuilder *builder) GVariantBuilder *builder)
@ -167,9 +183,6 @@ gtk_pango_get_default_attributes (PangoLayout *layout,
GVariantBuilder *builder) GVariantBuilder *builder)
{ {
PangoContext *context; PangoContext *context;
const char *val;
PangoAlignment align;
PangoWrapMode mode;
context = pango_layout_get_context (layout); context = pango_layout_get_context (layout);
if (context) if (context)
@ -186,26 +199,12 @@ gtk_pango_get_default_attributes (PangoLayout *layout,
if (font) if (font)
gtk_pango_get_font_attributes (font, builder); gtk_pango_get_font_attributes (font, builder);
} }
if (pango_layout_get_justify (layout))
{
val = "fill";
}
else
{
align = pango_layout_get_alignment (layout);
if (align == PANGO_ALIGN_LEFT)
val = "left";
else if (align == PANGO_ALIGN_CENTER)
val = "center";
else
val = "right";
}
g_variant_builder_add (builder, "{ss}", "justification", val);
mode = pango_layout_get_wrap (layout); g_variant_builder_add (builder, "{ss}", "justification",
pango_align_to_string (pango_layout_get_alignment (layout)));
g_variant_builder_add (builder, "{ss}", "wrap-mode", g_variant_builder_add (builder, "{ss}", "wrap-mode",
pango_wrap_mode_to_string (mode)); pango_wrap_mode_to_string (pango_layout_get_wrap (layout)));
g_variant_builder_add (builder, "{ss}", "strikethrough", "false"); g_variant_builder_add (builder, "{ss}", "strikethrough", "false");
g_variant_builder_add (builder, "{ss}", "underline", "false"); g_variant_builder_add (builder, "{ss}", "underline", "false");
g_variant_builder_add (builder, "{ss}", "rise", "0"); g_variant_builder_add (builder, "{ss}", "rise", "0");
@ -678,7 +677,9 @@ pango_layout_get_line_before (PangoLayout *layout,
{ {
PangoLayoutIter *iter; PangoLayoutIter *iter;
PangoLayoutLine *line, *prev_line = NULL, *prev_prev_line = NULL; PangoLayoutLine *line, *prev_line = NULL, *prev_prev_line = NULL;
int index, start_index, end_index; int index, start_index, length, end_index;
int prev_start_index, prev_length;
int prev_prev_start_index, prev_prev_length;
const char *text; const char *text;
gboolean found = FALSE; gboolean found = FALSE;
@ -688,8 +689,9 @@ pango_layout_get_line_before (PangoLayout *layout,
do do
{ {
line = pango_layout_iter_get_line (iter); line = pango_layout_iter_get_line (iter);
start_index = line->start_index; start_index = pango_layout_line_get_start_index (line);
end_index = start_index + line->length; length = pango_layout_line_get_length (line);
end_index = start_index + length;
if (index >= start_index && index <= end_index) if (index >= start_index && index <= end_index)
{ {
@ -700,14 +702,14 @@ pango_layout_get_line_before (PangoLayout *layout,
{ {
case ATSPI_TEXT_BOUNDARY_LINE_START: case ATSPI_TEXT_BOUNDARY_LINE_START:
end_index = start_index; end_index = start_index;
start_index = prev_line->start_index; start_index = prev_start_index;
break; break;
case ATSPI_TEXT_BOUNDARY_LINE_END: case ATSPI_TEXT_BOUNDARY_LINE_END:
if (prev_prev_line) if (prev_prev_line)
start_index = prev_prev_line->start_index + prev_prev_line->length; start_index = prev_prev_start_index + prev_prev_length;
else else
start_index = 0; start_index = 0;
end_index = prev_line->start_index + prev_line->length; end_index = prev_start_index + prev_length;
break; break;
case ATSPI_TEXT_BOUNDARY_CHAR: case ATSPI_TEXT_BOUNDARY_CHAR:
case ATSPI_TEXT_BOUNDARY_WORD_START: case ATSPI_TEXT_BOUNDARY_WORD_START:
@ -726,13 +728,17 @@ pango_layout_get_line_before (PangoLayout *layout,
} }
prev_prev_line = prev_line; prev_prev_line = prev_line;
prev_prev_start_index = prev_start_index;
prev_prev_length = prev_length;
prev_line = line; prev_line = line;
prev_start_index = start_index;
prev_length = length;
} }
while (pango_layout_iter_next_line (iter)); while (pango_layout_iter_next_line (iter));
if (!found) if (!found)
{ {
start_index = prev_line->start_index + prev_line->length; start_index = prev_start_index + prev_length;
end_index = start_index; end_index = start_index;
} }
pango_layout_iter_free (iter); pango_layout_iter_free (iter);
@ -750,7 +756,7 @@ pango_layout_get_line_at (PangoLayout *layout,
{ {
PangoLayoutIter *iter; PangoLayoutIter *iter;
PangoLayoutLine *line, *prev_line = NULL; PangoLayoutLine *line, *prev_line = NULL;
int index, start_index, end_index; int index, start_index, length, end_index;
const char *text; const char *text;
gboolean found = FALSE; gboolean found = FALSE;
@ -760,8 +766,9 @@ pango_layout_get_line_at (PangoLayout *layout,
do do
{ {
line = pango_layout_iter_get_line (iter); line = pango_layout_iter_get_line (iter);
start_index = line->start_index; start_index = pango_layout_line_get_start_index (line);
end_index = start_index + line->length; length = pango_layout_line_get_length (line);
end_index = start_index + length;
if (index >= start_index && index <= end_index) if (index >= start_index && index <= end_index)
{ {
@ -770,11 +777,11 @@ pango_layout_get_line_at (PangoLayout *layout,
{ {
case ATSPI_TEXT_BOUNDARY_LINE_START: case ATSPI_TEXT_BOUNDARY_LINE_START:
if (pango_layout_iter_next_line (iter)) if (pango_layout_iter_next_line (iter))
end_index = pango_layout_iter_get_line (iter)->start_index; end_index = pango_layout_line_get_start_index (pango_layout_iter_get_line (iter));
break; break;
case ATSPI_TEXT_BOUNDARY_LINE_END: case ATSPI_TEXT_BOUNDARY_LINE_END:
if (prev_line) if (prev_line)
start_index = prev_line->start_index + prev_line->length; start_index = pango_layout_line_get_start_index (prev_line) + pango_layout_line_get_length (prev_line);
break; break;
case ATSPI_TEXT_BOUNDARY_CHAR: case ATSPI_TEXT_BOUNDARY_CHAR:
case ATSPI_TEXT_BOUNDARY_WORD_START: case ATSPI_TEXT_BOUNDARY_WORD_START:
@ -795,7 +802,7 @@ pango_layout_get_line_at (PangoLayout *layout,
if (!found) if (!found)
{ {
start_index = prev_line->start_index + prev_line->length; start_index = pango_layout_line_get_start_index (prev_line) + pango_layout_line_get_length (prev_line);
end_index = start_index; end_index = start_index;
} }
pango_layout_iter_free (iter); pango_layout_iter_free (iter);
@ -813,7 +820,7 @@ pango_layout_get_line_after (PangoLayout *layout,
{ {
PangoLayoutIter *iter; PangoLayoutIter *iter;
PangoLayoutLine *line, *prev_line = NULL; PangoLayoutLine *line, *prev_line = NULL;
int index, start_index, end_index; int index, start_index, length, end_index;
const char *text; const char *text;
gboolean found = FALSE; gboolean found = FALSE;
@ -823,8 +830,9 @@ pango_layout_get_line_after (PangoLayout *layout,
do do
{ {
line = pango_layout_iter_get_line (iter); line = pango_layout_iter_get_line (iter);
start_index = line->start_index; start_index = pango_layout_line_get_start_index (line);
end_index = start_index + line->length; length = pango_layout_line_get_length (line);
end_index = start_index + length;
if (index >= start_index && index <= end_index) if (index >= start_index && index <= end_index)
{ {
@ -835,15 +843,15 @@ pango_layout_get_line_after (PangoLayout *layout,
switch (boundary_type) switch (boundary_type)
{ {
case ATSPI_TEXT_BOUNDARY_LINE_START: case ATSPI_TEXT_BOUNDARY_LINE_START:
start_index = line->start_index; start_index = pango_layout_line_get_start_index (line);
if (pango_layout_iter_next_line (iter)) if (pango_layout_iter_next_line (iter))
end_index = pango_layout_iter_get_line (iter)->start_index; end_index = pango_layout_line_get_start_index (pango_layout_iter_get_line (iter));
else else
end_index = start_index + line->length; end_index = start_index + pango_layout_line_get_length (line);
break; break;
case ATSPI_TEXT_BOUNDARY_LINE_END: case ATSPI_TEXT_BOUNDARY_LINE_END:
start_index = end_index; start_index = end_index;
end_index = line->start_index + line->length; end_index = pango_layout_line_get_start_index (line) + pango_layout_line_get_length (line);
break; break;
case ATSPI_TEXT_BOUNDARY_CHAR: case ATSPI_TEXT_BOUNDARY_CHAR:
case ATSPI_TEXT_BOUNDARY_WORD_START: case ATSPI_TEXT_BOUNDARY_WORD_START:
@ -867,7 +875,7 @@ pango_layout_get_line_after (PangoLayout *layout,
if (!found) if (!found)
{ {
start_index = prev_line->start_index + prev_line->length; start_index = pango_layout_line_get_start_index (prev_line) + pango_layout_line_get_length (prev_line);
end_index = start_index; end_index = start_index;
} }
pango_layout_iter_free (iter); pango_layout_iter_free (iter);

View File

@ -3085,7 +3085,7 @@ find_display_line_below (GtkTextLayout *layout,
int first_y, last_y; int first_y, last_y;
PangoLayoutLine *layout_line = pango_layout_iter_get_line_readonly (layout_iter); PangoLayoutLine *layout_line = pango_layout_iter_get_line_readonly (layout_iter);
found_byte = layout_line->start_index; found_byte = pango_layout_line_get_start_index (layout_line);
if (line_top >= y) if (line_top >= y)
{ {
@ -3157,7 +3157,7 @@ find_display_line_above (GtkTextLayout *layout,
int first_y, last_y; int first_y, last_y;
PangoLayoutLine *layout_line = pango_layout_iter_get_line_readonly (layout_iter); PangoLayoutLine *layout_line = pango_layout_iter_get_line_readonly (layout_iter);
found_byte = layout_line->start_index; found_byte = pango_layout_line_get_start_index (layout_line);
pango_layout_iter_get_line_yrange (layout_iter, &first_y, &last_y); pango_layout_iter_get_line_yrange (layout_iter, &first_y, &last_y);
@ -3290,10 +3290,10 @@ gtk_text_layout_move_iter_to_previous_line (GtkTextLayout *layout,
if (update_byte) if (update_byte)
{ {
line_byte = layout_line->start_index + layout_line->length; line_byte = pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line);
} }
if (line_byte < layout_line->length || !tmp_list->next) /* first line of paragraph */ if (line_byte < pango_layout_line_get_length (layout_line) || !tmp_list->next) /* first line of paragraph */
{ {
GtkTextLine *prev_line; GtkTextLine *prev_line;
@ -3315,7 +3315,7 @@ gtk_text_layout_move_iter_to_previous_line (GtkTextLayout *layout,
layout_line = tmp_list->data; layout_line = tmp_list->data;
line_display_index_to_iter (layout, display, iter, line_display_index_to_iter (layout, display, iter,
layout_line->start_index + layout_line->length, 0); pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line), 0);
break; break;
} }
@ -3324,21 +3324,21 @@ gtk_text_layout_move_iter_to_previous_line (GtkTextLayout *layout,
} }
else else
{ {
int prev_offset = layout_line->start_index; int prev_offset = pango_layout_line_get_start_index (layout_line);
tmp_list = tmp_list->next; tmp_list = tmp_list->next;
while (tmp_list) while (tmp_list)
{ {
layout_line = tmp_list->data; layout_line = tmp_list->data;
if (line_byte < layout_line->start_index + layout_line->length || if (line_byte < pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line) ||
!tmp_list->next) !tmp_list->next)
{ {
line_display_index_to_iter (layout, display, iter, prev_offset, 0); line_display_index_to_iter (layout, display, iter, prev_offset, 0);
break; break;
} }
prev_offset = layout_line->start_index; prev_offset = pango_layout_line_get_start_index (layout_line);
tmp_list = tmp_list->next; tmp_list = tmp_list->next;
} }
} }
@ -3405,10 +3405,10 @@ gtk_text_layout_move_iter_to_next_line (GtkTextLayout *layout,
if (found) if (found)
{ {
line_display_index_to_iter (layout, display, iter, line_display_index_to_iter (layout, display, iter,
layout_line->start_index, 0); pango_layout_line_get_start_index (layout_line), 0);
found_after = TRUE; found_after = TRUE;
} }
else if (line_byte < layout_line->start_index + layout_line->length || !tmp_list->next) else if (line_byte < pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line) || !tmp_list->next)
found = TRUE; found = TRUE;
tmp_list = tmp_list->next; tmp_list = tmp_list->next;
@ -3462,17 +3462,17 @@ gtk_text_layout_move_iter_to_line_end (GtkTextLayout *layout,
{ {
PangoLayoutLine *layout_line = tmp_list->data; PangoLayoutLine *layout_line = tmp_list->data;
if (line_byte < layout_line->start_index + layout_line->length || !tmp_list->next) if (line_byte < pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line) || !tmp_list->next)
{ {
line_display_index_to_iter (layout, display, iter, line_display_index_to_iter (layout, display, iter,
direction < 0 ? layout_line->start_index : layout_line->start_index + layout_line->length, direction < 0 ? pango_layout_line_get_start_index (layout_line) : pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line),
0); 0);
/* FIXME: As a bad hack, we move back one position when we /* FIXME: As a bad hack, we move back one position when we
* are inside a paragraph to avoid going to next line on a * are inside a paragraph to avoid going to next line on a
* forced break not at whitespace. Real fix is to keep track * forced break not at whitespace. Real fix is to keep track
* of whether marks are at leading or trailing edge? */ * of whether marks are at leading or trailing edge? */
if (direction > 0 && layout_line->length > 0 && if (direction > 0 && pango_layout_line_get_length (layout_line) > 0 &&
!gtk_text_iter_ends_line (iter) && !gtk_text_iter_ends_line (iter) &&
!_gtk_text_btree_char_is_invisible (iter)) !_gtk_text_btree_char_is_invisible (iter))
gtk_text_iter_backward_char (iter); gtk_text_iter_backward_char (iter);
@ -3518,7 +3518,7 @@ gtk_text_layout_iter_starts_line (GtkTextLayout *layout,
{ {
PangoLayoutLine *layout_line = tmp_list->data; PangoLayoutLine *layout_line = tmp_list->data;
if (line_byte < layout_line->start_index + layout_line->length || if (line_byte < pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line) ||
!tmp_list->next) !tmp_list->next)
{ {
/* We're located on this line or the para delimiters before /* We're located on this line or the para delimiters before
@ -3526,7 +3526,7 @@ gtk_text_layout_iter_starts_line (GtkTextLayout *layout,
*/ */
gtk_text_line_display_unref (display); gtk_text_line_display_unref (display);
if (line_byte == layout_line->start_index) if (line_byte == pango_layout_line_get_start_index (layout_line))
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
@ -3583,7 +3583,7 @@ gtk_text_layout_move_iter_to_x (GtkTextLayout *layout,
{ {
PangoLayoutLine *layout_line = pango_layout_iter_get_line_readonly (layout_iter); PangoLayoutLine *layout_line = pango_layout_iter_get_line_readonly (layout_iter);
if (line_byte < layout_line->start_index + layout_line->length || if (line_byte < pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line) ||
pango_layout_iter_at_last_line (layout_iter)) pango_layout_iter_at_last_line (layout_iter))
{ {
PangoRectangle logical_rect; PangoRectangle logical_rect;
@ -3908,7 +3908,7 @@ render_para (GskPangoRenderer *crenderer,
* only do it if the selection is opaque. * only do it if the selection is opaque.
*/ */
if (selection_start_index < byte_offset && if (selection_start_index < byte_offset &&
selection_end_index > line->length + byte_offset && selection_end_index > pango_layout_line_get_length (line) + byte_offset &&
selection->alpha >= 1) selection->alpha >= 1)
{ {
gtk_snapshot_append_color (crenderer->snapshot, gtk_snapshot_append_color (crenderer->snapshot,
@ -3944,11 +3944,11 @@ render_para (GskPangoRenderer *crenderer,
baseline); baseline);
/* Check if some part of the line is selected; the newline /* Check if some part of the line is selected; the newline
* that is after line->length for the last line of the * that is after pango_layout_line_get_length (line) for the last line of the
* paragraph counts as part of the line for this * paragraph counts as part of the line for this
*/ */
if ((selection_start_index < byte_offset + line->length || if ((selection_start_index < byte_offset + pango_layout_line_get_length (line) ||
(selection_start_index == byte_offset + line->length && pango_layout_iter_at_last_line (iter))) && (selection_start_index == byte_offset + pango_layout_line_get_length (line) && pango_layout_iter_at_last_line (iter))) &&
selection_end_index > byte_offset) selection_end_index > byte_offset)
{ {
int *ranges = NULL; int *ranges = NULL;
@ -3996,7 +3996,7 @@ render_para (GskPangoRenderer *crenderer,
/* Paint in the ends of the line */ /* Paint in the ends of the line */
if (line_rect.x > line_display->left_margin * PANGO_SCALE && if (line_rect.x > line_display->left_margin * PANGO_SCALE &&
((line_display->direction == GTK_TEXT_DIR_LTR && selection_start_index < byte_offset) || ((line_display->direction == GTK_TEXT_DIR_LTR && selection_start_index < byte_offset) ||
(line_display->direction == GTK_TEXT_DIR_RTL && selection_end_index > byte_offset + line->length))) (line_display->direction == GTK_TEXT_DIR_RTL && selection_end_index > byte_offset + pango_layout_line_get_length (line))))
gtk_snapshot_append_color (crenderer->snapshot, gtk_snapshot_append_color (crenderer->snapshot,
selection, selection,
&GRAPHENE_RECT_INIT (line_display->left_margin, &GRAPHENE_RECT_INIT (line_display->left_margin,
@ -4006,7 +4006,7 @@ render_para (GskPangoRenderer *crenderer,
if (line_rect.x + line_rect.width < if (line_rect.x + line_rect.width <
(screen_width + line_display->left_margin) * PANGO_SCALE && (screen_width + line_display->left_margin) * PANGO_SCALE &&
((line_display->direction == GTK_TEXT_DIR_LTR && selection_end_index > byte_offset + line->length) || ((line_display->direction == GTK_TEXT_DIR_LTR && selection_end_index > byte_offset + pango_layout_line_get_length (line)) ||
(line_display->direction == GTK_TEXT_DIR_RTL && selection_start_index < byte_offset))) (line_display->direction == GTK_TEXT_DIR_RTL && selection_start_index < byte_offset)))
{ {
int nonlayout_width = line_display->left_margin int nonlayout_width = line_display->left_margin
@ -4025,8 +4025,8 @@ render_para (GskPangoRenderer *crenderer,
gtk_widget_has_focus (crenderer->widget) && gtk_widget_has_focus (crenderer->widget) &&
cursor_alpha > 0 && cursor_alpha > 0 &&
byte_offset <= line_display->insert_index && byte_offset <= line_display->insert_index &&
(line_display->insert_index < byte_offset + line->length || (line_display->insert_index < byte_offset + pango_layout_line_get_length (line) ||
(at_last_line && line_display->insert_index == byte_offset + line->length))) (at_last_line && line_display->insert_index == byte_offset + pango_layout_line_get_length (line))))
{ {
GtkStyleContext *context; GtkStyleContext *context;
GdkRGBA cursor_color; GdkRGBA cursor_color;
@ -4061,7 +4061,7 @@ render_para (GskPangoRenderer *crenderer,
} }
} }
byte_offset += line->length; byte_offset += pango_layout_line_get_length (line);
} }
while (pango_layout_iter_next_line (iter)); while (pango_layout_iter_next_line (iter));

View File

@ -19,7 +19,7 @@
* Modified by the GTK+ Team and others 1997-2001. See the AUTHORS * Modified by the GTK+ Team and others 1997-2001. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog * file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with * files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/. * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/ */
#include "config.h" #include "config.h"
@ -64,7 +64,7 @@ limit_layout_lines (PangoLayout *layout)
int n_lines; int n_lines;
n_lines = pango_layout_get_line_count (layout); n_lines = pango_layout_get_line_count (layout);
if (n_lines >= DRAG_ICON_MAX_LINES) if (n_lines >= DRAG_ICON_MAX_LINES)
{ {
text = pango_layout_get_text (layout); text = pango_layout_get_text (layout);
@ -355,13 +355,13 @@ _gtk_text_util_get_block_cursor_location (PangoLayout *layout,
text = pango_layout_get_text (layout); text = pango_layout_get_text (layout);
if (index < layout_line->start_index + layout_line->length) if (index < pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line))
{ {
/* this may be a zero-width character in the middle of the line, /* this may be a zero-width character in the middle of the line,
* or it could be a character where line is wrapped, we do want * or it could be a character where line is wrapped, we do want
* block cursor in latter case */ * block cursor in latter case */
if (g_utf8_next_char (text + index) - text != if (g_utf8_next_char (text + index) - text !=
layout_line->start_index + layout_line->length) pango_layout_line_get_start_index (layout_line) + pango_layout_line_get_length (layout_line))
{ {
/* zero-width character in the middle of the line, do not /* zero-width character in the middle of the line, do not
* bother with block cursor */ * bother with block cursor */
@ -384,9 +384,9 @@ _gtk_text_util_get_block_cursor_location (PangoLayout *layout,
/* In case when index points to the end of line, pos->x is always most right /* In case when index points to the end of line, pos->x is always most right
* pixel of the layout line, so we need to correct it for RTL text. */ * pixel of the layout line, so we need to correct it for RTL text. */
if (layout_line->length) if (pango_layout_line_get_length (layout_line))
{ {
if (layout_line->resolved_dir == PANGO_DIRECTION_RTL) if (pango_layout_line_get_resolved_direction (layout_line) == PANGO_DIRECTION_RTL)
{ {
PangoLayoutIter *iter; PangoLayoutIter *iter;
PangoRectangle line_rect; PangoRectangle line_rect;