[gimp] app: fix line navigation for lines that are not left-aligned



commit 6c3e385cac848719bfa666ef992fe57c1f185312
Author: Michael Natterer <mitch gimp org>
Date:   Sat Feb 20 22:18:38 2010 +0100

    app: fix line navigation for lines that are not left-aligned
    
    Take the X position of the lines into account when navigating up and
    down by lines, so we end up at the right x-pos also for centered and
    right-aligned lines.

 app/tools/gimptexttool-editor.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/app/tools/gimptexttool-editor.c b/app/tools/gimptexttool-editor.c
index 95eb4dd..0db66fe 100644
--- a/app/tools/gimptexttool-editor.c
+++ b/app/tools/gimptexttool-editor.c
@@ -513,13 +513,15 @@ gimp_text_tool_move_cursor (GimpTextTool    *text_tool,
 
         pango_layout_iter_get_line_extents (layout_iter, NULL, &logical);
 
+        x_pos += logical.x;
+
         pango_layout_iter_free (layout_iter);
 
         /*  try to go to the remembered x_pos if it exists *and* we are at
          *  the beginning or at the end of the current line
          */
         if (text_tool->x_pos != -1 && (x_pos <= logical.x ||
-                                       x_pos >= logical.width))
+                                       x_pos >= logical.x + logical.width))
           x_pos = text_tool->x_pos;
 
         line += count;
@@ -544,7 +546,7 @@ gimp_text_tool_move_cursor (GimpTextTool    *text_tool,
 
         pango_layout_iter_free (layout_iter);
 
-        pango_layout_line_x_to_index (layout_line, x_pos,
+        pango_layout_line_x_to_index (layout_line, x_pos - logical.x,
                                       &cursor_index, &trailing);
 
         string = gtk_text_buffer_get_text (buffer, &start, &end, TRUE);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]