changeset 294:1973f21c5c6f

Fix: mouse selection for TextLayout
author Frank Benoit <benoit@tionex.de>
date Fri, 22 Aug 2008 15:15:19 +0200
parents 810b16d6559b
children f478f12be363
files dwt/graphics/TextLayout.d
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/graphics/TextLayout.d	Fri Aug 22 09:12:35 2008 +0200
+++ b/dwt/graphics/TextLayout.d	Fri Aug 22 15:15:19 2008 +0200
@@ -734,7 +734,7 @@
                 if (run.lineBreak && !run.softBreak) {
                     if (selectionStart <= run.start && run.start <= selectionEnd) extents = true;
                 } else {
-                    int endOffset = run.start + run.length - 1;
+                    int endOffset = segmentsText.getAbsoluteCodePointOffset( run.start + run.length, -1 );
                     if (selectionStart <= endOffset && endOffset < selectionEnd && (flags & DWT.FULL_SELECTION) !is 0) {
                         extents = true;
                     }
@@ -799,17 +799,17 @@
                         }
                         bool partialSelection = hasSelection && !(selectionStart > end || run.start > selectionEnd);
                         if (partialSelection) {
-                            int selStart = Math.max(selectionStart, run.start) - run.start;
-                            int selEnd = Math.min(selectionEnd, end) - run.start;
+                            int selStart = index8to16[ Math.max(selectionStart, run.start) ] - index8to16[run.start];
+                            int selEnd = index8to16[ Math.min(selectionEnd, end) ] - index8to16[ run.start ];
                             int cChars = index8to16[run.start+run.length] - index8to16[run.start]; // make it wchar
                             int gGlyphs = run.glyphCount;
                             int piX;
                             int* advances = run.justify !is null ? run.justify : run.advances;
-                            OS.ScriptCPtoX(index8to16[selStart], false, cChars, gGlyphs, run.clusters, run.visAttrs, advances, &run.analysis, &piX);
+                            OS.ScriptCPtoX(selStart, false, cChars, gGlyphs, run.clusters, run.visAttrs, advances, &run.analysis, &piX);
                             int runX = (orientation & DWT.RIGHT_TO_LEFT) !is 0 ? run.width - piX : piX;
                             rect.left = drawX + runX;
                             rect.top = drawY;
-                            OS.ScriptCPtoX(index8to16[selEnd], true, cChars, gGlyphs, run.clusters, run.visAttrs, advances, &run.analysis, &piX);
+                            OS.ScriptCPtoX(selEnd, true, cChars, gGlyphs, run.clusters, run.visAttrs, advances, &run.analysis, &piX);
                             runX = (orientation & DWT.RIGHT_TO_LEFT) !is 0 ? run.width - piX : piX;
                             rect.right = drawX + runX;
                             rect.bottom = drawY + lineHeight;