[gimp] app: honor text direction when moving the cursor
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: honor text direction when moving the cursor
- Date: Wed, 13 Oct 2010 23:02:45 +0000 (UTC)
commit 0c7ec05035e8a2bedb9f865705eb969f0f4d081a
Author: Michael Natterer <mitch gimp org>
Date: Thu Oct 14 01:01:33 2010 +0200
app: honor text direction when moving the cursor
Use pango_layout_move_cursor_visually() instead of e.g. simply using
gtk_text_iter_forward_cursor_position() when "right" was pressed.
This is much more correct now but still not 100% right.
app/tools/gimptexttool-editor.c | 32 ++++++++++++++++++++++++++++----
1 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/app/tools/gimptexttool-editor.c b/app/tools/gimptexttool-editor.c
index 8d7aa55..63dff30 100644
--- a/app/tools/gimptexttool-editor.c
+++ b/app/tools/gimptexttool-editor.c
@@ -675,10 +675,34 @@ gimp_text_tool_move_cursor (GimpTextTool *text_tool,
case GTK_MOVEMENT_VISUAL_POSITIONS:
if (! cancel_selection)
{
- if (count < 0)
- gtk_text_iter_backward_cursor_position (&cursor);
- else if (count > 0)
- gtk_text_iter_forward_cursor_position (&cursor);
+ PangoLayout *layout;
+ gint index;
+ gint trailing;
+
+ index = gimp_text_buffer_get_iter_index (text_tool->buffer,
+ &cursor, TRUE);
+
+ layout = gimp_text_layout_get_pango_layout (text_tool->layout);
+
+ while (count != 0)
+ {
+ if (count > 0)
+ {
+ pango_layout_move_cursor_visually (layout, TRUE, index, 0, 1,
+ &index, &trailing);
+ count--;
+ }
+ else
+ {
+ pango_layout_move_cursor_visually (layout, TRUE, index, 0, -1,
+ &index, &trailing);
+ count++;
+ }
+ }
+
+ gimp_text_buffer_get_iter_at_index (text_tool->buffer,
+ &cursor, index, TRUE);
+ gtk_text_iter_forward_chars (&cursor, trailing);
}
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]