Commit b9942804 authored by Massimo Valentini's avatar Massimo Valentini
Browse files

Bug 668814: Cannot move cursor right in on canvas editor

One possible way to decrease the incompatibilities
between letter spacing in a tagged gtk_text_buffer
and in an equivalent pango_layout

Remove also a valgrind reported invalid write in
gimptextbuffer.c
parent 0729c25b
......@@ -677,16 +677,19 @@ gimp_text_tool_move_cursor (GimpTextTool *text_tool,
if (! cancel_selection)
{
PangoLayout *layout;
const gchar *text;
if (! gimp_text_tool_ensure_layout (text_tool))
break;
layout = gimp_text_layout_get_pango_layout (text_tool->layout);
text = pango_layout_get_text (layout);
while (count != 0)
{
const gunichar word_joiner = 8288; /*g_utf8_get_char(WORD_JOINER);*/
gint index;
gint trailing;
gint trailing = 0;
gint new_index;
index = gimp_text_buffer_get_iter_index (text_tool->buffer,
......@@ -694,7 +697,13 @@ gimp_text_tool_move_cursor (GimpTextTool *text_tool,
if (count > 0)
{
pango_layout_move_cursor_visually (layout, TRUE, index, 0, 1,
if (g_utf8_get_char (text + index) == word_joiner)
pango_layout_move_cursor_visually (layout, TRUE, index, 0, 1,
&new_index, &trailing);
else
new_index = index;
pango_layout_move_cursor_visually (layout, TRUE, new_index, trailing, 1,
&new_index, &trailing);
count--;
}
......@@ -702,6 +711,10 @@ gimp_text_tool_move_cursor (GimpTextTool *text_tool,
{
pango_layout_move_cursor_visually (layout, TRUE, index, 0, -1,
&new_index, &trailing);
if (new_index != -1 && g_utf8_get_char (text + new_index) == word_joiner)
pango_layout_move_cursor_visually (layout, TRUE, new_index, trailing, -1,
&new_index, &trailing);
count++;
}
......
......@@ -1373,7 +1373,7 @@ gimp_text_buffer_get_iter_at_index (GimpTextBuffer *buffer,
if (g_list_find (buffer->kerning_tags, tag))
{
index -= WORD_JOINER_LENGTH;
index = MAX (0, index - WORD_JOINER_LENGTH);
break;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment