[gnome-commander/gcmd-1-4] Fixed text selection in int. viewer on lines with TAB characters



commit 450367c5de995465508b0658e7ec6c1a2e7478cb
Author: Jan Vleeshouwers <jamavlers gmail com>
Date:   Tue Apr 8 17:17:20 2014 +0200

    Fixed text selection in int. viewer on lines with TAB characters
    
    Signed-off-by: Uwe Scholz <uwescholz src gnome org>

 NEWS                         |   14 ++++++++++++++
 doc/C/releases.xml           |    7 +++++--
 src/intviewer/text-render.cc |   21 +++++++++++++++------
 3 files changed, 34 insertions(+), 8 deletions(-)
---
diff --git a/NEWS b/NEWS
index 547811f..2868f0b 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,20 @@ New features:
      ...            ...
 
 ===================================
+gnome-commander 1.4.2
+---------------
+
+Bug fixes:
+ * Fixed problem bgo#367949 (Corrected async_xfer_callback-results for mooving folders)
+ * Fixed problem bgo#598161 (Selecting text in internal viewer on lines with TAB characters)
+New features:
+* New or updated translations: 
+     ...
+* New key bindings:
+     ...            ...
+
+
+===================================
 gnome-commander 1.4.1
 ---------------
 
diff --git a/doc/C/releases.xml b/doc/C/releases.xml
index 7eea4c6..9c0664b 100644
--- a/doc/C/releases.xml
+++ b/doc/C/releases.xml
@@ -30,7 +30,10 @@
                 <para>
                     <itemizedlist>
                         <listitem>
-                            <para> Fixed problem bgo#367949 (Corrected async_xfer_callback-results for 
mooving folders)</para>
+                            <para>Fixed problem bgo#367949 (Corrected async_xfer_callback-results for 
mooving folders)</para>
+                        <listitem>
+                        </listitem>
+                            <para>Fixed problem bgo#598161 (Selecting text in internal viewer on lines with 
TAB characters)</para>
                         </listitem>
                         <listitem>
                             <para>New or updated docs: ??</para>
@@ -50,7 +53,7 @@
                 <para>
                     <itemizedlist>
                         <listitem>
-                            <para>Fixed problem bgo#641842 (use poppler-glib instead of poppler internal 
API)</para>
+                            <para>Fixed problem bgo#641842 (Use poppler-glib instead of poppler internal 
API)</para>
                         </listitem>
                         <listitem>
                             <para>Fixed problem bgo#726682 (Patch to fix undefined reference to 
vtable)</para>
diff --git a/src/intviewer/text-render.cc b/src/intviewer/text-render.cc
index 0e4f175..8983e92 100644
--- a/src/intviewer/text-render.cc
+++ b/src/intviewer/text-render.cc
@@ -1528,6 +1528,8 @@ static offset_type text_mode_pixel_to_offset(TextRender *obj, int x, int y, gboo
     int column = 0;
     offset_type offset;
     offset_type next_line_offset;
+    char_type choff; // character at offset
+    int choffcol = 0; // last column occupied by choff
 
     if (x<0)
         x = 0;
@@ -1541,20 +1543,27 @@ static offset_type text_mode_pixel_to_offset(TextRender *obj, int x, int y, gboo
         return obj->priv->current_offset;
 
     line = y / obj->priv->char_height;
-    column = x / obj->priv->char_width;
-
-    if (!start_marker)
-        column++;
+    column = x / obj->priv->char_width + obj->priv->column;
 
+    // Determine offset corresponding to start of line, the character at this offset and the last column 
occupied by character
     offset = gv_scroll_lines (obj->priv->dp, obj->priv->current_offset, line);
+    choff = gv_input_mode_get_utf8_char(obj->priv->im, offset);
+    choffcol = (choff=='\t') ? obj->priv->tab_size-1 : 0;
+
     next_line_offset = gv_scroll_lines (obj->priv->dp, offset, 1);
 
-    while (column>0 && offset<next_line_offset)
+    // While the current character does not occupy column 'column', check next character
+    while (column>choffcol && offset<next_line_offset)
     {
         offset = gv_input_get_next_char_offset(obj->priv->im, offset);
-        column--;
+       choff = gv_input_mode_get_utf8_char(obj->priv->im, offset);
+       choffcol += (choff=='\t') ? obj->priv->tab_size : 1;
     }
 
+    // Increment offset if doing end-marker
+    if (!start_marker)
+        offset++;
+
     return offset;
 }
 


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