[gimp] Bug 668814: Cannot move cursor right in on canvas editor
- From: Massimo Valentini <mvalentini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 668814: Cannot move cursor right in on canvas editor
- Date: Thu, 9 Feb 2012 11:41:09 +0000 (UTC)
commit b9942804734ded8d068de9026b2e370a638d376e
Author: Massimo Valentini <mvalentini src gnome org>
Date: Thu Feb 9 12:36:43 2012 +0100
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
app/tools/gimptexttool-editor.c | 17 +++++++++++++++--
app/widgets/gimptextbuffer.c | 2 +-
2 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/app/tools/gimptexttool-editor.c b/app/tools/gimptexttool-editor.c
index 25af4c4..bb15762 100644
--- a/app/tools/gimptexttool-editor.c
+++ b/app/tools/gimptexttool-editor.c
@@ -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++;
}
diff --git a/app/widgets/gimptextbuffer.c b/app/widgets/gimptextbuffer.c
index 24eb9cb..6a4cfad 100644
--- a/app/widgets/gimptextbuffer.c
+++ b/app/widgets/gimptextbuffer.c
@@ -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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]