[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/3.5/kdelibs/kate/part
From:       Dominik Haumann <dhdev () gmx ! de>
Date:       2007-05-27 19:59:50
Message-ID: 1180295990.937457.19832.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 668824 by dhaumann:

fix: tabs in wrapped line broke cursor navigation
Is there a better/faster way? - todo: forward port
Thanks to Ruud Koolen for the patch!

CCMAIL: kwrite-devel@kde.org
BUG: 94693


 M  +5 -5      katerenderer.cpp  
 M  +16 -1     kateviewinternal.cpp  


--- branches/KDE/3.5/kdelibs/kate/part/katerenderer.cpp #668823:668824
@@ -798,6 +798,11 @@
     Q_ASSERT(width);
     x += width;
 
+    // How should tabs be treated when they word-wrap on a print-out?
+    // if startcol != 0, this messes up (then again, word wrapping messes up anyway)
+    if (unicode[z] == QChar('\t'))
+      x -= x % width;
+
     if (unicode[z].isSpace())
     {
       lastWhiteSpace = z+1;
@@ -816,11 +821,6 @@
       }
     }
 
-    // How should tabs be treated when they word-wrap on a print-out?
-    // if startcol != 0, this messes up (then again, word wrapping messes up anyway)
-    if (unicode[z] == QChar('\t'))
-      x -= x % width;
-
     if (x <= maxwidth)
     {
       if (lastWhiteSpace > -1)
--- branches/KDE/3.5/kdelibs/kate/part/kateviewinternal.cpp #668823:668824
@@ -1653,7 +1653,22 @@
 
   if (maxX && range.wrap) {
     QChar lastCharInLine = textLine(range.line)->getChar(range.endCol - 1);
-    maxX -= m_view->renderer()->config()->fontMetrics()->width(lastCharInLine);
+
+    if (lastCharInLine == QChar('\t')) {
+      int lineSize = 0;
+      int lastTabSize = 0;
+      for(int i = range.startCol; i < range.endCol; i++) {
+        if (textLine(range.line)->getChar(i) == QChar('\t')) {
+          lastTabSize = m_view->tabWidth() - (lineSize % m_view->tabWidth());
+          lineSize += lastTabSize;
+        } else {
+          lineSize++;
+        }
+      }
+      maxX -= lastTabSize * m_view->renderer()->spaceWidth();
+    } else {
+      maxX -= m_view->renderer()->config()->fontMetrics()->width(lastCharInLine);
+    }
   }
 
   return maxX;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic